From 59eea35e596ac768c52b8e9b534b9d637fbbaeb3 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 6 Sep 2019 16:15:12 -0700 Subject: [PATCH 1/7] Introduce structural `tag T` types --- src/compiler/checker.ts | 67 ++- src/compiler/factory.ts | 4 +- src/compiler/parser.ts | 4 +- src/compiler/scanner.ts | 1 + src/compiler/types.ts | 12 +- .../reference/api/tsserverlibrary.d.ts | 383 +++++++++--------- tests/baselines/reference/api/typescript.d.ts | 383 +++++++++--------- .../baselines/reference/structuralTagTypes.js | 139 +++++++ .../reference/structuralTagTypes.symbols | 169 ++++++++ .../reference/structuralTagTypes.types | 174 ++++++++ .../reference/structuralTagTypes1.js | 53 +++ .../reference/structuralTagTypes1.symbols | 105 +++++ .../reference/structuralTagTypes1.types | 120 ++++++ .../structuralTagTypesControlFlow.errors.txt | 174 ++++++++ .../structuralTagTypesControlFlow.js | 144 +++++++ .../structuralTagTypesControlFlow.symbols | 260 ++++++++++++ .../structuralTagTypesControlFlow.types | 280 +++++++++++++ .../structuralTagTypesDeclarations.js | 29 ++ .../structuralTagTypesDeclarations.symbols | 28 ++ .../structuralTagTypesDeclarations.types | 26 ++ .../structuralTagTypesErr1.errors.txt | 70 ++++ .../reference/structuralTagTypesErr1.js | 46 +++ .../reference/structuralTagTypesErr1.symbols | 95 +++++ .../reference/structuralTagTypesErr1.types | 106 +++++ .../structuralTags/structuralTagTypes.ts | 55 +++ .../structuralTags/structuralTagTypes1.ts | 28 ++ .../structuralTagTypesControlFlow.ts | 82 ++++ .../structuralTagTypesDeclarations.ts | 8 + .../structuralTags/structuralTagTypesErr1.ts | 25 ++ 29 files changed, 2683 insertions(+), 387 deletions(-) create mode 100644 tests/baselines/reference/structuralTagTypes.js create mode 100644 tests/baselines/reference/structuralTagTypes.symbols create mode 100644 tests/baselines/reference/structuralTagTypes.types create mode 100644 tests/baselines/reference/structuralTagTypes1.js create mode 100644 tests/baselines/reference/structuralTagTypes1.symbols create mode 100644 tests/baselines/reference/structuralTagTypes1.types create mode 100644 tests/baselines/reference/structuralTagTypesControlFlow.errors.txt create mode 100644 tests/baselines/reference/structuralTagTypesControlFlow.js create mode 100644 tests/baselines/reference/structuralTagTypesControlFlow.symbols create mode 100644 tests/baselines/reference/structuralTagTypesControlFlow.types create mode 100644 tests/baselines/reference/structuralTagTypesDeclarations.js create mode 100644 tests/baselines/reference/structuralTagTypesDeclarations.symbols create mode 100644 tests/baselines/reference/structuralTagTypesDeclarations.types create mode 100644 tests/baselines/reference/structuralTagTypesErr1.errors.txt create mode 100644 tests/baselines/reference/structuralTagTypesErr1.js create mode 100644 tests/baselines/reference/structuralTagTypesErr1.symbols create mode 100644 tests/baselines/reference/structuralTagTypesErr1.types create mode 100644 tests/cases/conformance/types/structuralTags/structuralTagTypes.ts create mode 100644 tests/cases/conformance/types/structuralTags/structuralTagTypes1.ts create mode 100644 tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts create mode 100644 tests/cases/conformance/types/structuralTags/structuralTagTypesDeclarations.ts create mode 100644 tests/cases/conformance/types/structuralTags/structuralTagTypesErr1.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e3907885a4c0a..0df7ae2d9350c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -629,6 +629,7 @@ namespace ts { const literalTypes = createMap(); const indexedAccessTypes = createMap(); const substitutionTypes = createMap(); + const structuralTags = createMap(); const evolvingArrayTypes: EvolvingArrayType[] = []; const undefinedProperties = createMap() as UnderscoreEscapedMap; @@ -3796,6 +3797,10 @@ namespace ts { if (type.flags & TypeFlags.Substitution) { return typeToTypeNodeHelper((type).typeVariable, context); } + if (type.flags & TypeFlags.StructuralTag) { + context.approximateLength += 4; + return createTypeOperatorNode(SyntaxKind.TagKeyword, typeToTypeNodeHelper((type as StructuralTagType).type, context)); + } return Debug.fail("Should be unreachable."); @@ -8102,6 +8107,9 @@ namespace ts { if (t.flags & TypeFlags.Substitution) { return getBaseConstraint((t).substitute); } + if (t.flags & TypeFlags.StructuralTag) { + return unknownType; + } return t; } } @@ -9924,10 +9932,10 @@ namespace ts { return links.resolvedType; } - function addTypeToIntersection(typeSet: Map, includes: TypeFlags, type: Type) { + function addTypeToIntersection(typeSet: Map, includes: TypeFlags, type: Type, tagSet: Map) { const flags = type.flags; if (flags & TypeFlags.Intersection) { - return addTypesToIntersection(typeSet, includes, (type).types); + return addTypesToIntersection(typeSet, includes, (type).types, tagSet); } if (isEmptyAnonymousObjectType(type)) { if (!(includes & TypeFlags.IncludesEmptyObject)) { @@ -9939,6 +9947,9 @@ namespace ts { if (flags & TypeFlags.AnyOrUnknown) { if (type === wildcardType) includes |= TypeFlags.IncludesWildcard; } + else if (flags & TypeFlags.StructuralTag) { + tagSet.set(type.id.toString(), type as StructuralTagType); + } else if ((strictNullChecks || !(flags & TypeFlags.Nullable)) && !typeSet.has(type.id.toString())) { if (type.flags & TypeFlags.Unit && includes & TypeFlags.Unit) { // We have seen two distinct unit types which means we should reduce to an @@ -9954,9 +9965,23 @@ namespace ts { // Add the given types to the given type set. Order is preserved, freshness is removed from literal // types, duplicates are removed, and nested types of the given kind are flattened into the set. - function addTypesToIntersection(typeSet: Map, includes: TypeFlags, types: readonly Type[]) { + function addTypesToIntersection(typeSet: Map, includes: TypeFlags, types: readonly Type[], tagSet?: Map | undefined) { + const isTopLevel = !tagSet; + tagSet = tagSet || createMap(); for (const type of types) { - includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); + includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type), tagSet); + } + if (isTopLevel && tagSet.size) { + let tag: StructuralTagType; + if (tagSet.size === 1) { + tag = tagSet.values().next().value; + } + else { + const tagTypes: Type[] = []; + tagSet.forEach(t => tagTypes.push(t.type)); + tag = getStructuralTagForType(getIntersectionType(tagTypes)); + } + typeSet.set(tag.id.toString(), tag); } return includes; } @@ -10258,6 +10283,11 @@ namespace ts { case SyntaxKind.ReadonlyKeyword: links.resolvedType = getTypeFromTypeNode(node.type); break; + case SyntaxKind.TagKeyword: + const aliasSymbol = getAliasSymbolForTypeNode(node); + const aliasParams = getTypeArgumentsForAliasSymbol(aliasSymbol); + links.resolvedType = getStructuralTagForType(getTypeFromTypeNode(node.type), aliasSymbol, aliasParams); + break; default: throw Debug.assertNever(node.operator); } @@ -10272,6 +10302,19 @@ namespace ts { return type; } + function getStructuralTagForType(type: Type, aliasSymbol?: Symbol, aliasTypeArguments?: readonly Type[]) { + const tid = "" + getTypeId(type); + if (structuralTags.has(tid)) { + return structuralTags.get(tid)!; + } + const tag = createType(TypeFlags.StructuralTag) as StructuralTagType; + tag.type = type; + tag.aliasSymbol = aliasSymbol; + tag.aliasTypeArguments = aliasTypeArguments; + structuralTags.set(tid, tag); + return tag; + } + /** * Returns if a type is or consists of a JSLiteral object type * In addition to objects which are directly literals, @@ -11703,6 +11746,10 @@ namespace ts { return sub; } } + if (flags & TypeFlags.StructuralTag) { + const newType = instantiateType((type as StructuralTagType).type, mapper); + return newType !== type ? getStructuralTagForType(newType, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; + } return type; } @@ -13419,6 +13466,9 @@ namespace ts { if (flags & TypeFlags.Substitution) { return isRelatedTo((source).substitute, (target).substitute, /*reportErrors*/ false); } + if (flags & TypeFlags.StructuralTag) { + return isRelatedTo((source).type, (target).type, /*reportErrors*/ false); + } return Ternary.False; } @@ -13521,6 +13571,12 @@ namespace ts { } } } + else if (target.flags & TypeFlags.StructuralTag) { + if (source.flags & TypeFlags.StructuralTag) { + return isRelatedTo((source as StructuralTagType).type, (target as StructuralTagType).type, reportErrors); + } + return Ternary.False; + } if (source.flags & TypeFlags.TypeVariable) { if (source.flags & TypeFlags.IndexedAccess && target.flags & TypeFlags.IndexedAccess) { @@ -15724,6 +15780,9 @@ namespace ts { inferFromTypes((source).type, (target).type); contravariant = !contravariant; } + else if (source.flags & TypeFlags.StructuralTag && target.flags & TypeFlags.StructuralTag) { + inferFromTypes((source).type, (target).type); + } else if ((isLiteralType(source) || source.flags & TypeFlags.String) && target.flags & TypeFlags.Index) { const empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 033299cd587f6..4b4b23a1c2489 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -877,8 +877,8 @@ namespace ts { } export function createTypeOperatorNode(type: TypeNode): TypeOperatorNode; - export function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword, type: TypeNode): TypeOperatorNode; - export function createTypeOperatorNode(operatorOrType: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword | TypeNode, type?: TypeNode) { + export function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.TagKeyword, type: TypeNode): TypeOperatorNode; + export function createTypeOperatorNode(operatorOrType: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.TagKeyword | TypeNode, type?: TypeNode) { const node = createSynthesizedNode(SyntaxKind.TypeOperator) as TypeOperatorNode; node.operator = typeof operatorOrType === "number" ? operatorOrType : SyntaxKind.KeyOfKeyword; node.type = parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type! : operatorOrType); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f437ca697a854..2a84fd34571c7 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3057,6 +3057,7 @@ namespace ts { case SyntaxKind.ReadonlyKeyword: case SyntaxKind.SymbolKeyword: case SyntaxKind.UniqueKeyword: + case SyntaxKind.TagKeyword: case SyntaxKind.VoidKeyword: case SyntaxKind.UndefinedKeyword: case SyntaxKind.NullKeyword: @@ -3144,7 +3145,7 @@ namespace ts { return finishNode(postfix); } - function parseTypeOperator(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword) { + function parseTypeOperator(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.TagKeyword) { const node = createNode(SyntaxKind.TypeOperator); parseExpected(operator); node.operator = operator; @@ -3167,6 +3168,7 @@ namespace ts { case SyntaxKind.KeyOfKeyword: case SyntaxKind.UniqueKeyword: case SyntaxKind.ReadonlyKeyword: + case SyntaxKind.TagKeyword: return parseTypeOperator(operator); case SyntaxKind.InferKeyword: return parseInferType(); diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index ad60d29866db6..81db5d3d1fe0e 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -138,6 +138,7 @@ namespace ts { async: SyntaxKind.AsyncKeyword, await: SyntaxKind.AwaitKeyword, of: SyntaxKind.OfKeyword, + tag: SyntaxKind.TagKeyword, }; const textToKeyword = createMapFromTemplate(textToKeywordObj); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1828d056405c6..e161cee538feb 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -103,6 +103,7 @@ namespace ts { | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword + | SyntaxKind.TagKeyword | SyntaxKind.OfKeyword; export type JsxTokenSyntaxKind = @@ -277,6 +278,7 @@ namespace ts { FromKeyword, GlobalKeyword, BigIntKeyword, + TagKeyword, OfKeyword, // LastKeyword and LastToken and LastContextualKeyword // Parse tree nodes @@ -1247,7 +1249,7 @@ namespace ts { export interface TypeOperatorNode extends TypeNode { kind: SyntaxKind.TypeOperator; - operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword; + operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.TagKeyword; type: TypeNode; } @@ -4008,6 +4010,7 @@ namespace ts { Conditional = 1 << 24, // T extends U ? X : Y Substitution = 1 << 25, // Type parameter substitution NonPrimitive = 1 << 26, // intrinsic object type + StructuralTag = 1 << 27, // tag T /* @internal */ AnyOrUnknown = Any | Unknown, @@ -4037,7 +4040,7 @@ namespace ts { UnionOrIntersection = Union | Intersection, StructuredType = Object | Union | Intersection, TypeVariable = TypeParameter | IndexedAccess, - InstantiableNonPrimitive = TypeVariable | Conditional | Substitution, + InstantiableNonPrimitive = TypeVariable | Conditional | Substitution | StructuralTag, InstantiablePrimitive = Index, Instantiable = InstantiableNonPrimitive | InstantiablePrimitive, StructuredOrInstantiable = StructuredType | Instantiable, @@ -4455,6 +4458,11 @@ namespace ts { substitute: Type; // Type to substitute for type parameter } + // Structual tag type, or a `tag T` (TypeFlags.StructuralTag) + export interface StructuralTagType extends InstantiableType { + type: Type; + } + /* @internal */ export const enum JsxReferenceKind { Component, diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 58d513b2e0a4b..5fa7ff239088b 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -73,7 +73,7 @@ declare namespace ts { end: number; } export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; - export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | 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.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | 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 | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; + export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | 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.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | 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 | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.TagKeyword | SyntaxKind.OfKeyword; export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; export enum SyntaxKind { Unknown = 0, @@ -225,179 +225,180 @@ declare namespace ts { FromKeyword = 145, GlobalKeyword = 146, BigIntKeyword = 147, - OfKeyword = 148, - QualifiedName = 149, - ComputedPropertyName = 150, - TypeParameter = 151, - Parameter = 152, - Decorator = 153, - PropertySignature = 154, - PropertyDeclaration = 155, - MethodSignature = 156, - MethodDeclaration = 157, - Constructor = 158, - GetAccessor = 159, - SetAccessor = 160, - CallSignature = 161, - ConstructSignature = 162, - IndexSignature = 163, - TypePredicate = 164, - TypeReference = 165, - FunctionType = 166, - ConstructorType = 167, - TypeQuery = 168, - TypeLiteral = 169, - ArrayType = 170, - TupleType = 171, - OptionalType = 172, - RestType = 173, - UnionType = 174, - IntersectionType = 175, - ConditionalType = 176, - InferType = 177, - ParenthesizedType = 178, - ThisType = 179, - TypeOperator = 180, - IndexedAccessType = 181, - MappedType = 182, - LiteralType = 183, - ImportType = 184, - ObjectBindingPattern = 185, - ArrayBindingPattern = 186, - BindingElement = 187, - ArrayLiteralExpression = 188, - ObjectLiteralExpression = 189, - PropertyAccessExpression = 190, - ElementAccessExpression = 191, - CallExpression = 192, - NewExpression = 193, - TaggedTemplateExpression = 194, - TypeAssertionExpression = 195, - ParenthesizedExpression = 196, - FunctionExpression = 197, - ArrowFunction = 198, - DeleteExpression = 199, - TypeOfExpression = 200, - VoidExpression = 201, - AwaitExpression = 202, - PrefixUnaryExpression = 203, - PostfixUnaryExpression = 204, - BinaryExpression = 205, - ConditionalExpression = 206, - TemplateExpression = 207, - YieldExpression = 208, - SpreadElement = 209, - ClassExpression = 210, - OmittedExpression = 211, - ExpressionWithTypeArguments = 212, - AsExpression = 213, - NonNullExpression = 214, - MetaProperty = 215, - SyntheticExpression = 216, - TemplateSpan = 217, - SemicolonClassElement = 218, - Block = 219, - VariableStatement = 220, - EmptyStatement = 221, - ExpressionStatement = 222, - IfStatement = 223, - DoStatement = 224, - WhileStatement = 225, - ForStatement = 226, - ForInStatement = 227, - ForOfStatement = 228, - ContinueStatement = 229, - BreakStatement = 230, - ReturnStatement = 231, - WithStatement = 232, - SwitchStatement = 233, - LabeledStatement = 234, - ThrowStatement = 235, - TryStatement = 236, - DebuggerStatement = 237, - VariableDeclaration = 238, - VariableDeclarationList = 239, - FunctionDeclaration = 240, - ClassDeclaration = 241, - InterfaceDeclaration = 242, - TypeAliasDeclaration = 243, - EnumDeclaration = 244, - ModuleDeclaration = 245, - ModuleBlock = 246, - CaseBlock = 247, - NamespaceExportDeclaration = 248, - ImportEqualsDeclaration = 249, - ImportDeclaration = 250, - ImportClause = 251, - NamespaceImport = 252, - NamedImports = 253, - ImportSpecifier = 254, - ExportAssignment = 255, - ExportDeclaration = 256, - NamedExports = 257, - ExportSpecifier = 258, - MissingDeclaration = 259, - ExternalModuleReference = 260, - JsxElement = 261, - JsxSelfClosingElement = 262, - JsxOpeningElement = 263, - JsxClosingElement = 264, - JsxFragment = 265, - JsxOpeningFragment = 266, - JsxClosingFragment = 267, - JsxAttribute = 268, - JsxAttributes = 269, - JsxSpreadAttribute = 270, - JsxExpression = 271, - CaseClause = 272, - DefaultClause = 273, - HeritageClause = 274, - CatchClause = 275, - PropertyAssignment = 276, - ShorthandPropertyAssignment = 277, - SpreadAssignment = 278, - EnumMember = 279, - UnparsedPrologue = 280, - UnparsedPrepend = 281, - UnparsedText = 282, - UnparsedInternalText = 283, - UnparsedSyntheticReference = 284, - SourceFile = 285, - Bundle = 286, - UnparsedSource = 287, - InputFiles = 288, - JSDocTypeExpression = 289, - JSDocAllType = 290, - JSDocUnknownType = 291, - JSDocNullableType = 292, - JSDocNonNullableType = 293, - JSDocOptionalType = 294, - JSDocFunctionType = 295, - JSDocVariadicType = 296, - JSDocNamepathType = 297, - JSDocComment = 298, - JSDocTypeLiteral = 299, - JSDocSignature = 300, - JSDocTag = 301, - JSDocAugmentsTag = 302, - JSDocAuthorTag = 303, - JSDocClassTag = 304, - JSDocCallbackTag = 305, - JSDocEnumTag = 306, - JSDocParameterTag = 307, - JSDocReturnTag = 308, - JSDocThisTag = 309, - JSDocTypeTag = 310, - JSDocTemplateTag = 311, - JSDocTypedefTag = 312, - JSDocPropertyTag = 313, - SyntaxList = 314, - NotEmittedStatement = 315, - PartiallyEmittedExpression = 316, - CommaListExpression = 317, - MergeDeclarationMarker = 318, - EndOfDeclarationMarker = 319, - Count = 320, + TagKeyword = 148, + OfKeyword = 149, + QualifiedName = 150, + ComputedPropertyName = 151, + TypeParameter = 152, + Parameter = 153, + Decorator = 154, + PropertySignature = 155, + PropertyDeclaration = 156, + MethodSignature = 157, + MethodDeclaration = 158, + Constructor = 159, + GetAccessor = 160, + SetAccessor = 161, + CallSignature = 162, + ConstructSignature = 163, + IndexSignature = 164, + TypePredicate = 165, + TypeReference = 166, + FunctionType = 167, + ConstructorType = 168, + TypeQuery = 169, + TypeLiteral = 170, + ArrayType = 171, + TupleType = 172, + OptionalType = 173, + RestType = 174, + UnionType = 175, + IntersectionType = 176, + ConditionalType = 177, + InferType = 178, + ParenthesizedType = 179, + ThisType = 180, + TypeOperator = 181, + IndexedAccessType = 182, + MappedType = 183, + LiteralType = 184, + ImportType = 185, + ObjectBindingPattern = 186, + ArrayBindingPattern = 187, + BindingElement = 188, + ArrayLiteralExpression = 189, + ObjectLiteralExpression = 190, + PropertyAccessExpression = 191, + ElementAccessExpression = 192, + CallExpression = 193, + NewExpression = 194, + TaggedTemplateExpression = 195, + TypeAssertionExpression = 196, + ParenthesizedExpression = 197, + FunctionExpression = 198, + ArrowFunction = 199, + DeleteExpression = 200, + TypeOfExpression = 201, + VoidExpression = 202, + AwaitExpression = 203, + PrefixUnaryExpression = 204, + PostfixUnaryExpression = 205, + BinaryExpression = 206, + ConditionalExpression = 207, + TemplateExpression = 208, + YieldExpression = 209, + SpreadElement = 210, + ClassExpression = 211, + OmittedExpression = 212, + ExpressionWithTypeArguments = 213, + AsExpression = 214, + NonNullExpression = 215, + MetaProperty = 216, + SyntheticExpression = 217, + TemplateSpan = 218, + SemicolonClassElement = 219, + Block = 220, + VariableStatement = 221, + EmptyStatement = 222, + ExpressionStatement = 223, + IfStatement = 224, + DoStatement = 225, + WhileStatement = 226, + ForStatement = 227, + ForInStatement = 228, + ForOfStatement = 229, + ContinueStatement = 230, + BreakStatement = 231, + ReturnStatement = 232, + WithStatement = 233, + SwitchStatement = 234, + LabeledStatement = 235, + ThrowStatement = 236, + TryStatement = 237, + DebuggerStatement = 238, + VariableDeclaration = 239, + VariableDeclarationList = 240, + FunctionDeclaration = 241, + ClassDeclaration = 242, + InterfaceDeclaration = 243, + TypeAliasDeclaration = 244, + EnumDeclaration = 245, + ModuleDeclaration = 246, + ModuleBlock = 247, + CaseBlock = 248, + NamespaceExportDeclaration = 249, + ImportEqualsDeclaration = 250, + ImportDeclaration = 251, + ImportClause = 252, + NamespaceImport = 253, + NamedImports = 254, + ImportSpecifier = 255, + ExportAssignment = 256, + ExportDeclaration = 257, + NamedExports = 258, + ExportSpecifier = 259, + MissingDeclaration = 260, + ExternalModuleReference = 261, + JsxElement = 262, + JsxSelfClosingElement = 263, + JsxOpeningElement = 264, + JsxClosingElement = 265, + JsxFragment = 266, + JsxOpeningFragment = 267, + JsxClosingFragment = 268, + JsxAttribute = 269, + JsxAttributes = 270, + JsxSpreadAttribute = 271, + JsxExpression = 272, + CaseClause = 273, + DefaultClause = 274, + HeritageClause = 275, + CatchClause = 276, + PropertyAssignment = 277, + ShorthandPropertyAssignment = 278, + SpreadAssignment = 279, + EnumMember = 280, + UnparsedPrologue = 281, + UnparsedPrepend = 282, + UnparsedText = 283, + UnparsedInternalText = 284, + UnparsedSyntheticReference = 285, + SourceFile = 286, + Bundle = 287, + UnparsedSource = 288, + InputFiles = 289, + JSDocTypeExpression = 290, + JSDocAllType = 291, + JSDocUnknownType = 292, + JSDocNullableType = 293, + JSDocNonNullableType = 294, + JSDocOptionalType = 295, + JSDocFunctionType = 296, + JSDocVariadicType = 297, + JSDocNamepathType = 298, + JSDocComment = 299, + JSDocTypeLiteral = 300, + JSDocSignature = 301, + JSDocTag = 302, + JSDocAugmentsTag = 303, + JSDocAuthorTag = 304, + JSDocClassTag = 305, + JSDocCallbackTag = 306, + JSDocEnumTag = 307, + JSDocParameterTag = 308, + JSDocReturnTag = 309, + JSDocThisTag = 310, + JSDocTypeTag = 311, + JSDocTemplateTag = 312, + JSDocTypedefTag = 313, + JSDocPropertyTag = 314, + SyntaxList = 315, + NotEmittedStatement = 316, + PartiallyEmittedExpression = 317, + CommaListExpression = 318, + MergeDeclarationMarker = 319, + EndOfDeclarationMarker = 320, + Count = 321, FirstAssignment = 60, LastAssignment = 72, FirstCompoundAssignment = 61, @@ -405,15 +406,15 @@ declare namespace ts { FirstReservedWord = 74, LastReservedWord = 109, FirstKeyword = 74, - LastKeyword = 148, + LastKeyword = 149, FirstFutureReservedWord = 110, LastFutureReservedWord = 118, - FirstTypeNode = 164, - LastTypeNode = 184, + FirstTypeNode = 165, + LastTypeNode = 185, FirstPunctuation = 18, LastPunctuation = 72, FirstToken = 0, - LastToken = 148, + LastToken = 149, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -422,11 +423,11 @@ declare namespace ts { LastTemplateToken = 17, FirstBinaryOperator = 28, LastBinaryOperator = 72, - FirstNode = 149, - FirstJSDocNode = 289, - LastJSDocNode = 313, - FirstJSDocTagNode = 301, - LastJSDocTagNode = 313, + FirstNode = 150, + FirstJSDocNode = 290, + LastJSDocNode = 314, + FirstJSDocTagNode = 302, + LastJSDocTagNode = 314, } export enum NodeFlags { None = 0, @@ -823,7 +824,7 @@ declare namespace ts { } export interface TypeOperatorNode extends TypeNode { kind: SyntaxKind.TypeOperator; - operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword; + operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.TagKeyword; type: TypeNode; } export interface IndexedAccessTypeNode extends TypeNode { @@ -2261,6 +2262,7 @@ declare namespace ts { Conditional = 16777216, Substitution = 33554432, NonPrimitive = 67108864, + StructuralTag = 134217728, Literal = 2944, Unit = 109440, StringOrNumberLiteral = 384, @@ -2275,11 +2277,11 @@ declare namespace ts { UnionOrIntersection = 3145728, StructuredType = 3670016, TypeVariable = 8650752, - InstantiableNonPrimitive = 58982400, + InstantiableNonPrimitive = 193200128, InstantiablePrimitive = 4194304, - Instantiable = 63176704, - StructuredOrInstantiable = 66846720, - Narrowable = 133970943, + Instantiable = 197394432, + StructuredOrInstantiable = 201064448, + Narrowable = 268188671, NotUnionOrUnit = 67637251, } export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; @@ -2424,6 +2426,9 @@ declare namespace ts { typeVariable: TypeVariable; substitute: Type; } + export interface StructuralTagType extends InstantiableType { + type: Type; + } export enum SignatureKind { Call = 0, Construct = 1 @@ -3879,7 +3884,7 @@ declare namespace ts { function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; function createThisTypeNode(): ThisTypeNode; function createTypeOperatorNode(type: TypeNode): TypeOperatorNode; - function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword, type: TypeNode): TypeOperatorNode; + function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.TagKeyword, type: TypeNode): TypeOperatorNode; function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode; function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index bc71eaffa373f..e2e7c632a2130 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -73,7 +73,7 @@ declare namespace ts { end: number; } export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; - export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | 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.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | 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 | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; + export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | 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.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | 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 | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.TagKeyword | SyntaxKind.OfKeyword; export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; export enum SyntaxKind { Unknown = 0, @@ -225,179 +225,180 @@ declare namespace ts { FromKeyword = 145, GlobalKeyword = 146, BigIntKeyword = 147, - OfKeyword = 148, - QualifiedName = 149, - ComputedPropertyName = 150, - TypeParameter = 151, - Parameter = 152, - Decorator = 153, - PropertySignature = 154, - PropertyDeclaration = 155, - MethodSignature = 156, - MethodDeclaration = 157, - Constructor = 158, - GetAccessor = 159, - SetAccessor = 160, - CallSignature = 161, - ConstructSignature = 162, - IndexSignature = 163, - TypePredicate = 164, - TypeReference = 165, - FunctionType = 166, - ConstructorType = 167, - TypeQuery = 168, - TypeLiteral = 169, - ArrayType = 170, - TupleType = 171, - OptionalType = 172, - RestType = 173, - UnionType = 174, - IntersectionType = 175, - ConditionalType = 176, - InferType = 177, - ParenthesizedType = 178, - ThisType = 179, - TypeOperator = 180, - IndexedAccessType = 181, - MappedType = 182, - LiteralType = 183, - ImportType = 184, - ObjectBindingPattern = 185, - ArrayBindingPattern = 186, - BindingElement = 187, - ArrayLiteralExpression = 188, - ObjectLiteralExpression = 189, - PropertyAccessExpression = 190, - ElementAccessExpression = 191, - CallExpression = 192, - NewExpression = 193, - TaggedTemplateExpression = 194, - TypeAssertionExpression = 195, - ParenthesizedExpression = 196, - FunctionExpression = 197, - ArrowFunction = 198, - DeleteExpression = 199, - TypeOfExpression = 200, - VoidExpression = 201, - AwaitExpression = 202, - PrefixUnaryExpression = 203, - PostfixUnaryExpression = 204, - BinaryExpression = 205, - ConditionalExpression = 206, - TemplateExpression = 207, - YieldExpression = 208, - SpreadElement = 209, - ClassExpression = 210, - OmittedExpression = 211, - ExpressionWithTypeArguments = 212, - AsExpression = 213, - NonNullExpression = 214, - MetaProperty = 215, - SyntheticExpression = 216, - TemplateSpan = 217, - SemicolonClassElement = 218, - Block = 219, - VariableStatement = 220, - EmptyStatement = 221, - ExpressionStatement = 222, - IfStatement = 223, - DoStatement = 224, - WhileStatement = 225, - ForStatement = 226, - ForInStatement = 227, - ForOfStatement = 228, - ContinueStatement = 229, - BreakStatement = 230, - ReturnStatement = 231, - WithStatement = 232, - SwitchStatement = 233, - LabeledStatement = 234, - ThrowStatement = 235, - TryStatement = 236, - DebuggerStatement = 237, - VariableDeclaration = 238, - VariableDeclarationList = 239, - FunctionDeclaration = 240, - ClassDeclaration = 241, - InterfaceDeclaration = 242, - TypeAliasDeclaration = 243, - EnumDeclaration = 244, - ModuleDeclaration = 245, - ModuleBlock = 246, - CaseBlock = 247, - NamespaceExportDeclaration = 248, - ImportEqualsDeclaration = 249, - ImportDeclaration = 250, - ImportClause = 251, - NamespaceImport = 252, - NamedImports = 253, - ImportSpecifier = 254, - ExportAssignment = 255, - ExportDeclaration = 256, - NamedExports = 257, - ExportSpecifier = 258, - MissingDeclaration = 259, - ExternalModuleReference = 260, - JsxElement = 261, - JsxSelfClosingElement = 262, - JsxOpeningElement = 263, - JsxClosingElement = 264, - JsxFragment = 265, - JsxOpeningFragment = 266, - JsxClosingFragment = 267, - JsxAttribute = 268, - JsxAttributes = 269, - JsxSpreadAttribute = 270, - JsxExpression = 271, - CaseClause = 272, - DefaultClause = 273, - HeritageClause = 274, - CatchClause = 275, - PropertyAssignment = 276, - ShorthandPropertyAssignment = 277, - SpreadAssignment = 278, - EnumMember = 279, - UnparsedPrologue = 280, - UnparsedPrepend = 281, - UnparsedText = 282, - UnparsedInternalText = 283, - UnparsedSyntheticReference = 284, - SourceFile = 285, - Bundle = 286, - UnparsedSource = 287, - InputFiles = 288, - JSDocTypeExpression = 289, - JSDocAllType = 290, - JSDocUnknownType = 291, - JSDocNullableType = 292, - JSDocNonNullableType = 293, - JSDocOptionalType = 294, - JSDocFunctionType = 295, - JSDocVariadicType = 296, - JSDocNamepathType = 297, - JSDocComment = 298, - JSDocTypeLiteral = 299, - JSDocSignature = 300, - JSDocTag = 301, - JSDocAugmentsTag = 302, - JSDocAuthorTag = 303, - JSDocClassTag = 304, - JSDocCallbackTag = 305, - JSDocEnumTag = 306, - JSDocParameterTag = 307, - JSDocReturnTag = 308, - JSDocThisTag = 309, - JSDocTypeTag = 310, - JSDocTemplateTag = 311, - JSDocTypedefTag = 312, - JSDocPropertyTag = 313, - SyntaxList = 314, - NotEmittedStatement = 315, - PartiallyEmittedExpression = 316, - CommaListExpression = 317, - MergeDeclarationMarker = 318, - EndOfDeclarationMarker = 319, - Count = 320, + TagKeyword = 148, + OfKeyword = 149, + QualifiedName = 150, + ComputedPropertyName = 151, + TypeParameter = 152, + Parameter = 153, + Decorator = 154, + PropertySignature = 155, + PropertyDeclaration = 156, + MethodSignature = 157, + MethodDeclaration = 158, + Constructor = 159, + GetAccessor = 160, + SetAccessor = 161, + CallSignature = 162, + ConstructSignature = 163, + IndexSignature = 164, + TypePredicate = 165, + TypeReference = 166, + FunctionType = 167, + ConstructorType = 168, + TypeQuery = 169, + TypeLiteral = 170, + ArrayType = 171, + TupleType = 172, + OptionalType = 173, + RestType = 174, + UnionType = 175, + IntersectionType = 176, + ConditionalType = 177, + InferType = 178, + ParenthesizedType = 179, + ThisType = 180, + TypeOperator = 181, + IndexedAccessType = 182, + MappedType = 183, + LiteralType = 184, + ImportType = 185, + ObjectBindingPattern = 186, + ArrayBindingPattern = 187, + BindingElement = 188, + ArrayLiteralExpression = 189, + ObjectLiteralExpression = 190, + PropertyAccessExpression = 191, + ElementAccessExpression = 192, + CallExpression = 193, + NewExpression = 194, + TaggedTemplateExpression = 195, + TypeAssertionExpression = 196, + ParenthesizedExpression = 197, + FunctionExpression = 198, + ArrowFunction = 199, + DeleteExpression = 200, + TypeOfExpression = 201, + VoidExpression = 202, + AwaitExpression = 203, + PrefixUnaryExpression = 204, + PostfixUnaryExpression = 205, + BinaryExpression = 206, + ConditionalExpression = 207, + TemplateExpression = 208, + YieldExpression = 209, + SpreadElement = 210, + ClassExpression = 211, + OmittedExpression = 212, + ExpressionWithTypeArguments = 213, + AsExpression = 214, + NonNullExpression = 215, + MetaProperty = 216, + SyntheticExpression = 217, + TemplateSpan = 218, + SemicolonClassElement = 219, + Block = 220, + VariableStatement = 221, + EmptyStatement = 222, + ExpressionStatement = 223, + IfStatement = 224, + DoStatement = 225, + WhileStatement = 226, + ForStatement = 227, + ForInStatement = 228, + ForOfStatement = 229, + ContinueStatement = 230, + BreakStatement = 231, + ReturnStatement = 232, + WithStatement = 233, + SwitchStatement = 234, + LabeledStatement = 235, + ThrowStatement = 236, + TryStatement = 237, + DebuggerStatement = 238, + VariableDeclaration = 239, + VariableDeclarationList = 240, + FunctionDeclaration = 241, + ClassDeclaration = 242, + InterfaceDeclaration = 243, + TypeAliasDeclaration = 244, + EnumDeclaration = 245, + ModuleDeclaration = 246, + ModuleBlock = 247, + CaseBlock = 248, + NamespaceExportDeclaration = 249, + ImportEqualsDeclaration = 250, + ImportDeclaration = 251, + ImportClause = 252, + NamespaceImport = 253, + NamedImports = 254, + ImportSpecifier = 255, + ExportAssignment = 256, + ExportDeclaration = 257, + NamedExports = 258, + ExportSpecifier = 259, + MissingDeclaration = 260, + ExternalModuleReference = 261, + JsxElement = 262, + JsxSelfClosingElement = 263, + JsxOpeningElement = 264, + JsxClosingElement = 265, + JsxFragment = 266, + JsxOpeningFragment = 267, + JsxClosingFragment = 268, + JsxAttribute = 269, + JsxAttributes = 270, + JsxSpreadAttribute = 271, + JsxExpression = 272, + CaseClause = 273, + DefaultClause = 274, + HeritageClause = 275, + CatchClause = 276, + PropertyAssignment = 277, + ShorthandPropertyAssignment = 278, + SpreadAssignment = 279, + EnumMember = 280, + UnparsedPrologue = 281, + UnparsedPrepend = 282, + UnparsedText = 283, + UnparsedInternalText = 284, + UnparsedSyntheticReference = 285, + SourceFile = 286, + Bundle = 287, + UnparsedSource = 288, + InputFiles = 289, + JSDocTypeExpression = 290, + JSDocAllType = 291, + JSDocUnknownType = 292, + JSDocNullableType = 293, + JSDocNonNullableType = 294, + JSDocOptionalType = 295, + JSDocFunctionType = 296, + JSDocVariadicType = 297, + JSDocNamepathType = 298, + JSDocComment = 299, + JSDocTypeLiteral = 300, + JSDocSignature = 301, + JSDocTag = 302, + JSDocAugmentsTag = 303, + JSDocAuthorTag = 304, + JSDocClassTag = 305, + JSDocCallbackTag = 306, + JSDocEnumTag = 307, + JSDocParameterTag = 308, + JSDocReturnTag = 309, + JSDocThisTag = 310, + JSDocTypeTag = 311, + JSDocTemplateTag = 312, + JSDocTypedefTag = 313, + JSDocPropertyTag = 314, + SyntaxList = 315, + NotEmittedStatement = 316, + PartiallyEmittedExpression = 317, + CommaListExpression = 318, + MergeDeclarationMarker = 319, + EndOfDeclarationMarker = 320, + Count = 321, FirstAssignment = 60, LastAssignment = 72, FirstCompoundAssignment = 61, @@ -405,15 +406,15 @@ declare namespace ts { FirstReservedWord = 74, LastReservedWord = 109, FirstKeyword = 74, - LastKeyword = 148, + LastKeyword = 149, FirstFutureReservedWord = 110, LastFutureReservedWord = 118, - FirstTypeNode = 164, - LastTypeNode = 184, + FirstTypeNode = 165, + LastTypeNode = 185, FirstPunctuation = 18, LastPunctuation = 72, FirstToken = 0, - LastToken = 148, + LastToken = 149, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -422,11 +423,11 @@ declare namespace ts { LastTemplateToken = 17, FirstBinaryOperator = 28, LastBinaryOperator = 72, - FirstNode = 149, - FirstJSDocNode = 289, - LastJSDocNode = 313, - FirstJSDocTagNode = 301, - LastJSDocTagNode = 313, + FirstNode = 150, + FirstJSDocNode = 290, + LastJSDocNode = 314, + FirstJSDocTagNode = 302, + LastJSDocTagNode = 314, } export enum NodeFlags { None = 0, @@ -823,7 +824,7 @@ declare namespace ts { } export interface TypeOperatorNode extends TypeNode { kind: SyntaxKind.TypeOperator; - operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword; + operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.TagKeyword; type: TypeNode; } export interface IndexedAccessTypeNode extends TypeNode { @@ -2261,6 +2262,7 @@ declare namespace ts { Conditional = 16777216, Substitution = 33554432, NonPrimitive = 67108864, + StructuralTag = 134217728, Literal = 2944, Unit = 109440, StringOrNumberLiteral = 384, @@ -2275,11 +2277,11 @@ declare namespace ts { UnionOrIntersection = 3145728, StructuredType = 3670016, TypeVariable = 8650752, - InstantiableNonPrimitive = 58982400, + InstantiableNonPrimitive = 193200128, InstantiablePrimitive = 4194304, - Instantiable = 63176704, - StructuredOrInstantiable = 66846720, - Narrowable = 133970943, + Instantiable = 197394432, + StructuredOrInstantiable = 201064448, + Narrowable = 268188671, NotUnionOrUnit = 67637251, } export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; @@ -2424,6 +2426,9 @@ declare namespace ts { typeVariable: TypeVariable; substitute: Type; } + export interface StructuralTagType extends InstantiableType { + type: Type; + } export enum SignatureKind { Call = 0, Construct = 1 @@ -3879,7 +3884,7 @@ declare namespace ts { function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; function createThisTypeNode(): ThisTypeNode; function createTypeOperatorNode(type: TypeNode): TypeOperatorNode; - function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword, type: TypeNode): TypeOperatorNode; + function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.TagKeyword, type: TypeNode): TypeOperatorNode; function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode; function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; diff --git a/tests/baselines/reference/structuralTagTypes.js b/tests/baselines/reference/structuralTagTypes.js new file mode 100644 index 0000000000000..6eb7e2e5c5484 --- /dev/null +++ b/tests/baselines/reference/structuralTagTypes.js @@ -0,0 +1,139 @@ +//// [structuralTagTypes.ts] +export type Downcased = string & tag { downcased: void; }; +export type Analyzed = T & tag { analyzed: void; }; +export type Paired = { + x: number & tag {x: number;}; + y: number & tag {y: number;}; +}; + +export function downcase(x: string): Downcased { + return x.toLocaleLowerCase() as Downcased; +} + +export function downcaseLit(x: T): T & Downcased { + return x.toLocaleLowerCase() as T & Downcased; +} + +export function isDowncase(x: string): x is Downcased { + return null as any; +} + +export function analyze(x: T): Analyzed { + return x as Analyzed; +} + +export function isAnalyzed(x: T): x is Analyzed { + return Math.random() > 0.33 ? false : true; +} + +export function isPaired(x: {x: number, y: number}): x is Paired { + return true; +} + +export function makePair(x: number, y: number): Paired { + return {x, y} as Paired; +} + +const a = "ok"; +export const b = downcase(a); +export const d = downcaseLit(b); + +if (isDowncase(d)) { + d; +} + +const e = {data: { value: "str" }}; +export const f = analyze(e); +if (isAnalyzed(e)) { + e; +} + +export const g = makePair(0, 0); +const h = {x: 0, y: 0}; +if (isPaired(h)) { + h; +} + + +//// [structuralTagTypes.js] +"use strict"; +exports.__esModule = true; +function downcase(x) { + return x.toLocaleLowerCase(); +} +exports.downcase = downcase; +function downcaseLit(x) { + return x.toLocaleLowerCase(); +} +exports.downcaseLit = downcaseLit; +function isDowncase(x) { + return null; +} +exports.isDowncase = isDowncase; +function analyze(x) { + return x; +} +exports.analyze = analyze; +function isAnalyzed(x) { + return Math.random() > 0.33 ? false : true; +} +exports.isAnalyzed = isAnalyzed; +function isPaired(x) { + return true; +} +exports.isPaired = isPaired; +function makePair(x, y) { + return { x: x, y: y }; +} +exports.makePair = makePair; +var a = "ok"; +exports.b = downcase(a); +exports.d = downcaseLit(exports.b); +if (isDowncase(exports.d)) { + exports.d; +} +var e = { data: { value: "str" } }; +exports.f = analyze(e); +if (isAnalyzed(e)) { + e; +} +exports.g = makePair(0, 0); +var h = { x: 0, y: 0 }; +if (isPaired(h)) { + h; +} + + +//// [structuralTagTypes.d.ts] +export declare type Downcased = string & tag { + downcased: void; +}; +export declare type Analyzed = T & tag { + analyzed: void; +}; +export declare type Paired = { + x: number & tag { + x: number; + }; + y: number & tag { + y: number; + }; +}; +export declare function downcase(x: string): Downcased; +export declare function downcaseLit(x: T): T & Downcased; +export declare function isDowncase(x: string): x is Downcased; +export declare function analyze(x: T): Analyzed; +export declare function isAnalyzed(x: T): x is Analyzed; +export declare function isPaired(x: { + x: number; + y: number; +}): x is Paired; +export declare function makePair(x: number, y: number): Paired; +export declare const b: Downcased; +export declare const d: Downcased; +export declare const f: Analyzed<{ + data: { + value: string; + }; +}>; +export declare const g: Paired; diff --git a/tests/baselines/reference/structuralTagTypes.symbols b/tests/baselines/reference/structuralTagTypes.symbols new file mode 100644 index 0000000000000..ddea35d683bec --- /dev/null +++ b/tests/baselines/reference/structuralTagTypes.symbols @@ -0,0 +1,169 @@ +=== tests/cases/conformance/types/structuralTags/structuralTagTypes.ts === +export type Downcased = string & tag { downcased: void; }; +>Downcased : Symbol(Downcased, Decl(structuralTagTypes.ts, 0, 0)) +>downcased : Symbol(downcased, Decl(structuralTagTypes.ts, 0, 38)) + +export type Analyzed = T & tag { analyzed: void; }; +>Analyzed : Symbol(Analyzed, Decl(structuralTagTypes.ts, 0, 58)) +>T : Symbol(T, Decl(structuralTagTypes.ts, 1, 21)) +>T : Symbol(T, Decl(structuralTagTypes.ts, 1, 21)) +>analyzed : Symbol(analyzed, Decl(structuralTagTypes.ts, 1, 35)) + +export type Paired = { +>Paired : Symbol(Paired, Decl(structuralTagTypes.ts, 1, 54)) + + x: number & tag {x: number;}; +>x : Symbol(x, Decl(structuralTagTypes.ts, 2, 22)) +>x : Symbol(x, Decl(structuralTagTypes.ts, 3, 21)) + + y: number & tag {y: number;}; +>y : Symbol(y, Decl(structuralTagTypes.ts, 3, 33)) +>y : Symbol(y, Decl(structuralTagTypes.ts, 4, 21)) + +}; + +export function downcase(x: string): Downcased { +>downcase : Symbol(downcase, Decl(structuralTagTypes.ts, 5, 2)) +>x : Symbol(x, Decl(structuralTagTypes.ts, 7, 25)) +>Downcased : Symbol(Downcased, Decl(structuralTagTypes.ts, 0, 0)) + + return x.toLocaleLowerCase() as Downcased; +>x.toLocaleLowerCase : Symbol(String.toLocaleLowerCase, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(structuralTagTypes.ts, 7, 25)) +>toLocaleLowerCase : Symbol(String.toLocaleLowerCase, Decl(lib.es5.d.ts, --, --)) +>Downcased : Symbol(Downcased, Decl(structuralTagTypes.ts, 0, 0)) +} + +export function downcaseLit(x: T): T & Downcased { +>downcaseLit : Symbol(downcaseLit, Decl(structuralTagTypes.ts, 9, 1)) +>T : Symbol(T, Decl(structuralTagTypes.ts, 11, 28)) +>x : Symbol(x, Decl(structuralTagTypes.ts, 11, 46)) +>T : Symbol(T, Decl(structuralTagTypes.ts, 11, 28)) +>T : Symbol(T, Decl(structuralTagTypes.ts, 11, 28)) +>Downcased : Symbol(Downcased, Decl(structuralTagTypes.ts, 0, 0)) + + return x.toLocaleLowerCase() as T & Downcased; +>x.toLocaleLowerCase : Symbol(String.toLocaleLowerCase, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(structuralTagTypes.ts, 11, 46)) +>toLocaleLowerCase : Symbol(String.toLocaleLowerCase, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(structuralTagTypes.ts, 11, 28)) +>Downcased : Symbol(Downcased, Decl(structuralTagTypes.ts, 0, 0)) +} + +export function isDowncase(x: string): x is Downcased { +>isDowncase : Symbol(isDowncase, Decl(structuralTagTypes.ts, 13, 1)) +>x : Symbol(x, Decl(structuralTagTypes.ts, 15, 27)) +>x : Symbol(x, Decl(structuralTagTypes.ts, 15, 27)) +>Downcased : Symbol(Downcased, Decl(structuralTagTypes.ts, 0, 0)) + + return null as any; +} + +export function analyze(x: T): Analyzed { +>analyze : Symbol(analyze, Decl(structuralTagTypes.ts, 17, 1)) +>T : Symbol(T, Decl(structuralTagTypes.ts, 19, 24)) +>x : Symbol(x, Decl(structuralTagTypes.ts, 19, 27)) +>T : Symbol(T, Decl(structuralTagTypes.ts, 19, 24)) +>Analyzed : Symbol(Analyzed, Decl(structuralTagTypes.ts, 0, 58)) +>T : Symbol(T, Decl(structuralTagTypes.ts, 19, 24)) + + return x as Analyzed; +>x : Symbol(x, Decl(structuralTagTypes.ts, 19, 27)) +>Analyzed : Symbol(Analyzed, Decl(structuralTagTypes.ts, 0, 58)) +>T : Symbol(T, Decl(structuralTagTypes.ts, 19, 24)) +} + +export function isAnalyzed(x: T): x is Analyzed { +>isAnalyzed : Symbol(isAnalyzed, Decl(structuralTagTypes.ts, 21, 1)) +>T : Symbol(T, Decl(structuralTagTypes.ts, 23, 27)) +>x : Symbol(x, Decl(structuralTagTypes.ts, 23, 30)) +>T : Symbol(T, Decl(structuralTagTypes.ts, 23, 27)) +>x : Symbol(x, Decl(structuralTagTypes.ts, 23, 30)) +>Analyzed : Symbol(Analyzed, Decl(structuralTagTypes.ts, 0, 58)) +>T : Symbol(T, Decl(structuralTagTypes.ts, 23, 27)) + + return Math.random() > 0.33 ? false : true; +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +} + +export function isPaired(x: {x: number, y: number}): x is Paired { +>isPaired : Symbol(isPaired, Decl(structuralTagTypes.ts, 25, 1)) +>x : Symbol(x, Decl(structuralTagTypes.ts, 27, 25)) +>x : Symbol(x, Decl(structuralTagTypes.ts, 27, 29)) +>y : Symbol(y, Decl(structuralTagTypes.ts, 27, 39)) +>x : Symbol(x, Decl(structuralTagTypes.ts, 27, 25)) +>Paired : Symbol(Paired, Decl(structuralTagTypes.ts, 1, 54)) + + return true; +} + +export function makePair(x: number, y: number): Paired { +>makePair : Symbol(makePair, Decl(structuralTagTypes.ts, 29, 1)) +>x : Symbol(x, Decl(structuralTagTypes.ts, 31, 25)) +>y : Symbol(y, Decl(structuralTagTypes.ts, 31, 35)) +>Paired : Symbol(Paired, Decl(structuralTagTypes.ts, 1, 54)) + + return {x, y} as Paired; +>x : Symbol(x, Decl(structuralTagTypes.ts, 32, 12)) +>y : Symbol(y, Decl(structuralTagTypes.ts, 32, 14)) +>Paired : Symbol(Paired, Decl(structuralTagTypes.ts, 1, 54)) +} + +const a = "ok"; +>a : Symbol(a, Decl(structuralTagTypes.ts, 35, 5)) + +export const b = downcase(a); +>b : Symbol(b, Decl(structuralTagTypes.ts, 36, 12)) +>downcase : Symbol(downcase, Decl(structuralTagTypes.ts, 5, 2)) +>a : Symbol(a, Decl(structuralTagTypes.ts, 35, 5)) + +export const d = downcaseLit(b); +>d : Symbol(d, Decl(structuralTagTypes.ts, 37, 12)) +>downcaseLit : Symbol(downcaseLit, Decl(structuralTagTypes.ts, 9, 1)) +>b : Symbol(b, Decl(structuralTagTypes.ts, 36, 12)) + +if (isDowncase(d)) { +>isDowncase : Symbol(isDowncase, Decl(structuralTagTypes.ts, 13, 1)) +>d : Symbol(d, Decl(structuralTagTypes.ts, 37, 12)) + + d; +>d : Symbol(d, Decl(structuralTagTypes.ts, 37, 12)) +} + +const e = {data: { value: "str" }}; +>e : Symbol(e, Decl(structuralTagTypes.ts, 43, 5)) +>data : Symbol(data, Decl(structuralTagTypes.ts, 43, 11)) +>value : Symbol(value, Decl(structuralTagTypes.ts, 43, 18)) + +export const f = analyze(e); +>f : Symbol(f, Decl(structuralTagTypes.ts, 44, 12)) +>analyze : Symbol(analyze, Decl(structuralTagTypes.ts, 17, 1)) +>e : Symbol(e, Decl(structuralTagTypes.ts, 43, 5)) + +if (isAnalyzed(e)) { +>isAnalyzed : Symbol(isAnalyzed, Decl(structuralTagTypes.ts, 21, 1)) +>e : Symbol(e, Decl(structuralTagTypes.ts, 43, 5)) + + e; +>e : Symbol(e, Decl(structuralTagTypes.ts, 43, 5)) +} + +export const g = makePair(0, 0); +>g : Symbol(g, Decl(structuralTagTypes.ts, 49, 12)) +>makePair : Symbol(makePair, Decl(structuralTagTypes.ts, 29, 1)) + +const h = {x: 0, y: 0}; +>h : Symbol(h, Decl(structuralTagTypes.ts, 50, 5)) +>x : Symbol(x, Decl(structuralTagTypes.ts, 50, 11)) +>y : Symbol(y, Decl(structuralTagTypes.ts, 50, 16)) + +if (isPaired(h)) { +>isPaired : Symbol(isPaired, Decl(structuralTagTypes.ts, 25, 1)) +>h : Symbol(h, Decl(structuralTagTypes.ts, 50, 5)) + + h; +>h : Symbol(h, Decl(structuralTagTypes.ts, 50, 5)) +} + diff --git a/tests/baselines/reference/structuralTagTypes.types b/tests/baselines/reference/structuralTagTypes.types new file mode 100644 index 0000000000000..870c78d1f4730 --- /dev/null +++ b/tests/baselines/reference/structuralTagTypes.types @@ -0,0 +1,174 @@ +=== tests/cases/conformance/types/structuralTags/structuralTagTypes.ts === +export type Downcased = string & tag { downcased: void; }; +>Downcased : Downcased +>downcased : void + +export type Analyzed = T & tag { analyzed: void; }; +>Analyzed : Analyzed +>analyzed : void + +export type Paired = { +>Paired : Paired + + x: number & tag {x: number;}; +>x : number & tag { x: number; } +>x : number + + y: number & tag {y: number;}; +>y : number & tag { y: number; } +>y : number + +}; + +export function downcase(x: string): Downcased { +>downcase : (x: string) => Downcased +>x : string + + return x.toLocaleLowerCase() as Downcased; +>x.toLocaleLowerCase() as Downcased : Downcased +>x.toLocaleLowerCase() : string +>x.toLocaleLowerCase : (locales?: string | string[]) => string +>x : string +>toLocaleLowerCase : (locales?: string | string[]) => string +} + +export function downcaseLit(x: T): T & Downcased { +>downcaseLit : (x: T) => T & string & tag { downcased: void; } +>x : T + + return x.toLocaleLowerCase() as T & Downcased; +>x.toLocaleLowerCase() as T & Downcased : T & string & tag { downcased: void; } +>x.toLocaleLowerCase() : string +>x.toLocaleLowerCase : (locales?: string | string[]) => string +>x : T +>toLocaleLowerCase : (locales?: string | string[]) => string +} + +export function isDowncase(x: string): x is Downcased { +>isDowncase : (x: string) => x is Downcased +>x : string + + return null as any; +>null as any : any +>null : null +} + +export function analyze(x: T): Analyzed { +>analyze : (x: T) => Analyzed +>x : T + + return x as Analyzed; +>x as Analyzed : Analyzed +>x : T +} + +export function isAnalyzed(x: T): x is Analyzed { +>isAnalyzed : (x: T) => x is Analyzed +>x : T + + return Math.random() > 0.33 ? false : true; +>Math.random() > 0.33 ? false : true : boolean +>Math.random() > 0.33 : boolean +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>0.33 : 0.33 +>false : false +>true : true +} + +export function isPaired(x: {x: number, y: number}): x is Paired { +>isPaired : (x: { x: number; y: number; }) => x is Paired +>x : { x: number; y: number; } +>x : number +>y : number + + return true; +>true : true +} + +export function makePair(x: number, y: number): Paired { +>makePair : (x: number, y: number) => Paired +>x : number +>y : number + + return {x, y} as Paired; +>{x, y} as Paired : Paired +>{x, y} : { x: number; y: number; } +>x : number +>y : number +} + +const a = "ok"; +>a : "ok" +>"ok" : "ok" + +export const b = downcase(a); +>b : Downcased +>downcase(a) : Downcased +>downcase : (x: string) => Downcased +>a : "ok" + +export const d = downcaseLit(b); +>d : Downcased +>downcaseLit(b) : Downcased +>downcaseLit : (x: T) => T & string & tag { downcased: void; } +>b : Downcased + +if (isDowncase(d)) { +>isDowncase(d) : boolean +>isDowncase : (x: string) => x is Downcased +>d : Downcased + + d; +>d : Downcased +} + +const e = {data: { value: "str" }}; +>e : { data: { value: string; }; } +>{data: { value: "str" }} : { data: { value: string; }; } +>data : { value: string; } +>{ value: "str" } : { value: string; } +>value : string +>"str" : "str" + +export const f = analyze(e); +>f : Analyzed<{ data: { value: string; }; }> +>analyze(e) : Analyzed<{ data: { value: string; }; }> +>analyze : (x: T) => Analyzed +>e : { data: { value: string; }; } + +if (isAnalyzed(e)) { +>isAnalyzed(e) : boolean +>isAnalyzed : (x: T) => x is Analyzed +>e : { data: { value: string; }; } + + e; +>e : Analyzed<{ data: { value: string; }; }> +} + +export const g = makePair(0, 0); +>g : Paired +>makePair(0, 0) : Paired +>makePair : (x: number, y: number) => Paired +>0 : 0 +>0 : 0 + +const h = {x: 0, y: 0}; +>h : { x: number; y: number; } +>{x: 0, y: 0} : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + +if (isPaired(h)) { +>isPaired(h) : boolean +>isPaired : (x: { x: number; y: number; }) => x is Paired +>h : { x: number; y: number; } + + h; +>h : Paired +} + diff --git a/tests/baselines/reference/structuralTagTypes1.js b/tests/baselines/reference/structuralTagTypes1.js new file mode 100644 index 0000000000000..796e89765f3c4 --- /dev/null +++ b/tests/baselines/reference/structuralTagTypes1.js @@ -0,0 +1,53 @@ +//// [structuralTagTypes1.ts] +export type Paired = { + x: number & tag {x}; + y: number & tag {y}; +}; + + +export function isPaired(x: {x: number, y: number}): x is Paired { + return true; +} + +export function makePair(x: number, y: number): Paired { + return {x, y} as Paired; +} + +const a = makePair(0, 0); +const b = {x: 0, y: 0}; + +if (Math.random() > 0.3) { + b.x = a.x; + b.y = a.y; +} + +if (isPaired(b)) { + b.x = a.x; + b.y = a.y; + a.x = b.x; + a.y = b.y; +} + +//// [structuralTagTypes1.js] +"use strict"; +exports.__esModule = true; +function isPaired(x) { + return true; +} +exports.isPaired = isPaired; +function makePair(x, y) { + return { x: x, y: y }; +} +exports.makePair = makePair; +var a = makePair(0, 0); +var b = { x: 0, y: 0 }; +if (Math.random() > 0.3) { + b.x = a.x; + b.y = a.y; +} +if (isPaired(b)) { + b.x = a.x; + b.y = a.y; + a.x = b.x; + a.y = b.y; +} diff --git a/tests/baselines/reference/structuralTagTypes1.symbols b/tests/baselines/reference/structuralTagTypes1.symbols new file mode 100644 index 0000000000000..7c0961b0e4dc4 --- /dev/null +++ b/tests/baselines/reference/structuralTagTypes1.symbols @@ -0,0 +1,105 @@ +=== tests/cases/conformance/types/structuralTags/structuralTagTypes1.ts === +export type Paired = { +>Paired : Symbol(Paired, Decl(structuralTagTypes1.ts, 0, 0)) + + x: number & tag {x}; +>x : Symbol(x, Decl(structuralTagTypes1.ts, 0, 22)) +>x : Symbol(x, Decl(structuralTagTypes1.ts, 1, 21)) + + y: number & tag {y}; +>y : Symbol(y, Decl(structuralTagTypes1.ts, 1, 24)) +>y : Symbol(y, Decl(structuralTagTypes1.ts, 2, 21)) + +}; + + +export function isPaired(x: {x: number, y: number}): x is Paired { +>isPaired : Symbol(isPaired, Decl(structuralTagTypes1.ts, 3, 2)) +>x : Symbol(x, Decl(structuralTagTypes1.ts, 6, 25)) +>x : Symbol(x, Decl(structuralTagTypes1.ts, 6, 29)) +>y : Symbol(y, Decl(structuralTagTypes1.ts, 6, 39)) +>x : Symbol(x, Decl(structuralTagTypes1.ts, 6, 25)) +>Paired : Symbol(Paired, Decl(structuralTagTypes1.ts, 0, 0)) + + return true; +} + +export function makePair(x: number, y: number): Paired { +>makePair : Symbol(makePair, Decl(structuralTagTypes1.ts, 8, 1)) +>x : Symbol(x, Decl(structuralTagTypes1.ts, 10, 25)) +>y : Symbol(y, Decl(structuralTagTypes1.ts, 10, 35)) +>Paired : Symbol(Paired, Decl(structuralTagTypes1.ts, 0, 0)) + + return {x, y} as Paired; +>x : Symbol(x, Decl(structuralTagTypes1.ts, 11, 12)) +>y : Symbol(y, Decl(structuralTagTypes1.ts, 11, 14)) +>Paired : Symbol(Paired, Decl(structuralTagTypes1.ts, 0, 0)) +} + +const a = makePair(0, 0); +>a : Symbol(a, Decl(structuralTagTypes1.ts, 14, 5)) +>makePair : Symbol(makePair, Decl(structuralTagTypes1.ts, 8, 1)) + +const b = {x: 0, y: 0}; +>b : Symbol(b, Decl(structuralTagTypes1.ts, 15, 5)) +>x : Symbol(x, Decl(structuralTagTypes1.ts, 15, 11)) +>y : Symbol(y, Decl(structuralTagTypes1.ts, 15, 16)) + +if (Math.random() > 0.3) { +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) + + b.x = a.x; +>b.x : Symbol(x, Decl(structuralTagTypes1.ts, 15, 11)) +>b : Symbol(b, Decl(structuralTagTypes1.ts, 15, 5)) +>x : Symbol(x, Decl(structuralTagTypes1.ts, 15, 11)) +>a.x : Symbol(x, Decl(structuralTagTypes1.ts, 0, 22)) +>a : Symbol(a, Decl(structuralTagTypes1.ts, 14, 5)) +>x : Symbol(x, Decl(structuralTagTypes1.ts, 0, 22)) + + b.y = a.y; +>b.y : Symbol(y, Decl(structuralTagTypes1.ts, 15, 16)) +>b : Symbol(b, Decl(structuralTagTypes1.ts, 15, 5)) +>y : Symbol(y, Decl(structuralTagTypes1.ts, 15, 16)) +>a.y : Symbol(y, Decl(structuralTagTypes1.ts, 1, 24)) +>a : Symbol(a, Decl(structuralTagTypes1.ts, 14, 5)) +>y : Symbol(y, Decl(structuralTagTypes1.ts, 1, 24)) +} + +if (isPaired(b)) { +>isPaired : Symbol(isPaired, Decl(structuralTagTypes1.ts, 3, 2)) +>b : Symbol(b, Decl(structuralTagTypes1.ts, 15, 5)) + + b.x = a.x; +>b.x : Symbol(x, Decl(structuralTagTypes1.ts, 0, 22)) +>b : Symbol(b, Decl(structuralTagTypes1.ts, 15, 5)) +>x : Symbol(x, Decl(structuralTagTypes1.ts, 0, 22)) +>a.x : Symbol(x, Decl(structuralTagTypes1.ts, 0, 22)) +>a : Symbol(a, Decl(structuralTagTypes1.ts, 14, 5)) +>x : Symbol(x, Decl(structuralTagTypes1.ts, 0, 22)) + + b.y = a.y; +>b.y : Symbol(y, Decl(structuralTagTypes1.ts, 1, 24)) +>b : Symbol(b, Decl(structuralTagTypes1.ts, 15, 5)) +>y : Symbol(y, Decl(structuralTagTypes1.ts, 1, 24)) +>a.y : Symbol(y, Decl(structuralTagTypes1.ts, 1, 24)) +>a : Symbol(a, Decl(structuralTagTypes1.ts, 14, 5)) +>y : Symbol(y, Decl(structuralTagTypes1.ts, 1, 24)) + + a.x = b.x; +>a.x : Symbol(x, Decl(structuralTagTypes1.ts, 0, 22)) +>a : Symbol(a, Decl(structuralTagTypes1.ts, 14, 5)) +>x : Symbol(x, Decl(structuralTagTypes1.ts, 0, 22)) +>b.x : Symbol(x, Decl(structuralTagTypes1.ts, 0, 22)) +>b : Symbol(b, Decl(structuralTagTypes1.ts, 15, 5)) +>x : Symbol(x, Decl(structuralTagTypes1.ts, 0, 22)) + + a.y = b.y; +>a.y : Symbol(y, Decl(structuralTagTypes1.ts, 1, 24)) +>a : Symbol(a, Decl(structuralTagTypes1.ts, 14, 5)) +>y : Symbol(y, Decl(structuralTagTypes1.ts, 1, 24)) +>b.y : Symbol(y, Decl(structuralTagTypes1.ts, 1, 24)) +>b : Symbol(b, Decl(structuralTagTypes1.ts, 15, 5)) +>y : Symbol(y, Decl(structuralTagTypes1.ts, 1, 24)) +} diff --git a/tests/baselines/reference/structuralTagTypes1.types b/tests/baselines/reference/structuralTagTypes1.types new file mode 100644 index 0000000000000..78ded5be54aac --- /dev/null +++ b/tests/baselines/reference/structuralTagTypes1.types @@ -0,0 +1,120 @@ +=== tests/cases/conformance/types/structuralTags/structuralTagTypes1.ts === +export type Paired = { +>Paired : Paired + + x: number & tag {x}; +>x : number & tag { x: any; } +>x : any + + y: number & tag {y}; +>y : number & tag { y: any; } +>y : any + +}; + + +export function isPaired(x: {x: number, y: number}): x is Paired { +>isPaired : (x: { x: number; y: number; }) => x is Paired +>x : { x: number; y: number; } +>x : number +>y : number + + return true; +>true : true +} + +export function makePair(x: number, y: number): Paired { +>makePair : (x: number, y: number) => Paired +>x : number +>y : number + + return {x, y} as Paired; +>{x, y} as Paired : Paired +>{x, y} : { x: number; y: number; } +>x : number +>y : number +} + +const a = makePair(0, 0); +>a : Paired +>makePair(0, 0) : Paired +>makePair : (x: number, y: number) => Paired +>0 : 0 +>0 : 0 + +const b = {x: 0, y: 0}; +>b : { x: number; y: number; } +>{x: 0, y: 0} : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + +if (Math.random() > 0.3) { +>Math.random() > 0.3 : boolean +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>0.3 : 0.3 + + b.x = a.x; +>b.x = a.x : number & tag { x: any; } +>b.x : number +>b : { x: number; y: number; } +>x : number +>a.x : number & tag { x: any; } +>a : Paired +>x : number & tag { x: any; } + + b.y = a.y; +>b.y = a.y : number & tag { y: any; } +>b.y : number +>b : { x: number; y: number; } +>y : number +>a.y : number & tag { y: any; } +>a : Paired +>y : number & tag { y: any; } +} + +if (isPaired(b)) { +>isPaired(b) : boolean +>isPaired : (x: { x: number; y: number; }) => x is Paired +>b : { x: number; y: number; } + + b.x = a.x; +>b.x = a.x : number & tag { x: any; } +>b.x : number & tag { x: any; } +>b : Paired +>x : number & tag { x: any; } +>a.x : number & tag { x: any; } +>a : Paired +>x : number & tag { x: any; } + + b.y = a.y; +>b.y = a.y : number & tag { y: any; } +>b.y : number & tag { y: any; } +>b : Paired +>y : number & tag { y: any; } +>a.y : number & tag { y: any; } +>a : Paired +>y : number & tag { y: any; } + + a.x = b.x; +>a.x = b.x : number & tag { x: any; } +>a.x : number & tag { x: any; } +>a : Paired +>x : number & tag { x: any; } +>b.x : number & tag { x: any; } +>b : Paired +>x : number & tag { x: any; } + + a.y = b.y; +>a.y = b.y : number & tag { y: any; } +>a.y : number & tag { y: any; } +>a : Paired +>y : number & tag { y: any; } +>b.y : number & tag { y: any; } +>b : Paired +>y : number & tag { y: any; } +} diff --git a/tests/baselines/reference/structuralTagTypesControlFlow.errors.txt b/tests/baselines/reference/structuralTagTypesControlFlow.errors.txt new file mode 100644 index 0000000000000..acfdcceae9190 --- /dev/null +++ b/tests/baselines/reference/structuralTagTypesControlFlow.errors.txt @@ -0,0 +1,174 @@ +tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(22,23): error TS2345: Argument of type '{ x: number; } & BrandA' is not assignable to parameter of type 'BrandB'. +tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(24,27): error TS2345: Argument of type '{ x: number; } & BrandA' is not assignable to parameter of type 'tag ({ BrandA: void; } & { BrandB: void; })'. +tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(29,23): error TS2345: Argument of type '{ x: number; } & BrandB' is not assignable to parameter of type 'BrandA'. +tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(32,27): error TS2345: Argument of type '{ x: number; } & BrandB' is not assignable to parameter of type 'tag ({ BrandA: void; } & { BrandB: void; })'. +tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(35,23): error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type 'BrandA'. +tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(36,23): error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type 'BrandB'. +tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(37,26): error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type 'BrandA | BrandB'. + Type '{ x: number; }' is not assignable to type 'BrandB'. +tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(38,27): error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type 'tag ({ BrandA: void; } & { BrandB: void; })'. +tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(64,29): error TS2345: Argument of type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to parameter of type 'AbsolutePath'. + Type '"/a/b/c"' is not assignable to type 'AbsolutePath'. + Type '"/a/b/c"' is not assignable to type 'tag { AbsolutePath: void; }'. + Type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to type 'tag { AbsolutePath: void; }'. + Type '"/a/b/c"' is not assignable to type 'tag { AbsolutePath: void; }'. +tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(66,39): error TS2345: Argument of type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to parameter of type 'NormalizedAbsolutePath'. + Type '"/a/b/c"' is not assignable to type 'NormalizedAbsolutePath'. + Type '"/a/b/c"' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. + Type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. + Type '"/a/b/c"' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. +tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(71,31): error TS2345: Argument of type '"/a/b/c" & tag { AbsolutePath: void; }' is not assignable to parameter of type 'NormalizedPath'. + Type '"/a/b/c"' is not assignable to type 'NormalizedPath'. + Type '"/a/b/c"' is not assignable to type 'tag { NormalizedPath: void; }'. + Type '"/a/b/c" & tag { AbsolutePath: void; }' is not assignable to type 'tag { NormalizedPath: void; }'. + Type '"/a/b/c"' is not assignable to type 'tag { NormalizedPath: void; }'. +tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(74,39): error TS2345: Argument of type '"/a/b/c" & tag { AbsolutePath: void; }' is not assignable to parameter of type 'NormalizedAbsolutePath'. + Type '"/a/b/c"' is not assignable to type 'NormalizedAbsolutePath'. + Type '"/a/b/c"' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. + Type '"/a/b/c" & tag { AbsolutePath: void; }' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. + Type '"/a/b/c"' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. +tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(77,31): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath'. + Type '"/a/b/c"' is not assignable to type 'tag { NormalizedPath: void; }'. +tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(78,29): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'AbsolutePath'. + Type '"/a/b/c"' is not assignable to type 'tag { AbsolutePath: void; }'. +tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(79,41): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath | AbsolutePath'. +tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(80,39): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedAbsolutePath'. + Type '"/a/b/c"' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. + + +==== tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts (16 errors) ==== + type BrandA = tag {BrandA: void}; + type BrandB = tag {BrandB: void}; + + declare function isBrandA(x: any): x is BrandA; + declare function isBrandB(x: any): x is BrandB; + + declare function consumeBrandA(x: BrandA): void; + declare function consumeBrandB(x: BrandB): void; + declare function consumeBrandAOrB(x: BrandA | BrandB): void; + declare function consumeBrandAAndB(x: BrandA & BrandB): void; + + const x = {x: 12}; + if (isBrandA(x)) { + if (isBrandB(x)) { + consumeBrandA(x); + consumeBrandB(x); + consumeBrandAOrB(x); + consumeBrandAAndB(x); + } + else { + consumeBrandA(x); + consumeBrandB(x); // err + ~ +!!! error TS2345: Argument of type '{ x: number; } & BrandA' is not assignable to parameter of type 'BrandB'. + consumeBrandAOrB(x); + consumeBrandAAndB(x); // err + ~ +!!! error TS2345: Argument of type '{ x: number; } & BrandA' is not assignable to parameter of type 'tag ({ BrandA: void; } & { BrandB: void; })'. + } + } + else { + if (isBrandB(x)) { + consumeBrandA(x); // err + ~ +!!! error TS2345: Argument of type '{ x: number; } & BrandB' is not assignable to parameter of type 'BrandA'. + consumeBrandB(x); + consumeBrandAOrB(x); + consumeBrandAAndB(x); // err + ~ +!!! error TS2345: Argument of type '{ x: number; } & BrandB' is not assignable to parameter of type 'tag ({ BrandA: void; } & { BrandB: void; })'. + } + else { + consumeBrandA(x); // err + ~ +!!! error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type 'BrandA'. + consumeBrandB(x); // err + ~ +!!! error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type 'BrandB'. + consumeBrandAOrB(x); // err + ~ +!!! error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type 'BrandA | BrandB'. +!!! error TS2345: Type '{ x: number; }' is not assignable to type 'BrandB'. + consumeBrandAAndB(x); // err + ~ +!!! error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type 'tag ({ BrandA: void; } & { BrandB: void; })'. + } + } + + type NormalizedPath = string & tag {NormalizedPath: void}; + type AbsolutePath = string & tag {AbsolutePath: void}; + type NormalizedAbsolutePath = NormalizedPath & AbsolutePath; + + declare function isNormalizedPath(x: string): x is NormalizedPath; + declare function isAbsolutePath(x: string): x is AbsolutePath; + + declare function consumeNormalizedPath(x: NormalizedPath): void; + declare function consumeAbsolutePath(x: AbsolutePath): void; + declare function consumeNormalizedOrAbsolutePath(x: NormalizedPath | AbsolutePath): void; + declare function consumeNormalizedAbsolutePath(x: NormalizedAbsolutePath): void; + + const p = "/a/b/c"; + if (isNormalizedPath(p)) { + if (isAbsolutePath(p)) { + consumeNormalizedPath(p); + consumeAbsolutePath(p); + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); + } + else { + consumeNormalizedPath(p); + consumeAbsolutePath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to parameter of type 'AbsolutePath'. +!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'AbsolutePath'. +!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'tag { AbsolutePath: void; }'. +!!! error TS2345: Type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to type 'tag { AbsolutePath: void; }'. +!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'tag { AbsolutePath: void; }'. + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to parameter of type 'NormalizedAbsolutePath'. +!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'NormalizedAbsolutePath'. +!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. +!!! error TS2345: Type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. +!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. + } + } + else { + if (isAbsolutePath(p)) { + consumeNormalizedPath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c" & tag { AbsolutePath: void; }' is not assignable to parameter of type 'NormalizedPath'. +!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'NormalizedPath'. +!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'tag { NormalizedPath: void; }'. +!!! error TS2345: Type '"/a/b/c" & tag { AbsolutePath: void; }' is not assignable to type 'tag { NormalizedPath: void; }'. +!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'tag { NormalizedPath: void; }'. + consumeAbsolutePath(p); + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c" & tag { AbsolutePath: void; }' is not assignable to parameter of type 'NormalizedAbsolutePath'. +!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'NormalizedAbsolutePath'. +!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. +!!! error TS2345: Type '"/a/b/c" & tag { AbsolutePath: void; }' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. +!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. + } + else { + consumeNormalizedPath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath'. +!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'tag { NormalizedPath: void; }'. + consumeAbsolutePath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'AbsolutePath'. +!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'tag { AbsolutePath: void; }'. + consumeNormalizedOrAbsolutePath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath | AbsolutePath'. + consumeNormalizedAbsolutePath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedAbsolutePath'. +!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/structuralTagTypesControlFlow.js b/tests/baselines/reference/structuralTagTypesControlFlow.js new file mode 100644 index 0000000000000..9e07fc4d860f2 --- /dev/null +++ b/tests/baselines/reference/structuralTagTypesControlFlow.js @@ -0,0 +1,144 @@ +//// [structuralTagTypesControlFlow.ts] +type BrandA = tag {BrandA: void}; +type BrandB = tag {BrandB: void}; + +declare function isBrandA(x: any): x is BrandA; +declare function isBrandB(x: any): x is BrandB; + +declare function consumeBrandA(x: BrandA): void; +declare function consumeBrandB(x: BrandB): void; +declare function consumeBrandAOrB(x: BrandA | BrandB): void; +declare function consumeBrandAAndB(x: BrandA & BrandB): void; + +const x = {x: 12}; +if (isBrandA(x)) { + if (isBrandB(x)) { + consumeBrandA(x); + consumeBrandB(x); + consumeBrandAOrB(x); + consumeBrandAAndB(x); + } + else { + consumeBrandA(x); + consumeBrandB(x); // err + consumeBrandAOrB(x); + consumeBrandAAndB(x); // err + } +} +else { + if (isBrandB(x)) { + consumeBrandA(x); // err + consumeBrandB(x); + consumeBrandAOrB(x); + consumeBrandAAndB(x); // err + } + else { + consumeBrandA(x); // err + consumeBrandB(x); // err + consumeBrandAOrB(x); // err + consumeBrandAAndB(x); // err + } +} + +type NormalizedPath = string & tag {NormalizedPath: void}; +type AbsolutePath = string & tag {AbsolutePath: void}; +type NormalizedAbsolutePath = NormalizedPath & AbsolutePath; + +declare function isNormalizedPath(x: string): x is NormalizedPath; +declare function isAbsolutePath(x: string): x is AbsolutePath; + +declare function consumeNormalizedPath(x: NormalizedPath): void; +declare function consumeAbsolutePath(x: AbsolutePath): void; +declare function consumeNormalizedOrAbsolutePath(x: NormalizedPath | AbsolutePath): void; +declare function consumeNormalizedAbsolutePath(x: NormalizedAbsolutePath): void; + +const p = "/a/b/c"; +if (isNormalizedPath(p)) { + if (isAbsolutePath(p)) { + consumeNormalizedPath(p); + consumeAbsolutePath(p); + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); + } + else { + consumeNormalizedPath(p); + consumeAbsolutePath(p); // err + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); // err + } +} +else { + if (isAbsolutePath(p)) { + consumeNormalizedPath(p); // err + consumeAbsolutePath(p); + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); // err + } + else { + consumeNormalizedPath(p); // err + consumeAbsolutePath(p); // err + consumeNormalizedOrAbsolutePath(p); // err + consumeNormalizedAbsolutePath(p); // err + } +} + + +//// [structuralTagTypesControlFlow.js] +var x = { x: 12 }; +if (isBrandA(x)) { + if (isBrandB(x)) { + consumeBrandA(x); + consumeBrandB(x); + consumeBrandAOrB(x); + consumeBrandAAndB(x); + } + else { + consumeBrandA(x); + consumeBrandB(x); // err + consumeBrandAOrB(x); + consumeBrandAAndB(x); // err + } +} +else { + if (isBrandB(x)) { + consumeBrandA(x); // err + consumeBrandB(x); + consumeBrandAOrB(x); + consumeBrandAAndB(x); // err + } + else { + consumeBrandA(x); // err + consumeBrandB(x); // err + consumeBrandAOrB(x); // err + consumeBrandAAndB(x); // err + } +} +var p = "/a/b/c"; +if (isNormalizedPath(p)) { + if (isAbsolutePath(p)) { + consumeNormalizedPath(p); + consumeAbsolutePath(p); + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); + } + else { + consumeNormalizedPath(p); + consumeAbsolutePath(p); // err + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); // err + } +} +else { + if (isAbsolutePath(p)) { + consumeNormalizedPath(p); // err + consumeAbsolutePath(p); + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); // err + } + else { + consumeNormalizedPath(p); // err + consumeAbsolutePath(p); // err + consumeNormalizedOrAbsolutePath(p); // err + consumeNormalizedAbsolutePath(p); // err + } +} diff --git a/tests/baselines/reference/structuralTagTypesControlFlow.symbols b/tests/baselines/reference/structuralTagTypesControlFlow.symbols new file mode 100644 index 0000000000000..f4b2ea78107ae --- /dev/null +++ b/tests/baselines/reference/structuralTagTypesControlFlow.symbols @@ -0,0 +1,260 @@ +=== tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts === +type BrandA = tag {BrandA: void}; +>BrandA : Symbol(BrandA, Decl(structuralTagTypesControlFlow.ts, 0, 0)) +>BrandA : Symbol(BrandA, Decl(structuralTagTypesControlFlow.ts, 0, 19)) + +type BrandB = tag {BrandB: void}; +>BrandB : Symbol(BrandB, Decl(structuralTagTypesControlFlow.ts, 0, 33)) +>BrandB : Symbol(BrandB, Decl(structuralTagTypesControlFlow.ts, 1, 19)) + +declare function isBrandA(x: any): x is BrandA; +>isBrandA : Symbol(isBrandA, Decl(structuralTagTypesControlFlow.ts, 1, 33)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 3, 26)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 3, 26)) +>BrandA : Symbol(BrandA, Decl(structuralTagTypesControlFlow.ts, 0, 0)) + +declare function isBrandB(x: any): x is BrandB; +>isBrandB : Symbol(isBrandB, Decl(structuralTagTypesControlFlow.ts, 3, 47)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 4, 26)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 4, 26)) +>BrandB : Symbol(BrandB, Decl(structuralTagTypesControlFlow.ts, 0, 33)) + +declare function consumeBrandA(x: BrandA): void; +>consumeBrandA : Symbol(consumeBrandA, Decl(structuralTagTypesControlFlow.ts, 4, 47)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 6, 31)) +>BrandA : Symbol(BrandA, Decl(structuralTagTypesControlFlow.ts, 0, 0)) + +declare function consumeBrandB(x: BrandB): void; +>consumeBrandB : Symbol(consumeBrandB, Decl(structuralTagTypesControlFlow.ts, 6, 48)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 7, 31)) +>BrandB : Symbol(BrandB, Decl(structuralTagTypesControlFlow.ts, 0, 33)) + +declare function consumeBrandAOrB(x: BrandA | BrandB): void; +>consumeBrandAOrB : Symbol(consumeBrandAOrB, Decl(structuralTagTypesControlFlow.ts, 7, 48)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 8, 34)) +>BrandA : Symbol(BrandA, Decl(structuralTagTypesControlFlow.ts, 0, 0)) +>BrandB : Symbol(BrandB, Decl(structuralTagTypesControlFlow.ts, 0, 33)) + +declare function consumeBrandAAndB(x: BrandA & BrandB): void; +>consumeBrandAAndB : Symbol(consumeBrandAAndB, Decl(structuralTagTypesControlFlow.ts, 8, 60)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 9, 35)) +>BrandA : Symbol(BrandA, Decl(structuralTagTypesControlFlow.ts, 0, 0)) +>BrandB : Symbol(BrandB, Decl(structuralTagTypesControlFlow.ts, 0, 33)) + +const x = {x: 12}; +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 11, 5)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 11, 11)) + +if (isBrandA(x)) { +>isBrandA : Symbol(isBrandA, Decl(structuralTagTypesControlFlow.ts, 1, 33)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 11, 5)) + + if (isBrandB(x)) { +>isBrandB : Symbol(isBrandB, Decl(structuralTagTypesControlFlow.ts, 3, 47)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 11, 5)) + + consumeBrandA(x); +>consumeBrandA : Symbol(consumeBrandA, Decl(structuralTagTypesControlFlow.ts, 4, 47)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 11, 5)) + + consumeBrandB(x); +>consumeBrandB : Symbol(consumeBrandB, Decl(structuralTagTypesControlFlow.ts, 6, 48)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 11, 5)) + + consumeBrandAOrB(x); +>consumeBrandAOrB : Symbol(consumeBrandAOrB, Decl(structuralTagTypesControlFlow.ts, 7, 48)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 11, 5)) + + consumeBrandAAndB(x); +>consumeBrandAAndB : Symbol(consumeBrandAAndB, Decl(structuralTagTypesControlFlow.ts, 8, 60)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 11, 5)) + } + else { + consumeBrandA(x); +>consumeBrandA : Symbol(consumeBrandA, Decl(structuralTagTypesControlFlow.ts, 4, 47)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 11, 5)) + + consumeBrandB(x); // err +>consumeBrandB : Symbol(consumeBrandB, Decl(structuralTagTypesControlFlow.ts, 6, 48)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 11, 5)) + + consumeBrandAOrB(x); +>consumeBrandAOrB : Symbol(consumeBrandAOrB, Decl(structuralTagTypesControlFlow.ts, 7, 48)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 11, 5)) + + consumeBrandAAndB(x); // err +>consumeBrandAAndB : Symbol(consumeBrandAAndB, Decl(structuralTagTypesControlFlow.ts, 8, 60)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 11, 5)) + } +} +else { + if (isBrandB(x)) { +>isBrandB : Symbol(isBrandB, Decl(structuralTagTypesControlFlow.ts, 3, 47)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 11, 5)) + + consumeBrandA(x); // err +>consumeBrandA : Symbol(consumeBrandA, Decl(structuralTagTypesControlFlow.ts, 4, 47)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 11, 5)) + + consumeBrandB(x); +>consumeBrandB : Symbol(consumeBrandB, Decl(structuralTagTypesControlFlow.ts, 6, 48)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 11, 5)) + + consumeBrandAOrB(x); +>consumeBrandAOrB : Symbol(consumeBrandAOrB, Decl(structuralTagTypesControlFlow.ts, 7, 48)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 11, 5)) + + consumeBrandAAndB(x); // err +>consumeBrandAAndB : Symbol(consumeBrandAAndB, Decl(structuralTagTypesControlFlow.ts, 8, 60)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 11, 5)) + } + else { + consumeBrandA(x); // err +>consumeBrandA : Symbol(consumeBrandA, Decl(structuralTagTypesControlFlow.ts, 4, 47)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 11, 5)) + + consumeBrandB(x); // err +>consumeBrandB : Symbol(consumeBrandB, Decl(structuralTagTypesControlFlow.ts, 6, 48)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 11, 5)) + + consumeBrandAOrB(x); // err +>consumeBrandAOrB : Symbol(consumeBrandAOrB, Decl(structuralTagTypesControlFlow.ts, 7, 48)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 11, 5)) + + consumeBrandAAndB(x); // err +>consumeBrandAAndB : Symbol(consumeBrandAAndB, Decl(structuralTagTypesControlFlow.ts, 8, 60)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 11, 5)) + } +} + +type NormalizedPath = string & tag {NormalizedPath: void}; +>NormalizedPath : Symbol(NormalizedPath, Decl(structuralTagTypesControlFlow.ts, 39, 1)) +>NormalizedPath : Symbol(NormalizedPath, Decl(structuralTagTypesControlFlow.ts, 41, 36)) + +type AbsolutePath = string & tag {AbsolutePath: void}; +>AbsolutePath : Symbol(AbsolutePath, Decl(structuralTagTypesControlFlow.ts, 41, 58)) +>AbsolutePath : Symbol(AbsolutePath, Decl(structuralTagTypesControlFlow.ts, 42, 34)) + +type NormalizedAbsolutePath = NormalizedPath & AbsolutePath; +>NormalizedAbsolutePath : Symbol(NormalizedAbsolutePath, Decl(structuralTagTypesControlFlow.ts, 42, 54)) +>NormalizedPath : Symbol(NormalizedPath, Decl(structuralTagTypesControlFlow.ts, 39, 1)) +>AbsolutePath : Symbol(AbsolutePath, Decl(structuralTagTypesControlFlow.ts, 41, 58)) + +declare function isNormalizedPath(x: string): x is NormalizedPath; +>isNormalizedPath : Symbol(isNormalizedPath, Decl(structuralTagTypesControlFlow.ts, 43, 60)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 45, 34)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 45, 34)) +>NormalizedPath : Symbol(NormalizedPath, Decl(structuralTagTypesControlFlow.ts, 39, 1)) + +declare function isAbsolutePath(x: string): x is AbsolutePath; +>isAbsolutePath : Symbol(isAbsolutePath, Decl(structuralTagTypesControlFlow.ts, 45, 66)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 46, 32)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 46, 32)) +>AbsolutePath : Symbol(AbsolutePath, Decl(structuralTagTypesControlFlow.ts, 41, 58)) + +declare function consumeNormalizedPath(x: NormalizedPath): void; +>consumeNormalizedPath : Symbol(consumeNormalizedPath, Decl(structuralTagTypesControlFlow.ts, 46, 62)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 48, 39)) +>NormalizedPath : Symbol(NormalizedPath, Decl(structuralTagTypesControlFlow.ts, 39, 1)) + +declare function consumeAbsolutePath(x: AbsolutePath): void; +>consumeAbsolutePath : Symbol(consumeAbsolutePath, Decl(structuralTagTypesControlFlow.ts, 48, 64)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 49, 37)) +>AbsolutePath : Symbol(AbsolutePath, Decl(structuralTagTypesControlFlow.ts, 41, 58)) + +declare function consumeNormalizedOrAbsolutePath(x: NormalizedPath | AbsolutePath): void; +>consumeNormalizedOrAbsolutePath : Symbol(consumeNormalizedOrAbsolutePath, Decl(structuralTagTypesControlFlow.ts, 49, 60)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 50, 49)) +>NormalizedPath : Symbol(NormalizedPath, Decl(structuralTagTypesControlFlow.ts, 39, 1)) +>AbsolutePath : Symbol(AbsolutePath, Decl(structuralTagTypesControlFlow.ts, 41, 58)) + +declare function consumeNormalizedAbsolutePath(x: NormalizedAbsolutePath): void; +>consumeNormalizedAbsolutePath : Symbol(consumeNormalizedAbsolutePath, Decl(structuralTagTypesControlFlow.ts, 50, 89)) +>x : Symbol(x, Decl(structuralTagTypesControlFlow.ts, 51, 47)) +>NormalizedAbsolutePath : Symbol(NormalizedAbsolutePath, Decl(structuralTagTypesControlFlow.ts, 42, 54)) + +const p = "/a/b/c"; +>p : Symbol(p, Decl(structuralTagTypesControlFlow.ts, 53, 5)) + +if (isNormalizedPath(p)) { +>isNormalizedPath : Symbol(isNormalizedPath, Decl(structuralTagTypesControlFlow.ts, 43, 60)) +>p : Symbol(p, Decl(structuralTagTypesControlFlow.ts, 53, 5)) + + if (isAbsolutePath(p)) { +>isAbsolutePath : Symbol(isAbsolutePath, Decl(structuralTagTypesControlFlow.ts, 45, 66)) +>p : Symbol(p, Decl(structuralTagTypesControlFlow.ts, 53, 5)) + + consumeNormalizedPath(p); +>consumeNormalizedPath : Symbol(consumeNormalizedPath, Decl(structuralTagTypesControlFlow.ts, 46, 62)) +>p : Symbol(p, Decl(structuralTagTypesControlFlow.ts, 53, 5)) + + consumeAbsolutePath(p); +>consumeAbsolutePath : Symbol(consumeAbsolutePath, Decl(structuralTagTypesControlFlow.ts, 48, 64)) +>p : Symbol(p, Decl(structuralTagTypesControlFlow.ts, 53, 5)) + + consumeNormalizedOrAbsolutePath(p); +>consumeNormalizedOrAbsolutePath : Symbol(consumeNormalizedOrAbsolutePath, Decl(structuralTagTypesControlFlow.ts, 49, 60)) +>p : Symbol(p, Decl(structuralTagTypesControlFlow.ts, 53, 5)) + + consumeNormalizedAbsolutePath(p); +>consumeNormalizedAbsolutePath : Symbol(consumeNormalizedAbsolutePath, Decl(structuralTagTypesControlFlow.ts, 50, 89)) +>p : Symbol(p, Decl(structuralTagTypesControlFlow.ts, 53, 5)) + } + else { + consumeNormalizedPath(p); +>consumeNormalizedPath : Symbol(consumeNormalizedPath, Decl(structuralTagTypesControlFlow.ts, 46, 62)) +>p : Symbol(p, Decl(structuralTagTypesControlFlow.ts, 53, 5)) + + consumeAbsolutePath(p); // err +>consumeAbsolutePath : Symbol(consumeAbsolutePath, Decl(structuralTagTypesControlFlow.ts, 48, 64)) +>p : Symbol(p, Decl(structuralTagTypesControlFlow.ts, 53, 5)) + + consumeNormalizedOrAbsolutePath(p); +>consumeNormalizedOrAbsolutePath : Symbol(consumeNormalizedOrAbsolutePath, Decl(structuralTagTypesControlFlow.ts, 49, 60)) +>p : Symbol(p, Decl(structuralTagTypesControlFlow.ts, 53, 5)) + + consumeNormalizedAbsolutePath(p); // err +>consumeNormalizedAbsolutePath : Symbol(consumeNormalizedAbsolutePath, Decl(structuralTagTypesControlFlow.ts, 50, 89)) +>p : Symbol(p, Decl(structuralTagTypesControlFlow.ts, 53, 5)) + } +} +else { + if (isAbsolutePath(p)) { +>isAbsolutePath : Symbol(isAbsolutePath, Decl(structuralTagTypesControlFlow.ts, 45, 66)) +>p : Symbol(p, Decl(structuralTagTypesControlFlow.ts, 53, 5)) + + consumeNormalizedPath(p); // err +>consumeNormalizedPath : Symbol(consumeNormalizedPath, Decl(structuralTagTypesControlFlow.ts, 46, 62)) +>p : Symbol(p, Decl(structuralTagTypesControlFlow.ts, 53, 5)) + + consumeAbsolutePath(p); +>consumeAbsolutePath : Symbol(consumeAbsolutePath, Decl(structuralTagTypesControlFlow.ts, 48, 64)) +>p : Symbol(p, Decl(structuralTagTypesControlFlow.ts, 53, 5)) + + consumeNormalizedOrAbsolutePath(p); +>consumeNormalizedOrAbsolutePath : Symbol(consumeNormalizedOrAbsolutePath, Decl(structuralTagTypesControlFlow.ts, 49, 60)) +>p : Symbol(p, Decl(structuralTagTypesControlFlow.ts, 53, 5)) + + consumeNormalizedAbsolutePath(p); // err +>consumeNormalizedAbsolutePath : Symbol(consumeNormalizedAbsolutePath, Decl(structuralTagTypesControlFlow.ts, 50, 89)) +>p : Symbol(p, Decl(structuralTagTypesControlFlow.ts, 53, 5)) + } + else { + consumeNormalizedPath(p); // err +>consumeNormalizedPath : Symbol(consumeNormalizedPath, Decl(structuralTagTypesControlFlow.ts, 46, 62)) +>p : Symbol(p, Decl(structuralTagTypesControlFlow.ts, 53, 5)) + + consumeAbsolutePath(p); // err +>consumeAbsolutePath : Symbol(consumeAbsolutePath, Decl(structuralTagTypesControlFlow.ts, 48, 64)) +>p : Symbol(p, Decl(structuralTagTypesControlFlow.ts, 53, 5)) + + consumeNormalizedOrAbsolutePath(p); // err +>consumeNormalizedOrAbsolutePath : Symbol(consumeNormalizedOrAbsolutePath, Decl(structuralTagTypesControlFlow.ts, 49, 60)) +>p : Symbol(p, Decl(structuralTagTypesControlFlow.ts, 53, 5)) + + consumeNormalizedAbsolutePath(p); // err +>consumeNormalizedAbsolutePath : Symbol(consumeNormalizedAbsolutePath, Decl(structuralTagTypesControlFlow.ts, 50, 89)) +>p : Symbol(p, Decl(structuralTagTypesControlFlow.ts, 53, 5)) + } +} + diff --git a/tests/baselines/reference/structuralTagTypesControlFlow.types b/tests/baselines/reference/structuralTagTypesControlFlow.types new file mode 100644 index 0000000000000..543c385336f6b --- /dev/null +++ b/tests/baselines/reference/structuralTagTypesControlFlow.types @@ -0,0 +1,280 @@ +=== tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts === +type BrandA = tag {BrandA: void}; +>BrandA : BrandA +>BrandA : void + +type BrandB = tag {BrandB: void}; +>BrandB : BrandB +>BrandB : void + +declare function isBrandA(x: any): x is BrandA; +>isBrandA : (x: any) => x is BrandA +>x : any + +declare function isBrandB(x: any): x is BrandB; +>isBrandB : (x: any) => x is BrandB +>x : any + +declare function consumeBrandA(x: BrandA): void; +>consumeBrandA : (x: BrandA) => void +>x : BrandA + +declare function consumeBrandB(x: BrandB): void; +>consumeBrandB : (x: BrandB) => void +>x : BrandB + +declare function consumeBrandAOrB(x: BrandA | BrandB): void; +>consumeBrandAOrB : (x: BrandA | BrandB) => void +>x : BrandA | BrandB + +declare function consumeBrandAAndB(x: BrandA & BrandB): void; +>consumeBrandAAndB : (x: tag ({ BrandA: void; } & { BrandB: void; })) => void +>x : tag ({ BrandA: void; } & { BrandB: void; }) + +const x = {x: 12}; +>x : { x: number; } +>{x: 12} : { x: number; } +>x : number +>12 : 12 + +if (isBrandA(x)) { +>isBrandA(x) : boolean +>isBrandA : (x: any) => x is BrandA +>x : { x: number; } + + if (isBrandB(x)) { +>isBrandB(x) : boolean +>isBrandB : (x: any) => x is BrandB +>x : { x: number; } & BrandA + + consumeBrandA(x); +>consumeBrandA(x) : void +>consumeBrandA : (x: BrandA) => void +>x : { x: number; } & tag ({ BrandA: void; } & { BrandB: void; }) + + consumeBrandB(x); +>consumeBrandB(x) : void +>consumeBrandB : (x: BrandB) => void +>x : { x: number; } & tag ({ BrandA: void; } & { BrandB: void; }) + + consumeBrandAOrB(x); +>consumeBrandAOrB(x) : void +>consumeBrandAOrB : (x: BrandA | BrandB) => void +>x : { x: number; } & tag ({ BrandA: void; } & { BrandB: void; }) + + consumeBrandAAndB(x); +>consumeBrandAAndB(x) : void +>consumeBrandAAndB : (x: tag ({ BrandA: void; } & { BrandB: void; })) => void +>x : { x: number; } & tag ({ BrandA: void; } & { BrandB: void; }) + } + else { + consumeBrandA(x); +>consumeBrandA(x) : void +>consumeBrandA : (x: BrandA) => void +>x : { x: number; } & BrandA + + consumeBrandB(x); // err +>consumeBrandB(x) : void +>consumeBrandB : (x: BrandB) => void +>x : { x: number; } & BrandA + + consumeBrandAOrB(x); +>consumeBrandAOrB(x) : void +>consumeBrandAOrB : (x: BrandA | BrandB) => void +>x : { x: number; } & BrandA + + consumeBrandAAndB(x); // err +>consumeBrandAAndB(x) : void +>consumeBrandAAndB : (x: tag ({ BrandA: void; } & { BrandB: void; })) => void +>x : { x: number; } & BrandA + } +} +else { + if (isBrandB(x)) { +>isBrandB(x) : boolean +>isBrandB : (x: any) => x is BrandB +>x : { x: number; } + + consumeBrandA(x); // err +>consumeBrandA(x) : void +>consumeBrandA : (x: BrandA) => void +>x : { x: number; } & BrandB + + consumeBrandB(x); +>consumeBrandB(x) : void +>consumeBrandB : (x: BrandB) => void +>x : { x: number; } & BrandB + + consumeBrandAOrB(x); +>consumeBrandAOrB(x) : void +>consumeBrandAOrB : (x: BrandA | BrandB) => void +>x : { x: number; } & BrandB + + consumeBrandAAndB(x); // err +>consumeBrandAAndB(x) : void +>consumeBrandAAndB : (x: tag ({ BrandA: void; } & { BrandB: void; })) => void +>x : { x: number; } & BrandB + } + else { + consumeBrandA(x); // err +>consumeBrandA(x) : void +>consumeBrandA : (x: BrandA) => void +>x : { x: number; } + + consumeBrandB(x); // err +>consumeBrandB(x) : void +>consumeBrandB : (x: BrandB) => void +>x : { x: number; } + + consumeBrandAOrB(x); // err +>consumeBrandAOrB(x) : void +>consumeBrandAOrB : (x: BrandA | BrandB) => void +>x : { x: number; } + + consumeBrandAAndB(x); // err +>consumeBrandAAndB(x) : void +>consumeBrandAAndB : (x: tag ({ BrandA: void; } & { BrandB: void; })) => void +>x : { x: number; } + } +} + +type NormalizedPath = string & tag {NormalizedPath: void}; +>NormalizedPath : NormalizedPath +>NormalizedPath : void + +type AbsolutePath = string & tag {AbsolutePath: void}; +>AbsolutePath : AbsolutePath +>AbsolutePath : void + +type NormalizedAbsolutePath = NormalizedPath & AbsolutePath; +>NormalizedAbsolutePath : NormalizedAbsolutePath + +declare function isNormalizedPath(x: string): x is NormalizedPath; +>isNormalizedPath : (x: string) => x is NormalizedPath +>x : string + +declare function isAbsolutePath(x: string): x is AbsolutePath; +>isAbsolutePath : (x: string) => x is AbsolutePath +>x : string + +declare function consumeNormalizedPath(x: NormalizedPath): void; +>consumeNormalizedPath : (x: NormalizedPath) => void +>x : NormalizedPath + +declare function consumeAbsolutePath(x: AbsolutePath): void; +>consumeAbsolutePath : (x: AbsolutePath) => void +>x : AbsolutePath + +declare function consumeNormalizedOrAbsolutePath(x: NormalizedPath | AbsolutePath): void; +>consumeNormalizedOrAbsolutePath : (x: NormalizedPath | AbsolutePath) => void +>x : NormalizedPath | AbsolutePath + +declare function consumeNormalizedAbsolutePath(x: NormalizedAbsolutePath): void; +>consumeNormalizedAbsolutePath : (x: NormalizedAbsolutePath) => void +>x : NormalizedAbsolutePath + +const p = "/a/b/c"; +>p : "/a/b/c" +>"/a/b/c" : "/a/b/c" + +if (isNormalizedPath(p)) { +>isNormalizedPath(p) : boolean +>isNormalizedPath : (x: string) => x is NormalizedPath +>p : "/a/b/c" + + if (isAbsolutePath(p)) { +>isAbsolutePath(p) : boolean +>isAbsolutePath : (x: string) => x is AbsolutePath +>p : "/a/b/c" & tag { NormalizedPath: void; } + + consumeNormalizedPath(p); +>consumeNormalizedPath(p) : void +>consumeNormalizedPath : (x: NormalizedPath) => void +>p : "/a/b/c" & tag ({ NormalizedPath: void; } & { AbsolutePath: void; }) + + consumeAbsolutePath(p); +>consumeAbsolutePath(p) : void +>consumeAbsolutePath : (x: AbsolutePath) => void +>p : "/a/b/c" & tag ({ NormalizedPath: void; } & { AbsolutePath: void; }) + + consumeNormalizedOrAbsolutePath(p); +>consumeNormalizedOrAbsolutePath(p) : void +>consumeNormalizedOrAbsolutePath : (x: NormalizedPath | AbsolutePath) => void +>p : "/a/b/c" & tag ({ NormalizedPath: void; } & { AbsolutePath: void; }) + + consumeNormalizedAbsolutePath(p); +>consumeNormalizedAbsolutePath(p) : void +>consumeNormalizedAbsolutePath : (x: NormalizedAbsolutePath) => void +>p : "/a/b/c" & tag ({ NormalizedPath: void; } & { AbsolutePath: void; }) + } + else { + consumeNormalizedPath(p); +>consumeNormalizedPath(p) : void +>consumeNormalizedPath : (x: NormalizedPath) => void +>p : "/a/b/c" & tag { NormalizedPath: void; } + + consumeAbsolutePath(p); // err +>consumeAbsolutePath(p) : void +>consumeAbsolutePath : (x: AbsolutePath) => void +>p : "/a/b/c" & tag { NormalizedPath: void; } + + consumeNormalizedOrAbsolutePath(p); +>consumeNormalizedOrAbsolutePath(p) : void +>consumeNormalizedOrAbsolutePath : (x: NormalizedPath | AbsolutePath) => void +>p : "/a/b/c" & tag { NormalizedPath: void; } + + consumeNormalizedAbsolutePath(p); // err +>consumeNormalizedAbsolutePath(p) : void +>consumeNormalizedAbsolutePath : (x: NormalizedAbsolutePath) => void +>p : "/a/b/c" & tag { NormalizedPath: void; } + } +} +else { + if (isAbsolutePath(p)) { +>isAbsolutePath(p) : boolean +>isAbsolutePath : (x: string) => x is AbsolutePath +>p : "/a/b/c" + + consumeNormalizedPath(p); // err +>consumeNormalizedPath(p) : void +>consumeNormalizedPath : (x: NormalizedPath) => void +>p : "/a/b/c" & tag { AbsolutePath: void; } + + consumeAbsolutePath(p); +>consumeAbsolutePath(p) : void +>consumeAbsolutePath : (x: AbsolutePath) => void +>p : "/a/b/c" & tag { AbsolutePath: void; } + + consumeNormalizedOrAbsolutePath(p); +>consumeNormalizedOrAbsolutePath(p) : void +>consumeNormalizedOrAbsolutePath : (x: NormalizedPath | AbsolutePath) => void +>p : "/a/b/c" & tag { AbsolutePath: void; } + + consumeNormalizedAbsolutePath(p); // err +>consumeNormalizedAbsolutePath(p) : void +>consumeNormalizedAbsolutePath : (x: NormalizedAbsolutePath) => void +>p : "/a/b/c" & tag { AbsolutePath: void; } + } + else { + consumeNormalizedPath(p); // err +>consumeNormalizedPath(p) : void +>consumeNormalizedPath : (x: NormalizedPath) => void +>p : "/a/b/c" + + consumeAbsolutePath(p); // err +>consumeAbsolutePath(p) : void +>consumeAbsolutePath : (x: AbsolutePath) => void +>p : "/a/b/c" + + consumeNormalizedOrAbsolutePath(p); // err +>consumeNormalizedOrAbsolutePath(p) : void +>consumeNormalizedOrAbsolutePath : (x: NormalizedPath | AbsolutePath) => void +>p : "/a/b/c" + + consumeNormalizedAbsolutePath(p); // err +>consumeNormalizedAbsolutePath(p) : void +>consumeNormalizedAbsolutePath : (x: NormalizedAbsolutePath) => void +>p : "/a/b/c" + } +} + diff --git a/tests/baselines/reference/structuralTagTypesDeclarations.js b/tests/baselines/reference/structuralTagTypesDeclarations.js new file mode 100644 index 0000000000000..a4eac62e3135f --- /dev/null +++ b/tests/baselines/reference/structuralTagTypesDeclarations.js @@ -0,0 +1,29 @@ +//// [structuralTagTypesDeclarations.ts] +export type Downcased = string & tag {downcased: void}; + +export function downcaseLit(x: T): T & Downcased { + return x.toLocaleLowerCase() as T & Downcased; +} +const a = "ok"; +export const c = downcaseLit(a); // no visibility error, tag reproduced structurally + + +//// [structuralTagTypesDeclarations.js] +"use strict"; +exports.__esModule = true; +function downcaseLit(x) { + return x.toLocaleLowerCase(); +} +exports.downcaseLit = downcaseLit; +var a = "ok"; +exports.c = downcaseLit(a); // no visibility error, tag reproduced structurally + + +//// [structuralTagTypesDeclarations.d.ts] +export declare type Downcased = string & tag { + downcased: void; +}; +export declare function downcaseLit(x: T): T & Downcased; +export declare const c: "ok" & tag { + downcased: void; +}; diff --git a/tests/baselines/reference/structuralTagTypesDeclarations.symbols b/tests/baselines/reference/structuralTagTypesDeclarations.symbols new file mode 100644 index 0000000000000..f32407f24880b --- /dev/null +++ b/tests/baselines/reference/structuralTagTypesDeclarations.symbols @@ -0,0 +1,28 @@ +=== tests/cases/conformance/types/structuralTags/structuralTagTypesDeclarations.ts === +export type Downcased = string & tag {downcased: void}; +>Downcased : Symbol(Downcased, Decl(structuralTagTypesDeclarations.ts, 0, 0)) +>downcased : Symbol(downcased, Decl(structuralTagTypesDeclarations.ts, 0, 38)) + +export function downcaseLit(x: T): T & Downcased { +>downcaseLit : Symbol(downcaseLit, Decl(structuralTagTypesDeclarations.ts, 0, 55)) +>T : Symbol(T, Decl(structuralTagTypesDeclarations.ts, 2, 28)) +>x : Symbol(x, Decl(structuralTagTypesDeclarations.ts, 2, 46)) +>T : Symbol(T, Decl(structuralTagTypesDeclarations.ts, 2, 28)) +>T : Symbol(T, Decl(structuralTagTypesDeclarations.ts, 2, 28)) +>Downcased : Symbol(Downcased, Decl(structuralTagTypesDeclarations.ts, 0, 0)) + + return x.toLocaleLowerCase() as T & Downcased; +>x.toLocaleLowerCase : Symbol(String.toLocaleLowerCase, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(structuralTagTypesDeclarations.ts, 2, 46)) +>toLocaleLowerCase : Symbol(String.toLocaleLowerCase, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(structuralTagTypesDeclarations.ts, 2, 28)) +>Downcased : Symbol(Downcased, Decl(structuralTagTypesDeclarations.ts, 0, 0)) +} +const a = "ok"; +>a : Symbol(a, Decl(structuralTagTypesDeclarations.ts, 5, 5)) + +export const c = downcaseLit(a); // no visibility error, tag reproduced structurally +>c : Symbol(c, Decl(structuralTagTypesDeclarations.ts, 6, 12)) +>downcaseLit : Symbol(downcaseLit, Decl(structuralTagTypesDeclarations.ts, 0, 55)) +>a : Symbol(a, Decl(structuralTagTypesDeclarations.ts, 5, 5)) + diff --git a/tests/baselines/reference/structuralTagTypesDeclarations.types b/tests/baselines/reference/structuralTagTypesDeclarations.types new file mode 100644 index 0000000000000..b7bc921d9a4d2 --- /dev/null +++ b/tests/baselines/reference/structuralTagTypesDeclarations.types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/types/structuralTags/structuralTagTypesDeclarations.ts === +export type Downcased = string & tag {downcased: void}; +>Downcased : Downcased +>downcased : void + +export function downcaseLit(x: T): T & Downcased { +>downcaseLit : (x: T) => T & string & tag { downcased: void; } +>x : T + + return x.toLocaleLowerCase() as T & Downcased; +>x.toLocaleLowerCase() as T & Downcased : T & string & tag { downcased: void; } +>x.toLocaleLowerCase() : string +>x.toLocaleLowerCase : (locales?: string | string[]) => string +>x : T +>toLocaleLowerCase : (locales?: string | string[]) => string +} +const a = "ok"; +>a : "ok" +>"ok" : "ok" + +export const c = downcaseLit(a); // no visibility error, tag reproduced structurally +>c : "ok" & tag { downcased: void; } +>downcaseLit(a) : "ok" & tag { downcased: void; } +>downcaseLit : (x: T) => T & string & tag { downcased: void; } +>a : "ok" + diff --git a/tests/baselines/reference/structuralTagTypesErr1.errors.txt b/tests/baselines/reference/structuralTagTypesErr1.errors.txt new file mode 100644 index 0000000000000..4ca5fc6aa8bf0 --- /dev/null +++ b/tests/baselines/reference/structuralTagTypesErr1.errors.txt @@ -0,0 +1,70 @@ +tests/cases/conformance/types/structuralTags/structuralTagTypesErr1.ts(18,1): error TS2322: Type 'number & tag { y: any; }' is not assignable to type 'number & tag { x: any; }'. + Type 'number' is not assignable to type 'number & tag { x: any; }'. + Type 'number' is not assignable to type 'tag { x: any; }'. + Type 'number & tag { y: any; }' is not assignable to type 'tag { x: any; }'. + Type 'number' is not assignable to type 'tag { x: any; }'. +tests/cases/conformance/types/structuralTags/structuralTagTypesErr1.ts(19,1): error TS2322: Type 'number & tag { x: any; }' is not assignable to type 'number & tag { y: any; }'. + Type 'number' is not assignable to type 'number & tag { y: any; }'. + Type 'number' is not assignable to type 'tag { y: any; }'. + Type 'number & tag { x: any; }' is not assignable to type 'tag { y: any; }'. + Type 'number' is not assignable to type 'tag { y: any; }'. +tests/cases/conformance/types/structuralTags/structuralTagTypesErr1.ts(21,1): error TS2322: Type 'number' is not assignable to type 'number & tag { x: any; }'. + Type 'number' is not assignable to type 'tag { x: any; }'. +tests/cases/conformance/types/structuralTags/structuralTagTypesErr1.ts(22,1): error TS2322: Type 'number' is not assignable to type 'number & tag { y: any; }'. + Type 'number' is not assignable to type 'tag { y: any; }'. +tests/cases/conformance/types/structuralTags/structuralTagTypesErr1.ts(24,1): error TS2322: Type 'number' is not assignable to type 'number & tag { x: any; }'. + Type 'number' is not assignable to type 'tag { x: any; }'. +tests/cases/conformance/types/structuralTags/structuralTagTypesErr1.ts(25,1): error TS2322: Type 'number' is not assignable to type 'number & tag { y: any; }'. + Type 'number' is not assignable to type 'tag { y: any; }'. + + +==== tests/cases/conformance/types/structuralTags/structuralTagTypesErr1.ts (6 errors) ==== + export type Paired = { + x: number & tag {x}; + y: number & tag {y}; + }; + + + export function isPaired(x: {x: number, y: number}): x is Paired { + return true; + } + + export function makePair(x: number, y: number): Paired { + return {x, y} as Paired; + } + + const a = makePair(0, 0); + const b = {x: 0, y: 0}; + + a.x = a.y; // err + ~~~ +!!! error TS2322: Type 'number & tag { y: any; }' is not assignable to type 'number & tag { x: any; }'. +!!! error TS2322: Type 'number' is not assignable to type 'number & tag { x: any; }'. +!!! error TS2322: Type 'number' is not assignable to type 'tag { x: any; }'. +!!! error TS2322: Type 'number & tag { y: any; }' is not assignable to type 'tag { x: any; }'. +!!! error TS2322: Type 'number' is not assignable to type 'tag { x: any; }'. + a.y = a.x; // err + ~~~ +!!! error TS2322: Type 'number & tag { x: any; }' is not assignable to type 'number & tag { y: any; }'. +!!! error TS2322: Type 'number' is not assignable to type 'number & tag { y: any; }'. +!!! error TS2322: Type 'number' is not assignable to type 'tag { y: any; }'. +!!! error TS2322: Type 'number & tag { x: any; }' is not assignable to type 'tag { y: any; }'. +!!! error TS2322: Type 'number' is not assignable to type 'tag { y: any; }'. + + a.x = b.y; // err + ~~~ +!!! error TS2322: Type 'number' is not assignable to type 'number & tag { x: any; }'. +!!! error TS2322: Type 'number' is not assignable to type 'tag { x: any; }'. + a.y = b.y; // err + ~~~ +!!! error TS2322: Type 'number' is not assignable to type 'number & tag { y: any; }'. +!!! error TS2322: Type 'number' is not assignable to type 'tag { y: any; }'. + + a.x = b.x; // err + ~~~ +!!! error TS2322: Type 'number' is not assignable to type 'number & tag { x: any; }'. +!!! error TS2322: Type 'number' is not assignable to type 'tag { x: any; }'. + a.y = b.x; // err + ~~~ +!!! error TS2322: Type 'number' is not assignable to type 'number & tag { y: any; }'. +!!! error TS2322: Type 'number' is not assignable to type 'tag { y: any; }'. \ No newline at end of file diff --git a/tests/baselines/reference/structuralTagTypesErr1.js b/tests/baselines/reference/structuralTagTypesErr1.js new file mode 100644 index 0000000000000..85ac3109ff855 --- /dev/null +++ b/tests/baselines/reference/structuralTagTypesErr1.js @@ -0,0 +1,46 @@ +//// [structuralTagTypesErr1.ts] +export type Paired = { + x: number & tag {x}; + y: number & tag {y}; +}; + + +export function isPaired(x: {x: number, y: number}): x is Paired { + return true; +} + +export function makePair(x: number, y: number): Paired { + return {x, y} as Paired; +} + +const a = makePair(0, 0); +const b = {x: 0, y: 0}; + +a.x = a.y; // err +a.y = a.x; // err + +a.x = b.y; // err +a.y = b.y; // err + +a.x = b.x; // err +a.y = b.x; // err + +//// [structuralTagTypesErr1.js] +"use strict"; +exports.__esModule = true; +function isPaired(x) { + return true; +} +exports.isPaired = isPaired; +function makePair(x, y) { + return { x: x, y: y }; +} +exports.makePair = makePair; +var a = makePair(0, 0); +var b = { x: 0, y: 0 }; +a.x = a.y; // err +a.y = a.x; // err +a.x = b.y; // err +a.y = b.y; // err +a.x = b.x; // err +a.y = b.x; // err diff --git a/tests/baselines/reference/structuralTagTypesErr1.symbols b/tests/baselines/reference/structuralTagTypesErr1.symbols new file mode 100644 index 0000000000000..272e65a0d469e --- /dev/null +++ b/tests/baselines/reference/structuralTagTypesErr1.symbols @@ -0,0 +1,95 @@ +=== tests/cases/conformance/types/structuralTags/structuralTagTypesErr1.ts === +export type Paired = { +>Paired : Symbol(Paired, Decl(structuralTagTypesErr1.ts, 0, 0)) + + x: number & tag {x}; +>x : Symbol(x, Decl(structuralTagTypesErr1.ts, 0, 22)) +>x : Symbol(x, Decl(structuralTagTypesErr1.ts, 1, 21)) + + y: number & tag {y}; +>y : Symbol(y, Decl(structuralTagTypesErr1.ts, 1, 24)) +>y : Symbol(y, Decl(structuralTagTypesErr1.ts, 2, 21)) + +}; + + +export function isPaired(x: {x: number, y: number}): x is Paired { +>isPaired : Symbol(isPaired, Decl(structuralTagTypesErr1.ts, 3, 2)) +>x : Symbol(x, Decl(structuralTagTypesErr1.ts, 6, 25)) +>x : Symbol(x, Decl(structuralTagTypesErr1.ts, 6, 29)) +>y : Symbol(y, Decl(structuralTagTypesErr1.ts, 6, 39)) +>x : Symbol(x, Decl(structuralTagTypesErr1.ts, 6, 25)) +>Paired : Symbol(Paired, Decl(structuralTagTypesErr1.ts, 0, 0)) + + return true; +} + +export function makePair(x: number, y: number): Paired { +>makePair : Symbol(makePair, Decl(structuralTagTypesErr1.ts, 8, 1)) +>x : Symbol(x, Decl(structuralTagTypesErr1.ts, 10, 25)) +>y : Symbol(y, Decl(structuralTagTypesErr1.ts, 10, 35)) +>Paired : Symbol(Paired, Decl(structuralTagTypesErr1.ts, 0, 0)) + + return {x, y} as Paired; +>x : Symbol(x, Decl(structuralTagTypesErr1.ts, 11, 12)) +>y : Symbol(y, Decl(structuralTagTypesErr1.ts, 11, 14)) +>Paired : Symbol(Paired, Decl(structuralTagTypesErr1.ts, 0, 0)) +} + +const a = makePair(0, 0); +>a : Symbol(a, Decl(structuralTagTypesErr1.ts, 14, 5)) +>makePair : Symbol(makePair, Decl(structuralTagTypesErr1.ts, 8, 1)) + +const b = {x: 0, y: 0}; +>b : Symbol(b, Decl(structuralTagTypesErr1.ts, 15, 5)) +>x : Symbol(x, Decl(structuralTagTypesErr1.ts, 15, 11)) +>y : Symbol(y, Decl(structuralTagTypesErr1.ts, 15, 16)) + +a.x = a.y; // err +>a.x : Symbol(x, Decl(structuralTagTypesErr1.ts, 0, 22)) +>a : Symbol(a, Decl(structuralTagTypesErr1.ts, 14, 5)) +>x : Symbol(x, Decl(structuralTagTypesErr1.ts, 0, 22)) +>a.y : Symbol(y, Decl(structuralTagTypesErr1.ts, 1, 24)) +>a : Symbol(a, Decl(structuralTagTypesErr1.ts, 14, 5)) +>y : Symbol(y, Decl(structuralTagTypesErr1.ts, 1, 24)) + +a.y = a.x; // err +>a.y : Symbol(y, Decl(structuralTagTypesErr1.ts, 1, 24)) +>a : Symbol(a, Decl(structuralTagTypesErr1.ts, 14, 5)) +>y : Symbol(y, Decl(structuralTagTypesErr1.ts, 1, 24)) +>a.x : Symbol(x, Decl(structuralTagTypesErr1.ts, 0, 22)) +>a : Symbol(a, Decl(structuralTagTypesErr1.ts, 14, 5)) +>x : Symbol(x, Decl(structuralTagTypesErr1.ts, 0, 22)) + +a.x = b.y; // err +>a.x : Symbol(x, Decl(structuralTagTypesErr1.ts, 0, 22)) +>a : Symbol(a, Decl(structuralTagTypesErr1.ts, 14, 5)) +>x : Symbol(x, Decl(structuralTagTypesErr1.ts, 0, 22)) +>b.y : Symbol(y, Decl(structuralTagTypesErr1.ts, 15, 16)) +>b : Symbol(b, Decl(structuralTagTypesErr1.ts, 15, 5)) +>y : Symbol(y, Decl(structuralTagTypesErr1.ts, 15, 16)) + +a.y = b.y; // err +>a.y : Symbol(y, Decl(structuralTagTypesErr1.ts, 1, 24)) +>a : Symbol(a, Decl(structuralTagTypesErr1.ts, 14, 5)) +>y : Symbol(y, Decl(structuralTagTypesErr1.ts, 1, 24)) +>b.y : Symbol(y, Decl(structuralTagTypesErr1.ts, 15, 16)) +>b : Symbol(b, Decl(structuralTagTypesErr1.ts, 15, 5)) +>y : Symbol(y, Decl(structuralTagTypesErr1.ts, 15, 16)) + +a.x = b.x; // err +>a.x : Symbol(x, Decl(structuralTagTypesErr1.ts, 0, 22)) +>a : Symbol(a, Decl(structuralTagTypesErr1.ts, 14, 5)) +>x : Symbol(x, Decl(structuralTagTypesErr1.ts, 0, 22)) +>b.x : Symbol(x, Decl(structuralTagTypesErr1.ts, 15, 11)) +>b : Symbol(b, Decl(structuralTagTypesErr1.ts, 15, 5)) +>x : Symbol(x, Decl(structuralTagTypesErr1.ts, 15, 11)) + +a.y = b.x; // err +>a.y : Symbol(y, Decl(structuralTagTypesErr1.ts, 1, 24)) +>a : Symbol(a, Decl(structuralTagTypesErr1.ts, 14, 5)) +>y : Symbol(y, Decl(structuralTagTypesErr1.ts, 1, 24)) +>b.x : Symbol(x, Decl(structuralTagTypesErr1.ts, 15, 11)) +>b : Symbol(b, Decl(structuralTagTypesErr1.ts, 15, 5)) +>x : Symbol(x, Decl(structuralTagTypesErr1.ts, 15, 11)) + diff --git a/tests/baselines/reference/structuralTagTypesErr1.types b/tests/baselines/reference/structuralTagTypesErr1.types new file mode 100644 index 0000000000000..92820b492ff85 --- /dev/null +++ b/tests/baselines/reference/structuralTagTypesErr1.types @@ -0,0 +1,106 @@ +=== tests/cases/conformance/types/structuralTags/structuralTagTypesErr1.ts === +export type Paired = { +>Paired : Paired + + x: number & tag {x}; +>x : number & tag { x: any; } +>x : any + + y: number & tag {y}; +>y : number & tag { y: any; } +>y : any + +}; + + +export function isPaired(x: {x: number, y: number}): x is Paired { +>isPaired : (x: { x: number; y: number; }) => x is Paired +>x : { x: number; y: number; } +>x : number +>y : number + + return true; +>true : true +} + +export function makePair(x: number, y: number): Paired { +>makePair : (x: number, y: number) => Paired +>x : number +>y : number + + return {x, y} as Paired; +>{x, y} as Paired : Paired +>{x, y} : { x: number; y: number; } +>x : number +>y : number +} + +const a = makePair(0, 0); +>a : Paired +>makePair(0, 0) : Paired +>makePair : (x: number, y: number) => Paired +>0 : 0 +>0 : 0 + +const b = {x: 0, y: 0}; +>b : { x: number; y: number; } +>{x: 0, y: 0} : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + +a.x = a.y; // err +>a.x = a.y : number & tag { y: any; } +>a.x : number & tag { x: any; } +>a : Paired +>x : number & tag { x: any; } +>a.y : number & tag { y: any; } +>a : Paired +>y : number & tag { y: any; } + +a.y = a.x; // err +>a.y = a.x : number & tag { x: any; } +>a.y : number & tag { y: any; } +>a : Paired +>y : number & tag { y: any; } +>a.x : number & tag { x: any; } +>a : Paired +>x : number & tag { x: any; } + +a.x = b.y; // err +>a.x = b.y : number +>a.x : number & tag { x: any; } +>a : Paired +>x : number & tag { x: any; } +>b.y : number +>b : { x: number; y: number; } +>y : number + +a.y = b.y; // err +>a.y = b.y : number +>a.y : number & tag { y: any; } +>a : Paired +>y : number & tag { y: any; } +>b.y : number +>b : { x: number; y: number; } +>y : number + +a.x = b.x; // err +>a.x = b.x : number +>a.x : number & tag { x: any; } +>a : Paired +>x : number & tag { x: any; } +>b.x : number +>b : { x: number; y: number; } +>x : number + +a.y = b.x; // err +>a.y = b.x : number +>a.y : number & tag { y: any; } +>a : Paired +>y : number & tag { y: any; } +>b.x : number +>b : { x: number; y: number; } +>x : number + diff --git a/tests/cases/conformance/types/structuralTags/structuralTagTypes.ts b/tests/cases/conformance/types/structuralTags/structuralTagTypes.ts new file mode 100644 index 0000000000000..8d3ab4e0a862c --- /dev/null +++ b/tests/cases/conformance/types/structuralTags/structuralTagTypes.ts @@ -0,0 +1,55 @@ +// @declaration: true +export type Downcased = string & tag { downcased: void; }; +export type Analyzed = T & tag { analyzed: void; }; +export type Paired = { + x: number & tag {x: number;}; + y: number & tag {y: number;}; +}; + +export function downcase(x: string): Downcased { + return x.toLocaleLowerCase() as Downcased; +} + +export function downcaseLit(x: T): T & Downcased { + return x.toLocaleLowerCase() as T & Downcased; +} + +export function isDowncase(x: string): x is Downcased { + return null as any; +} + +export function analyze(x: T): Analyzed { + return x as Analyzed; +} + +export function isAnalyzed(x: T): x is Analyzed { + return Math.random() > 0.33 ? false : true; +} + +export function isPaired(x: {x: number, y: number}): x is Paired { + return true; +} + +export function makePair(x: number, y: number): Paired { + return {x, y} as Paired; +} + +const a = "ok"; +export const b = downcase(a); +export const d = downcaseLit(b); + +if (isDowncase(d)) { + d; +} + +const e = {data: { value: "str" }}; +export const f = analyze(e); +if (isAnalyzed(e)) { + e; +} + +export const g = makePair(0, 0); +const h = {x: 0, y: 0}; +if (isPaired(h)) { + h; +} diff --git a/tests/cases/conformance/types/structuralTags/structuralTagTypes1.ts b/tests/cases/conformance/types/structuralTags/structuralTagTypes1.ts new file mode 100644 index 0000000000000..8e917eab04fd1 --- /dev/null +++ b/tests/cases/conformance/types/structuralTags/structuralTagTypes1.ts @@ -0,0 +1,28 @@ +export type Paired = { + x: number & tag {x}; + y: number & tag {y}; +}; + + +export function isPaired(x: {x: number, y: number}): x is Paired { + return true; +} + +export function makePair(x: number, y: number): Paired { + return {x, y} as Paired; +} + +const a = makePair(0, 0); +const b = {x: 0, y: 0}; + +if (Math.random() > 0.3) { + b.x = a.x; + b.y = a.y; +} + +if (isPaired(b)) { + b.x = a.x; + b.y = a.y; + a.x = b.x; + a.y = b.y; +} \ No newline at end of file diff --git a/tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts b/tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts new file mode 100644 index 0000000000000..383c1f4a5adc5 --- /dev/null +++ b/tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts @@ -0,0 +1,82 @@ +type BrandA = tag {BrandA: void}; +type BrandB = tag {BrandB: void}; + +declare function isBrandA(x: any): x is BrandA; +declare function isBrandB(x: any): x is BrandB; + +declare function consumeBrandA(x: BrandA): void; +declare function consumeBrandB(x: BrandB): void; +declare function consumeBrandAOrB(x: BrandA | BrandB): void; +declare function consumeBrandAAndB(x: BrandA & BrandB): void; + +const x = {x: 12}; +if (isBrandA(x)) { + if (isBrandB(x)) { + consumeBrandA(x); + consumeBrandB(x); + consumeBrandAOrB(x); + consumeBrandAAndB(x); + } + else { + consumeBrandA(x); + consumeBrandB(x); // err + consumeBrandAOrB(x); + consumeBrandAAndB(x); // err + } +} +else { + if (isBrandB(x)) { + consumeBrandA(x); // err + consumeBrandB(x); + consumeBrandAOrB(x); + consumeBrandAAndB(x); // err + } + else { + consumeBrandA(x); // err + consumeBrandB(x); // err + consumeBrandAOrB(x); // err + consumeBrandAAndB(x); // err + } +} + +type NormalizedPath = string & tag {NormalizedPath: void}; +type AbsolutePath = string & tag {AbsolutePath: void}; +type NormalizedAbsolutePath = NormalizedPath & AbsolutePath; + +declare function isNormalizedPath(x: string): x is NormalizedPath; +declare function isAbsolutePath(x: string): x is AbsolutePath; + +declare function consumeNormalizedPath(x: NormalizedPath): void; +declare function consumeAbsolutePath(x: AbsolutePath): void; +declare function consumeNormalizedOrAbsolutePath(x: NormalizedPath | AbsolutePath): void; +declare function consumeNormalizedAbsolutePath(x: NormalizedAbsolutePath): void; + +const p = "/a/b/c"; +if (isNormalizedPath(p)) { + if (isAbsolutePath(p)) { + consumeNormalizedPath(p); + consumeAbsolutePath(p); + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); + } + else { + consumeNormalizedPath(p); + consumeAbsolutePath(p); // err + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); // err + } +} +else { + if (isAbsolutePath(p)) { + consumeNormalizedPath(p); // err + consumeAbsolutePath(p); + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); // err + } + else { + consumeNormalizedPath(p); // err + consumeAbsolutePath(p); // err + consumeNormalizedOrAbsolutePath(p); // err + consumeNormalizedAbsolutePath(p); // err + } +} diff --git a/tests/cases/conformance/types/structuralTags/structuralTagTypesDeclarations.ts b/tests/cases/conformance/types/structuralTags/structuralTagTypesDeclarations.ts new file mode 100644 index 0000000000000..f7d9f281090fa --- /dev/null +++ b/tests/cases/conformance/types/structuralTags/structuralTagTypesDeclarations.ts @@ -0,0 +1,8 @@ +// @declaration: true +export type Downcased = string & tag {downcased: void}; + +export function downcaseLit(x: T): T & Downcased { + return x.toLocaleLowerCase() as T & Downcased; +} +const a = "ok"; +export const c = downcaseLit(a); // no visibility error, tag reproduced structurally diff --git a/tests/cases/conformance/types/structuralTags/structuralTagTypesErr1.ts b/tests/cases/conformance/types/structuralTags/structuralTagTypesErr1.ts new file mode 100644 index 0000000000000..c2a02bf3253ad --- /dev/null +++ b/tests/cases/conformance/types/structuralTags/structuralTagTypesErr1.ts @@ -0,0 +1,25 @@ +export type Paired = { + x: number & tag {x}; + y: number & tag {y}; +}; + + +export function isPaired(x: {x: number, y: number}): x is Paired { + return true; +} + +export function makePair(x: number, y: number): Paired { + return {x, y} as Paired; +} + +const a = makePair(0, 0); +const b = {x: 0, y: 0}; + +a.x = a.y; // err +a.y = a.x; // err + +a.x = b.y; // err +a.y = b.y; // err + +a.x = b.x; // err +a.y = b.x; // err \ No newline at end of file From b8b63d9ce1b8e49257698140045cc8a81310cfb0 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 9 Sep 2019 15:22:28 -0700 Subject: [PATCH 2/7] Swap from instantiable type to structure type, fix inference --- src/compiler/checker.ts | 21 ++++++++-- src/compiler/types.ts | 14 +++++-- .../reference/api/tsserverlibrary.d.ts | 10 ++--- tests/baselines/reference/api/typescript.d.ts | 10 ++--- .../structuralTagTypesControlFlow.errors.txt | 40 ++++--------------- .../structuralTagTypesErr1.errors.txt | 20 ++-------- .../structuraltagConditonalExtract.js | 10 +++++ .../structuraltagConditonalExtract.symbols | 22 ++++++++++ .../structuraltagConditonalExtract.types | 17 ++++++++ .../structuraltagConditonalExtract.ts | 6 +++ 10 files changed, 105 insertions(+), 65 deletions(-) create mode 100644 tests/baselines/reference/structuraltagConditonalExtract.js create mode 100644 tests/baselines/reference/structuraltagConditonalExtract.symbols create mode 100644 tests/baselines/reference/structuraltagConditonalExtract.types create mode 100644 tests/cases/conformance/types/structuralTags/structuraltagConditonalExtract.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0df7ae2d9350c..f6968e54273f0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7775,10 +7775,18 @@ namespace ts { else if (type.flags & TypeFlags.Intersection) { resolveIntersectionTypeMembers(type); } + else if (type.flags & TypeFlags.StructuralTag) { + resolveStructuralTagTypeMembers(type); + } } return type; } + function resolveStructuralTagTypeMembers(type: StructuralTagType) { + // Explicitly do nothing - structured tags, despite "containing structure" (in their argument), do not have any visible structure. + setStructuredTypeMembers(type, emptySymbols, emptyArray, emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + } + /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type: Type): Symbol[] { if (type.flags & TypeFlags.Object) { @@ -11432,7 +11440,7 @@ namespace ts { function instantiateSymbol(symbol: Symbol, mapper: TypeMapper): Symbol { const links = getSymbolLinks(symbol); - if (links.type && !maybeTypeOfKind(links.type, TypeFlags.Object | TypeFlags.Instantiable)) { + if (links.type && !maybeTypeOfKind(links.type, TypeFlags.Object | TypeFlags.Instantiable | TypeFlags.StructuralTag)) { // If the type of the symbol is already resolved, and if that type could not possibly // be affected by instantiation, simply return the symbol itself. return symbol; @@ -15474,6 +15482,7 @@ namespace ts { function couldContainTypeVariables(type: Type): boolean { const objectFlags = getObjectFlags(type); return !!(type.flags & TypeFlags.Instantiable || + type.flags & TypeFlags.StructuralTag && couldContainTypeVariables((type as StructuralTagType).type) || objectFlags & ObjectFlags.Reference && forEach((type).typeArguments, couldContainTypeVariables) || objectFlags & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) && type.symbol.declarations || objectFlags & ObjectFlags.Mapped || @@ -15809,6 +15818,12 @@ namespace ts { else if (target.flags & TypeFlags.UnionOrIntersection) { inferToMultipleTypes(source, (target).types, target.flags); } + else if (target.flags & TypeFlags.StructuralTag && source.flags & TypeFlags.Intersection) { + const tagsOnly = getIntersectionType(filter((source as IntersectionType).types, t => !!(t.flags & TypeFlags.StructuralTag))); + if (tagsOnly !== source) { + inferFromTypes(tagsOnly, target); + } + } else if (source.flags & TypeFlags.Union) { // Source is a union or intersection type, infer from each constituent type const sourceTypes = (source).types; @@ -19325,7 +19340,7 @@ namespace ts { // are classified as instantiable (i.e. it doesn't instantiate object types), and (b) it performs // no reductions on instantiated union types. function instantiateInstantiableTypes(type: Type, mapper: TypeMapper): Type { - if (type.flags & TypeFlags.Instantiable) { + if (type.flags & (TypeFlags.Instantiable | TypeFlags.StructuralTag)) { return instantiateType(type, mapper); } if (type.flags & TypeFlags.Union) { @@ -20013,7 +20028,7 @@ namespace ts { return isValidSpreadType(constraint); } } - return !!(type.flags & (TypeFlags.Any | TypeFlags.NonPrimitive | TypeFlags.Object | TypeFlags.InstantiableNonPrimitive) || + return !!(type.flags & (TypeFlags.Any | TypeFlags.NonPrimitive | TypeFlags.Object | TypeFlags.StructuralTag | TypeFlags.InstantiableNonPrimitive) || getFalsyFlags(type) & TypeFlags.DefinitelyFalsy && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & TypeFlags.UnionOrIntersection && every((type).types, isValidSpreadType)); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index e161cee538feb..1c8db2402edd1 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4038,9 +4038,9 @@ namespace ts { /* @internal */ DisjointDomains = NonPrimitive | StringLike | NumberLike | BigIntLike | BooleanLike | ESSymbolLike | VoidLike | Null, UnionOrIntersection = Union | Intersection, - StructuredType = Object | Union | Intersection, + StructuredType = Object | Union | Intersection | StructuralTag, TypeVariable = TypeParameter | IndexedAccess, - InstantiableNonPrimitive = TypeVariable | Conditional | Substitution | StructuralTag, + InstantiableNonPrimitive = TypeVariable | Conditional | Substitution, InstantiablePrimitive = Index, Instantiable = InstantiableNonPrimitive | InstantiablePrimitive, StructuredOrInstantiable = StructuredType | Instantiable, @@ -4292,7 +4292,7 @@ namespace ts { resolvedApparentType: Type; } - export type StructuredType = ObjectType | UnionType | IntersectionType; + export type StructuredType = ObjectType | UnionType | IntersectionType | StructuralTagType; /* @internal */ // An instantiated anonymous type has a target and a mapper @@ -4459,8 +4459,14 @@ namespace ts { } // Structual tag type, or a `tag T` (TypeFlags.StructuralTag) - export interface StructuralTagType extends InstantiableType { + export interface StructuralTagType extends Type { type: Type; + /* @internal */ members?: SymbolTable; // Always emptySymbols + /* @internal */ properties?: Symbol[]; // Always emptyArray + /* @internal */ callSignatures?: ReadonlyArray; // Always emptyArray + /* @internal */ constructSignatures?: ReadonlyArray; // Always emptyArray + /* @internal */ stringIndexInfo?: undefined; + /* @internal */ numberIndexInfo?: undefined; } /* @internal */ diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 5fa7ff239088b..c484e3ac730a2 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2275,11 +2275,11 @@ declare namespace ts { ESSymbolLike = 12288, VoidLike = 49152, UnionOrIntersection = 3145728, - StructuredType = 3670016, + StructuredType = 137887744, TypeVariable = 8650752, - InstantiableNonPrimitive = 193200128, + InstantiableNonPrimitive = 58982400, InstantiablePrimitive = 4194304, - Instantiable = 197394432, + Instantiable = 63176704, StructuredOrInstantiable = 201064448, Narrowable = 268188671, NotUnionOrUnit = 67637251, @@ -2382,7 +2382,7 @@ declare namespace ts { } export interface IntersectionType extends UnionOrIntersectionType { } - export type StructuredType = ObjectType | UnionType | IntersectionType; + export type StructuredType = ObjectType | UnionType | IntersectionType | StructuralTagType; export interface EvolvingArrayType extends ObjectType { elementType: Type; finalArrayType?: Type; @@ -2426,7 +2426,7 @@ declare namespace ts { typeVariable: TypeVariable; substitute: Type; } - export interface StructuralTagType extends InstantiableType { + export interface StructuralTagType extends Type { type: Type; } export enum SignatureKind { diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index e2e7c632a2130..e1a04fe461c42 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2275,11 +2275,11 @@ declare namespace ts { ESSymbolLike = 12288, VoidLike = 49152, UnionOrIntersection = 3145728, - StructuredType = 3670016, + StructuredType = 137887744, TypeVariable = 8650752, - InstantiableNonPrimitive = 193200128, + InstantiableNonPrimitive = 58982400, InstantiablePrimitive = 4194304, - Instantiable = 197394432, + Instantiable = 63176704, StructuredOrInstantiable = 201064448, Narrowable = 268188671, NotUnionOrUnit = 67637251, @@ -2382,7 +2382,7 @@ declare namespace ts { } export interface IntersectionType extends UnionOrIntersectionType { } - export type StructuredType = ObjectType | UnionType | IntersectionType; + export type StructuredType = ObjectType | UnionType | IntersectionType | StructuralTagType; export interface EvolvingArrayType extends ObjectType { elementType: Type; finalArrayType?: Type; @@ -2426,7 +2426,7 @@ declare namespace ts { typeVariable: TypeVariable; substitute: Type; } - export interface StructuralTagType extends InstantiableType { + export interface StructuralTagType extends Type { type: Type; } export enum SignatureKind { diff --git a/tests/baselines/reference/structuralTagTypesControlFlow.errors.txt b/tests/baselines/reference/structuralTagTypesControlFlow.errors.txt index acfdcceae9190..f43900c0c8c96 100644 --- a/tests/baselines/reference/structuralTagTypesControlFlow.errors.txt +++ b/tests/baselines/reference/structuralTagTypesControlFlow.errors.txt @@ -8,25 +8,13 @@ tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(37 Type '{ x: number; }' is not assignable to type 'BrandB'. tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(38,27): error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type 'tag ({ BrandA: void; } & { BrandB: void; })'. tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(64,29): error TS2345: Argument of type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to parameter of type 'AbsolutePath'. - Type '"/a/b/c"' is not assignable to type 'AbsolutePath'. - Type '"/a/b/c"' is not assignable to type 'tag { AbsolutePath: void; }'. - Type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to type 'tag { AbsolutePath: void; }'. - Type '"/a/b/c"' is not assignable to type 'tag { AbsolutePath: void; }'. + Type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to type 'tag { AbsolutePath: void; }'. tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(66,39): error TS2345: Argument of type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to parameter of type 'NormalizedAbsolutePath'. - Type '"/a/b/c"' is not assignable to type 'NormalizedAbsolutePath'. - Type '"/a/b/c"' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. - Type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. - Type '"/a/b/c"' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. + Type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(71,31): error TS2345: Argument of type '"/a/b/c" & tag { AbsolutePath: void; }' is not assignable to parameter of type 'NormalizedPath'. - Type '"/a/b/c"' is not assignable to type 'NormalizedPath'. - Type '"/a/b/c"' is not assignable to type 'tag { NormalizedPath: void; }'. - Type '"/a/b/c" & tag { AbsolutePath: void; }' is not assignable to type 'tag { NormalizedPath: void; }'. - Type '"/a/b/c"' is not assignable to type 'tag { NormalizedPath: void; }'. + Type '"/a/b/c" & tag { AbsolutePath: void; }' is not assignable to type 'tag { NormalizedPath: void; }'. tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(74,39): error TS2345: Argument of type '"/a/b/c" & tag { AbsolutePath: void; }' is not assignable to parameter of type 'NormalizedAbsolutePath'. - Type '"/a/b/c"' is not assignable to type 'NormalizedAbsolutePath'. - Type '"/a/b/c"' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. - Type '"/a/b/c" & tag { AbsolutePath: void; }' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. - Type '"/a/b/c"' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. + Type '"/a/b/c" & tag { AbsolutePath: void; }' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(77,31): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath'. Type '"/a/b/c"' is not assignable to type 'tag { NormalizedPath: void; }'. tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(78,29): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'AbsolutePath'. @@ -120,18 +108,12 @@ tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(80 consumeAbsolutePath(p); // err ~ !!! error TS2345: Argument of type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to parameter of type 'AbsolutePath'. -!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'AbsolutePath'. -!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'tag { AbsolutePath: void; }'. -!!! error TS2345: Type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to type 'tag { AbsolutePath: void; }'. -!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'tag { AbsolutePath: void; }'. +!!! error TS2345: Type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to type 'tag { AbsolutePath: void; }'. consumeNormalizedOrAbsolutePath(p); consumeNormalizedAbsolutePath(p); // err ~ !!! error TS2345: Argument of type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to parameter of type 'NormalizedAbsolutePath'. -!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'NormalizedAbsolutePath'. -!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. -!!! error TS2345: Type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. -!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. +!!! error TS2345: Type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. } } else { @@ -139,19 +121,13 @@ tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(80 consumeNormalizedPath(p); // err ~ !!! error TS2345: Argument of type '"/a/b/c" & tag { AbsolutePath: void; }' is not assignable to parameter of type 'NormalizedPath'. -!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'NormalizedPath'. -!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'tag { NormalizedPath: void; }'. -!!! error TS2345: Type '"/a/b/c" & tag { AbsolutePath: void; }' is not assignable to type 'tag { NormalizedPath: void; }'. -!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'tag { NormalizedPath: void; }'. +!!! error TS2345: Type '"/a/b/c" & tag { AbsolutePath: void; }' is not assignable to type 'tag { NormalizedPath: void; }'. consumeAbsolutePath(p); consumeNormalizedOrAbsolutePath(p); consumeNormalizedAbsolutePath(p); // err ~ !!! error TS2345: Argument of type '"/a/b/c" & tag { AbsolutePath: void; }' is not assignable to parameter of type 'NormalizedAbsolutePath'. -!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'NormalizedAbsolutePath'. -!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. -!!! error TS2345: Type '"/a/b/c" & tag { AbsolutePath: void; }' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. -!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. +!!! error TS2345: Type '"/a/b/c" & tag { AbsolutePath: void; }' is not assignable to type 'tag ({ NormalizedPath: void; } & { AbsolutePath: void; })'. } else { consumeNormalizedPath(p); // err diff --git a/tests/baselines/reference/structuralTagTypesErr1.errors.txt b/tests/baselines/reference/structuralTagTypesErr1.errors.txt index 4ca5fc6aa8bf0..e16bb3114ce97 100644 --- a/tests/baselines/reference/structuralTagTypesErr1.errors.txt +++ b/tests/baselines/reference/structuralTagTypesErr1.errors.txt @@ -1,13 +1,7 @@ tests/cases/conformance/types/structuralTags/structuralTagTypesErr1.ts(18,1): error TS2322: Type 'number & tag { y: any; }' is not assignable to type 'number & tag { x: any; }'. - Type 'number' is not assignable to type 'number & tag { x: any; }'. - Type 'number' is not assignable to type 'tag { x: any; }'. - Type 'number & tag { y: any; }' is not assignable to type 'tag { x: any; }'. - Type 'number' is not assignable to type 'tag { x: any; }'. + Type 'number & tag { y: any; }' is not assignable to type 'tag { x: any; }'. tests/cases/conformance/types/structuralTags/structuralTagTypesErr1.ts(19,1): error TS2322: Type 'number & tag { x: any; }' is not assignable to type 'number & tag { y: any; }'. - Type 'number' is not assignable to type 'number & tag { y: any; }'. - Type 'number' is not assignable to type 'tag { y: any; }'. - Type 'number & tag { x: any; }' is not assignable to type 'tag { y: any; }'. - Type 'number' is not assignable to type 'tag { y: any; }'. + Type 'number & tag { x: any; }' is not assignable to type 'tag { y: any; }'. tests/cases/conformance/types/structuralTags/structuralTagTypesErr1.ts(21,1): error TS2322: Type 'number' is not assignable to type 'number & tag { x: any; }'. Type 'number' is not assignable to type 'tag { x: any; }'. tests/cases/conformance/types/structuralTags/structuralTagTypesErr1.ts(22,1): error TS2322: Type 'number' is not assignable to type 'number & tag { y: any; }'. @@ -39,17 +33,11 @@ tests/cases/conformance/types/structuralTags/structuralTagTypesErr1.ts(25,1): er a.x = a.y; // err ~~~ !!! error TS2322: Type 'number & tag { y: any; }' is not assignable to type 'number & tag { x: any; }'. -!!! error TS2322: Type 'number' is not assignable to type 'number & tag { x: any; }'. -!!! error TS2322: Type 'number' is not assignable to type 'tag { x: any; }'. -!!! error TS2322: Type 'number & tag { y: any; }' is not assignable to type 'tag { x: any; }'. -!!! error TS2322: Type 'number' is not assignable to type 'tag { x: any; }'. +!!! error TS2322: Type 'number & tag { y: any; }' is not assignable to type 'tag { x: any; }'. a.y = a.x; // err ~~~ !!! error TS2322: Type 'number & tag { x: any; }' is not assignable to type 'number & tag { y: any; }'. -!!! error TS2322: Type 'number' is not assignable to type 'number & tag { y: any; }'. -!!! error TS2322: Type 'number' is not assignable to type 'tag { y: any; }'. -!!! error TS2322: Type 'number & tag { x: any; }' is not assignable to type 'tag { y: any; }'. -!!! error TS2322: Type 'number' is not assignable to type 'tag { y: any; }'. +!!! error TS2322: Type 'number & tag { x: any; }' is not assignable to type 'tag { y: any; }'. a.x = b.y; // err ~~~ diff --git a/tests/baselines/reference/structuraltagConditonalExtract.js b/tests/baselines/reference/structuraltagConditonalExtract.js new file mode 100644 index 0000000000000..ac0a34d009cc0 --- /dev/null +++ b/tests/baselines/reference/structuraltagConditonalExtract.js @@ -0,0 +1,10 @@ +//// [structuraltagConditonalExtract.ts] +type GetTag = T extends tag infer U ? U : never +type ThatTag = string & tag {x: number}; + +type WhichTag = GetTag; + +const obj: WhichTag = {x: 12}; // should be OK + +//// [structuraltagConditonalExtract.js] +var obj = { x: 12 }; // should be OK diff --git a/tests/baselines/reference/structuraltagConditonalExtract.symbols b/tests/baselines/reference/structuraltagConditonalExtract.symbols new file mode 100644 index 0000000000000..9d7e92ce2756c --- /dev/null +++ b/tests/baselines/reference/structuraltagConditonalExtract.symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/types/structuralTags/structuraltagConditonalExtract.ts === +type GetTag = T extends tag infer U ? U : never +>GetTag : Symbol(GetTag, Decl(structuraltagConditonalExtract.ts, 0, 0)) +>T : Symbol(T, Decl(structuraltagConditonalExtract.ts, 0, 12)) +>T : Symbol(T, Decl(structuraltagConditonalExtract.ts, 0, 12)) +>U : Symbol(U, Decl(structuraltagConditonalExtract.ts, 0, 36)) +>U : Symbol(U, Decl(structuraltagConditonalExtract.ts, 0, 36)) + +type ThatTag = string & tag {x: number}; +>ThatTag : Symbol(ThatTag, Decl(structuraltagConditonalExtract.ts, 0, 50)) +>x : Symbol(x, Decl(structuraltagConditonalExtract.ts, 1, 29)) + +type WhichTag = GetTag; +>WhichTag : Symbol(WhichTag, Decl(structuraltagConditonalExtract.ts, 1, 40)) +>GetTag : Symbol(GetTag, Decl(structuraltagConditonalExtract.ts, 0, 0)) +>ThatTag : Symbol(ThatTag, Decl(structuraltagConditonalExtract.ts, 0, 50)) + +const obj: WhichTag = {x: 12}; // should be OK +>obj : Symbol(obj, Decl(structuraltagConditonalExtract.ts, 5, 5)) +>WhichTag : Symbol(WhichTag, Decl(structuraltagConditonalExtract.ts, 1, 40)) +>x : Symbol(x, Decl(structuraltagConditonalExtract.ts, 5, 23)) + diff --git a/tests/baselines/reference/structuraltagConditonalExtract.types b/tests/baselines/reference/structuraltagConditonalExtract.types new file mode 100644 index 0000000000000..b0ec00a7ecdca --- /dev/null +++ b/tests/baselines/reference/structuraltagConditonalExtract.types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/types/structuralTags/structuraltagConditonalExtract.ts === +type GetTag = T extends tag infer U ? U : never +>GetTag : GetTag + +type ThatTag = string & tag {x: number}; +>ThatTag : ThatTag +>x : number + +type WhichTag = GetTag; +>WhichTag : { x: number; } + +const obj: WhichTag = {x: 12}; // should be OK +>obj : { x: number; } +>{x: 12} : { x: number; } +>x : number +>12 : 12 + diff --git a/tests/cases/conformance/types/structuralTags/structuraltagConditonalExtract.ts b/tests/cases/conformance/types/structuralTags/structuraltagConditonalExtract.ts new file mode 100644 index 0000000000000..a32c8c126ae2d --- /dev/null +++ b/tests/cases/conformance/types/structuralTags/structuraltagConditonalExtract.ts @@ -0,0 +1,6 @@ +type GetTag = T extends tag infer U ? U : never +type ThatTag = string & tag {x: number}; + +type WhichTag = GetTag; + +const obj: WhichTag = {x: 12}; // should be OK \ No newline at end of file From 3da3129f4c3ca3abe3d4acb5d3e8fc920af1e21e Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 9 Sep 2019 16:50:53 -0700 Subject: [PATCH 3/7] Preserve aliases in tags better, add global Tag alias, distribute tags into unions --- src/compiler/checker.ts | 44 ++- src/harness/fourslash.ts | 1 + src/lib/es5.d.ts | 7 + .../reference/numericLiteralTypes1.js | 10 +- .../reference/numericLiteralTypes1.symbols | 22 +- .../reference/numericLiteralTypes1.types | 12 +- .../reference/numericLiteralTypes2.js | 10 +- .../reference/numericLiteralTypes2.symbols | 22 +- .../reference/numericLiteralTypes2.types | 12 +- .../structuralTagTypesControlFlow.errors.txt | 12 +- .../structuralTagTypesControlFlow.types | 20 +- ...uralTagTypesUsingGlobalTagAlias.errors.txt | 113 ++++++++ .../structuralTagTypesUsingGlobalTagAlias.js | 126 +++++++++ ...ucturalTagTypesUsingGlobalTagAlias.symbols | 238 ++++++++++++++++ ...tructuralTagTypesUsingGlobalTagAlias.types | 258 ++++++++++++++++++ .../typeGuardNarrowsPrimitiveIntersection.js | 6 +- ...eGuardNarrowsPrimitiveIntersection.symbols | 26 +- ...ypeGuardNarrowsPrimitiveIntersection.types | 20 +- .../typeGuardNarrowsPrimitiveIntersection.ts | 6 +- .../types/literal/numericLiteralTypes1.ts | 10 +- .../types/literal/numericLiteralTypes2.ts | 10 +- .../structuralTagTypesUsingGlobalTagAlias.ts | 71 +++++ 22 files changed, 953 insertions(+), 103 deletions(-) create mode 100644 tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.errors.txt create mode 100644 tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.js create mode 100644 tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.symbols create mode 100644 tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.types create mode 100644 tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f6968e54273f0..795a09b1f38a9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -629,7 +629,7 @@ namespace ts { const literalTypes = createMap(); const indexedAccessTypes = createMap(); const substitutionTypes = createMap(); - const structuralTags = createMap(); + const structuralTags = createMap(); const evolvingArrayTypes: EvolvingArrayType[] = []; const undefinedProperties = createMap() as UnderscoreEscapedMap; @@ -3798,8 +3798,33 @@ namespace ts { return typeToTypeNodeHelper((type).typeVariable, context); } if (type.flags & TypeFlags.StructuralTag) { + const innerType = (type as StructuralTagType).type; + if (innerType.flags & TypeFlags.Intersection) { + // If some inner type of the intersection has an alias when hoisted out, (attempt to) hoist out all of the aliasable things + if (some((innerType as IntersectionType).types, t => !!getStructuralTagForType(t).aliasSymbol)) { + const aliasingTypes: Type[] = []; + const nonAliasingTypes: Type[] = []; + for (const t of (innerType as IntersectionType).types) { + const taggedVersion = getStructuralTagForType(t); + if (taggedVersion.aliasSymbol && (context.flags & NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope || isTypeSymbolAccessible(taggedVersion.aliasSymbol, context.enclosingDeclaration))) { + aliasingTypes.push(taggedVersion); + } + else { + nonAliasingTypes.push(t); + } + } + if (length(aliasingTypes)) { + if (length(nonAliasingTypes)) { + aliasingTypes.push(getStructuralTagForType(getIntersectionType(nonAliasingTypes))); + } + // Do note: this can make an intersection become nested within another intersection - this _is_ handled correctly + // during emit, so is fine (and honestly is more clear, since it groups all the tags together) + return createUnionOrIntersectionTypeNode(SyntaxKind.IntersectionType, map(aliasingTypes, t => typeToTypeNodeHelper(t, context))); + } + } + } context.approximateLength += 4; - return createTypeOperatorNode(SyntaxKind.TagKeyword, typeToTypeNodeHelper((type as StructuralTagType).type, context)); + return createTypeOperatorNode(SyntaxKind.TagKeyword, typeToTypeNodeHelper(innerType, context)); } return Debug.fail("Should be unreachable."); @@ -9980,7 +10005,7 @@ namespace ts { includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type), tagSet); } if (isTopLevel && tagSet.size) { - let tag: StructuralTagType; + let tag: Type; if (tagSet.size === 1) { tag = tagSet.values().next().value; } @@ -9988,6 +10013,9 @@ namespace ts { const tagTypes: Type[] = []; tagSet.forEach(t => tagTypes.push(t.type)); tag = getStructuralTagForType(getIntersectionType(tagTypes)); + if (tag.flags & TypeFlags.Union) { + includes |= TypeFlags.Union; + } } typeSet.set(tag.id.toString(), tag); } @@ -10310,11 +10338,19 @@ namespace ts { return type; } - function getStructuralTagForType(type: Type, aliasSymbol?: Symbol, aliasTypeArguments?: readonly Type[]) { + function getStructuralTagForType(type: Type, aliasSymbol?: Symbol | number, aliasTypeArguments?: readonly Type[]) { + if (typeof aliasSymbol === "number") { + aliasSymbol = undefined; + } const tid = "" + getTypeId(type); if (structuralTags.has(tid)) { return structuralTags.get(tid)!; } + if (type.flags & TypeFlags.Union) { + const union = getUnionType(map((type as UnionType).types, getStructuralTagForType), UnionReduction.Subtype, aliasSymbol, aliasTypeArguments); + structuralTags.set(tid, union); + return union; + } const tag = createType(TypeFlags.StructuralTag) as StructuralTagType; tag.type = type; tag.aliasSymbol = aliasSymbol; diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index cf01109bb9af5..dac5ae4e55190 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -4672,6 +4672,7 @@ namespace FourSlashInterface { typeEntry("ReturnType"), typeEntry("InstanceType"), interfaceEntry("ThisType"), + typeEntry("Tag"), varEntry("ArrayBuffer"), interfaceEntry("ArrayBufferTypes"), typeEntry("ArrayBufferLike"), diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 7dfccb327ea41..ec8ab43c2843e 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1478,6 +1478,13 @@ type InstanceType any> = T extends new (...args: */ interface ThisType { } +/** + * Constructs a structural tag over property name(s) `K` + */ +type Tag = tag { + [_ in K]: void; + }; + /** * Represents a raw buffer of binary data, which is used to store data for the * different typed arrays. ArrayBuffers cannot be read from or written to directly, diff --git a/tests/baselines/reference/numericLiteralTypes1.js b/tests/baselines/reference/numericLiteralTypes1.js index 17c24d872efe5..fed7c81609f1b 100644 --- a/tests/baselines/reference/numericLiteralTypes1.js +++ b/tests/baselines/reference/numericLiteralTypes1.js @@ -66,9 +66,9 @@ function assertNever(x: never): never { throw new Error("Unexpected value"); } -type Tag = 0 | 1 | 2; +type NumericTag = 0 | 1 | 2; -function f10(x: Tag) { +function f10(x: NumericTag) { switch (x) { case 0: return "a"; case 1: return "b"; @@ -76,7 +76,7 @@ function f10(x: Tag) { } } -function f11(x: Tag) { +function f11(x: NumericTag) { switch (x) { case 0: return "a"; case 1: return "b"; @@ -85,7 +85,7 @@ function f11(x: Tag) { return assertNever(x); } -function f12(x: Tag) { +function f12(x: NumericTag) { if (x) { x; } @@ -94,7 +94,7 @@ function f12(x: Tag) { } } -function f13(x: Tag) { +function f13(x: NumericTag) { if (x === 0 || x === 2) { x; } diff --git a/tests/baselines/reference/numericLiteralTypes1.symbols b/tests/baselines/reference/numericLiteralTypes1.symbols index 9144474a5bfe8..17efcbd7acae8 100644 --- a/tests/baselines/reference/numericLiteralTypes1.symbols +++ b/tests/baselines/reference/numericLiteralTypes1.symbols @@ -221,13 +221,13 @@ function assertNever(x: never): never { >Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) } -type Tag = 0 | 1 | 2; ->Tag : Symbol(Tag, Decl(numericLiteralTypes1.ts, 65, 1)) +type NumericTag = 0 | 1 | 2; +>NumericTag : Symbol(NumericTag, Decl(numericLiteralTypes1.ts, 65, 1)) -function f10(x: Tag) { ->f10 : Symbol(f10, Decl(numericLiteralTypes1.ts, 67, 21)) +function f10(x: NumericTag) { +>f10 : Symbol(f10, Decl(numericLiteralTypes1.ts, 67, 28)) >x : Symbol(x, Decl(numericLiteralTypes1.ts, 69, 13)) ->Tag : Symbol(Tag, Decl(numericLiteralTypes1.ts, 65, 1)) +>NumericTag : Symbol(NumericTag, Decl(numericLiteralTypes1.ts, 65, 1)) switch (x) { >x : Symbol(x, Decl(numericLiteralTypes1.ts, 69, 13)) @@ -238,10 +238,10 @@ function f10(x: Tag) { } } -function f11(x: Tag) { +function f11(x: NumericTag) { >f11 : Symbol(f11, Decl(numericLiteralTypes1.ts, 75, 1)) >x : Symbol(x, Decl(numericLiteralTypes1.ts, 77, 13)) ->Tag : Symbol(Tag, Decl(numericLiteralTypes1.ts, 65, 1)) +>NumericTag : Symbol(NumericTag, Decl(numericLiteralTypes1.ts, 65, 1)) switch (x) { >x : Symbol(x, Decl(numericLiteralTypes1.ts, 77, 13)) @@ -255,10 +255,10 @@ function f11(x: Tag) { >x : Symbol(x, Decl(numericLiteralTypes1.ts, 77, 13)) } -function f12(x: Tag) { +function f12(x: NumericTag) { >f12 : Symbol(f12, Decl(numericLiteralTypes1.ts, 84, 1)) >x : Symbol(x, Decl(numericLiteralTypes1.ts, 86, 13)) ->Tag : Symbol(Tag, Decl(numericLiteralTypes1.ts, 65, 1)) +>NumericTag : Symbol(NumericTag, Decl(numericLiteralTypes1.ts, 65, 1)) if (x) { >x : Symbol(x, Decl(numericLiteralTypes1.ts, 86, 13)) @@ -272,10 +272,10 @@ function f12(x: Tag) { } } -function f13(x: Tag) { +function f13(x: NumericTag) { >f13 : Symbol(f13, Decl(numericLiteralTypes1.ts, 93, 1)) >x : Symbol(x, Decl(numericLiteralTypes1.ts, 95, 13)) ->Tag : Symbol(Tag, Decl(numericLiteralTypes1.ts, 65, 1)) +>NumericTag : Symbol(NumericTag, Decl(numericLiteralTypes1.ts, 65, 1)) if (x === 0 || x === 2) { >x : Symbol(x, Decl(numericLiteralTypes1.ts, 95, 13)) diff --git a/tests/baselines/reference/numericLiteralTypes1.types b/tests/baselines/reference/numericLiteralTypes1.types index 7556d0818ee45..630c8e2e9cf86 100644 --- a/tests/baselines/reference/numericLiteralTypes1.types +++ b/tests/baselines/reference/numericLiteralTypes1.types @@ -259,10 +259,10 @@ function assertNever(x: never): never { >"Unexpected value" : "Unexpected value" } -type Tag = 0 | 1 | 2; ->Tag : 0 | 1 | 2 +type NumericTag = 0 | 1 | 2; +>NumericTag : 0 | 1 | 2 -function f10(x: Tag) { +function f10(x: NumericTag) { >f10 : (x: 0 | 1 | 2) => "a" | "b" | "c" >x : 0 | 1 | 2 @@ -283,7 +283,7 @@ function f10(x: Tag) { } } -function f11(x: Tag) { +function f11(x: NumericTag) { >f11 : (x: 0 | 1 | 2) => "a" | "b" | "c" >x : 0 | 1 | 2 @@ -308,7 +308,7 @@ function f11(x: Tag) { >x : never } -function f12(x: Tag) { +function f12(x: NumericTag) { >f12 : (x: 0 | 1 | 2) => void >x : 0 | 1 | 2 @@ -324,7 +324,7 @@ function f12(x: Tag) { } } -function f13(x: Tag) { +function f13(x: NumericTag) { >f13 : (x: 0 | 1 | 2) => void >x : 0 | 1 | 2 diff --git a/tests/baselines/reference/numericLiteralTypes2.js b/tests/baselines/reference/numericLiteralTypes2.js index ff0404e42dd7c..8503052f46ce8 100644 --- a/tests/baselines/reference/numericLiteralTypes2.js +++ b/tests/baselines/reference/numericLiteralTypes2.js @@ -66,9 +66,9 @@ function assertNever(x: never): never { throw new Error("Unexpected value"); } -type Tag = 0 | 1 | 2; +type NumericTag = 0 | 1 | 2; -function f10(x: Tag) { +function f10(x: NumericTag) { switch (x) { case 0: return "a"; case 1: return "b"; @@ -76,7 +76,7 @@ function f10(x: Tag) { } } -function f11(x: Tag) { +function f11(x: NumericTag) { switch (x) { case 0: return "a"; case 1: return "b"; @@ -85,7 +85,7 @@ function f11(x: Tag) { return assertNever(x); } -function f12(x: Tag) { +function f12(x: NumericTag) { if (x) { x; } @@ -94,7 +94,7 @@ function f12(x: Tag) { } } -function f13(x: Tag) { +function f13(x: NumericTag) { if (x === 0 || x === 2) { x; } diff --git a/tests/baselines/reference/numericLiteralTypes2.symbols b/tests/baselines/reference/numericLiteralTypes2.symbols index c8265d419b84b..8cf510121eec9 100644 --- a/tests/baselines/reference/numericLiteralTypes2.symbols +++ b/tests/baselines/reference/numericLiteralTypes2.symbols @@ -221,13 +221,13 @@ function assertNever(x: never): never { >Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) } -type Tag = 0 | 1 | 2; ->Tag : Symbol(Tag, Decl(numericLiteralTypes2.ts, 65, 1)) +type NumericTag = 0 | 1 | 2; +>NumericTag : Symbol(NumericTag, Decl(numericLiteralTypes2.ts, 65, 1)) -function f10(x: Tag) { ->f10 : Symbol(f10, Decl(numericLiteralTypes2.ts, 67, 21)) +function f10(x: NumericTag) { +>f10 : Symbol(f10, Decl(numericLiteralTypes2.ts, 67, 28)) >x : Symbol(x, Decl(numericLiteralTypes2.ts, 69, 13)) ->Tag : Symbol(Tag, Decl(numericLiteralTypes2.ts, 65, 1)) +>NumericTag : Symbol(NumericTag, Decl(numericLiteralTypes2.ts, 65, 1)) switch (x) { >x : Symbol(x, Decl(numericLiteralTypes2.ts, 69, 13)) @@ -238,10 +238,10 @@ function f10(x: Tag) { } } -function f11(x: Tag) { +function f11(x: NumericTag) { >f11 : Symbol(f11, Decl(numericLiteralTypes2.ts, 75, 1)) >x : Symbol(x, Decl(numericLiteralTypes2.ts, 77, 13)) ->Tag : Symbol(Tag, Decl(numericLiteralTypes2.ts, 65, 1)) +>NumericTag : Symbol(NumericTag, Decl(numericLiteralTypes2.ts, 65, 1)) switch (x) { >x : Symbol(x, Decl(numericLiteralTypes2.ts, 77, 13)) @@ -255,10 +255,10 @@ function f11(x: Tag) { >x : Symbol(x, Decl(numericLiteralTypes2.ts, 77, 13)) } -function f12(x: Tag) { +function f12(x: NumericTag) { >f12 : Symbol(f12, Decl(numericLiteralTypes2.ts, 84, 1)) >x : Symbol(x, Decl(numericLiteralTypes2.ts, 86, 13)) ->Tag : Symbol(Tag, Decl(numericLiteralTypes2.ts, 65, 1)) +>NumericTag : Symbol(NumericTag, Decl(numericLiteralTypes2.ts, 65, 1)) if (x) { >x : Symbol(x, Decl(numericLiteralTypes2.ts, 86, 13)) @@ -272,10 +272,10 @@ function f12(x: Tag) { } } -function f13(x: Tag) { +function f13(x: NumericTag) { >f13 : Symbol(f13, Decl(numericLiteralTypes2.ts, 93, 1)) >x : Symbol(x, Decl(numericLiteralTypes2.ts, 95, 13)) ->Tag : Symbol(Tag, Decl(numericLiteralTypes2.ts, 65, 1)) +>NumericTag : Symbol(NumericTag, Decl(numericLiteralTypes2.ts, 65, 1)) if (x === 0 || x === 2) { >x : Symbol(x, Decl(numericLiteralTypes2.ts, 95, 13)) diff --git a/tests/baselines/reference/numericLiteralTypes2.types b/tests/baselines/reference/numericLiteralTypes2.types index 32396d13da251..39d3ea2303e5c 100644 --- a/tests/baselines/reference/numericLiteralTypes2.types +++ b/tests/baselines/reference/numericLiteralTypes2.types @@ -259,10 +259,10 @@ function assertNever(x: never): never { >"Unexpected value" : "Unexpected value" } -type Tag = 0 | 1 | 2; ->Tag : 0 | 1 | 2 +type NumericTag = 0 | 1 | 2; +>NumericTag : 0 | 1 | 2 -function f10(x: Tag) { +function f10(x: NumericTag) { >f10 : (x: 0 | 1 | 2) => "a" | "b" | "c" >x : 0 | 1 | 2 @@ -283,7 +283,7 @@ function f10(x: Tag) { } } -function f11(x: Tag) { +function f11(x: NumericTag) { >f11 : (x: 0 | 1 | 2) => "a" | "b" | "c" >x : 0 | 1 | 2 @@ -308,7 +308,7 @@ function f11(x: Tag) { >x : never } -function f12(x: Tag) { +function f12(x: NumericTag) { >f12 : (x: 0 | 1 | 2) => void >x : 0 | 1 | 2 @@ -324,7 +324,7 @@ function f12(x: Tag) { } } -function f13(x: Tag) { +function f13(x: NumericTag) { >f13 : (x: 0 | 1 | 2) => void >x : 0 | 1 | 2 diff --git a/tests/baselines/reference/structuralTagTypesControlFlow.errors.txt b/tests/baselines/reference/structuralTagTypesControlFlow.errors.txt index f43900c0c8c96..3ac74f5d95c24 100644 --- a/tests/baselines/reference/structuralTagTypesControlFlow.errors.txt +++ b/tests/baselines/reference/structuralTagTypesControlFlow.errors.txt @@ -1,12 +1,12 @@ tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(22,23): error TS2345: Argument of type '{ x: number; } & BrandA' is not assignable to parameter of type 'BrandB'. -tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(24,27): error TS2345: Argument of type '{ x: number; } & BrandA' is not assignable to parameter of type 'tag ({ BrandA: void; } & { BrandB: void; })'. +tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(24,27): error TS2345: Argument of type '{ x: number; } & BrandA' is not assignable to parameter of type 'BrandA & BrandB'. tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(29,23): error TS2345: Argument of type '{ x: number; } & BrandB' is not assignable to parameter of type 'BrandA'. -tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(32,27): error TS2345: Argument of type '{ x: number; } & BrandB' is not assignable to parameter of type 'tag ({ BrandA: void; } & { BrandB: void; })'. +tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(32,27): error TS2345: Argument of type '{ x: number; } & BrandB' is not assignable to parameter of type 'BrandA & BrandB'. tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(35,23): error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type 'BrandA'. tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(36,23): error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type 'BrandB'. tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(37,26): error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type 'BrandA | BrandB'. Type '{ x: number; }' is not assignable to type 'BrandB'. -tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(38,27): error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type 'tag ({ BrandA: void; } & { BrandB: void; })'. +tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(38,27): error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type 'BrandA & BrandB'. tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(64,29): error TS2345: Argument of type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to parameter of type 'AbsolutePath'. Type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to type 'tag { AbsolutePath: void; }'. tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(66,39): error TS2345: Argument of type '"/a/b/c" & tag { NormalizedPath: void; }' is not assignable to parameter of type 'NormalizedAbsolutePath'. @@ -52,7 +52,7 @@ tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(80 consumeBrandAOrB(x); consumeBrandAAndB(x); // err ~ -!!! error TS2345: Argument of type '{ x: number; } & BrandA' is not assignable to parameter of type 'tag ({ BrandA: void; } & { BrandB: void; })'. +!!! error TS2345: Argument of type '{ x: number; } & BrandA' is not assignable to parameter of type 'BrandA & BrandB'. } } else { @@ -64,7 +64,7 @@ tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(80 consumeBrandAOrB(x); consumeBrandAAndB(x); // err ~ -!!! error TS2345: Argument of type '{ x: number; } & BrandB' is not assignable to parameter of type 'tag ({ BrandA: void; } & { BrandB: void; })'. +!!! error TS2345: Argument of type '{ x: number; } & BrandB' is not assignable to parameter of type 'BrandA & BrandB'. } else { consumeBrandA(x); // err @@ -79,7 +79,7 @@ tests/cases/conformance/types/structuralTags/structuralTagTypesControlFlow.ts(80 !!! error TS2345: Type '{ x: number; }' is not assignable to type 'BrandB'. consumeBrandAAndB(x); // err ~ -!!! error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type 'tag ({ BrandA: void; } & { BrandB: void; })'. +!!! error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type 'BrandA & BrandB'. } } diff --git a/tests/baselines/reference/structuralTagTypesControlFlow.types b/tests/baselines/reference/structuralTagTypesControlFlow.types index 543c385336f6b..0a18d2310f81a 100644 --- a/tests/baselines/reference/structuralTagTypesControlFlow.types +++ b/tests/baselines/reference/structuralTagTypesControlFlow.types @@ -28,8 +28,8 @@ declare function consumeBrandAOrB(x: BrandA | BrandB): void; >x : BrandA | BrandB declare function consumeBrandAAndB(x: BrandA & BrandB): void; ->consumeBrandAAndB : (x: tag ({ BrandA: void; } & { BrandB: void; })) => void ->x : tag ({ BrandA: void; } & { BrandB: void; }) +>consumeBrandAAndB : (x: BrandA & BrandB) => void +>x : BrandA & BrandB const x = {x: 12}; >x : { x: number; } @@ -50,22 +50,22 @@ if (isBrandA(x)) { consumeBrandA(x); >consumeBrandA(x) : void >consumeBrandA : (x: BrandA) => void ->x : { x: number; } & tag ({ BrandA: void; } & { BrandB: void; }) +>x : { x: number; } & (BrandA & BrandB) consumeBrandB(x); >consumeBrandB(x) : void >consumeBrandB : (x: BrandB) => void ->x : { x: number; } & tag ({ BrandA: void; } & { BrandB: void; }) +>x : { x: number; } & (BrandA & BrandB) consumeBrandAOrB(x); >consumeBrandAOrB(x) : void >consumeBrandAOrB : (x: BrandA | BrandB) => void ->x : { x: number; } & tag ({ BrandA: void; } & { BrandB: void; }) +>x : { x: number; } & (BrandA & BrandB) consumeBrandAAndB(x); >consumeBrandAAndB(x) : void ->consumeBrandAAndB : (x: tag ({ BrandA: void; } & { BrandB: void; })) => void ->x : { x: number; } & tag ({ BrandA: void; } & { BrandB: void; }) +>consumeBrandAAndB : (x: BrandA & BrandB) => void +>x : { x: number; } & (BrandA & BrandB) } else { consumeBrandA(x); @@ -85,7 +85,7 @@ if (isBrandA(x)) { consumeBrandAAndB(x); // err >consumeBrandAAndB(x) : void ->consumeBrandAAndB : (x: tag ({ BrandA: void; } & { BrandB: void; })) => void +>consumeBrandAAndB : (x: BrandA & BrandB) => void >x : { x: number; } & BrandA } } @@ -112,7 +112,7 @@ else { consumeBrandAAndB(x); // err >consumeBrandAAndB(x) : void ->consumeBrandAAndB : (x: tag ({ BrandA: void; } & { BrandB: void; })) => void +>consumeBrandAAndB : (x: BrandA & BrandB) => void >x : { x: number; } & BrandB } else { @@ -133,7 +133,7 @@ else { consumeBrandAAndB(x); // err >consumeBrandAAndB(x) : void ->consumeBrandAAndB : (x: tag ({ BrandA: void; } & { BrandB: void; })) => void +>consumeBrandAAndB : (x: BrandA & BrandB) => void >x : { x: number; } } } diff --git a/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.errors.txt b/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.errors.txt new file mode 100644 index 0000000000000..4e6029db2b260 --- /dev/null +++ b/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.errors.txt @@ -0,0 +1,113 @@ +tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(53,29): error TS2345: Argument of type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to parameter of type 'AbsolutePath'. + Type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to type 'Tag<"AbsolutePath">'. +tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(55,39): error TS2345: Argument of type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to parameter of type 'NormalizedAbsolutePath'. + Type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'. +tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(60,31): error TS2345: Argument of type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to parameter of type 'NormalizedPath'. + Type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to type 'Tag<"NormalizedPath">'. +tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(63,39): error TS2345: Argument of type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to parameter of type 'NormalizedAbsolutePath'. + Type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'. +tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(66,31): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath'. + Type '"/a/b/c"' is not assignable to type 'Tag<"NormalizedPath">'. +tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(67,29): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'AbsolutePath'. + Type '"/a/b/c"' is not assignable to type 'Tag<"AbsolutePath">'. +tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(68,41): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath | AbsolutePath'. +tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(69,39): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedAbsolutePath'. + Type '"/a/b/c"' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'. + + +==== tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts (8 errors) ==== + export type Paired = { + x: number & Tag<"x">; + y: number & Tag<"y">; + }; + + + export function isPaired(x: {x: number, y: number}): x is Paired { + return true; + } + + export function makePair(x: number, y: number): Paired { + return {x, y} as Paired; + } + + const a = makePair(0, 0); + const b = {x: 0, y: 0}; + + if (Math.random() > 0.3) { + b.x = a.x; + b.y = a.y; + } + + if (isPaired(b)) { + b.x = a.x; + b.y = a.y; + a.x = b.x; + a.y = b.y; + } + + + type NormalizedPath = string & Tag<"NormalizedPath">; + type AbsolutePath = string & Tag<"AbsolutePath">; + type NormalizedAbsolutePath = NormalizedPath & AbsolutePath; + + declare function isNormalizedPath(x: string): x is NormalizedPath; + declare function isAbsolutePath(x: string): x is AbsolutePath; + + declare function consumeNormalizedPath(x: NormalizedPath): void; + declare function consumeAbsolutePath(x: AbsolutePath): void; + declare function consumeNormalizedOrAbsolutePath(x: NormalizedPath | AbsolutePath): void; + declare function consumeNormalizedAbsolutePath(x: NormalizedAbsolutePath): void; + + const p = "/a/b/c"; + if (isNormalizedPath(p)) { + if (isAbsolutePath(p)) { + consumeNormalizedPath(p); + consumeAbsolutePath(p); + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); + } + else { + consumeNormalizedPath(p); + consumeAbsolutePath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to parameter of type 'AbsolutePath'. +!!! error TS2345: Type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to type 'Tag<"AbsolutePath">'. + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to parameter of type 'NormalizedAbsolutePath'. +!!! error TS2345: Type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'. + } + } + else { + if (isAbsolutePath(p)) { + consumeNormalizedPath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to parameter of type 'NormalizedPath'. +!!! error TS2345: Type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to type 'Tag<"NormalizedPath">'. + consumeAbsolutePath(p); + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to parameter of type 'NormalizedAbsolutePath'. +!!! error TS2345: Type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'. + } + else { + consumeNormalizedPath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath'. +!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'Tag<"NormalizedPath">'. + consumeAbsolutePath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'AbsolutePath'. +!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'Tag<"AbsolutePath">'. + consumeNormalizedOrAbsolutePath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath | AbsolutePath'. + consumeNormalizedAbsolutePath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedAbsolutePath'. +!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'. + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.js b/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.js new file mode 100644 index 0000000000000..2792bd5973bcc --- /dev/null +++ b/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.js @@ -0,0 +1,126 @@ +//// [structuralTagTypesUsingGlobalTagAlias.ts] +export type Paired = { + x: number & Tag<"x">; + y: number & Tag<"y">; +}; + + +export function isPaired(x: {x: number, y: number}): x is Paired { + return true; +} + +export function makePair(x: number, y: number): Paired { + return {x, y} as Paired; +} + +const a = makePair(0, 0); +const b = {x: 0, y: 0}; + +if (Math.random() > 0.3) { + b.x = a.x; + b.y = a.y; +} + +if (isPaired(b)) { + b.x = a.x; + b.y = a.y; + a.x = b.x; + a.y = b.y; +} + + +type NormalizedPath = string & Tag<"NormalizedPath">; +type AbsolutePath = string & Tag<"AbsolutePath">; +type NormalizedAbsolutePath = NormalizedPath & AbsolutePath; + +declare function isNormalizedPath(x: string): x is NormalizedPath; +declare function isAbsolutePath(x: string): x is AbsolutePath; + +declare function consumeNormalizedPath(x: NormalizedPath): void; +declare function consumeAbsolutePath(x: AbsolutePath): void; +declare function consumeNormalizedOrAbsolutePath(x: NormalizedPath | AbsolutePath): void; +declare function consumeNormalizedAbsolutePath(x: NormalizedAbsolutePath): void; + +const p = "/a/b/c"; +if (isNormalizedPath(p)) { + if (isAbsolutePath(p)) { + consumeNormalizedPath(p); + consumeAbsolutePath(p); + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); + } + else { + consumeNormalizedPath(p); + consumeAbsolutePath(p); // err + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); // err + } +} +else { + if (isAbsolutePath(p)) { + consumeNormalizedPath(p); // err + consumeAbsolutePath(p); + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); // err + } + else { + consumeNormalizedPath(p); // err + consumeAbsolutePath(p); // err + consumeNormalizedOrAbsolutePath(p); // err + consumeNormalizedAbsolutePath(p); // err + } +} + + +//// [structuralTagTypesUsingGlobalTagAlias.js] +"use strict"; +exports.__esModule = true; +function isPaired(x) { + return true; +} +exports.isPaired = isPaired; +function makePair(x, y) { + return { x: x, y: y }; +} +exports.makePair = makePair; +var a = makePair(0, 0); +var b = { x: 0, y: 0 }; +if (Math.random() > 0.3) { + b.x = a.x; + b.y = a.y; +} +if (isPaired(b)) { + b.x = a.x; + b.y = a.y; + a.x = b.x; + a.y = b.y; +} +var p = "/a/b/c"; +if (isNormalizedPath(p)) { + if (isAbsolutePath(p)) { + consumeNormalizedPath(p); + consumeAbsolutePath(p); + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); + } + else { + consumeNormalizedPath(p); + consumeAbsolutePath(p); // err + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); // err + } +} +else { + if (isAbsolutePath(p)) { + consumeNormalizedPath(p); // err + consumeAbsolutePath(p); + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); // err + } + else { + consumeNormalizedPath(p); // err + consumeAbsolutePath(p); // err + consumeNormalizedOrAbsolutePath(p); // err + consumeNormalizedAbsolutePath(p); // err + } +} diff --git a/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.symbols b/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.symbols new file mode 100644 index 0000000000000..b8f6e1934238d --- /dev/null +++ b/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.symbols @@ -0,0 +1,238 @@ +=== tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts === +export type Paired = { +>Paired : Symbol(Paired, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 0)) + + x: number & Tag<"x">; +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) +>Tag : Symbol(Tag, Decl(lib.es5.d.ts, --, --)) + + y: number & Tag<"y">; +>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) +>Tag : Symbol(Tag, Decl(lib.es5.d.ts, --, --)) + +}; + + +export function isPaired(x: {x: number, y: number}): x is Paired { +>isPaired : Symbol(isPaired, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 3, 2)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 6, 25)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 6, 29)) +>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 6, 39)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 6, 25)) +>Paired : Symbol(Paired, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 0)) + + return true; +} + +export function makePair(x: number, y: number): Paired { +>makePair : Symbol(makePair, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 8, 1)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 10, 25)) +>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 10, 35)) +>Paired : Symbol(Paired, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 0)) + + return {x, y} as Paired; +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 11, 12)) +>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 11, 14)) +>Paired : Symbol(Paired, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 0)) +} + +const a = makePair(0, 0); +>a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5)) +>makePair : Symbol(makePair, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 8, 1)) + +const b = {x: 0, y: 0}; +>b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 11)) +>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 16)) + +if (Math.random() > 0.3) { +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) + + b.x = a.x; +>b.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 11)) +>b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 11)) +>a.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) +>a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) + + b.y = a.y; +>b.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 16)) +>b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5)) +>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 16)) +>a.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) +>a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5)) +>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) +} + +if (isPaired(b)) { +>isPaired : Symbol(isPaired, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 3, 2)) +>b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5)) + + b.x = a.x; +>b.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) +>b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) +>a.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) +>a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) + + b.y = a.y; +>b.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) +>b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5)) +>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) +>a.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) +>a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5)) +>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) + + a.x = b.x; +>a.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) +>a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) +>b.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) +>b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) + + a.y = b.y; +>a.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) +>a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5)) +>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) +>b.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) +>b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5)) +>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) +} + + +type NormalizedPath = string & Tag<"NormalizedPath">; +>NormalizedPath : Symbol(NormalizedPath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 27, 1)) +>Tag : Symbol(Tag, Decl(lib.es5.d.ts, --, --)) + +type AbsolutePath = string & Tag<"AbsolutePath">; +>AbsolutePath : Symbol(AbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 30, 53)) +>Tag : Symbol(Tag, Decl(lib.es5.d.ts, --, --)) + +type NormalizedAbsolutePath = NormalizedPath & AbsolutePath; +>NormalizedAbsolutePath : Symbol(NormalizedAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 31, 49)) +>NormalizedPath : Symbol(NormalizedPath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 27, 1)) +>AbsolutePath : Symbol(AbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 30, 53)) + +declare function isNormalizedPath(x: string): x is NormalizedPath; +>isNormalizedPath : Symbol(isNormalizedPath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 32, 60)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 34, 34)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 34, 34)) +>NormalizedPath : Symbol(NormalizedPath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 27, 1)) + +declare function isAbsolutePath(x: string): x is AbsolutePath; +>isAbsolutePath : Symbol(isAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 34, 66)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 35, 32)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 35, 32)) +>AbsolutePath : Symbol(AbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 30, 53)) + +declare function consumeNormalizedPath(x: NormalizedPath): void; +>consumeNormalizedPath : Symbol(consumeNormalizedPath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 35, 62)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 37, 39)) +>NormalizedPath : Symbol(NormalizedPath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 27, 1)) + +declare function consumeAbsolutePath(x: AbsolutePath): void; +>consumeAbsolutePath : Symbol(consumeAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 37, 64)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 38, 37)) +>AbsolutePath : Symbol(AbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 30, 53)) + +declare function consumeNormalizedOrAbsolutePath(x: NormalizedPath | AbsolutePath): void; +>consumeNormalizedOrAbsolutePath : Symbol(consumeNormalizedOrAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 38, 60)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 39, 49)) +>NormalizedPath : Symbol(NormalizedPath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 27, 1)) +>AbsolutePath : Symbol(AbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 30, 53)) + +declare function consumeNormalizedAbsolutePath(x: NormalizedAbsolutePath): void; +>consumeNormalizedAbsolutePath : Symbol(consumeNormalizedAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 39, 89)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 40, 47)) +>NormalizedAbsolutePath : Symbol(NormalizedAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 31, 49)) + +const p = "/a/b/c"; +>p : Symbol(p, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 42, 5)) + +if (isNormalizedPath(p)) { +>isNormalizedPath : Symbol(isNormalizedPath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 32, 60)) +>p : Symbol(p, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 42, 5)) + + if (isAbsolutePath(p)) { +>isAbsolutePath : Symbol(isAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 34, 66)) +>p : Symbol(p, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 42, 5)) + + consumeNormalizedPath(p); +>consumeNormalizedPath : Symbol(consumeNormalizedPath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 35, 62)) +>p : Symbol(p, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 42, 5)) + + consumeAbsolutePath(p); +>consumeAbsolutePath : Symbol(consumeAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 37, 64)) +>p : Symbol(p, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 42, 5)) + + consumeNormalizedOrAbsolutePath(p); +>consumeNormalizedOrAbsolutePath : Symbol(consumeNormalizedOrAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 38, 60)) +>p : Symbol(p, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 42, 5)) + + consumeNormalizedAbsolutePath(p); +>consumeNormalizedAbsolutePath : Symbol(consumeNormalizedAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 39, 89)) +>p : Symbol(p, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 42, 5)) + } + else { + consumeNormalizedPath(p); +>consumeNormalizedPath : Symbol(consumeNormalizedPath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 35, 62)) +>p : Symbol(p, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 42, 5)) + + consumeAbsolutePath(p); // err +>consumeAbsolutePath : Symbol(consumeAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 37, 64)) +>p : Symbol(p, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 42, 5)) + + consumeNormalizedOrAbsolutePath(p); +>consumeNormalizedOrAbsolutePath : Symbol(consumeNormalizedOrAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 38, 60)) +>p : Symbol(p, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 42, 5)) + + consumeNormalizedAbsolutePath(p); // err +>consumeNormalizedAbsolutePath : Symbol(consumeNormalizedAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 39, 89)) +>p : Symbol(p, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 42, 5)) + } +} +else { + if (isAbsolutePath(p)) { +>isAbsolutePath : Symbol(isAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 34, 66)) +>p : Symbol(p, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 42, 5)) + + consumeNormalizedPath(p); // err +>consumeNormalizedPath : Symbol(consumeNormalizedPath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 35, 62)) +>p : Symbol(p, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 42, 5)) + + consumeAbsolutePath(p); +>consumeAbsolutePath : Symbol(consumeAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 37, 64)) +>p : Symbol(p, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 42, 5)) + + consumeNormalizedOrAbsolutePath(p); +>consumeNormalizedOrAbsolutePath : Symbol(consumeNormalizedOrAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 38, 60)) +>p : Symbol(p, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 42, 5)) + + consumeNormalizedAbsolutePath(p); // err +>consumeNormalizedAbsolutePath : Symbol(consumeNormalizedAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 39, 89)) +>p : Symbol(p, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 42, 5)) + } + else { + consumeNormalizedPath(p); // err +>consumeNormalizedPath : Symbol(consumeNormalizedPath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 35, 62)) +>p : Symbol(p, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 42, 5)) + + consumeAbsolutePath(p); // err +>consumeAbsolutePath : Symbol(consumeAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 37, 64)) +>p : Symbol(p, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 42, 5)) + + consumeNormalizedOrAbsolutePath(p); // err +>consumeNormalizedOrAbsolutePath : Symbol(consumeNormalizedOrAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 38, 60)) +>p : Symbol(p, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 42, 5)) + + consumeNormalizedAbsolutePath(p); // err +>consumeNormalizedAbsolutePath : Symbol(consumeNormalizedAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 39, 89)) +>p : Symbol(p, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 42, 5)) + } +} + diff --git a/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.types b/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.types new file mode 100644 index 0000000000000..b73dfb6f1f7db --- /dev/null +++ b/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.types @@ -0,0 +1,258 @@ +=== tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts === +export type Paired = { +>Paired : Paired + + x: number & Tag<"x">; +>x : number & Tag<"x"> + + y: number & Tag<"y">; +>y : number & Tag<"y"> + +}; + + +export function isPaired(x: {x: number, y: number}): x is Paired { +>isPaired : (x: { x: number; y: number; }) => x is Paired +>x : { x: number; y: number; } +>x : number +>y : number + + return true; +>true : true +} + +export function makePair(x: number, y: number): Paired { +>makePair : (x: number, y: number) => Paired +>x : number +>y : number + + return {x, y} as Paired; +>{x, y} as Paired : Paired +>{x, y} : { x: number; y: number; } +>x : number +>y : number +} + +const a = makePair(0, 0); +>a : Paired +>makePair(0, 0) : Paired +>makePair : (x: number, y: number) => Paired +>0 : 0 +>0 : 0 + +const b = {x: 0, y: 0}; +>b : { x: number; y: number; } +>{x: 0, y: 0} : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + +if (Math.random() > 0.3) { +>Math.random() > 0.3 : boolean +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>0.3 : 0.3 + + b.x = a.x; +>b.x = a.x : number & Tag<"x"> +>b.x : number +>b : { x: number; y: number; } +>x : number +>a.x : number & Tag<"x"> +>a : Paired +>x : number & Tag<"x"> + + b.y = a.y; +>b.y = a.y : number & Tag<"y"> +>b.y : number +>b : { x: number; y: number; } +>y : number +>a.y : number & Tag<"y"> +>a : Paired +>y : number & Tag<"y"> +} + +if (isPaired(b)) { +>isPaired(b) : boolean +>isPaired : (x: { x: number; y: number; }) => x is Paired +>b : { x: number; y: number; } + + b.x = a.x; +>b.x = a.x : number & Tag<"x"> +>b.x : number & Tag<"x"> +>b : Paired +>x : number & Tag<"x"> +>a.x : number & Tag<"x"> +>a : Paired +>x : number & Tag<"x"> + + b.y = a.y; +>b.y = a.y : number & Tag<"y"> +>b.y : number & Tag<"y"> +>b : Paired +>y : number & Tag<"y"> +>a.y : number & Tag<"y"> +>a : Paired +>y : number & Tag<"y"> + + a.x = b.x; +>a.x = b.x : number & Tag<"x"> +>a.x : number & Tag<"x"> +>a : Paired +>x : number & Tag<"x"> +>b.x : number & Tag<"x"> +>b : Paired +>x : number & Tag<"x"> + + a.y = b.y; +>a.y = b.y : number & Tag<"y"> +>a.y : number & Tag<"y"> +>a : Paired +>y : number & Tag<"y"> +>b.y : number & Tag<"y"> +>b : Paired +>y : number & Tag<"y"> +} + + +type NormalizedPath = string & Tag<"NormalizedPath">; +>NormalizedPath : NormalizedPath + +type AbsolutePath = string & Tag<"AbsolutePath">; +>AbsolutePath : AbsolutePath + +type NormalizedAbsolutePath = NormalizedPath & AbsolutePath; +>NormalizedAbsolutePath : NormalizedAbsolutePath + +declare function isNormalizedPath(x: string): x is NormalizedPath; +>isNormalizedPath : (x: string) => x is NormalizedPath +>x : string + +declare function isAbsolutePath(x: string): x is AbsolutePath; +>isAbsolutePath : (x: string) => x is AbsolutePath +>x : string + +declare function consumeNormalizedPath(x: NormalizedPath): void; +>consumeNormalizedPath : (x: NormalizedPath) => void +>x : NormalizedPath + +declare function consumeAbsolutePath(x: AbsolutePath): void; +>consumeAbsolutePath : (x: AbsolutePath) => void +>x : AbsolutePath + +declare function consumeNormalizedOrAbsolutePath(x: NormalizedPath | AbsolutePath): void; +>consumeNormalizedOrAbsolutePath : (x: NormalizedPath | AbsolutePath) => void +>x : NormalizedPath | AbsolutePath + +declare function consumeNormalizedAbsolutePath(x: NormalizedAbsolutePath): void; +>consumeNormalizedAbsolutePath : (x: NormalizedAbsolutePath) => void +>x : NormalizedAbsolutePath + +const p = "/a/b/c"; +>p : "/a/b/c" +>"/a/b/c" : "/a/b/c" + +if (isNormalizedPath(p)) { +>isNormalizedPath(p) : boolean +>isNormalizedPath : (x: string) => x is NormalizedPath +>p : "/a/b/c" + + if (isAbsolutePath(p)) { +>isAbsolutePath(p) : boolean +>isAbsolutePath : (x: string) => x is AbsolutePath +>p : "/a/b/c" & Tag<"NormalizedPath"> + + consumeNormalizedPath(p); +>consumeNormalizedPath(p) : void +>consumeNormalizedPath : (x: NormalizedPath) => void +>p : "/a/b/c" & (Tag<"NormalizedPath"> & Tag<"AbsolutePath">) + + consumeAbsolutePath(p); +>consumeAbsolutePath(p) : void +>consumeAbsolutePath : (x: AbsolutePath) => void +>p : "/a/b/c" & (Tag<"NormalizedPath"> & Tag<"AbsolutePath">) + + consumeNormalizedOrAbsolutePath(p); +>consumeNormalizedOrAbsolutePath(p) : void +>consumeNormalizedOrAbsolutePath : (x: NormalizedPath | AbsolutePath) => void +>p : "/a/b/c" & (Tag<"NormalizedPath"> & Tag<"AbsolutePath">) + + consumeNormalizedAbsolutePath(p); +>consumeNormalizedAbsolutePath(p) : void +>consumeNormalizedAbsolutePath : (x: NormalizedAbsolutePath) => void +>p : "/a/b/c" & (Tag<"NormalizedPath"> & Tag<"AbsolutePath">) + } + else { + consumeNormalizedPath(p); +>consumeNormalizedPath(p) : void +>consumeNormalizedPath : (x: NormalizedPath) => void +>p : "/a/b/c" & Tag<"NormalizedPath"> + + consumeAbsolutePath(p); // err +>consumeAbsolutePath(p) : void +>consumeAbsolutePath : (x: AbsolutePath) => void +>p : "/a/b/c" & Tag<"NormalizedPath"> + + consumeNormalizedOrAbsolutePath(p); +>consumeNormalizedOrAbsolutePath(p) : void +>consumeNormalizedOrAbsolutePath : (x: NormalizedPath | AbsolutePath) => void +>p : "/a/b/c" & Tag<"NormalizedPath"> + + consumeNormalizedAbsolutePath(p); // err +>consumeNormalizedAbsolutePath(p) : void +>consumeNormalizedAbsolutePath : (x: NormalizedAbsolutePath) => void +>p : "/a/b/c" & Tag<"NormalizedPath"> + } +} +else { + if (isAbsolutePath(p)) { +>isAbsolutePath(p) : boolean +>isAbsolutePath : (x: string) => x is AbsolutePath +>p : "/a/b/c" + + consumeNormalizedPath(p); // err +>consumeNormalizedPath(p) : void +>consumeNormalizedPath : (x: NormalizedPath) => void +>p : "/a/b/c" & Tag<"AbsolutePath"> + + consumeAbsolutePath(p); +>consumeAbsolutePath(p) : void +>consumeAbsolutePath : (x: AbsolutePath) => void +>p : "/a/b/c" & Tag<"AbsolutePath"> + + consumeNormalizedOrAbsolutePath(p); +>consumeNormalizedOrAbsolutePath(p) : void +>consumeNormalizedOrAbsolutePath : (x: NormalizedPath | AbsolutePath) => void +>p : "/a/b/c" & Tag<"AbsolutePath"> + + consumeNormalizedAbsolutePath(p); // err +>consumeNormalizedAbsolutePath(p) : void +>consumeNormalizedAbsolutePath : (x: NormalizedAbsolutePath) => void +>p : "/a/b/c" & Tag<"AbsolutePath"> + } + else { + consumeNormalizedPath(p); // err +>consumeNormalizedPath(p) : void +>consumeNormalizedPath : (x: NormalizedPath) => void +>p : "/a/b/c" + + consumeAbsolutePath(p); // err +>consumeAbsolutePath(p) : void +>consumeAbsolutePath : (x: AbsolutePath) => void +>p : "/a/b/c" + + consumeNormalizedOrAbsolutePath(p); // err +>consumeNormalizedOrAbsolutePath(p) : void +>consumeNormalizedOrAbsolutePath : (x: NormalizedPath | AbsolutePath) => void +>p : "/a/b/c" + + consumeNormalizedAbsolutePath(p); // err +>consumeNormalizedAbsolutePath(p) : void +>consumeNormalizedAbsolutePath : (x: NormalizedAbsolutePath) => void +>p : "/a/b/c" + } +} + diff --git a/tests/baselines/reference/typeGuardNarrowsPrimitiveIntersection.js b/tests/baselines/reference/typeGuardNarrowsPrimitiveIntersection.js index a4cba6f4ab5c1..b3d24615aafcb 100644 --- a/tests/baselines/reference/typeGuardNarrowsPrimitiveIntersection.js +++ b/tests/baselines/reference/typeGuardNarrowsPrimitiveIntersection.js @@ -1,7 +1,7 @@ //// [typeGuardNarrowsPrimitiveIntersection.ts] -type Tag = {__tag: any}; -declare function isNonBlank(value: string) : value is (string & Tag); -declare function doThis(value: string & Tag): void; +type MyTag = {__tag: any}; +declare function isNonBlank(value: string) : value is (string & MyTag); +declare function doThis(value: string & MyTag): void; declare function doThat(value: string) : void; let value: string; if (isNonBlank(value)) { diff --git a/tests/baselines/reference/typeGuardNarrowsPrimitiveIntersection.symbols b/tests/baselines/reference/typeGuardNarrowsPrimitiveIntersection.symbols index da507fb94c5dc..08ea3ee9f72ad 100644 --- a/tests/baselines/reference/typeGuardNarrowsPrimitiveIntersection.symbols +++ b/tests/baselines/reference/typeGuardNarrowsPrimitiveIntersection.symbols @@ -1,37 +1,37 @@ === tests/cases/conformance/expressions/typeGuards/typeGuardNarrowsPrimitiveIntersection.ts === -type Tag = {__tag: any}; ->Tag : Symbol(Tag, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 0, 0)) ->__tag : Symbol(__tag, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 0, 12)) +type MyTag = {__tag: any}; +>MyTag : Symbol(MyTag, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 0, 0)) +>__tag : Symbol(__tag, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 0, 14)) -declare function isNonBlank(value: string) : value is (string & Tag); ->isNonBlank : Symbol(isNonBlank, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 0, 24)) +declare function isNonBlank(value: string) : value is (string & MyTag); +>isNonBlank : Symbol(isNonBlank, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 0, 26)) >value : Symbol(value, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 1, 28)) >value : Symbol(value, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 1, 28)) ->Tag : Symbol(Tag, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 0, 0)) +>MyTag : Symbol(MyTag, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 0, 0)) -declare function doThis(value: string & Tag): void; ->doThis : Symbol(doThis, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 1, 69)) +declare function doThis(value: string & MyTag): void; +>doThis : Symbol(doThis, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 1, 71)) >value : Symbol(value, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 2, 24)) ->Tag : Symbol(Tag, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 0, 0)) +>MyTag : Symbol(MyTag, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 0, 0)) declare function doThat(value: string) : void; ->doThat : Symbol(doThat, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 2, 51)) +>doThat : Symbol(doThat, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 2, 53)) >value : Symbol(value, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 3, 24)) let value: string; >value : Symbol(value, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 4, 3)) if (isNonBlank(value)) { ->isNonBlank : Symbol(isNonBlank, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 0, 24)) +>isNonBlank : Symbol(isNonBlank, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 0, 26)) >value : Symbol(value, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 4, 3)) doThis(value); ->doThis : Symbol(doThis, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 1, 69)) +>doThis : Symbol(doThis, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 1, 71)) >value : Symbol(value, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 4, 3)) } else { doThat(value); ->doThat : Symbol(doThat, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 2, 51)) +>doThat : Symbol(doThat, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 2, 53)) >value : Symbol(value, Decl(typeGuardNarrowsPrimitiveIntersection.ts, 4, 3)) } diff --git a/tests/baselines/reference/typeGuardNarrowsPrimitiveIntersection.types b/tests/baselines/reference/typeGuardNarrowsPrimitiveIntersection.types index a14629c3e2a9e..197bc201b7bed 100644 --- a/tests/baselines/reference/typeGuardNarrowsPrimitiveIntersection.types +++ b/tests/baselines/reference/typeGuardNarrowsPrimitiveIntersection.types @@ -1,15 +1,15 @@ === tests/cases/conformance/expressions/typeGuards/typeGuardNarrowsPrimitiveIntersection.ts === -type Tag = {__tag: any}; ->Tag : Tag +type MyTag = {__tag: any}; +>MyTag : MyTag >__tag : any -declare function isNonBlank(value: string) : value is (string & Tag); ->isNonBlank : (value: string) => value is string & Tag +declare function isNonBlank(value: string) : value is (string & MyTag); +>isNonBlank : (value: string) => value is string & MyTag >value : string -declare function doThis(value: string & Tag): void; ->doThis : (value: string & Tag) => void ->value : string & Tag +declare function doThis(value: string & MyTag): void; +>doThis : (value: string & MyTag) => void +>value : string & MyTag declare function doThat(value: string) : void; >doThat : (value: string) => void @@ -20,13 +20,13 @@ let value: string; if (isNonBlank(value)) { >isNonBlank(value) : boolean ->isNonBlank : (value: string) => value is string & Tag +>isNonBlank : (value: string) => value is string & MyTag >value : string doThis(value); >doThis(value) : void ->doThis : (value: string & Tag) => void ->value : string & Tag +>doThis : (value: string & MyTag) => void +>value : string & MyTag } else { doThat(value); diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardNarrowsPrimitiveIntersection.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardNarrowsPrimitiveIntersection.ts index 376a78275c83b..3c3b0fcd74864 100644 --- a/tests/cases/conformance/expressions/typeGuards/typeGuardNarrowsPrimitiveIntersection.ts +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardNarrowsPrimitiveIntersection.ts @@ -1,6 +1,6 @@ -type Tag = {__tag: any}; -declare function isNonBlank(value: string) : value is (string & Tag); -declare function doThis(value: string & Tag): void; +type MyTag = {__tag: any}; +declare function isNonBlank(value: string) : value is (string & MyTag); +declare function doThis(value: string & MyTag): void; declare function doThat(value: string) : void; let value: string; if (isNonBlank(value)) { diff --git a/tests/cases/conformance/types/literal/numericLiteralTypes1.ts b/tests/cases/conformance/types/literal/numericLiteralTypes1.ts index 76d8265a841c3..e42218396b0bc 100644 --- a/tests/cases/conformance/types/literal/numericLiteralTypes1.ts +++ b/tests/cases/conformance/types/literal/numericLiteralTypes1.ts @@ -65,9 +65,9 @@ function assertNever(x: never): never { throw new Error("Unexpected value"); } -type Tag = 0 | 1 | 2; +type NumericTag = 0 | 1 | 2; -function f10(x: Tag) { +function f10(x: NumericTag) { switch (x) { case 0: return "a"; case 1: return "b"; @@ -75,7 +75,7 @@ function f10(x: Tag) { } } -function f11(x: Tag) { +function f11(x: NumericTag) { switch (x) { case 0: return "a"; case 1: return "b"; @@ -84,7 +84,7 @@ function f11(x: Tag) { return assertNever(x); } -function f12(x: Tag) { +function f12(x: NumericTag) { if (x) { x; } @@ -93,7 +93,7 @@ function f12(x: Tag) { } } -function f13(x: Tag) { +function f13(x: NumericTag) { if (x === 0 || x === 2) { x; } diff --git a/tests/cases/conformance/types/literal/numericLiteralTypes2.ts b/tests/cases/conformance/types/literal/numericLiteralTypes2.ts index 3ab0fd5631fc8..ce56404abb3c4 100644 --- a/tests/cases/conformance/types/literal/numericLiteralTypes2.ts +++ b/tests/cases/conformance/types/literal/numericLiteralTypes2.ts @@ -67,9 +67,9 @@ function assertNever(x: never): never { throw new Error("Unexpected value"); } -type Tag = 0 | 1 | 2; +type NumericTag = 0 | 1 | 2; -function f10(x: Tag) { +function f10(x: NumericTag) { switch (x) { case 0: return "a"; case 1: return "b"; @@ -77,7 +77,7 @@ function f10(x: Tag) { } } -function f11(x: Tag) { +function f11(x: NumericTag) { switch (x) { case 0: return "a"; case 1: return "b"; @@ -86,7 +86,7 @@ function f11(x: Tag) { return assertNever(x); } -function f12(x: Tag) { +function f12(x: NumericTag) { if (x) { x; } @@ -95,7 +95,7 @@ function f12(x: Tag) { } } -function f13(x: Tag) { +function f13(x: NumericTag) { if (x === 0 || x === 2) { x; } diff --git a/tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts b/tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts new file mode 100644 index 0000000000000..b47d6ba90d113 --- /dev/null +++ b/tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts @@ -0,0 +1,71 @@ +export type Paired = { + x: number & Tag<"x">; + y: number & Tag<"y">; +}; + + +export function isPaired(x: {x: number, y: number}): x is Paired { + return true; +} + +export function makePair(x: number, y: number): Paired { + return {x, y} as Paired; +} + +const a = makePair(0, 0); +const b = {x: 0, y: 0}; + +if (Math.random() > 0.3) { + b.x = a.x; + b.y = a.y; +} + +if (isPaired(b)) { + b.x = a.x; + b.y = a.y; + a.x = b.x; + a.y = b.y; +} + + +type NormalizedPath = string & Tag<"NormalizedPath">; +type AbsolutePath = string & Tag<"AbsolutePath">; +type NormalizedAbsolutePath = NormalizedPath & AbsolutePath; + +declare function isNormalizedPath(x: string): x is NormalizedPath; +declare function isAbsolutePath(x: string): x is AbsolutePath; + +declare function consumeNormalizedPath(x: NormalizedPath): void; +declare function consumeAbsolutePath(x: AbsolutePath): void; +declare function consumeNormalizedOrAbsolutePath(x: NormalizedPath | AbsolutePath): void; +declare function consumeNormalizedAbsolutePath(x: NormalizedAbsolutePath): void; + +const p = "/a/b/c"; +if (isNormalizedPath(p)) { + if (isAbsolutePath(p)) { + consumeNormalizedPath(p); + consumeAbsolutePath(p); + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); + } + else { + consumeNormalizedPath(p); + consumeAbsolutePath(p); // err + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); // err + } +} +else { + if (isAbsolutePath(p)) { + consumeNormalizedPath(p); // err + consumeAbsolutePath(p); + consumeNormalizedOrAbsolutePath(p); + consumeNormalizedAbsolutePath(p); // err + } + else { + consumeNormalizedPath(p); // err + consumeAbsolutePath(p); // err + consumeNormalizedOrAbsolutePath(p); // err + consumeNormalizedAbsolutePath(p); // err + } +} From d7760874a6ef5bd71031eacaac0169edc9353480 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 17 Sep 2019 16:05:09 -0700 Subject: [PATCH 4/7] Fix or suppress eslint issues --- .eslintignore | 4 +++- src/compiler/types.ts | 4 ++-- src/lib/es5.d.ts | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.eslintignore b/.eslintignore index 404b4177c9773..93ca3411489f9 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,6 @@ /built/local/** /tests/** /lib/** -/src/lib/*.generated.d.ts \ No newline at end of file +/src/lib/*.generated.d.ts +# TODO: Remove once tag types are supported by eslint's TS parser +/src/lib/es5.d.ts \ No newline at end of file diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1c8db2402edd1..e64c57e058bf0 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4463,8 +4463,8 @@ namespace ts { type: Type; /* @internal */ members?: SymbolTable; // Always emptySymbols /* @internal */ properties?: Symbol[]; // Always emptyArray - /* @internal */ callSignatures?: ReadonlyArray; // Always emptyArray - /* @internal */ constructSignatures?: ReadonlyArray; // Always emptyArray + /* @internal */ callSignatures?: readonly Signature[]; // Always emptyArray + /* @internal */ constructSignatures?: readonly Signature[]; // Always emptyArray /* @internal */ stringIndexInfo?: undefined; /* @internal */ numberIndexInfo?: undefined; } diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index ec8ab43c2843e..035ba04ffb659 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1483,7 +1483,7 @@ interface ThisType { } */ type Tag = tag { [_ in K]: void; - }; +}; /** * Represents a raw buffer of binary data, which is used to store data for the From 2cd6752498d28fb4df3fb62ff84a4c4b443314aa Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 17 Sep 2019 17:22:43 -0700 Subject: [PATCH 5/7] Remove lib change --- src/harness/fourslash.ts | 2 +- src/lib/es5.d.ts | 6 +- ...uralTagTypesUsingGlobalTagAlias.errors.txt | 52 ++---- ...ucturalTagTypesUsingGlobalTagAlias.symbols | 20 +-- ...tructuralTagTypesUsingGlobalTagAlias.types | 164 +++++++++--------- 5 files changed, 107 insertions(+), 137 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index dac5ae4e55190..c5e22f3dff890 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -4672,7 +4672,7 @@ namespace FourSlashInterface { typeEntry("ReturnType"), typeEntry("InstanceType"), interfaceEntry("ThisType"), - typeEntry("Tag"), + // typeEntry("Tag"), varEntry("ArrayBuffer"), interfaceEntry("ArrayBufferTypes"), typeEntry("ArrayBufferLike"), diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 035ba04ffb659..cca2a6f676c93 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1481,9 +1481,9 @@ interface ThisType { } /** * Constructs a structural tag over property name(s) `K` */ -type Tag = tag { - [_ in K]: void; -}; +// type Tag = tag { +// [_ in K]: void; +// }; /** * Represents a raw buffer of binary data, which is used to store data for the diff --git a/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.errors.txt b/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.errors.txt index 4e6029db2b260..99dc014a2b45e 100644 --- a/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.errors.txt +++ b/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.errors.txt @@ -1,24 +1,17 @@ -tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(53,29): error TS2345: Argument of type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to parameter of type 'AbsolutePath'. - Type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to type 'Tag<"AbsolutePath">'. -tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(55,39): error TS2345: Argument of type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to parameter of type 'NormalizedAbsolutePath'. - Type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'. -tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(60,31): error TS2345: Argument of type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to parameter of type 'NormalizedPath'. - Type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to type 'Tag<"NormalizedPath">'. -tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(63,39): error TS2345: Argument of type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to parameter of type 'NormalizedAbsolutePath'. - Type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'. -tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(66,31): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath'. - Type '"/a/b/c"' is not assignable to type 'Tag<"NormalizedPath">'. -tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(67,29): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'AbsolutePath'. - Type '"/a/b/c"' is not assignable to type 'Tag<"AbsolutePath">'. -tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(68,41): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath | AbsolutePath'. -tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(69,39): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedAbsolutePath'. - Type '"/a/b/c"' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'. +tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(2,17): error TS2304: Cannot find name 'Tag'. +tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(3,17): error TS2304: Cannot find name 'Tag'. +tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(31,32): error TS2304: Cannot find name 'Tag'. +tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(32,30): error TS2304: Cannot find name 'Tag'. -==== tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts (8 errors) ==== +==== tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts (4 errors) ==== export type Paired = { x: number & Tag<"x">; + ~~~ +!!! error TS2304: Cannot find name 'Tag'. y: number & Tag<"y">; + ~~~ +!!! error TS2304: Cannot find name 'Tag'. }; @@ -47,7 +40,11 @@ tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAli type NormalizedPath = string & Tag<"NormalizedPath">; + ~~~ +!!! error TS2304: Cannot find name 'Tag'. type AbsolutePath = string & Tag<"AbsolutePath">; + ~~~ +!!! error TS2304: Cannot find name 'Tag'. type NormalizedAbsolutePath = NormalizedPath & AbsolutePath; declare function isNormalizedPath(x: string): x is NormalizedPath; @@ -69,45 +66,22 @@ tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAli else { consumeNormalizedPath(p); consumeAbsolutePath(p); // err - ~ -!!! error TS2345: Argument of type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to parameter of type 'AbsolutePath'. -!!! error TS2345: Type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to type 'Tag<"AbsolutePath">'. consumeNormalizedOrAbsolutePath(p); consumeNormalizedAbsolutePath(p); // err - ~ -!!! error TS2345: Argument of type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to parameter of type 'NormalizedAbsolutePath'. -!!! error TS2345: Type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'. } } else { if (isAbsolutePath(p)) { consumeNormalizedPath(p); // err - ~ -!!! error TS2345: Argument of type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to parameter of type 'NormalizedPath'. -!!! error TS2345: Type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to type 'Tag<"NormalizedPath">'. consumeAbsolutePath(p); consumeNormalizedOrAbsolutePath(p); consumeNormalizedAbsolutePath(p); // err - ~ -!!! error TS2345: Argument of type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to parameter of type 'NormalizedAbsolutePath'. -!!! error TS2345: Type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'. } else { consumeNormalizedPath(p); // err - ~ -!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath'. -!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'Tag<"NormalizedPath">'. consumeAbsolutePath(p); // err - ~ -!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'AbsolutePath'. -!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'Tag<"AbsolutePath">'. consumeNormalizedOrAbsolutePath(p); // err - ~ -!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath | AbsolutePath'. consumeNormalizedAbsolutePath(p); // err - ~ -!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedAbsolutePath'. -!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'. } } \ No newline at end of file diff --git a/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.symbols b/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.symbols index b8f6e1934238d..3b430533138d4 100644 --- a/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.symbols +++ b/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.symbols @@ -4,11 +4,9 @@ export type Paired = { x: number & Tag<"x">; >x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) ->Tag : Symbol(Tag, Decl(lib.es5.d.ts, --, --)) y: number & Tag<"y">; >y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) ->Tag : Symbol(Tag, Decl(lib.es5.d.ts, --, --)) }; @@ -72,17 +70,17 @@ if (isPaired(b)) { >b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5)) b.x = a.x; ->b.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) +>b.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 11)) >b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5)) ->x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 11)) >a.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) >a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5)) >x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) b.y = a.y; ->b.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) +>b.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 16)) >b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5)) ->y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) +>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 16)) >a.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) >a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5)) >y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) @@ -91,27 +89,25 @@ if (isPaired(b)) { >a.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) >a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5)) >x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) ->b.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) +>b.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 11)) >b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5)) ->x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 11)) a.y = b.y; >a.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) >a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5)) >y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) ->b.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) +>b.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 16)) >b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5)) ->y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) +>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 16)) } type NormalizedPath = string & Tag<"NormalizedPath">; >NormalizedPath : Symbol(NormalizedPath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 27, 1)) ->Tag : Symbol(Tag, Decl(lib.es5.d.ts, --, --)) type AbsolutePath = string & Tag<"AbsolutePath">; >AbsolutePath : Symbol(AbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 30, 53)) ->Tag : Symbol(Tag, Decl(lib.es5.d.ts, --, --)) type NormalizedAbsolutePath = NormalizedPath & AbsolutePath; >NormalizedAbsolutePath : Symbol(NormalizedAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 31, 49)) diff --git a/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.types b/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.types index b73dfb6f1f7db..5725bc65f7c04 100644 --- a/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.types +++ b/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.types @@ -3,10 +3,10 @@ export type Paired = { >Paired : Paired x: number & Tag<"x">; ->x : number & Tag<"x"> +>x : any y: number & Tag<"y">; ->y : number & Tag<"y"> +>y : any }; @@ -57,22 +57,22 @@ if (Math.random() > 0.3) { >0.3 : 0.3 b.x = a.x; ->b.x = a.x : number & Tag<"x"> +>b.x = a.x : any >b.x : number >b : { x: number; y: number; } >x : number ->a.x : number & Tag<"x"> +>a.x : any >a : Paired ->x : number & Tag<"x"> +>x : any b.y = a.y; ->b.y = a.y : number & Tag<"y"> +>b.y = a.y : any >b.y : number >b : { x: number; y: number; } >y : number ->a.y : number & Tag<"y"> +>a.y : any >a : Paired ->y : number & Tag<"y"> +>y : any } if (isPaired(b)) { @@ -81,75 +81,75 @@ if (isPaired(b)) { >b : { x: number; y: number; } b.x = a.x; ->b.x = a.x : number & Tag<"x"> ->b.x : number & Tag<"x"> ->b : Paired ->x : number & Tag<"x"> ->a.x : number & Tag<"x"> +>b.x = a.x : any +>b.x : number +>b : { x: number; y: number; } +>x : number +>a.x : any >a : Paired ->x : number & Tag<"x"> +>x : any b.y = a.y; ->b.y = a.y : number & Tag<"y"> ->b.y : number & Tag<"y"> ->b : Paired ->y : number & Tag<"y"> ->a.y : number & Tag<"y"> +>b.y = a.y : any +>b.y : number +>b : { x: number; y: number; } +>y : number +>a.y : any >a : Paired ->y : number & Tag<"y"> +>y : any a.x = b.x; ->a.x = b.x : number & Tag<"x"> ->a.x : number & Tag<"x"> +>a.x = b.x : number +>a.x : any >a : Paired ->x : number & Tag<"x"> ->b.x : number & Tag<"x"> ->b : Paired ->x : number & Tag<"x"> +>x : any +>b.x : number +>b : { x: number; y: number; } +>x : number a.y = b.y; ->a.y = b.y : number & Tag<"y"> ->a.y : number & Tag<"y"> +>a.y = b.y : number +>a.y : any >a : Paired ->y : number & Tag<"y"> ->b.y : number & Tag<"y"> ->b : Paired ->y : number & Tag<"y"> +>y : any +>b.y : number +>b : { x: number; y: number; } +>y : number } type NormalizedPath = string & Tag<"NormalizedPath">; ->NormalizedPath : NormalizedPath +>NormalizedPath : any type AbsolutePath = string & Tag<"AbsolutePath">; ->AbsolutePath : AbsolutePath +>AbsolutePath : any type NormalizedAbsolutePath = NormalizedPath & AbsolutePath; ->NormalizedAbsolutePath : NormalizedAbsolutePath +>NormalizedAbsolutePath : any declare function isNormalizedPath(x: string): x is NormalizedPath; ->isNormalizedPath : (x: string) => x is NormalizedPath +>isNormalizedPath : (x: string) => x is any >x : string declare function isAbsolutePath(x: string): x is AbsolutePath; ->isAbsolutePath : (x: string) => x is AbsolutePath +>isAbsolutePath : (x: string) => x is any >x : string declare function consumeNormalizedPath(x: NormalizedPath): void; ->consumeNormalizedPath : (x: NormalizedPath) => void ->x : NormalizedPath +>consumeNormalizedPath : (x: any) => void +>x : any declare function consumeAbsolutePath(x: AbsolutePath): void; ->consumeAbsolutePath : (x: AbsolutePath) => void ->x : AbsolutePath +>consumeAbsolutePath : (x: any) => void +>x : any declare function consumeNormalizedOrAbsolutePath(x: NormalizedPath | AbsolutePath): void; ->consumeNormalizedOrAbsolutePath : (x: NormalizedPath | AbsolutePath) => void ->x : NormalizedPath | AbsolutePath +>consumeNormalizedOrAbsolutePath : (x: any) => void +>x : any declare function consumeNormalizedAbsolutePath(x: NormalizedAbsolutePath): void; ->consumeNormalizedAbsolutePath : (x: NormalizedAbsolutePath) => void ->x : NormalizedAbsolutePath +>consumeNormalizedAbsolutePath : (x: any) => void +>x : any const p = "/a/b/c"; >p : "/a/b/c" @@ -157,102 +157,102 @@ const p = "/a/b/c"; if (isNormalizedPath(p)) { >isNormalizedPath(p) : boolean ->isNormalizedPath : (x: string) => x is NormalizedPath +>isNormalizedPath : (x: string) => x is any >p : "/a/b/c" if (isAbsolutePath(p)) { >isAbsolutePath(p) : boolean ->isAbsolutePath : (x: string) => x is AbsolutePath ->p : "/a/b/c" & Tag<"NormalizedPath"> +>isAbsolutePath : (x: string) => x is any +>p : "/a/b/c" consumeNormalizedPath(p); >consumeNormalizedPath(p) : void ->consumeNormalizedPath : (x: NormalizedPath) => void ->p : "/a/b/c" & (Tag<"NormalizedPath"> & Tag<"AbsolutePath">) +>consumeNormalizedPath : (x: any) => void +>p : "/a/b/c" consumeAbsolutePath(p); >consumeAbsolutePath(p) : void ->consumeAbsolutePath : (x: AbsolutePath) => void ->p : "/a/b/c" & (Tag<"NormalizedPath"> & Tag<"AbsolutePath">) +>consumeAbsolutePath : (x: any) => void +>p : "/a/b/c" consumeNormalizedOrAbsolutePath(p); >consumeNormalizedOrAbsolutePath(p) : void ->consumeNormalizedOrAbsolutePath : (x: NormalizedPath | AbsolutePath) => void ->p : "/a/b/c" & (Tag<"NormalizedPath"> & Tag<"AbsolutePath">) +>consumeNormalizedOrAbsolutePath : (x: any) => void +>p : "/a/b/c" consumeNormalizedAbsolutePath(p); >consumeNormalizedAbsolutePath(p) : void ->consumeNormalizedAbsolutePath : (x: NormalizedAbsolutePath) => void ->p : "/a/b/c" & (Tag<"NormalizedPath"> & Tag<"AbsolutePath">) +>consumeNormalizedAbsolutePath : (x: any) => void +>p : "/a/b/c" } else { consumeNormalizedPath(p); >consumeNormalizedPath(p) : void ->consumeNormalizedPath : (x: NormalizedPath) => void ->p : "/a/b/c" & Tag<"NormalizedPath"> +>consumeNormalizedPath : (x: any) => void +>p : never consumeAbsolutePath(p); // err >consumeAbsolutePath(p) : void ->consumeAbsolutePath : (x: AbsolutePath) => void ->p : "/a/b/c" & Tag<"NormalizedPath"> +>consumeAbsolutePath : (x: any) => void +>p : never consumeNormalizedOrAbsolutePath(p); >consumeNormalizedOrAbsolutePath(p) : void ->consumeNormalizedOrAbsolutePath : (x: NormalizedPath | AbsolutePath) => void ->p : "/a/b/c" & Tag<"NormalizedPath"> +>consumeNormalizedOrAbsolutePath : (x: any) => void +>p : never consumeNormalizedAbsolutePath(p); // err >consumeNormalizedAbsolutePath(p) : void ->consumeNormalizedAbsolutePath : (x: NormalizedAbsolutePath) => void ->p : "/a/b/c" & Tag<"NormalizedPath"> +>consumeNormalizedAbsolutePath : (x: any) => void +>p : never } } else { if (isAbsolutePath(p)) { >isAbsolutePath(p) : boolean ->isAbsolutePath : (x: string) => x is AbsolutePath ->p : "/a/b/c" +>isAbsolutePath : (x: string) => x is any +>p : never consumeNormalizedPath(p); // err >consumeNormalizedPath(p) : void ->consumeNormalizedPath : (x: NormalizedPath) => void ->p : "/a/b/c" & Tag<"AbsolutePath"> +>consumeNormalizedPath : (x: any) => void +>p : never consumeAbsolutePath(p); >consumeAbsolutePath(p) : void ->consumeAbsolutePath : (x: AbsolutePath) => void ->p : "/a/b/c" & Tag<"AbsolutePath"> +>consumeAbsolutePath : (x: any) => void +>p : never consumeNormalizedOrAbsolutePath(p); >consumeNormalizedOrAbsolutePath(p) : void ->consumeNormalizedOrAbsolutePath : (x: NormalizedPath | AbsolutePath) => void ->p : "/a/b/c" & Tag<"AbsolutePath"> +>consumeNormalizedOrAbsolutePath : (x: any) => void +>p : never consumeNormalizedAbsolutePath(p); // err >consumeNormalizedAbsolutePath(p) : void ->consumeNormalizedAbsolutePath : (x: NormalizedAbsolutePath) => void ->p : "/a/b/c" & Tag<"AbsolutePath"> +>consumeNormalizedAbsolutePath : (x: any) => void +>p : never } else { consumeNormalizedPath(p); // err >consumeNormalizedPath(p) : void ->consumeNormalizedPath : (x: NormalizedPath) => void ->p : "/a/b/c" +>consumeNormalizedPath : (x: any) => void +>p : never consumeAbsolutePath(p); // err >consumeAbsolutePath(p) : void ->consumeAbsolutePath : (x: AbsolutePath) => void ->p : "/a/b/c" +>consumeAbsolutePath : (x: any) => void +>p : never consumeNormalizedOrAbsolutePath(p); // err >consumeNormalizedOrAbsolutePath(p) : void ->consumeNormalizedOrAbsolutePath : (x: NormalizedPath | AbsolutePath) => void ->p : "/a/b/c" +>consumeNormalizedOrAbsolutePath : (x: any) => void +>p : never consumeNormalizedAbsolutePath(p); // err >consumeNormalizedAbsolutePath(p) : void ->consumeNormalizedAbsolutePath : (x: NormalizedAbsolutePath) => void ->p : "/a/b/c" +>consumeNormalizedAbsolutePath : (x: any) => void +>p : never } } From a35bd7ed6d9f15b124d714b2dd9480be891ae1f8 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 17 Sep 2019 17:24:14 -0700 Subject: [PATCH 6/7] LKG to support compiler feature --- lib/ko/diagnosticMessages.generated.json | 2 +- lib/lib.es2015.collection.d.ts | 8 +- lib/lib.es2015.core.d.ts | 14 +- lib/lib.es2017.object.d.ts | 2 +- lib/lib.es2018.intl.d.ts | 6 +- lib/lib.es2019.array.d.ts | 6 +- lib/lib.es2019.string.d.ts | 16 +- lib/lib.es2020.string.d.ts | 12 +- lib/lib.es2020.symbol.wellknown.d.ts | 22 +- lib/lib.es5.d.ts | 4290 +++-- lib/lib.esnext.bigint.d.ts | 650 +- lib/lib.esnext.d.ts | 2 +- lib/lib.esnext.intl.d.ts | 2 +- lib/pl/diagnosticMessages.generated.json | 2 +- lib/protocol.d.ts | 30 +- lib/tsc.js | 10838 ++++++------ lib/tsserver.js | 18111 ++++++++++++--------- lib/tsserverlibrary.d.ts | 2072 +-- lib/tsserverlibrary.js | 18055 +++++++++++--------- lib/typescript.d.ts | 1947 +-- lib/typescript.js | 17892 +++++++++++--------- lib/typescriptServices.d.ts | 1947 +-- lib/typescriptServices.js | 17892 +++++++++++--------- lib/typingsInstaller.js | 13076 ++++++++------- 24 files changed, 58752 insertions(+), 48142 deletions(-) diff --git a/lib/ko/diagnosticMessages.generated.json b/lib/ko/diagnosticMessages.generated.json index abda4ace91fd7..1f1f563e44c96 100644 --- a/lib/ko/diagnosticMessages.generated.json +++ b/lib/ko/diagnosticMessages.generated.json @@ -885,7 +885,7 @@ "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701": "개체 rest 할당의 대상은 변수 또는 속성 액세스여야 합니다.", "The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1_2684": "'{0}' 형식의 'this' 컨텍스트를 메서드의 '{1}' 형식 'this'에 할당할 수 없습니다.", "The_this_types_of_each_signature_are_incompatible_2685": "각 시그니처의 'this' 형식이 호환되지 않습니다.", - "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453": "형식 매개 변수 '{0}'의 형식 인수를 유추할 수 없습니다. 형식 인수를 명시적으로 지정하세요.", + "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453": "사용량에서 형식 매개 변수 '{0}'의 형식 인수를 유추할 수 없습니다. 형식 인수를 명시적으로 지정하세요.", "The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value__2547": "비동기 반복기의 'next()' 메서드에서 반환하는 형식은 'value' 속성이 있는 형식에 대한 프라미스여야 합니다.", "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490": "반복기의 'next()' 메서드에 의해 반환되는 형식에는 'value' 속성이 있어야 합니다.", "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189": "'for...in' 문의 변수 선언에 이니셜라이저가 포함될 수 없습니다.", diff --git a/lib/lib.es2015.collection.d.ts b/lib/lib.es2015.collection.d.ts index 557bfd9bcf3fc..dc93004c04b45 100644 --- a/lib/lib.es2015.collection.d.ts +++ b/lib/lib.es2015.collection.d.ts @@ -30,7 +30,7 @@ interface Map { interface MapConstructor { new(): Map; - new(entries?: ReadonlyArray | null): Map; + new(entries?: readonly (readonly [K, V])[] | null): Map; readonly prototype: Map; } declare var Map: MapConstructor; @@ -50,7 +50,7 @@ interface WeakMap { } interface WeakMapConstructor { - new (entries?: ReadonlyArray<[K, V]> | null): WeakMap; + new (entries?: readonly [K, V][] | null): WeakMap; readonly prototype: WeakMap; } declare var WeakMap: WeakMapConstructor; @@ -65,7 +65,7 @@ interface Set { } interface SetConstructor { - new (values?: ReadonlyArray | null): Set; + new (values?: readonly T[] | null): Set; readonly prototype: Set; } declare var Set: SetConstructor; @@ -83,7 +83,7 @@ interface WeakSet { } interface WeakSetConstructor { - new (values?: ReadonlyArray | null): WeakSet; + new (values?: readonly T[] | null): WeakSet; readonly prototype: WeakSet; } declare var WeakSet: WeakSetConstructor; diff --git a/lib/lib.es2015.core.d.ts b/lib/lib.es2015.core.d.ts index 8cecc6e01d8aa..e0c83ad4647a6 100644 --- a/lib/lib.es2015.core.d.ts +++ b/lib/lib.es2015.core.d.ts @@ -319,9 +319,9 @@ interface ObjectConstructor { getOwnPropertySymbols(o: any): symbol[]; /** - * Returns the names of the enumerable string properties and methods of an object. - * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. - */ + * Returns the names of the enumerable string properties and methods of an object. + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ keys(o: {}): string[]; /** @@ -332,7 +332,7 @@ interface ObjectConstructor { is(value1: any, value2: any): boolean; /** - * Sets the prototype of a specified object o to object proto or null. Returns the object o. + * Sets the prototype of a specified object o to object proto or null. Returns the object o. * @param o The object to change its prototype. * @param proto The value of the new prototype or null. */ @@ -349,8 +349,8 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => value is S, thisArg?: any): S | undefined; - find(predicate: (value: T, index: number, obj: ReadonlyArray) => unknown, thisArg?: any): T | undefined; + find(predicate: (this: void, value: T, index: number, obj: readonly T[]) => value is S, thisArg?: any): S | undefined; + find(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -361,7 +361,7 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: T, index: number, obj: ReadonlyArray) => unknown, thisArg?: any): number; + findIndex(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): number; } interface RegExp { diff --git a/lib/lib.es2017.object.d.ts b/lib/lib.es2017.object.d.ts index 65aa1f959284c..aaea4246c8335 100644 --- a/lib/lib.es2017.object.d.ts +++ b/lib/lib.es2017.object.d.ts @@ -23,7 +23,7 @@ interface ObjectConstructor { * Returns an array of values of the enumerable properties of an object * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. */ - values(o: { [s: string]: T } | ArrayLike): T[]; + values(o: { [s: string]: T } | ArrayLike): T[]; /** * Returns an array of values of the enumerable properties of an object diff --git a/lib/lib.es2018.intl.d.ts b/lib/lib.es2018.intl.d.ts index 84e95f481b467..6ab0dca02e75d 100644 --- a/lib/lib.es2018.intl.d.ts +++ b/lib/lib.es2018.intl.d.ts @@ -20,14 +20,14 @@ and limitations under the License. declare namespace Intl { interface PluralRulesOptions { - localeMatcher?: 'lookup' | 'best fit'; - type?: 'cardinal' | 'ordinal'; + localeMatcher?: "lookup" | "best fit"; + type?: "cardinal" | "ordinal"; } interface ResolvedPluralRulesOptions { locale: string; pluralCategories: string[]; - type: 'cardinal' | 'ordinal'; + type: "cardinal" | "ordinal"; minimumIntegerDigits: number; minimumFractionDigits: number; maximumFractionDigits: number; diff --git a/lib/lib.es2019.array.d.ts b/lib/lib.es2019.array.d.ts index 6c75122320954..b67c7c14c49a9 100644 --- a/lib/lib.es2019.array.d.ts +++ b/lib/lib.es2019.array.d.ts @@ -31,7 +31,7 @@ interface ReadonlyArray { * thisArg is omitted, undefined is used as the this value. */ flatMap ( - callback: (this: This, value: T, index: number, array: T[]) => U|ReadonlyArray, + callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This ): U[] @@ -130,7 +130,7 @@ interface ReadonlyArray { * @param depth The maximum recursion depth */ flat(depth?: number): any[]; - } +} interface Array { @@ -145,7 +145,7 @@ interface Array { * thisArg is omitted, undefined is used as the this value. */ flatMap ( - callback: (this: This, value: T, index: number, array: T[]) => U|ReadonlyArray, + callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This ): U[] diff --git a/lib/lib.es2019.string.d.ts b/lib/lib.es2019.string.d.ts index 60985db048047..a5a9dc6920479 100644 --- a/lib/lib.es2019.string.d.ts +++ b/lib/lib.es2019.string.d.ts @@ -19,15 +19,15 @@ and limitations under the License. interface String { - /** Removes the trailing white space and line terminator characters from a string. */ - trimEnd(): string; + /** Removes the trailing white space and line terminator characters from a string. */ + trimEnd(): string; - /** Removes the leading white space and line terminator characters from a string. */ - trimStart(): string; + /** Removes the leading white space and line terminator characters from a string. */ + trimStart(): string; - /** Removes the leading white space and line terminator characters from a string. */ - trimLeft(): string; + /** Removes the leading white space and line terminator characters from a string. */ + trimLeft(): string; - /** Removes the trailing white space and line terminator characters from a string. */ - trimRight(): string; + /** Removes the trailing white space and line terminator characters from a string. */ + trimRight(): string; } diff --git a/lib/lib.es2020.string.d.ts b/lib/lib.es2020.string.d.ts index c9a99d3228176..146786641bd94 100644 --- a/lib/lib.es2020.string.d.ts +++ b/lib/lib.es2020.string.d.ts @@ -21,10 +21,10 @@ and limitations under the License. /// interface String { - /** - * Matches a string with a regular expression, and returns an iterable of matches - * containing the results of that search. - * @param regexp A variable name or string literal containing the regular expression pattern and flags. - */ - matchAll(regexp: RegExp): IterableIterator; + /** + * Matches a string with a regular expression, and returns an iterable of matches + * containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ + matchAll(regexp: RegExp): IterableIterator; } diff --git a/lib/lib.es2020.symbol.wellknown.d.ts b/lib/lib.es2020.symbol.wellknown.d.ts index f513f5e960b18..599d62d24a89c 100644 --- a/lib/lib.es2020.symbol.wellknown.d.ts +++ b/lib/lib.es2020.symbol.wellknown.d.ts @@ -22,18 +22,18 @@ and limitations under the License. /// interface SymbolConstructor { - /** - * A regular expression method that matches the regular expression against a string. Called - * by the String.prototype.matchAll method. - */ - readonly matchAll: symbol; + /** + * A regular expression method that matches the regular expression against a string. Called + * by the String.prototype.matchAll method. + */ + readonly matchAll: symbol; } interface RegExp { - /** - * Matches a string with this regular expression, and returns an iterable of matches - * containing the results of that search. - * @param string A string to search within. - */ - [Symbol.matchAll](str: string): IterableIterator; + /** + * Matches a string with this regular expression, and returns an iterable of matches + * containing the results of that search. + * @param string A string to search within. + */ + [Symbol.matchAll](str: string): IterableIterator; } diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index 48637e9de1773..f48741aa83e99 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -26,80 +26,80 @@ declare var NaN: number; declare var Infinity: number; /** - * Evaluates JavaScript code and executes it. - * @param x A String value that contains valid JavaScript code. - */ + * Evaluates JavaScript code and executes it. + * @param x A String value that contains valid JavaScript code. + */ declare function eval(x: string): any; /** - * Converts a string to an integer. - * @param s A string to convert into a number. - * @param radix A value between 2 and 36 that specifies the base of the number in numString. - * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. - * All other strings are considered decimal. - */ + * Converts a string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ declare function parseInt(s: string, radix?: number): number; /** - * Converts a string to a floating-point number. - * @param string A string that contains a floating-point number. - */ + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ declare function parseFloat(string: string): number; /** - * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). - * @param number A numeric value. - */ + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). + * @param number A numeric value. + */ declare function isNaN(number: number): boolean; /** - * Determines whether a supplied number is finite. - * @param number Any numeric value. - */ + * Determines whether a supplied number is finite. + * @param number Any numeric value. + */ declare function isFinite(number: number): boolean; /** - * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). - * @param encodedURI A value representing an encoded URI. - */ + * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). + * @param encodedURI A value representing an encoded URI. + */ declare function decodeURI(encodedURI: string): string; /** - * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). - * @param encodedURIComponent A value representing an encoded URI component. - */ + * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). + * @param encodedURIComponent A value representing an encoded URI component. + */ declare function decodeURIComponent(encodedURIComponent: string): string; /** - * Encodes a text string as a valid Uniform Resource Identifier (URI) - * @param uri A value representing an encoded URI. - */ + * Encodes a text string as a valid Uniform Resource Identifier (URI) + * @param uri A value representing an encoded URI. + */ declare function encodeURI(uri: string): string; /** - * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). - * @param uriComponent A value representing an encoded URI component. - */ + * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). + * @param uriComponent A value representing an encoded URI component. + */ declare function encodeURIComponent(uriComponent: string | number | boolean): string; /** - * Computes a new string in which certain characters have been replaced by a hexadecimal escape sequence. - * @param string A string value - */ + * Computes a new string in which certain characters have been replaced by a hexadecimal escape sequence. + * @param string A string value + */ declare function escape(string: string): string; /** - * Computes a new string in which hexadecimal escape sequences are replaced with the character that it represents. - * @param string A string value - */ + * Computes a new string in which hexadecimal escape sequences are replaced with the character that it represents. + * @param string A string value + */ declare function unescape(string: string): string; interface Symbol { - /** Returns a string representation of an object. */ - toString(): string; + /** Returns a string representation of an object. */ + toString(): string; - /** Returns the primitive value of the specified object. */ - valueOf(): symbol; + /** Returns the primitive value of the specified object. */ + valueOf(): symbol; } declare type PropertyKey = string | number | symbol; @@ -131,21 +131,21 @@ interface Object { valueOf(): Object; /** - * Determines whether an object has a property with the specified name. - * @param v A property name. - */ + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ hasOwnProperty(v: PropertyKey): boolean; /** - * Determines whether an object exists in another object's prototype chain. - * @param v Another object whose prototype chain is to be checked. - */ + * Determines whether an object exists in another object's prototype chain. + * @param v Another object whose prototype chain is to be checked. + */ isPrototypeOf(v: Object): boolean; /** - * Determines whether a specified property is enumerable. - * @param v A property name. - */ + * Determines whether a specified property is enumerable. + * @param v A property name. + */ propertyIsEnumerable(v: PropertyKey): boolean; } @@ -158,138 +158,138 @@ interface ObjectConstructor { readonly prototype: Object; /** - * Returns the prototype of an object. - * @param o The object that references the prototype. - */ + * Returns the prototype of an object. + * @param o The object that references the prototype. + */ getPrototypeOf(o: any): any; /** - * Gets the own property descriptor of the specified object. - * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. - * @param o Object that contains the property. - * @param p Name of the property. - */ + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ getOwnPropertyDescriptor(o: any, p: PropertyKey): PropertyDescriptor | undefined; /** - * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly - * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. - * @param o Object that contains the own properties. - */ + * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly + * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. + * @param o Object that contains the own properties. + */ getOwnPropertyNames(o: any): string[]; /** - * Creates an object that has the specified prototype or that has null prototype. - * @param o Object to use as a prototype. May be null. - */ + * Creates an object that has the specified prototype or that has null prototype. + * @param o Object to use as a prototype. May be null. + */ create(o: object | null): any; /** - * Creates an object that has the specified prototype, and that optionally contains specified properties. - * @param o Object to use as a prototype. May be null - * @param properties JavaScript object that contains one or more property descriptors. - */ + * Creates an object that has the specified prototype, and that optionally contains specified properties. + * @param o Object to use as a prototype. May be null + * @param properties JavaScript object that contains one or more property descriptors. + */ create(o: object | null, properties: PropertyDescriptorMap & ThisType): any; /** - * Adds a property to an object, or modifies attributes of an existing property. - * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. - * @param p The property name. - * @param attributes Descriptor for the property. It can be for a data property or an accessor property. - */ + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor property. + */ defineProperty(o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType): any; /** - * Adds one or more properties to an object, and/or modifies attributes of existing properties. - * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. - * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. - */ + * Adds one or more properties to an object, and/or modifies attributes of existing properties. + * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. + * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. + */ defineProperties(o: any, properties: PropertyDescriptorMap & ThisType): any; /** - * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ + * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ seal(o: T): T; /** - * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ - freeze(a: T[]): ReadonlyArray; + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + freeze(a: T[]): readonly T[]; /** - * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ freeze(f: T): T; /** - * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ freeze(o: T): Readonly; /** - * Prevents the addition of new properties to an object. - * @param o Object to make non-extensible. - */ + * Prevents the addition of new properties to an object. + * @param o Object to make non-extensible. + */ preventExtensions(o: T): T; /** - * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. - * @param o Object to test. - */ + * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. + * @param o Object to test. + */ isSealed(o: any): boolean; /** - * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. - * @param o Object to test. - */ + * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. + * @param o Object to test. + */ isFrozen(o: any): boolean; /** - * Returns a value that indicates whether new properties can be added to an object. - * @param o Object to test. - */ + * Returns a value that indicates whether new properties can be added to an object. + * @param o Object to test. + */ isExtensible(o: any): boolean; /** - * Returns the names of the enumerable string properties and methods of an object. - * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. - */ - keys(o: object): string[]; + * Returns the names of the enumerable string properties and methods of an object. + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ + keys(o: object): string[]; } /** - * Provides functionality common to all JavaScript objects. - */ + * Provides functionality common to all JavaScript objects. + */ declare var Object: ObjectConstructor; /** - * Creates a new function. - */ + * Creates a new function. + */ interface Function { /** - * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. - * @param thisArg The object to be used as the this object. - * @param argArray A set of arguments to be passed to the function. - */ + * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. + * @param thisArg The object to be used as the this object. + * @param argArray A set of arguments to be passed to the function. + */ apply(this: Function, thisArg: any, argArray?: any): any; /** - * Calls a method of an object, substituting another object for the current object. - * @param thisArg The object to be used as the current object. - * @param argArray A list of arguments to be passed to the method. - */ + * Calls a method of an object, substituting another object for the current object. + * @param thisArg The object to be used as the current object. + * @param argArray A list of arguments to be passed to the method. + */ call(this: Function, thisArg: any, ...argArray: any[]): any; /** - * For a given function, creates a bound function that has the same body as the original function. - * The this object of the bound function is associated with the specified object, and has the specified initial parameters. - * @param thisArg An object to which the this keyword can refer inside the new function. - * @param argArray A list of arguments to be passed to the new function. - */ + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg An object to which the this keyword can refer inside the new function. + * @param argArray A list of arguments to be passed to the new function. + */ bind(this: Function, thisArg: any, ...argArray: any[]): any; /** Returns a string representation of a function. */ @@ -305,9 +305,9 @@ interface Function { interface FunctionConstructor { /** - * Creates a new function. - * @param args A list of arguments the function accepts. - */ + * Creates a new function. + * @param args A list of arguments the function accepts. + */ new(...args: string[]): Function; (...args: string[]): Function; readonly prototype: Function; @@ -327,26 +327,26 @@ type OmitThisParameter = unknown extends ThisParameterType ? T : T extends interface CallableFunction extends Function { /** - * Calls the function with the specified object as the this value and the elements of specified array as the arguments. - * @param thisArg The object to be used as the this object. - * @param args An array of argument values to be passed to the function. - */ + * Calls the function with the specified object as the this value and the elements of specified array as the arguments. + * @param thisArg The object to be used as the this object. + * @param args An array of argument values to be passed to the function. + */ apply(this: (this: T) => R, thisArg: T): R; apply(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; /** - * Calls the function with the specified object as the this value and the specified rest arguments as the arguments. - * @param thisArg The object to be used as the this object. - * @param args Argument values to be passed to the function. - */ + * Calls the function with the specified object as the this value and the specified rest arguments as the arguments. + * @param thisArg The object to be used as the this object. + * @param args Argument values to be passed to the function. + */ call(this: (this: T, ...args: A) => R, thisArg: T, ...args: A): R; /** - * For a given function, creates a bound function that has the same body as the original function. - * The this object of the bound function is associated with the specified object, and has the specified initial parameters. - * @param thisArg The object to be used as the this object. - * @param args Arguments to bind to the parameters of the function. - */ + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg The object to be used as the this object. + * @param args Arguments to bind to the parameters of the function. + */ bind(this: T, thisArg: ThisParameterType): OmitThisParameter; bind(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R; bind(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R; @@ -357,26 +357,26 @@ interface CallableFunction extends Function { interface NewableFunction extends Function { /** - * Calls the function with the specified object as the this value and the elements of specified array as the arguments. - * @param thisArg The object to be used as the this object. - * @param args An array of argument values to be passed to the function. - */ + * Calls the function with the specified object as the this value and the elements of specified array as the arguments. + * @param thisArg The object to be used as the this object. + * @param args An array of argument values to be passed to the function. + */ apply(this: new () => T, thisArg: T): void; apply(this: new (...args: A) => T, thisArg: T, args: A): void; /** - * Calls the function with the specified object as the this value and the specified rest arguments as the arguments. - * @param thisArg The object to be used as the this object. - * @param args Argument values to be passed to the function. - */ + * Calls the function with the specified object as the this value and the specified rest arguments as the arguments. + * @param thisArg The object to be used as the this object. + * @param args Argument values to be passed to the function. + */ call(this: new (...args: A) => T, thisArg: T, ...args: A): void; /** - * For a given function, creates a bound function that has the same body as the original function. - * The this object of the bound function is associated with the specified object, and has the specified initial parameters. - * @param thisArg The object to be used as the this object. - * @param args Arguments to bind to the parameters of the function. - */ + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg The object to be used as the this object. + * @param args Arguments to bind to the parameters of the function. + */ bind(this: T, thisArg: any): T; bind(this: new (arg0: A0, ...args: A) => R, thisArg: any, arg0: A0): new (...args: A) => R; bind(this: new (arg0: A0, arg1: A1, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1): new (...args: A) => R; @@ -396,103 +396,103 @@ interface String { toString(): string; /** - * Returns the character at the specified index. - * @param pos The zero-based index of the desired character. - */ + * Returns the character at the specified index. + * @param pos The zero-based index of the desired character. + */ charAt(pos: number): string; /** - * Returns the Unicode value of the character at the specified location. - * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. - */ + * Returns the Unicode value of the character at the specified location. + * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. + */ charCodeAt(index: number): number; /** - * Returns a string that contains the concatenation of two or more strings. - * @param strings The strings to append to the end of the string. - */ + * Returns a string that contains the concatenation of two or more strings. + * @param strings The strings to append to the end of the string. + */ concat(...strings: string[]): string; /** - * Returns the position of the first occurrence of a substring. - * @param searchString The substring to search for in the string - * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. - */ + * Returns the position of the first occurrence of a substring. + * @param searchString The substring to search for in the string + * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. + */ indexOf(searchString: string, position?: number): number; /** - * Returns the last occurrence of a substring in the string. - * @param searchString The substring to search for. - * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. - */ + * Returns the last occurrence of a substring in the string. + * @param searchString The substring to search for. + * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. + */ lastIndexOf(searchString: string, position?: number): number; /** - * Determines whether two strings are equivalent in the current locale. - * @param that String to compare to target string - */ + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + */ localeCompare(that: string): number; /** - * Matches a string with a regular expression, and returns an array containing the results of that search. - * @param regexp A variable name or string literal containing the regular expression pattern and flags. - */ + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ match(regexp: string | RegExp): RegExpMatchArray | null; /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A string to search for. - * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. - */ + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A string to search for. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ replace(searchValue: string | RegExp, replaceValue: string): string; /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A string to search for. - * @param replacer A function that returns the replacement text. - */ + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A string to search for. + * @param replacer A function that returns the replacement text. + */ replace(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; /** - * Finds the first substring match in a regular expression search. - * @param regexp The regular expression pattern and applicable flags. - */ + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ search(regexp: string | RegExp): number; /** - * Returns a section of a string. - * @param start The index to the beginning of the specified portion of stringObj. - * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. - * If this value is not specified, the substring continues to the end of stringObj. - */ + * Returns a section of a string. + * @param start The index to the beginning of the specified portion of stringObj. + * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. + * If this value is not specified, the substring continues to the end of stringObj. + */ slice(start?: number, end?: number): string; /** - * Split a string into substrings using the specified separator and return them as an array. - * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. - * @param limit A value used to limit the number of elements returned in the array. - */ + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ split(separator: string | RegExp, limit?: number): string[]; /** - * Returns the substring at the specified location within a String object. - * @param start The zero-based index number indicating the beginning of the substring. - * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. - * If end is omitted, the characters from start through the end of the original string are returned. - */ + * Returns the substring at the specified location within a String object. + * @param start The zero-based index number indicating the beginning of the substring. + * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. + * If end is omitted, the characters from start through the end of the original string are returned. + */ substring(start: number, end?: number): string; /** Converts all the alphabetic characters in a string to lowercase. */ toLowerCase(): string; /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ - toLocaleLowerCase(): string; + toLocaleLowerCase(locales?: string | string[]): string; /** Converts all the alphabetic characters in a string to uppercase. */ toUpperCase(): string; /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ - toLocaleUpperCase(): string; + toLocaleUpperCase(locales?: string | string[]): string; /** Removes the leading and trailing white space and line terminator characters from a string. */ trim(): string; @@ -502,10 +502,10 @@ interface String { // IE extensions /** - * Gets a substring beginning at the specified location and having the specified length. - * @param from The starting position of the desired substring. The index of the first character in the string is zero. - * @param length The number of characters to include in the returned substring. - */ + * Gets a substring beginning at the specified location and having the specified length. + * @param from The starting position of the desired substring. The index of the first character in the string is zero. + * @param length The number of characters to include in the returned substring. + */ substr(from: number, length?: number): string; /** Returns the primitive value of the specified object. */ @@ -522,8 +522,8 @@ interface StringConstructor { } /** - * Allows manipulation and formatting of text strings and determination and location of substrings within strings. - */ + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. + */ declare var String: StringConstructor; interface Boolean { @@ -541,27 +541,27 @@ declare var Boolean: BooleanConstructor; interface Number { /** - * Returns a string representation of an object. - * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. - */ + * Returns a string representation of an object. + * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. + */ toString(radix?: number): string; /** - * Returns a string representing a number in fixed-point notation. - * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. - */ + * Returns a string representing a number in fixed-point notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ toFixed(fractionDigits?: number): string; /** - * Returns a string containing a number represented in exponential notation. - * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. - */ + * Returns a string containing a number represented in exponential notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ toExponential(fractionDigits?: number): string; /** - * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. - * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. - */ + * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. + * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. + */ toPrecision(precision?: number): string; /** Returns the primitive value of the specified object. */ @@ -580,21 +580,21 @@ interface NumberConstructor { readonly MIN_VALUE: number; /** - * A value that is not a number. - * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. - */ + * A value that is not a number. + * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. + */ readonly NaN: number; /** - * A value that is less than the largest negative number that can be represented in JavaScript. - * JavaScript displays NEGATIVE_INFINITY values as -infinity. - */ + * A value that is less than the largest negative number that can be represented in JavaScript. + * JavaScript displays NEGATIVE_INFINITY values as -infinity. + */ readonly NEGATIVE_INFINITY: number; /** - * A value greater than the largest number that can be represented in JavaScript. - * JavaScript displays POSITIVE_INFINITY values as infinity. - */ + * A value greater than the largest number that can be represented in JavaScript. + * JavaScript displays POSITIVE_INFINITY values as infinity. + */ readonly POSITIVE_INFINITY: number; } @@ -602,7 +602,7 @@ interface NumberConstructor { declare var Number: NumberConstructor; interface TemplateStringsArray extends ReadonlyArray { - readonly raw: ReadonlyArray; + readonly raw: readonly string[]; } /** @@ -632,94 +632,94 @@ interface Math { /** The square root of 2. */ readonly SQRT2: number; /** - * Returns the absolute value of a number (the value without regard to whether it is positive or negative). - * For example, the absolute value of -5 is the same as the absolute value of 5. - * @param x A numeric expression for which the absolute value is needed. - */ + * Returns the absolute value of a number (the value without regard to whether it is positive or negative). + * For example, the absolute value of -5 is the same as the absolute value of 5. + * @param x A numeric expression for which the absolute value is needed. + */ abs(x: number): number; /** - * Returns the arc cosine (or inverse cosine) of a number. - * @param x A numeric expression. - */ + * Returns the arc cosine (or inverse cosine) of a number. + * @param x A numeric expression. + */ acos(x: number): number; /** - * Returns the arcsine of a number. - * @param x A numeric expression. - */ + * Returns the arcsine of a number. + * @param x A numeric expression. + */ asin(x: number): number; /** - * Returns the arctangent of a number. - * @param x A numeric expression for which the arctangent is needed. - */ + * Returns the arctangent of a number. + * @param x A numeric expression for which the arctangent is needed. + */ atan(x: number): number; /** - * Returns the angle (in radians) from the X axis to a point. - * @param y A numeric expression representing the cartesian y-coordinate. - * @param x A numeric expression representing the cartesian x-coordinate. - */ + * Returns the angle (in radians) from the X axis to a point. + * @param y A numeric expression representing the cartesian y-coordinate. + * @param x A numeric expression representing the cartesian x-coordinate. + */ atan2(y: number, x: number): number; /** - * Returns the smallest integer greater than or equal to its numeric argument. - * @param x A numeric expression. - */ + * Returns the smallest integer greater than or equal to its numeric argument. + * @param x A numeric expression. + */ ceil(x: number): number; /** - * Returns the cosine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ + * Returns the cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ cos(x: number): number; /** - * Returns e (the base of natural logarithms) raised to a power. - * @param x A numeric expression representing the power of e. - */ + * Returns e (the base of natural logarithms) raised to a power. + * @param x A numeric expression representing the power of e. + */ exp(x: number): number; /** - * Returns the greatest integer less than or equal to its numeric argument. - * @param x A numeric expression. - */ + * Returns the greatest integer less than or equal to its numeric argument. + * @param x A numeric expression. + */ floor(x: number): number; /** - * Returns the natural logarithm (base e) of a number. - * @param x A numeric expression. - */ + * Returns the natural logarithm (base e) of a number. + * @param x A numeric expression. + */ log(x: number): number; /** - * Returns the larger of a set of supplied numeric expressions. - * @param values Numeric expressions to be evaluated. - */ + * Returns the larger of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ max(...values: number[]): number; /** - * Returns the smaller of a set of supplied numeric expressions. - * @param values Numeric expressions to be evaluated. - */ + * Returns the smaller of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ min(...values: number[]): number; /** - * Returns the value of a base expression taken to a specified power. - * @param x The base value of the expression. - * @param y The exponent value of the expression. - */ + * Returns the value of a base expression taken to a specified power. + * @param x The base value of the expression. + * @param y The exponent value of the expression. + */ pow(x: number, y: number): number; /** Returns a pseudorandom number between 0 and 1. */ random(): number; /** - * Returns a supplied numeric expression rounded to the nearest number. - * @param x The value to be rounded to the nearest number. - */ + * Returns a supplied numeric expression rounded to the nearest number. + * @param x The value to be rounded to the nearest number. + */ round(x: number): number; /** - * Returns the sine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ + * Returns the sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ sin(x: number): number; /** - * Returns the square root of a number. - * @param x A numeric expression. - */ + * Returns the square root of a number. + * @param x A numeric expression. + */ sqrt(x: number): number; /** - * Returns the tangent of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ + * Returns the tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ tan(x: number): number; } /** An intrinsic object that provides basic mathematics functionality and constants. */ @@ -778,98 +778,98 @@ interface Date { /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ getTimezoneOffset(): number; /** - * Sets the date and time value in the Date object. - * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. - */ + * Sets the date and time value in the Date object. + * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. + */ setTime(time: number): number; /** - * Sets the milliseconds value in the Date object using local time. - * @param ms A numeric value equal to the millisecond value. - */ + * Sets the milliseconds value in the Date object using local time. + * @param ms A numeric value equal to the millisecond value. + */ setMilliseconds(ms: number): number; /** - * Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). - * @param ms A numeric value equal to the millisecond value. - */ + * Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). + * @param ms A numeric value equal to the millisecond value. + */ setUTCMilliseconds(ms: number): number; /** - * Sets the seconds value in the Date object using local time. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ + * Sets the seconds value in the Date object using local time. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ setSeconds(sec: number, ms?: number): number; /** - * Sets the seconds value in the Date object using Universal Coordinated Time (UTC). - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ + * Sets the seconds value in the Date object using Universal Coordinated Time (UTC). + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ setUTCSeconds(sec: number, ms?: number): number; /** - * Sets the minutes value in the Date object using local time. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ + * Sets the minutes value in the Date object using local time. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ setMinutes(min: number, sec?: number, ms?: number): number; /** - * Sets the minutes value in the Date object using Universal Coordinated Time (UTC). - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ + * Sets the minutes value in the Date object using Universal Coordinated Time (UTC). + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ setUTCMinutes(min: number, sec?: number, ms?: number): number; /** - * Sets the hour value in the Date object using local time. - * @param hours A numeric value equal to the hours value. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ + * Sets the hour value in the Date object using local time. + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ setHours(hours: number, min?: number, sec?: number, ms?: number): number; /** - * Sets the hours value in the Date object using Universal Coordinated Time (UTC). - * @param hours A numeric value equal to the hours value. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ + * Sets the hours value in the Date object using Universal Coordinated Time (UTC). + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ setUTCHours(hours: number, min?: number, sec?: number, ms?: number): number; /** - * Sets the numeric day-of-the-month value of the Date object using local time. - * @param date A numeric value equal to the day of the month. - */ + * Sets the numeric day-of-the-month value of the Date object using local time. + * @param date A numeric value equal to the day of the month. + */ setDate(date: number): number; /** - * Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). - * @param date A numeric value equal to the day of the month. - */ + * Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). + * @param date A numeric value equal to the day of the month. + */ setUTCDate(date: number): number; /** - * Sets the month value in the Date object using local time. - * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. - * @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used. - */ + * Sets the month value in the Date object using local time. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used. + */ setMonth(month: number, date?: number): number; /** - * Sets the month value in the Date object using Universal Coordinated Time (UTC). - * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. - * @param date A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used. - */ + * Sets the month value in the Date object using Universal Coordinated Time (UTC). + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used. + */ setUTCMonth(month: number, date?: number): number; /** - * Sets the year of the Date object using local time. - * @param year A numeric value for the year. - * @param month A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified. - * @param date A numeric value equal for the day of the month. - */ + * Sets the year of the Date object using local time. + * @param year A numeric value for the year. + * @param month A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified. + * @param date A numeric value equal for the day of the month. + */ setFullYear(year: number, month?: number, date?: number): number; /** - * Sets the year value in the Date object using Universal Coordinated Time (UTC). - * @param year A numeric value equal to the year. - * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied. - * @param date A numeric value equal to the day of the month. - */ + * Sets the year value in the Date object using Universal Coordinated Time (UTC). + * @param year A numeric value equal to the year. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied. + * @param date A numeric value equal to the day of the month. + */ setUTCFullYear(year: number, month?: number, date?: number): number; /** Returns a date converted to a string using Universal Coordinated Time (UTC). */ toUTCString(): string; @@ -886,20 +886,20 @@ interface DateConstructor { (): string; readonly prototype: Date; /** - * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. - * @param s A date string - */ + * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. + * @param s A date string + */ parse(s: string): number; /** - * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. - * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. - * @param month The month as an number between 0 and 11 (January to December). - * @param date The date as an number between 1 and 31. - * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. - * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. - * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. - * @param ms An number from 0 to 999 that specifies the milliseconds. - */ + * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. + * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. + * @param month The month as an number between 0 and 11 (January to December). + * @param date The date as an number between 1 and 31. + * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. + * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. + * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. + * @param ms An number from 0 to 999 that specifies the milliseconds. + */ UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } @@ -918,15 +918,15 @@ interface RegExpExecArray extends Array { interface RegExp { /** - * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. - * @param string The String object or string literal on which to perform the search. - */ + * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. + * @param string The String object or string literal on which to perform the search. + */ exec(string: string): RegExpExecArray | null; /** - * Returns a Boolean value that indicates whether or not a pattern exists in a searched string. - * @param string String on which to perform the search. - */ + * Returns a Boolean value that indicates whether or not a pattern exists in a searched string. + * @param string String on which to perform the search. + */ test(string: string): boolean; /** Returns a copy of the text of the regular expression pattern. Read-only. The regExp argument is a Regular expression object. It can be a variable name or a literal. */ @@ -1051,31 +1051,31 @@ declare var URIError: URIErrorConstructor; interface JSON { /** - * Converts a JavaScript Object Notation (JSON) string into an object. - * @param text A valid JSON string. - * @param reviver A function that transforms the results. This function is called for each member of the object. - * If a member contains nested objects, the nested objects are transformed before the parent object is. - */ + * Converts a JavaScript Object Notation (JSON) string into an object. + * @param text A valid JSON string. + * @param reviver A function that transforms the results. This function is called for each member of the object. + * If a member contains nested objects, the nested objects are transformed before the parent object is. + */ parse(text: string, reviver?: (this: any, key: string, value: any) => any): any; /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer A function that transforms the results. - * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. - */ + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer An array of strings and numbers that acts as a approved list for selecting the object properties that will be stringified. - * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. - */ + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer An array of strings and numbers that acts as a approved list for selecting the object properties that will be stringified. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string; } /** - * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. - */ + * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. + */ declare var JSON: JSON; @@ -1085,112 +1085,112 @@ declare var JSON: JSON; interface ReadonlyArray { /** - * Gets the length of the array. This is a number one higher than the highest element defined in an array. - */ + * Gets the length of the array. This is a number one higher than the highest element defined in an array. + */ readonly length: number; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; /** - * Returns a string representation of an array. The elements are converted to string using their toLocalString methods. - */ + * Returns a string representation of an array. The elements are converted to string using their toLocalString methods. + */ toLocaleString(): string; /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ concat(...items: ConcatArray[]): T[]; /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ concat(...items: (T | ConcatArray)[]): T[]; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): T[]; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + */ indexOf(searchElement: T, fromIndex?: number): number; /** - * Returns the index of the last occurrence of a specified value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. - */ + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ lastIndexOf(searchElement: T, fromIndex?: number): number; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: T, index: number, array: ReadonlyArray) => unknown, thisArg?: any): boolean; - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: T, index: number, array: ReadonlyArray) => unknown, thisArg?: any): boolean; - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: T, index: number, array: ReadonlyArray) => void, thisArg?: any): void; - /** - * Calls a defined callback function on each element of an array, and returns an array that contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: T, index: number, array: ReadonlyArray) => U, thisArg?: any): U[]; + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean; + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean; + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: T, index: number, array: readonly T[]) => void, thisArg?: any): void; + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: T, index: number, array: readonly T[]) => U, thisArg?: any): U[]; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: T, index: number, array: ReadonlyArray) => value is S, thisArg?: any): S[]; - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: T, index: number, array: ReadonlyArray) => unknown, thisArg?: any): T[]; - /** - * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T): T; - reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T, initialValue: T): T; - /** - * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: ReadonlyArray) => U, initialValue: U): U; - /** - * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T): T; - reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T, initialValue: T): T; - /** - * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: ReadonlyArray) => U, initialValue: U): U; + filter(callbackfn: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S[]; + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T[]; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T; + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T; + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U; readonly [n: number]: T; } @@ -1204,113 +1204,113 @@ interface ConcatArray { interface Array { /** - * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. - */ + * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. + */ length: number; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; /** - * Returns a string representation of an array. The elements are converted to string using their toLocalString methods. - */ + * Returns a string representation of an array. The elements are converted to string using their toLocalString methods. + */ toLocaleString(): string; /** - * Removes the last element from an array and returns it. - */ + * Removes the last element from an array and returns it. + */ pop(): T | undefined; /** - * Appends new elements to an array, and returns the new length of the array. - * @param items New elements of the Array. - */ + * Appends new elements to an array, and returns the new length of the array. + * @param items New elements of the Array. + */ push(...items: T[]): number; /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ concat(...items: ConcatArray[]): T[]; /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ concat(...items: (T | ConcatArray)[]): T[]; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): T[]; /** - * Removes the first element from an array and returns it. - */ + * Removes the first element from an array and returns it. + */ shift(): T | undefined; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): T[]; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. + */ sort(compareFn?: (a: T, b: T) => number): this; /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. - */ + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + */ splice(start: number, deleteCount?: number): T[]; /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. - * @param items Elements to insert into the array in place of the deleted elements. - */ + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + */ splice(start: number, deleteCount: number, ...items: T[]): T[]; /** - * Inserts new elements at the start of an array. - * @param items Elements to insert at the start of the Array. - */ + * Inserts new elements at the start of an array. + * @param items Elements to insert at the start of the Array. + */ unshift(...items: T[]): number; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + */ indexOf(searchElement: T, fromIndex?: number): number; /** - * Returns the index of the last occurrence of a specified value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. - */ + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ lastIndexOf(searchElement: T, fromIndex?: number): number; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ every(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ some(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; /** - * Calls a defined callback function on each element of an array, and returns an array that contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; /** * Returns the elements of an array that meet the condition specified in a callback function. @@ -1319,36 +1319,36 @@ interface Array { */ filter(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; /** - * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; /** - * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; /** - * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; [n: number]: T; @@ -1361,8 +1361,8 @@ interface ArrayConstructor { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; - isArray(arg: any): arg is Array; - readonly prototype: Array; + isArray(arg: any): arg is any[]; + readonly prototype: any[]; } declare var Array: ArrayConstructor; @@ -1499,20 +1499,27 @@ type InstanceType any> = T extends new (...args: interface ThisType { } /** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ + * Constructs a structural tag over property name(s) `K` + */ +// type Tag = tag { +// [_ in K]: void; +// }; + +/** + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ interface ArrayBuffer { /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ + * Read-only. The length of the ArrayBuffer (in bytes). + */ readonly byteLength: number; /** - * Returns a section of an ArrayBuffer. - */ + * Returns a section of an ArrayBuffer. + */ slice(begin: number, end?: number): ArrayBuffer; } @@ -1533,18 +1540,18 @@ declare var ArrayBuffer: ArrayBufferConstructor; interface ArrayBufferView { /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ byteLength: number; /** - * The offset in bytes of the array. - */ + * The offset in bytes of the array. + */ byteOffset: number; } @@ -1553,126 +1560,126 @@ interface DataView { readonly byteLength: number; readonly byteOffset: number; /** - * Gets the Float32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Float32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getFloat32(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Float64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Float64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getFloat64(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Int8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Int8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getInt8(byteOffset: number): number; /** - * Gets the Int16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Int16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getInt16(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Int32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Int32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getInt32(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Uint8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Uint8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getUint8(byteOffset: number): number; /** - * Gets the Uint16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Uint16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getUint16(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Uint32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Uint32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getUint32(byteOffset: number, littleEndian?: boolean): number; /** - * Stores an Float32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Float64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Int8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ + * Stores an Int8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ setInt8(byteOffset: number, value: number): void; /** - * Stores an Int16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Int32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Uint8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ + * Stores an Uint8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ setUint8(byteOffset: number, value: number): void; /** - * Stores an Uint16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Uint32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; } @@ -1682,241 +1689,241 @@ interface DataViewConstructor { declare var DataView: DataViewConstructor; /** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ interface Int8Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * The offset in bytes of the array. + */ readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: number, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: number, index: number, array: Int8Array) => any, thisArg?: any): Int8Array; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: number, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: number, fromIndex?: number): number; /** - * The length of the array. - */ + * The length of the array. + */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Int8Array; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Int8Array; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int8Array; + * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): Int8Array; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -1928,28 +1935,28 @@ interface Int8ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int8Array; /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Int8Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Int8Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array; @@ -1957,241 +1964,241 @@ interface Int8ArrayConstructor { declare var Int8Array: Int8ArrayConstructor; /** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ interface Uint8Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * The offset in bytes of the array. + */ readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: number, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: number, index: number, array: Uint8Array) => any, thisArg?: any): Uint8Array; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: number, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: number, fromIndex?: number): number; /** - * The length of the array. - */ + * The length of the array. + */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Uint8Array; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Uint8Array; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8Array; + * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): Uint8Array; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -2204,269 +2211,269 @@ interface Uint8ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint8Array; /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Uint8Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Uint8Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array; } declare var Uint8Array: Uint8ArrayConstructor; /** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. - * If the requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ interface Uint8ClampedArray { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * The offset in bytes of the array. + */ readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: number, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => any, thisArg?: any): Uint8ClampedArray; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: number, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: number, fromIndex?: number): number; /** - * The length of the array. - */ + * The length of the array. + */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Uint8ClampedArray; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Uint8ClampedArray; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8ClampedArray; + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): Uint8ClampedArray; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -2479,267 +2486,267 @@ interface Uint8ClampedArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint8ClampedArray; /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Uint8ClampedArray; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Uint8ClampedArray; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray; } declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; /** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ interface Int16Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * The offset in bytes of the array. + */ readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: number, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: number, index: number, array: Int16Array) => any, thisArg?: any): Int16Array; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: number, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: number, fromIndex?: number): number; /** - * The length of the array. - */ + * The length of the array. + */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Int16Array; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Int16Array; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int16Array; + * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): Int16Array; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -2752,28 +2759,28 @@ interface Int16ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int16Array; /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Int16Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Int16Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array; @@ -2781,241 +2788,241 @@ interface Int16ArrayConstructor { declare var Int16Array: Int16ArrayConstructor; /** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ interface Uint16Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * The offset in bytes of the array. + */ readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: number, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: number, index: number, array: Uint16Array) => any, thisArg?: any): Uint16Array; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: number, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: number, fromIndex?: number): number; /** - * The length of the array. - */ + * The length of the array. + */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Uint16Array; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Uint16Array; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint16Array; + * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): Uint16Array; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -3028,269 +3035,269 @@ interface Uint16ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint16Array; /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Uint16Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Uint16Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array; } declare var Uint16Array: Uint16ArrayConstructor; /** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ interface Int32Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * The offset in bytes of the array. + */ readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: number, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: number, index: number, array: Int32Array) => any, thisArg?: any): Int32Array; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: number, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: number, fromIndex?: number): number; /** - * The length of the array. - */ + * The length of the array. + */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Int32Array; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Int32Array; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int32Array; + * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): Int32Array; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -3303,268 +3310,268 @@ interface Int32ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int32Array; /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Int32Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Int32Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array; } declare var Int32Array: Int32ArrayConstructor; /** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ interface Uint32Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * The offset in bytes of the array. + */ readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: number, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: number, index: number, array: Uint32Array) => any, thisArg?: any): Uint32Array; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: number, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: number, fromIndex?: number): number; /** - * The length of the array. - */ + * The length of the array. + */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Uint32Array; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Uint32Array; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint32Array; + * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): Uint32Array; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -3577,269 +3584,269 @@ interface Uint32ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint32Array; /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Uint32Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Uint32Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array; } declare var Uint32Array: Uint32ArrayConstructor; /** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ interface Float32Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * The offset in bytes of the array. + */ readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: number, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: number, index: number, array: Float32Array) => any, thisArg?: any): Float32Array; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: number, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: number, fromIndex?: number): number; /** - * The length of the array. - */ + * The length of the array. + */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Float32Array; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Float32Array; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float32Array; + * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): Float32Array; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -3852,28 +3859,28 @@ interface Float32ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Float32Array; /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Float32Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Float32Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array; @@ -3881,241 +3888,232 @@ interface Float32ArrayConstructor { declare var Float32Array: Float32ArrayConstructor; /** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ interface Float64Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * The offset in bytes of the array. + */ readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: number, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: number, index: number, array: Float64Array) => any, thisArg?: any): Float64Array; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: number, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: number, fromIndex?: number): number; /** - * The length of the array. - */ + * The length of the array. + */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Float64Array; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Float64Array; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float64Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): Float64Array; - /** - * Returns a string representation of an array. - */ toString(): string; [index: number]: number; @@ -4128,28 +4126,28 @@ interface Float64ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Float64Array; /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Float64Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Float64Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array; } @@ -4272,41 +4270,41 @@ declare namespace Intl { interface String { /** - * Determines whether two strings are equivalent in the current or specified locale. - * @param that String to compare to target string - * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. - * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. - */ + * Determines whether two strings are equivalent in the current or specified locale. + * @param that String to compare to target string + * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. + * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. + */ localeCompare(that: string, locales?: string | string[], options?: Intl.CollatorOptions): number; } interface Number { /** - * Converts a number to a string by using the current or specified locale. - * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. - * @param options An object that contains one or more properties that specify comparison options. - */ + * Converts a number to a string by using the current or specified locale. + * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ toLocaleString(locales?: string | string[], options?: Intl.NumberFormatOptions): string; } interface Date { /** - * Converts a date and time to a string by using the current or specified locale. - * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. - * @param options An object that contains one or more properties that specify comparison options. - */ + * Converts a date and time to a string by using the current or specified locale. + * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ toLocaleString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; /** - * Converts a date to a string by using the current or specified locale. - * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. - * @param options An object that contains one or more properties that specify comparison options. - */ + * Converts a date to a string by using the current or specified locale. + * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ toLocaleDateString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; /** - * Converts a time to a string by using the current or specified locale. - * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. - * @param options An object that contains one or more properties that specify comparison options. - */ + * Converts a time to a string by using the current or specified locale. + * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ toLocaleTimeString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; } diff --git a/lib/lib.esnext.bigint.d.ts b/lib/lib.esnext.bigint.d.ts index 50967de98fea7..ba9bae6e85939 100644 --- a/lib/lib.esnext.bigint.d.ts +++ b/lib/lib.esnext.bigint.d.ts @@ -20,9 +20,9 @@ and limitations under the License. interface BigInt { /** - * Returns a string representation of an object. - * @param radix Specifies a radix for converting numeric values to strings. - */ + * Returns a string representation of an object. + * @param radix Specifies a radix for converting numeric values to strings. + */ toString(radix?: number): string; /** Returns a string representation appropriate to the host environment's current locale. */ @@ -39,27 +39,27 @@ interface BigIntConstructor { readonly prototype: BigInt; /** - * Interprets the low bits of a BigInt as a 2's-complement signed integer. - * All higher bits are discarded. - * @param bits The number of low bits to use - * @param int The BigInt whose bits to extract - */ + * Interprets the low bits of a BigInt as a 2's-complement signed integer. + * All higher bits are discarded. + * @param bits The number of low bits to use + * @param int The BigInt whose bits to extract + */ asIntN(bits: number, int: bigint): bigint; /** - * Interprets the low bits of a BigInt as an unsigned integer. - * All higher bits are discarded. - * @param bits The number of low bits to use - * @param int The BigInt whose bits to extract - */ + * Interprets the low bits of a BigInt as an unsigned integer. + * All higher bits are discarded. + * @param bits The number of low bits to use + * @param int The BigInt whose bits to extract + */ asUintN(bits: number, int: bigint): bigint; } declare var BigInt: BigIntConstructor; /** - * A typed array of 64-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated, an exception is raised. - */ + * A typed array of 64-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated, an exception is raised. + */ interface BigInt64Array { /** The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; @@ -74,213 +74,213 @@ interface BigInt64Array { readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** Yields index, value pairs for every entry in the array. */ entries(): IterableIterator<[number, bigint]>; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in the array until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in the array until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ every(callbackfn: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: bigint, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: bigint, index: number, array: BigInt64Array) => any, thisArg?: any): BigInt64Array; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): bigint | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: bigint, index: number, array: BigInt64Array) => void, thisArg?: any): void; /** - * Determines whether an array includes a certain element, returning true or false as appropriate. - * @param searchElement The element to search for. - * @param fromIndex The position in this array at which to begin searching for searchElement. - */ + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ includes(searchElement: bigint, fromIndex?: number): boolean; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: bigint, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** Yields each index in the array. */ keys(): IterableIterator; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: bigint, fromIndex?: number): number; /** The length of the array. */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: bigint, index: number, array: BigInt64Array) => bigint, thisArg?: any): BigInt64Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array) => bigint): bigint; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigInt64Array) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array) => bigint): bigint; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigInt64Array) => U, initialValue: U): U; /** Reverses the elements in the array. */ reverse(): this; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ slice(start?: number, end?: number): BigInt64Array; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in the array until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in the array until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ some(callbackfn: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): boolean; /** - * Sorts the array. - * @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order. - */ + * Sorts the array. + * @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order. + */ sort(compareFn?: (a: bigint, b: bigint) => number | bigint): this; /** - * Gets a new BigInt64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): BigInt64Array; + * Gets a new BigInt64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): BigInt64Array; /** Converts the array to a string by using the current locale. */ toLocaleString(): string; @@ -308,17 +308,17 @@ interface BigInt64ArrayConstructor { readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: bigint[]): BigInt64Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike): BigInt64Array; from(arrayLike: ArrayLike, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigInt64Array; } @@ -326,9 +326,9 @@ interface BigInt64ArrayConstructor { declare var BigInt64Array: BigInt64ArrayConstructor; /** - * A typed array of 64-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated, an exception is raised. - */ + * A typed array of 64-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated, an exception is raised. + */ interface BigUint64Array { /** The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; @@ -343,213 +343,213 @@ interface BigUint64Array { readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** Yields index, value pairs for every entry in the array. */ entries(): IterableIterator<[number, bigint]>; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in the array until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in the array until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ every(callbackfn: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: bigint, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: bigint, index: number, array: BigUint64Array) => any, thisArg?: any): BigUint64Array; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): bigint | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: bigint, index: number, array: BigUint64Array) => void, thisArg?: any): void; /** - * Determines whether an array includes a certain element, returning true or false as appropriate. - * @param searchElement The element to search for. - * @param fromIndex The position in this array at which to begin searching for searchElement. - */ + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ includes(searchElement: bigint, fromIndex?: number): boolean; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: bigint, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** Yields each index in the array. */ keys(): IterableIterator; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: bigint, fromIndex?: number): number; /** The length of the array. */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: bigint, index: number, array: BigUint64Array) => bigint, thisArg?: any): BigUint64Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array) => bigint): bigint; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigUint64Array) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array) => bigint): bigint; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigUint64Array) => U, initialValue: U): U; /** Reverses the elements in the array. */ reverse(): this; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ slice(start?: number, end?: number): BigUint64Array; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in the array until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in the array until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ some(callbackfn: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): boolean; /** - * Sorts the array. - * @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order. - */ + * Sorts the array. + * @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order. + */ sort(compareFn?: (a: bigint, b: bigint) => number | bigint): this; /** - * Gets a new BigUint64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): BigUint64Array; + * Gets a new BigUint64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): BigUint64Array; /** Converts the array to a string by using the current locale. */ toLocaleString(): string; @@ -577,17 +577,17 @@ interface BigUint64ArrayConstructor { readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: bigint[]): BigUint64Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike): BigUint64Array; from(arrayLike: ArrayLike, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigUint64Array; } @@ -596,34 +596,34 @@ declare var BigUint64Array: BigUint64ArrayConstructor; interface DataView { /** - * Gets the BigInt64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the BigInt64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getBigInt64(byteOffset: number, littleEndian?: boolean): bigint; /** - * Gets the BigUint64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the BigUint64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getBigUint64(byteOffset: number, littleEndian?: boolean): bigint; /** - * Stores a BigInt64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores a BigInt64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setBigInt64(byteOffset: number, value: bigint, littleEndian?: boolean): void; /** - * Stores a BigUint64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores a BigUint64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setBigUint64(byteOffset: number, value: bigint, littleEndian?: boolean): void; } diff --git a/lib/lib.esnext.d.ts b/lib/lib.esnext.d.ts index ea5841bdf89ba..d71ce67c5359c 100644 --- a/lib/lib.esnext.d.ts +++ b/lib/lib.esnext.d.ts @@ -18,6 +18,6 @@ and limitations under the License. /// -/// +/// /// /// diff --git a/lib/lib.esnext.intl.d.ts b/lib/lib.esnext.intl.d.ts index 73a45eedf2076..404ffc35bf468 100644 --- a/lib/lib.esnext.intl.d.ts +++ b/lib/lib.esnext.intl.d.ts @@ -29,4 +29,4 @@ declare namespace Intl { interface NumberFormat { formatToParts(number?: number): NumberFormatPart[]; } - } +} diff --git a/lib/pl/diagnosticMessages.generated.json b/lib/pl/diagnosticMessages.generated.json index 8573d802c7439..9d219542c8696 100644 --- a/lib/pl/diagnosticMessages.generated.json +++ b/lib/pl/diagnosticMessages.generated.json @@ -278,7 +278,7 @@ "Computed_property_names_are_not_allowed_in_enums_1164": "Obliczone nazwy właściwości nie są dozwolone w wyliczeniach.", "Computed_values_are_not_permitted_in_an_enum_with_string_valued_members_2553": "Obliczone wartości nie są dozwolone w wyliczeniu ze składowymi o wartości ciągu.", "Concatenate_and_emit_output_to_single_file_6001": "Połącz i wyemituj dane wyjściowe do pojedynczego pliku.", - "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090": "Znaleziono sprzeczne definicje dla „{0}” w „{1}” i „{2}”. Rozważ zainstalowanie konkretnej wersji tej biblioteki, aby rozwiązać problem.", + "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090": "Znaleziono definicje będące w konflikcie dla „{0}” w „{1}” i „{2}”. Rozważ zainstalowanie konkretnej wersji tej biblioteki, aby rozwiązać problem.", "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013": "Dla sygnatury konstrukcji bez adnotacji zwracanego typu niejawnie określono zwracany typ „any”.", "Constructor_implementation_is_missing_2390": "Brak implementacji konstruktora.", "Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration_2673": "Konstruktor klasy „{0}” jest prywatny i dostępny tylko w ramach deklaracji klasy.", diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index ca84f3dab7979..bb03e4f012bde 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -467,7 +467,7 @@ declare namespace ts.server.protocol { scope: OrganizeImportsScope; } interface OrganizeImportsResponse extends Response { - body: ReadonlyArray; + body: readonly FileCodeEdits[]; } interface GetEditsForFileRenameRequest extends Request { command: CommandTypes.GetEditsForFileRename; @@ -479,7 +479,7 @@ declare namespace ts.server.protocol { readonly newFilePath: string; } interface GetEditsForFileRenameResponse extends Response { - body: ReadonlyArray; + body: readonly FileCodeEdits[]; } /** * Request for the available codefixes at a specific position. @@ -526,7 +526,7 @@ declare namespace ts.server.protocol { /** * Errorcodes we want to get the fixes for. */ - errorCodes: ReadonlyArray; + errorCodes: readonly number[]; } interface GetCombinedCodeFixRequestArgs { scope: GetCombinedCodeFixScope; @@ -643,7 +643,7 @@ declare namespace ts.server.protocol { interface FileSpanWithContext extends FileSpan, TextSpanWithContext { } interface DefinitionInfoAndBoundSpan { - definitions: ReadonlyArray; + definitions: readonly FileSpanWithContext[]; textSpan: TextSpan; } /** @@ -781,7 +781,7 @@ declare namespace ts.server.protocol { /** * The file locations referencing the symbol. */ - refs: ReadonlyArray; + refs: readonly ReferencesResponseItem[]; /** * The name of the symbol. */ @@ -885,7 +885,7 @@ declare namespace ts.server.protocol { /** * An array of span groups (one per file) that refer to the item to be renamed. */ - locs: ReadonlyArray; + locs: readonly SpanGroup[]; } /** * Rename response message. @@ -1364,8 +1364,8 @@ declare namespace ts.server.protocol { commands?: {}[]; } interface CombinedCodeActions { - changes: ReadonlyArray; - commands?: ReadonlyArray<{}>; + changes: readonly FileCodeEdits[]; + commands?: readonly {}[]; } interface CodeFixAction extends CodeAction { /** Short name to identify the fix, for use by telemetry. */ @@ -1572,7 +1572,7 @@ declare namespace ts.server.protocol { readonly isGlobalCompletion: boolean; readonly isMemberCompletion: boolean; readonly isNewIdentifierLocation: boolean; - readonly entries: ReadonlyArray; + readonly entries: readonly CompletionEntry[]; } interface CompletionDetailsResponse extends Response { body?: CompletionEntryDetails[]; @@ -2251,7 +2251,7 @@ declare namespace ts.server.protocol { /** * list of packages to install */ - packages: ReadonlyArray; + packages: readonly string[]; } interface BeginInstallTypesEventBody extends InstallTypesEventBody { } @@ -2532,7 +2532,7 @@ declare namespace ts.server.protocol { string = "string" } - interface TypeAcquisition { + export interface TypeAcquisition { enableAutoDiscovery?: boolean; enable?: boolean; include?: string[]; @@ -2540,7 +2540,7 @@ declare namespace ts.server.protocol { [option: string]: string[] | boolean | undefined; } - interface FileExtensionInfo { + export interface FileExtensionInfo { extension: string; isMixedContent: boolean; scriptKind?: ScriptKind; @@ -2560,11 +2560,11 @@ declare namespace ts.server.protocol { [index: string]: T; } - interface PluginImport { + export interface PluginImport { name: string; } - interface ProjectReference { + export interface ProjectReference { /** A normalized path on disk */ path: string; /** The path as the user originally wrote it */ @@ -2575,7 +2575,7 @@ declare namespace ts.server.protocol { circular?: boolean; } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; + export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; } declare namespace ts { // these types are empty stubs for types from services and should not be used directly diff --git a/lib/tsc.js b/lib/tsc.js index ba422ff94a2ea..233ad7602ede4 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -15,6 +15,13 @@ and limitations under the License. "use strict"; +var __spreadArrays = (this && this.__spreadArrays) || function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +}; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { @@ -59,7 +66,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook }; var ts; (function (ts) { - ts.versionMajorMinor = "3.6"; + ts.versionMajorMinor = "3.7"; ts.version = ts.versionMajorMinor + ".0-dev"; })(ts || (ts = {})); (function (ts) { @@ -697,7 +704,7 @@ var ts; return array1; if (!some(array1)) return array2; - return array1.concat(array2); + return __spreadArrays(array1, array2); } ts.concatenate = concatenate; function deduplicateRelational(array, equalityComparer, comparer) { @@ -1047,6 +1054,18 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; + function getAllKeys(obj) { + var result = []; + do { + var names = Object.getOwnPropertyNames(obj); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name = names_1[_i]; + pushIfUnique(result, name); + } + } while (obj = Object.getPrototypeOf(obj)); + return result; + } + ts.getAllKeys = getAllKeys; function getOwnValues(sparseArray) { var values = []; for (var key in sparseArray) { @@ -1765,7 +1784,7 @@ var ts; Debug.assertEachDefined = assertEachDefined; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } - var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); + var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); return fail(message + " " + detail, stackCrawlMark || assertNever); } Debug.assertNever = assertNever; @@ -2009,6 +2028,41 @@ var ts; })(performance = ts.performance || (ts.performance = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var nullLogger = { + logEvent: ts.noop, + logErrEvent: ts.noop, + logPerfEvent: ts.noop, + logInfoEvent: ts.noop, + logStartCommand: ts.noop, + logStopCommand: ts.noop, + logStartUpdateProgram: ts.noop, + logStopUpdateProgram: ts.noop, + logStartUpdateGraph: ts.noop, + logStopUpdateGraph: ts.noop, + logStartResolveModule: ts.noop, + logStopResolveModule: ts.noop, + logStartParseSourceFile: ts.noop, + logStopParseSourceFile: ts.noop, + logStartReadFile: ts.noop, + logStopReadFile: ts.noop, + logStartBindFile: ts.noop, + logStopBindFile: ts.noop, + logStartScheduledOperation: ts.noop, + logStopScheduledOperation: ts.noop, + }; + var etwModule; + try { + etwModule = require("@microsoft/typescript-etw"); + } + catch (e) { + etwModule = undefined; + } + ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; + var args = typeof process === "undefined" ? [] : process.argv; + ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify(args)); +})(ts || (ts = {})); +var ts; (function (ts) { var versionRegExp = /^(0|[1-9]\d*)(?:\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*)(?:\-([a-z0-9-.]+))?(?:\+([a-z0-9-.]+))?)?)?$/i; var prereleaseRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)(?:\.(?:0|[1-9]\d*|[a-z-][a-z0-9-]*))*$/i; @@ -2297,12 +2351,19 @@ var ts; return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + var RefFileKind; + (function (RefFileKind) { + RefFileKind[RefFileKind["Import"] = 0] = "Import"; + RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile"; + RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective"; + })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {})); var ExitStatus; (function (ExitStatus) { ExitStatus[ExitStatus["Success"] = 0] = "Success"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped"; + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { @@ -2456,7 +2517,7 @@ var ts; function getCustomPollingBasedLevels(baseVariable, defaultLevels) { var customLevels = getCustomLevels(baseVariable); return (pollingIntervalChanged || customLevels) && - createPollingIntervalBasedLevels(customLevels ? __assign({}, defaultLevels, customLevels) : defaultLevels); + createPollingIntervalBasedLevels(customLevels ? __assign(__assign({}, defaultLevels), customLevels) : defaultLevels); } } ts.setCustomPollingValues = setCustomPollingValues; @@ -2595,6 +2656,37 @@ var ts; } } ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile; + function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) { + var cache = ts.createMap(); + var callbacksCache = ts.createMultiMap(); + var toCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); + return function (fileName, callback, pollingInterval) { + var path = toCanonicalFileName(fileName); + var existing = cache.get(path); + if (existing) { + existing.refCount++; + } + else { + cache.set(path, { + watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval), + refCount: 1 + }); + } + callbacksCache.add(path, callback); + return { + close: function () { + var watcher = ts.Debug.assertDefined(cache.get(path)); + callbacksCache.remove(path, callback); + watcher.refCount--; + if (watcher.refCount) + return; + cache.delete(path); + ts.closeFileWatcherOf(watcher); + } + }; + }; + } + ts.createSingleFileWatcherPerName = createSingleFileWatcherPerName; function onWatchedFileStat(watchedFile, modifiedTime) { var oldTime = watchedFile.mtime.getTime(); var newTime = modifiedTime.getTime(); @@ -2615,6 +2707,7 @@ var ts; } ts.getFileWatcherEventKind = getFileWatcherEventKind; ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"]; + ts.sysLog = ts.noop; function createRecursiveDirectoryWatcher(host) { var cache = ts.createMap(); var callbackCache = ts.createMultiMap(); @@ -2727,11 +2820,13 @@ var ts; 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 useNonPollingWatchers = process.env.TSC_NONPOLLING_WATCHER; var tscWatchFile = process.env.TSC_WATCHFILE; var tscWatchDirectory = process.env.TSC_WATCHDIRECTORY; + var fsWatchFile = createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames); var dynamicPollingWatchFile; var nodeSystem = { args: process.argv.slice(2), @@ -2854,7 +2949,7 @@ var ts; } return useNonPollingWatchers ? createNonPollingWatchFile() : - function (fileName, callback) { return fsWatchFile(fileName, callback); }; + function (fileName, callback) { return fsWatchFile(fileName, callback, undefined); }; } function getWatchDirectory() { var fsSupportsRecursive = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin"); @@ -2923,7 +3018,7 @@ var ts; return watcher; } } - function fsWatchFile(fileName, callback, pollingInterval) { + function fsWatchFileWorker(fileName, callback, pollingInterval) { _fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged); var eventKind; return { @@ -2971,6 +3066,12 @@ var ts; } function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingWatchFile, pollingInterval) { var options; + var lastDirectoryPartWithDirectorySeparator; + var lastDirectoryPart; + if (isLinuxOrMacOs) { + lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator)); + lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length); + } var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry() : watchPresentFileSystemEntry(); @@ -2981,6 +3082,7 @@ var ts; } }; function invokeCallbackAndUpdateWatcher(createWatcher) { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); callback("rename", ""); if (watcher) { watcher.close(); @@ -2997,7 +3099,9 @@ var ts; } } try { - var presentWatcher = _fs.watch(fileOrDirectory, options, callback); + var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ? + callbackChangingToMissingFileSystemEntry : + callback); presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); }); return presentWatcher; } @@ -3005,7 +3109,17 @@ var ts; return watchPresentFileSystemEntryWithFsWatchFile(); } } + function callbackChangingToMissingFileSystemEntry(event, relativeName) { + return event === "rename" && + (!relativeName || + relativeName === lastDirectoryPart || + relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) && + !fileSystemEntryExists(fileOrDirectory, entryKind) ? + invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) : + callback(event, relativeName); + } function watchPresentFileSystemEntryWithFsWatchFile() { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile"); return fallbackPollingWatchFile(fileOrDirectory, createFileWatcherCallback(callback), pollingInterval); } function watchMissingFileSystemEntry() { @@ -3031,7 +3145,7 @@ var ts; function createWatchDirectoryUsing(fsWatchFile) { return function (directoryName, callback) { return fsWatchFile(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium); }; } - function readFile(fileName, _encoding) { + function readFileWorker(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -3054,7 +3168,14 @@ var ts; } return buffer.toString("utf8"); } + function readFile(fileName, _encoding) { + ts.perfLogger.logStartReadFile(fileName); + var file = readFileWorker(fileName, _encoding); + ts.perfLogger.logStopReadFile(); + return file; + } function writeFile(fileName, data, writeByteOrderMark) { + ts.perfLogger.logEvent("WriteFile: " + fileName); if (writeByteOrderMark) { data = byteOrderMarkIndicator + data; } @@ -3070,6 +3191,7 @@ var ts; } } function getAccessibleFileSystemEntries(path) { + ts.perfLogger.logEvent("ReadDir: " + (path || ".")); try { var entries = _fs.readdirSync(path || ".").sort(); var files = []; @@ -3123,6 +3245,7 @@ var ts; return fileSystemEntryExists(path, 1); } function getDirectories(path) { + ts.perfLogger.logEvent("ReadDir: " + path); return ts.filter(_fs.readdirSync(path), function (dir) { return fileSystemEntryExists(ts.combinePaths(path, dir), 1); }); } function realpath(path) { @@ -3304,7 +3427,6 @@ var ts; A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), - An_accessor_cannot_be_declared_in_an_ambient_context: diag(1086, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_declared_in_an_ambient_context_1086", "An accessor cannot be declared in an ambient context."), _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), @@ -3359,7 +3481,6 @@ var ts; Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: diag(1150, ts.DiagnosticCategory.Error, "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", "'new T[]' cannot be used to create an array. Use 'new Array()' instead."), const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), @@ -3457,6 +3578,7 @@ var ts; 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."), Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), 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."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -3489,7 +3611,7 @@ var ts; Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), - The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), @@ -3503,6 +3625,7 @@ var ts; readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), + An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), @@ -4283,6 +4406,8 @@ var ts; Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2: diag(6381, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381", "Project '{0}' is out of date because output for it was generated with version '{1}' that differs with current version '{2}'"), + Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), + Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), 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."), @@ -4398,6 +4523,7 @@ var ts; require_call_may_be_converted_to_an_import: diag(80005, ts.DiagnosticCategory.Suggestion, "require_call_may_be_converted_to_an_import_80005", "'require' call may be converted to an import."), This_may_be_converted_to_an_async_function: diag(80006, ts.DiagnosticCategory.Suggestion, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."), await_has_no_effect_on_the_type_of_this_expression: diag(80007, ts.DiagnosticCategory.Suggestion, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."), + Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, ts.DiagnosticCategory.Suggestion, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."), Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"), Make_super_call_the_first_statement_in_the_constructor: diag(90002, ts.DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"), Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"), @@ -4515,6 +4641,12 @@ var ts; Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"), Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"), Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"), + Enable_the_jsx_flag_in_your_configuration_file: diag(95088, ts.DiagnosticCategory.Message, "Enable_the_jsx_flag_in_your_configuration_file_95088", "Enable the '--jsx' flag in your configuration file"), + Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"), + Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"), + Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"), + Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"), + Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"), 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?"), @@ -4607,14 +4739,17 @@ var ts; _a.yield = 118, _a.async = 122, _a.await = 123, - _a.of = 148, + _a.of = 149, + _a.tag = 148, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 18, "}": 19, "(": 20, ")": 21, "[": 22, "]": 23, ".": 24, "...": 25, ";": 26, ",": 27, "<": 28, ">": 30, "<=": 31, ">=": 32, "==": 33, "!=": 34, "===": 35, "!==": 36, "=>": 37, "+": 38, "-": 39, "**": 41, "*": 40, "/": 42, "%": 43, "++": 44, "--": 45, "<<": 46, ">": 47, ">>>": 48, "&": 49, "|": 50, "^": 51, "!": 52, "~": 53, "&&": 54, "||": 55, "?": 56, ":": 57, "=": 60, "+=": 61, "-=": 62, "*=": 63, "**=": 64, "/=": 65, "%=": 66, "<<=": 67, ">>=": 68, ">>>=": 69, "&=": 70, "|=": 71, "^=": 72, "@": 58, "`": 59 })); + var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18, "}": 19, "(": 20, ")": 21, "[": 22, "]": 23, ".": 24, "...": 25, ";": 26, ",": 27, "<": 28, ">": 30, "<=": 31, ">=": 32, "==": 33, "!=": 34, "===": 35, "!==": 36, "=>": 37, "+": 38, "-": 39, "**": 41, "*": 40, "/": 42, "%": 43, "++": 44, "--": 45, "<<": 46, ">": 47, ">>>": 48, "&": 49, "|": 50, "^": 51, "!": 52, "~": 53, "&&": 54, "||": 55, "?": 56, ":": 57, "=": 60, "+=": 61, "-=": 62, "*=": 63, "**=": 64, "/=": 65, "%=": 66, "<<=": 67, ">>=": 68, ">>>=": 69, "&=": 70, "|=": 71, "^=": 72, "@": 58, "`": 59 })); var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + var unicodeESNextIdentifierStart = [65, 90, 97, 122, 170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2809, 2809, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101]; + var unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2208, 2228, 2230, 2237, 2259, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3328, 3331, 3333, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7673, 7675, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43047, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69376, 69404, 69415, 69415, 69424, 69456, 69600, 69622, 69632, 69702, 69734, 69743, 69759, 69818, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69958, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70096, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70206, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70751, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71680, 71738, 71840, 71913, 71935, 71935, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123584, 123641, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101, 917760, 917999]; function lookupInUnicodeMap(code, map) { if (code < map[0]) { return false; @@ -4638,15 +4773,17 @@ var ts; return false; } function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 1 ? - lookupInUnicodeMap(code, unicodeES5IdentifierStart) : - lookupInUnicodeMap(code, unicodeES3IdentifierStart); + return languageVersion >= 2 ? + lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : + languageVersion === 1 ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 1 ? - lookupInUnicodeMap(code, unicodeES5IdentifierPart) : - lookupInUnicodeMap(code, unicodeES3IdentifierPart); + return languageVersion >= 2 ? + lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : + languageVersion === 1 ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { var result = []; @@ -5069,11 +5206,12 @@ var ts; } ts.isIdentifierPart = isIdentifierPart; function isIdentifierText(name, languageVersion) { - if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { + var ch = codePointAt(name, 0); + if (!isIdentifierStart(ch, languageVersion)) { return false; } - for (var i = 1; i < name.length; i++) { - if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { + for (var i = charSize(ch); i < name.length; i += charSize(ch)) { + if (!isIdentifierPart(ch = codePointAt(name, i), languageVersion)) { return false; } } @@ -5092,13 +5230,14 @@ var ts; var tokenFlags; var inJSDocType = 0; setText(text, start, length); - return { + var scanner = { getStartPos: function () { return startPos; }, getTextPos: function () { return pos; }, getToken: function () { return token; }, getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024) !== 0; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1) !== 0; }, isIdentifier: function () { return token === 73 || token > 109; }, @@ -5126,6 +5265,15 @@ var ts; lookAhead: lookAhead, scanRange: scanRange, }; + if (ts.Debug.isDebugging) { + Object.defineProperty(scanner, "__debugShowCurrentPositionInText", { + get: function () { + var text = scanner.getText(); + return text.slice(0, scanner.getStartPos()) + "║" + text.slice(scanner.getStartPos()); + }, + }); + } + return scanner; function error(message, errPos, length) { if (errPos === void 0) { errPos = pos; } if (onError) { @@ -5225,7 +5373,7 @@ var ts; } } function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) { - if (!isIdentifierStart(text.charCodeAt(pos), languageVersion)) { + if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) { return; } var identifierStart = pos; @@ -5415,6 +5563,7 @@ var ts; pos++; return scanExtendedUnicodeEscape(); } + tokenFlags |= 1024; return scanHexadecimalEscape(4); case 120: return scanHexadecimalEscape(2); @@ -5487,21 +5636,41 @@ var ts; } return -1; } + function peekExtendedUnicodeEscape() { + if (languageVersion >= 2 && codePointAt(text, pos + 1) === 117 && codePointAt(text, pos + 2) === 123) { + var start_2 = pos; + pos += 3; + var escapedValueString = scanMinimumNumberOfHexDigits(1, false); + var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; + pos = start_2; + return escapedValue; + } + return -1; + } function scanIdentifierParts() { var result = ""; var start = pos; while (pos < end) { - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); if (isIdentifierPart(ch, languageVersion)) { - pos++; + pos += charSize(ch); } else if (ch === 92) { + ch = peekExtendedUnicodeEscape(); + if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { + pos += 3; + tokenFlags |= 8; + result += scanExtendedUnicodeEscape(); + start = pos; + continue; + } ch = peekUnicodeEscape(); if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } + tokenFlags |= 1024; result += text.substring(start, pos); - result += String.fromCharCode(ch); + result += utf16EncodeAsString(ch); pos += 6; start = pos; } @@ -5588,7 +5757,7 @@ var ts; if (pos >= end) { return token = 1; } - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); if (skipTrivia) { @@ -5943,9 +6112,17 @@ var ts; pos++; return token = 58; case 92: + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; + tokenFlags |= 1024; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } @@ -5954,9 +6131,9 @@ var ts; return token = 0; default: if (isIdentifierStart(ch, languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; + pos += charSize(ch); + while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) + pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); if (ch === 92) { tokenValue += scanIdentifierParts(); @@ -5964,16 +6141,16 @@ var ts; return token = getIdentifierToken(); } else if (isWhiteSpaceSingleLine(ch)) { - pos++; + pos += charSize(ch); continue; } else if (isLineBreak(ch)) { tokenFlags |= 1; - pos++; + pos += charSize(ch); continue; } error(ts.Diagnostics.Invalid_character); - pos++; + pos += charSize(ch); return token = 0; } } @@ -6104,17 +6281,19 @@ var ts; } function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { - var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { + if (ch === 45) { + tokenValue += "-"; pos++; + continue; } - else { + var oldPos = pos; + tokenValue += scanIdentifierParts(); + if (pos === oldPos) { break; } } - tokenValue += text.substring(firstCharPosition, pos); } return token; } @@ -6135,8 +6314,8 @@ var ts; if (pos >= end) { return token = 1; } - var ch = text.charCodeAt(pos); - pos++; + var ch = codePointAt(text, pos); + pos += charSize(ch); switch (ch) { case 9: case 11: @@ -6174,12 +6353,33 @@ var ts; return token = 24; case 96: return token = 59; - } - if (isIdentifierStart(ch, 99)) { - while (isIdentifierPart(text.charCodeAt(pos), 99) && pos < end) { + case 92: + pos--; + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } + var cookedChar = peekUnicodeEscape(); + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + pos += 6; + tokenFlags |= 1024; + tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); + return token = getIdentifierToken(); + } pos++; - } + return token = 0; + } + if (isIdentifierStart(ch, languageVersion)) { + var char = ch; + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45) + pos += charSize(char); tokenValue = text.substring(tokenPos, pos); + if (char === 92) { + tokenValue += scanIdentifierParts(); + } return token = getIdentifierToken(); } else { @@ -6260,6 +6460,26 @@ var ts; } } ts.createScanner = createScanner; + var codePointAt = String.prototype.codePointAt ? function (s, i) { return s.codePointAt(i); } : function codePointAt(str, i) { + var size = str.length; + if (i < 0 || i >= size) { + return undefined; + } + var first = str.charCodeAt(i); + if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) { + var second = str.charCodeAt(i + 1); + if (second >= 0xDC00 && second <= 0xDFFF) { + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + } + } + return first; + }; + function charSize(ch) { + if (ch >= 0x10000) { + return 2; + } + return 1; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -6419,7 +6639,7 @@ var ts; } ts.copyEntries = copyEntries; function arrayToSet(array, makeKey) { - return ts.arrayToMap(array, makeKey || (function (s) { return s; }), function () { return true; }); + return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue); } ts.arrayToSet = arrayToSet; function cloneMap(map) { @@ -6520,7 +6740,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 285) { + while (node && node.kind !== 286) { node = node.parent; } return node; @@ -6528,11 +6748,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 219: - case 247: - case 226: + case 220: + case 248: case 227: case 228: + case 229: return true; } return false; @@ -6592,7 +6812,7 @@ var ts; break; } } - to.splice.apply(to, [statementIndex, 0].concat(from)); + to.splice.apply(to, __spreadArrays([statementIndex, 0], from)); return to; } function insertStatementAfterPrologue(to, statement, isPrologueDirective) { @@ -6655,7 +6875,7 @@ var ts; if (includeJsDoc && ts.hasJSDocNodes(node)) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 313 && node._children.length > 0) { + if (node.kind === 315 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -6674,7 +6894,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 289 || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 290 || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -6720,13 +6940,21 @@ var ts; return '"' + escapeText(node.text, 34) + '"'; } case 14: - return "`" + escapeText(node.text, 96) + "`"; case 15: - return "`" + escapeText(node.text, 96) + "${"; case 16: - return "}" + escapeText(node.text, 96) + "${"; case 17: - return "}" + escapeText(node.text, 96) + "`"; + var rawText = node.rawText || escapeTemplateSubstitution(escapeText(node.text, 96)); + switch (node.kind) { + case 14: + return "`" + rawText + "`"; + case 15: + return "`" + rawText + "${"; + case 16: + return "}" + rawText + "${"; + case 17: + return "}" + rawText + "`"; + } + break; case 8: case 9: case 13: @@ -6750,7 +6978,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 238 && node.parent.kind === 275; + return node.kind === 239 && node.parent.kind === 276; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -6774,11 +7002,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node && node.kind === 245 && (!node.body); + return node && node.kind === 246 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 285 || - node.kind === 245 || + return node.kind === 286 || + node.kind === 246 || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6792,9 +7020,9 @@ var ts; ts.isExternalModuleAugmentation = isExternalModuleAugmentation; function isModuleAugmentationExternal(node) { switch (node.parent.kind) { - case 285: + case 286: return ts.isExternalModule(node.parent); - case 246: + case 247: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6808,24 +7036,52 @@ var ts; return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS) && !!node.commonJsModuleIndicator); } ts.isEffectiveExternalModule = isEffectiveExternalModule; + function isEffectiveStrictModeSourceFile(node, compilerOptions) { + switch (node.scriptKind) { + case 1: + case 3: + case 2: + case 4: + break; + default: + return false; + } + if (node.isDeclarationFile) { + return false; + } + if (ts.getStrictOptionValue(compilerOptions, "alwaysStrict")) { + return true; + } + if (ts.startsWithUseStrict(node.statements)) { + return true; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + if (ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { + return true; + } + return !compilerOptions.noImplicitUseStrict; + } + return false; + } + ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 285: - case 247: - case 275: - case 245: - case 226: + case 286: + case 248: + case 276: + case 246: case 227: case 228: - case 158: - case 157: + case 229: case 159: + case 158: case 160: - case 240: - case 197: + case 161: + case 241: case 198: + case 199: return true; - case 219: + case 220: return !ts.isFunctionLike(parentNode); } return false; @@ -6833,9 +7089,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 304: - case 311: - case 299: + case 306: + case 313: + case 301: return true; default: ts.assertType(node); @@ -6845,25 +7101,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 161: case 162: - case 156: case 163: - case 166: + case 157: + case 164: case 167: - case 295: - case 241: - case 210: + case 168: + case 296: case 242: + case 211: case 243: - case 310: - case 240: - case 157: + case 244: + case 312: + case 241: case 158: case 159: case 160: - case 197: + case 161: case 198: + case 199: return true; default: ts.assertType(node); @@ -6873,8 +7129,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { + case 251: case 250: - case 249: return true; default: return false; @@ -6883,15 +7139,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { + case 251: case 250: - case 249: - case 220: - case 241: - case 240: - case 245: - case 243: + case 221: case 242: + case 241: + case 246: case 244: + case 243: + case 245: return true; default: return false; @@ -6922,7 +7178,7 @@ var ts; case 8: case 14: return ts.escapeLeadingUnderscores(name.text); - case 150: + case 151: 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"); @@ -6935,9 +7191,9 @@ var ts; switch (name.kind) { case 73: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 149: + case 150: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 190: + case 191: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -6982,7 +7238,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 219) { + if (node.body && node.body.kind === 220) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6994,36 +7250,37 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 285: + case 286: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 238: - case 187: - case 241: - case 210: + case 239: + case 188: case 242: + case 211: + case 243: + case 246: case 245: - case 244: - case 279: - case 240: - case 197: - case 157: - case 159: + case 280: + case 241: + case 198: + case 158: case 160: - case 243: + case 161: + case 244: + case 156: case 155: - case 154: errorNode = node.name; break; - case 198: + case 199: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { return getSpanOfTokenAtPosition(sourceFile, node.pos); } + ts.Debug.assert(!ts.isJSDoc(errorNode)); var isMissing = nodeIsMissing(errorNode); var pos = isMissing || ts.isJsxText(node) ? errorNode.pos @@ -7052,7 +7309,7 @@ var ts; } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 && !ts.isParameterPropertyDeclaration(declaration)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { @@ -7064,19 +7321,25 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 192 && n.expression.kind === 99; + return n.kind === 193 && n.expression.kind === 99; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 192 && n.expression.kind === 93; + return n.kind === 193 && n.expression.kind === 93; } ts.isImportCall = isImportCall; + function isImportMeta(n) { + return ts.isMetaProperty(n) + && n.keywordToken === 93 + && n.name.escapedText === "meta"; + } + ts.isImportMeta = isImportMeta; function isLiteralImportTypeNode(n) { return ts.isImportTypeNode(n) && ts.isLiteralTypeNode(n.argument) && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 222 + return node.kind === 223 && node.expression.kind === 10; } ts.isPrologueDirective = isPrologueDirective; @@ -7085,11 +7348,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 152 || - node.kind === 151 || - node.kind === 197 || + var commentRanges = (node.kind === 153 || + node.kind === 152 || node.kind === 198 || - node.kind === 196) ? + node.kind === 199 || + node.kind === 197) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); return ts.filter(commentRanges, function (comment) { @@ -7104,7 +7367,7 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (164 <= node.kind && node.kind <= 184) { + if (165 <= node.kind && node.kind <= 185) { return true; } switch (node.kind) { @@ -7120,63 +7383,63 @@ var ts; case 133: return true; case 107: - return node.parent.kind !== 201; - case 212: + return node.parent.kind !== 202; + case 213: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 151: - return node.parent.kind === 182 || node.parent.kind === 177; + case 152: + return node.parent.kind === 183 || node.parent.kind === 178; case 73: - if (node.parent.kind === 149 && node.parent.right === node) { + if (node.parent.kind === 150 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 190 && node.parent.name === node) { + else if (node.parent.kind === 191 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 73 || node.kind === 149 || node.kind === 190, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 149: - case 190: + ts.Debug.assert(node.kind === 73 || node.kind === 150 || node.kind === 191, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 150: + case 191: case 101: { var parent = node.parent; - if (parent.kind === 168) { + if (parent.kind === 169) { return false; } - if (parent.kind === 184) { + if (parent.kind === 185) { return !parent.isTypeOf; } - if (164 <= parent.kind && parent.kind <= 184) { + if (165 <= parent.kind && parent.kind <= 185) { return true; } switch (parent.kind) { - case 212: + case 213: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 151: + case 152: return node === parent.constraint; - case 310: + case 312: return node === parent.constraint; + case 156: case 155: - case 154: - case 152: - case 238: + case 153: + case 239: return node === parent.type; - case 240: - case 197: + case 241: case 198: + case 199: + case 159: case 158: case 157: - case 156: - case 159: case 160: - return node === parent.type; case 161: + return node === parent.type; case 162: case 163: + case 164: return node === parent.type; - case 195: + case 196: return node === parent.type; - case 192: case 193: - return ts.contains(parent.typeArguments, node); case 194: + return ts.contains(parent.typeArguments, node); + case 195: return false; } } @@ -7198,23 +7461,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 231: + case 232: return visitor(node); - case 247: - case 219: - case 223: + case 248: + case 220: case 224: case 225: case 226: case 227: case 228: - case 232: + case 229: case 233: - case 272: - case 273: case 234: - case 236: - case 275: + case 273: + case 274: + case 235: + case 237: + case 276: return ts.forEachChild(node, traverse); } } @@ -7224,23 +7487,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 208: + case 209: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 244: - case 242: case 245: case 243: - case 241: - case 210: + case 246: + case 244: + case 242: + case 211: return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 150) { + if (node.name && node.name.kind === 151) { traverse(node.name.expression); return; } @@ -7253,10 +7516,10 @@ var ts; } ts.forEachYieldExpression = forEachYieldExpression; function getRestParameterElementType(node) { - if (node && node.kind === 170) { + if (node && node.kind === 171) { return node.elementType; } - else if (node && node.kind === 165) { + else if (node && node.kind === 166) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -7266,12 +7529,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { + case 243: case 242: - case 241: - case 210: - case 169: + case 211: + case 170: return node.members; - case 189: + case 190: return node.properties; } } @@ -7279,14 +7542,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 187: - case 279: - case 152: - case 276: - case 155: - case 154: + case 188: + case 280: + case 153: case 277: - case 238: + case 156: + case 155: + case 278: + case 239: return true; } } @@ -7298,8 +7561,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 239 - && node.parent.parent.kind === 220; + return node.parent.kind === 240 + && node.parent.parent.kind === 221; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -7310,13 +7573,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 157: - case 156: case 158: + case 157: case 159: case 160: - case 240: - case 197: + case 161: + case 241: + case 198: return true; } return false; @@ -7327,7 +7590,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 234) { + if (node.statement.kind !== 235) { return node.statement; } node = node.statement; @@ -7335,17 +7598,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 219 && ts.isFunctionLike(node.parent); + return node && node.kind === 220 && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 157 && node.parent.kind === 189; + return node && node.kind === 158 && node.parent.kind === 190; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 157 && - (node.parent.kind === 189 || - node.parent.kind === 210); + return node.kind === 158 && + (node.parent.kind === 190 || + node.parent.kind === 211); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -7358,7 +7621,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 276) { + if (property.kind === 277) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -7399,46 +7662,46 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 285); + ts.Debug.assert(node.kind !== 286); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); } switch (node.kind) { - case 150: + case 151: if (ts.isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 153: - if (node.parent.kind === 152 && ts.isClassElement(node.parent.parent)) { + case 154: + if (node.parent.kind === 153 && ts.isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (ts.isClassElement(node.parent)) { node = node.parent; } break; - case 198: + case 199: if (!includeArrowFunctions) { continue; } - case 240: - case 197: - case 245: - case 155: - case 154: - case 157: + case 241: + case 198: + case 246: case 156: + case 155: case 158: + case 157: case 159: case 160: case 161: case 162: case 163: - case 244: - case 285: + case 164: + case 245: + case 286: return node; } } @@ -7448,9 +7711,9 @@ var ts; var container = getThisContainer(node, false); if (container) { switch (container.kind) { - case 158: - case 240: - case 197: + case 159: + case 241: + case 198: return container; } } @@ -7464,25 +7727,25 @@ var ts; return node; } switch (node.kind) { - case 150: + case 151: node = node.parent; break; - case 240: - case 197: + case 241: case 198: + case 199: if (!stopOnFunctions) { continue; } - case 155: - case 154: - case 157: case 156: + case 155: case 158: + case 157: case 159: case 160: + case 161: return node; - case 153: - if (node.parent.kind === 152 && ts.isClassElement(node.parent.parent)) { + case 154: + if (node.parent.kind === 153 && ts.isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (ts.isClassElement(node.parent)) { @@ -7494,14 +7757,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 197 || func.kind === 198) { + if (func.kind === 198 || func.kind === 199) { var prev = func; var parent = func.parent; - while (parent.kind === 196) { + while (parent.kind === 197) { prev = parent; parent = parent.parent; } - if (parent.kind === 192 && parent.expression === prev) { + if (parent.kind === 193 && parent.expression === prev) { return parent; } } @@ -7514,26 +7777,26 @@ var ts; ts.isSuperOrSuperProperty = isSuperOrSuperProperty; function isSuperProperty(node) { var kind = node.kind; - return (kind === 190 || kind === 191) + return (kind === 191 || kind === 192) && node.expression.kind === 99; } ts.isSuperProperty = isSuperProperty; function isThisProperty(node) { var kind = node.kind; - return (kind === 190 || kind === 191) + return (kind === 191 || kind === 192) && node.expression.kind === 101; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 165: + case 166: return node.typeName; - case 212: + case 213: return isEntityNameExpression(node.expression) ? node.expression : undefined; case 73: - case 149: + case 150: return node; } return undefined; @@ -7541,10 +7804,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 194: + case 195: return node.tag; + case 264: case 263: - case 262: return node.tagName; default: return node.expression; @@ -7553,21 +7816,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 241: + case 242: return true; - case 155: - return parent.kind === 241; - case 159: + case 156: + return parent.kind === 242; case 160: - case 157: + case 161: + case 158: return node.body !== undefined - && parent.kind === 241; - case 152: + && parent.kind === 242; + case 153: return parent.body !== undefined - && (parent.kind === 158 - || parent.kind === 157 - || parent.kind === 160) - && grandparent.kind === 241; + && (parent.kind === 159 + || parent.kind === 158 + || parent.kind === 161) + && grandparent.kind === 242; } return false; } @@ -7583,10 +7846,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 241: + case 242: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); - case 157: - case 160: + case 158: + case 161: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); default: return false; @@ -7595,9 +7858,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 263 || - parent.kind === 262 || - parent.kind === 264) { + if (parent.kind === 264 || + parent.kind === 263 || + parent.kind === 265) { return parent.tagName === node; } return false; @@ -7610,45 +7873,45 @@ var ts; case 103: case 88: case 13: - case 188: case 189: case 190: case 191: case 192: case 193: case 194: - case 213: case 195: case 214: case 196: + case 215: case 197: - case 210: case 198: - case 201: + case 211: case 199: + case 202: case 200: - case 203: + case 201: case 204: case 205: case 206: - case 209: case 207: + case 210: + case 208: case 14: - case 211: - case 261: + case 212: case 262: - case 265: - case 208: - case 202: - case 215: + case 263: + case 266: + case 209: + case 203: + case 216: return true; - case 149: - while (node.parent.kind === 149) { + case 150: + while (node.parent.kind === 150) { node = node.parent; } - return node.parent.kind === 168 || isJSXTagName(node); + return node.parent.kind === 169 || isJSXTagName(node); case 73: - if (node.parent.kind === 168 || isJSXTagName(node)) { + if (node.parent.kind === 169 || isJSXTagName(node)) { return true; } case 8: @@ -7664,49 +7927,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 238: - case 152: + case 239: + case 153: + case 156: case 155: - case 154: - case 279: - case 276: - case 187: + case 280: + case 277: + case 188: return parent.initializer === node; - case 222: case 223: case 224: case 225: - case 231: + case 226: case 232: case 233: - case 272: - case 235: + case 234: + case 273: + case 236: return parent.expression === node; - case 226: + case 227: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 239) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 240) || forStatement.condition === node || forStatement.incrementor === node; - case 227: case 228: + case 229: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 239) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 240) || forInStatement.expression === node; - case 195: - case 213: + case 196: + case 214: return node === parent.expression; - case 217: + case 218: return node === parent.expression; - case 150: + case 151: return node === parent.expression; - case 153: + case 154: + case 272: case 271: - case 270: - case 278: + case 279: return true; - case 212: + case 213: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 277: + case 278: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -7714,7 +7977,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 && node.moduleReference.kind === 260; + return node.kind === 250 && node.moduleReference.kind === 261; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7723,7 +7986,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 && node.moduleReference.kind !== 260; + return node.kind === 250 && node.moduleReference.kind !== 261; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -7755,7 +8018,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 192) { + if (callExpression.kind !== 193) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -7851,11 +8114,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 197 || e.kind === 198 ? initializer : undefined; + return e.kind === 198 || e.kind === 199 ? initializer : undefined; } - if (initializer.kind === 197 || - initializer.kind === 210 || - initializer.kind === 198) { + if (initializer.kind === 198 || + initializer.kind === 211 || + initializer.kind === 199) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -7998,7 +8261,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 222 && + expr.parent && expr.parent.kind === 223 && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -8007,7 +8270,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 240 || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 241 || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -8016,14 +8279,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 250: - case 256: + case 251: + case 257: return node.parent; - case 260: + case 261: return node.parent.parent; - case 192: + case 193: return isImportCall(node.parent) || isRequireCall(node.parent, false) ? node.parent : undefined; - case 183: + case 184: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -8033,12 +8296,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 250: - case 256: + case 251: + case 257: return node.moduleSpecifier; - case 249: - return node.moduleReference.kind === 260 ? node.moduleReference.expression : undefined; - case 184: + case 250: + return node.moduleReference.kind === 261 ? node.moduleReference.expression : undefined; + case 185: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -8047,11 +8310,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 250: + case 251: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 249: + case 250: return node; - case 256: + case 257: return undefined; default: return ts.Debug.assertNever(node); @@ -8059,19 +8322,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 250 && !!node.importClause && !!node.importClause.name; + return node.kind === 251 && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 152: + case 153: + case 158: case 157: - case 156: + case 278: case 277: - case 276: + case 156: case 155: - case 154: return node.questionToken !== undefined; } } @@ -8085,7 +8348,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 311 || node.kind === 304; + return node.kind === 313 || node.kind === 306 || node.kind === 307; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -8110,12 +8373,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 220: + case 221: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 155: + case 156: return node.initializer; - case 276: + case 277: return node.initializer; } } @@ -8126,7 +8389,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 245 + node.body.kind === 246 ? node.body : undefined; } @@ -8140,11 +8403,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 152) { + if (node.kind === 153) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 151) { + if (node.kind === 152) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -8155,10 +8418,10 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 276 || - parent.kind === 255 || - parent.kind === 155 || - parent.kind === 222 && node.kind === 190 || + if (parent.kind === 277 || + parent.kind === 256 || + parent.kind === 156 || + parent.kind === 223 && node.kind === 191 || getNestedModuleDeclaration(parent) || ts.isBinaryExpression(node) && node.operatorToken.kind === 60) { return parent; @@ -8212,7 +8475,7 @@ var ts; function getTypeParameterFromJsDoc(node) { var name = node.name.escapedText; var typeParameters = node.parent.parent.parent.typeParameters; - return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); + return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { @@ -8222,38 +8485,38 @@ 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 === 296; + return node.dotDotDotToken !== undefined || !!type && type.kind === 297; } ts.isRestParameter = isRestParameter; function getAssignmentTargetKind(node) { var parent = node.parent; while (true) { switch (parent.kind) { - case 205: + case 206: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 60 ? 1 : 2 : 0; - case 203: case 204: + case 205: var unaryOperator = parent.operator; return unaryOperator === 44 || unaryOperator === 45 ? 2 : 0; - case 227: case 228: + case 229: return parent.initializer === node ? 1 : 0; - case 196: - case 188: - case 209: - case 214: + case 197: + case 189: + case 210: + case 215: node = parent; break; - case 277: + case 278: if (parent.name !== node) { return 0; } node = parent.parent; break; - case 276: + case 277: if (parent.name === node) { return 0; } @@ -8272,22 +8535,22 @@ var ts; ts.isAssignmentTarget = isAssignmentTarget; function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 219: case 220: - case 232: - case 223: + case 221: case 233: - case 247: - case 272: - case 273: + case 224: case 234: - case 226: + case 248: + case 273: + case 274: + case 235: case 227: case 228: - case 224: + case 229: case 225: - case 236: - case 275: + case 226: + case 237: + case 276: return true; } return false; @@ -8304,32 +8567,32 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 178); + return walkUp(node, 179); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 196); + return walkUp(node, 197); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 196) { + while (node.kind === 197) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 196) { + while (node.kind === 197) { node = node.parent; } return node; } function isDeleteTarget(node) { - if (node.kind !== 190 && node.kind !== 191) { + if (node.kind !== 191 && node.kind !== 192) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 199; + return node && node.kind === 200; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -8376,49 +8639,49 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 10 || node.kind === 8) && - node.parent.kind === 150 && + node.parent.kind === 151 && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { + case 156: case 155: - case 154: + case 158: case 157: - case 156: - case 159: case 160: - case 279: - case 276: - case 190: + case 161: + case 280: + case 277: + case 191: return parent.name === node; - case 149: + case 150: if (parent.right === node) { - while (parent.kind === 149) { + while (parent.kind === 150) { parent = parent.parent; } - return parent.kind === 168 || parent.kind === 165; + return parent.kind === 169 || parent.kind === 166; } return false; - case 187: - case 254: + case 188: + case 255: return parent.propertyName === node; - case 258: - case 268: + case 259: + case 269: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 249 || - node.kind === 248 || - node.kind === 251 && !!node.name || - node.kind === 252 || - node.kind === 254 || - node.kind === 258 || - node.kind === 255 && exportAssignmentIsAlias(node) || + return node.kind === 250 || + node.kind === 249 || + node.kind === 252 && !!node.name || + node.kind === 253 || + node.kind === 255 || + node.kind === 259 || + node.kind === 256 && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -8449,9 +8712,9 @@ var ts; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getAllSuperTypeNodes(node) { - return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray - : ts.emptyArray; + return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray : + ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : + ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { @@ -8482,17 +8745,21 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 74 <= token && token <= 148; + return 74 <= token && token <= 149; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 119 <= token && token <= 148; + return 119 <= token && token <= 149; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { return isKeyword(token) && !isContextualKeyword(token); } ts.isNonContextualKeyword = isNonContextualKeyword; + function isFutureReservedKeyword(token) { + return 110 <= token && token <= 118; + } + ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { var token = ts.stringToToken(name); return token !== undefined && isNonContextualKeyword(token); @@ -8513,13 +8780,13 @@ var ts; } var flags = 0; switch (node.kind) { - case 240: - case 197: - case 157: + case 241: + case 198: + case 158: if (node.asteriskToken) { flags |= 1; } - case 198: + case 199: if (hasModifier(node, 256)) { flags |= 2; } @@ -8533,10 +8800,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 240: - case 197: + case 241: case 198: - case 157: + case 199: + case 158: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256); @@ -8558,7 +8825,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 150 && + return name.kind === 151 && !isStringOrNumericLiteralLike(name.expression) && !isSignedNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); @@ -8575,7 +8842,7 @@ var ts; case 10: case 8: return ts.escapeLeadingUnderscores(name.text); - case 150: + case 151: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -8627,11 +8894,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 152; + return root.kind === 153; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 187) { + while (node.kind === 188) { node = node.parent.parent; } return node; @@ -8639,15 +8906,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 158 - || kind === 197 - || kind === 240 + return kind === 159 || kind === 198 - || kind === 157 - || kind === 159 + || kind === 241 + || kind === 199 + || kind === 158 || kind === 160 - || kind === 245 - || kind === 285; + || kind === 161 + || kind === 246 + || kind === 286; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -8661,23 +8928,23 @@ var ts; ts.getOriginalSourceFile = getOriginalSourceFile; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 && expression.arguments !== undefined; + var hasArguments = expression.kind === 194 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 193: + case 194: return hasArguments ? 0 : 1; - case 203: - case 200: + case 204: case 201: - case 199: case 202: - case 206: - case 208: + case 200: + case 203: + case 207: + case 209: return 1; - case 205: + case 206: switch (operator) { case 41: case 60: @@ -8701,15 +8968,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 && expression.arguments !== undefined; + var hasArguments = expression.kind === 194 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 205) { + if (expression.kind === 206) { return expression.operatorToken.kind; } - else if (expression.kind === 203 || expression.kind === 204) { + else if (expression.kind === 204 || expression.kind === 205) { return expression.operator; } else { @@ -8719,15 +8986,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 316: + case 318: return 0; - case 209: + case 210: return 1; - case 208: + case 209: return 2; - case 206: + case 207: return 4; - case 205: + case 206: switch (operatorKind) { case 27: return 0; @@ -8748,21 +9015,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } - case 203: - case 200: + case 204: case 201: - case 199: case 202: + case 200: + case 203: return 16; - case 204: + case 205: return 17; - case 192: - return 18; case 193: - return hasArguments ? 19 : 18; + return 18; case 194: - case 190: + return hasArguments ? 19 : 18; + case 195: case 191: + case 192: return 19; case 101: case 99: @@ -8773,19 +9040,19 @@ var ts; case 8: case 9: case 10: - case 188: case 189: - case 197: + case 190: case 198: - case 210: - case 261: + case 199: + case 211: case 262: - case 265: + case 263: + case 266: case 13: case 14: - case 207: - case 196: - case 211: + case 208: + case 197: + case 212: return 20; default: return -1; @@ -8902,9 +9169,13 @@ var ts; } } ts.createDiagnosticCollection = createDiagnosticCollection; + var templateSubstitutionRegExp = /\$\{/g; + function escapeTemplateSubstitution(str) { + return str.replace(templateSubstitutionRegExp, "\\${"); + } var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var backtickQuoteEscapedCharsRegExp = /[\\\`\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var backtickQuoteEscapedCharsRegExp = /[\\\`]/g; var escapedCharsMap = ts.createMapFromTemplate({ "\t": "\\t", "\v": "\\v", @@ -9068,7 +9339,7 @@ var ts; }; } ts.createTextWriter = createTextWriter; - function getTrailingSemicolonOmittingWriter(writer) { + function getTrailingSemicolonDeferringWriter(writer) { var pendingTrailingSemicolon = false; function commitPendingTrailingSemicolon() { if (pendingTrailingSemicolon) { @@ -9076,7 +9347,7 @@ var ts; pendingTrailingSemicolon = false; } } - return __assign({}, writer, { writeTrailingSemicolon: function () { + return __assign(__assign({}, writer), { writeTrailingSemicolon: function () { pendingTrailingSemicolon = true; }, writeLiteral: function (s) { @@ -9130,6 +9401,17 @@ var ts; decreaseIndent: function () { commitPendingTrailingSemicolon(); writer.decreaseIndent(); + }, + resetPendingTrailingSemicolon: function () { + pendingTrailingSemicolon = false; + } }); + } + ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter; + function getTrailingSemicolonOmittingWriter(writer) { + var deferringWriter = getTrailingSemicolonDeferringWriter(writer); + return __assign(__assign({}, deferringWriter), { writeLine: function () { + deferringWriter.resetPendingTrailingSemicolon(); + writer.writeLine(); } }); } ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; @@ -9237,6 +9519,7 @@ var ts; return accessor.parameters[hasThis ? 1 : 0]; } } + ts.getSetAccessorValueParameter = getSetAccessorValueParameter; function getSetAccessorTypeAnnotationNode(accessor) { var parameter = getSetAccessorValueParameter(accessor); return parameter && parameter.type; @@ -9270,10 +9553,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 159) { + if (accessor.kind === 160) { getAccessor = accessor; } - else if (accessor.kind === 160) { + else if (accessor.kind === 161) { setAccessor = accessor; } else { @@ -9293,10 +9576,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 159 && !getAccessor) { + if (member.kind === 160 && !getAccessor) { getAccessor = member; } - if (member.kind === 160 && !setAccessor) { + if (member.kind === 161 && !setAccessor) { setAccessor = member; } } @@ -9333,7 +9616,7 @@ var ts; } ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 297 && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 299 && tag.parent.tags.some(isJSDocTypeAlias)); } function getEffectiveSetAccessorTypeAnnotationNode(node) { var parameter = getSetAccessorValueParameter(node); @@ -9582,8 +9865,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, true)) { var kind = node.left.kind; - return kind === 189 - || kind === 188; + return kind === 190 + || kind === 189; } return false; } @@ -9615,17 +9898,17 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 149 && node.parent.right === node) || - (node.parent.kind === 190 && node.parent.name === node); + return (node.parent.kind === 150 && node.parent.right === node) || + (node.parent.kind === 191 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 189 && + return expression.kind === 190 && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 188 && + return expression.kind === 189 && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -9863,8 +10146,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 244: case 245: + case 246: return parseNode === parseNode.parent.name; } } @@ -9930,32 +10213,32 @@ var ts; if (!parent) return 0; switch (parent.kind) { - case 196: + case 197: return accessKind(parent); + case 205: case 204: - case 203: var operator = parent.operator; return operator === 44 || operator === 45 ? writeOrReadWrite() : 0; - case 205: + case 206: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? operatorToken.kind === 60 ? 1 : writeOrReadWrite() : 0; - case 190: + case 191: return parent.name !== node ? 0 : accessKind(parent); - case 276: { + case 277: { var parentAccess = accessKind(parent.parent); return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 277: + case 278: return node === parent.objectAssignmentInitializer ? 0 : accessKind(parent.parent); - case 188: + case 189: return accessKind(parent); default: return 0; } function writeOrReadWrite() { - return parent.parent && skipParenthesesUp(parent.parent).kind === 222 ? 1 : 2; + return parent.parent && skipParenthesesUp(parent.parent).kind === 223 ? 1 : 2; } } function reverseAccessKind(a) { @@ -9994,8 +10277,8 @@ var ts; map.clear(); } ts.clearMap = clearMap; - function mutateMap(map, newMap, options) { - var createNewValue = options.createNewValue, onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; + function mutateMapSkippingNewValues(map, newMap, options) { + var onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; map.forEach(function (existingValue, key) { var valueInNewMap = newMap.get(key); if (valueInNewMap === undefined) { @@ -10006,6 +10289,11 @@ var ts; onExistingValue(existingValue, valueInNewMap, key); } }); + } + ts.mutateMapSkippingNewValues = mutateMapSkippingNewValues; + function mutateMap(map, newMap, options) { + mutateMapSkippingNewValues(map, newMap, options); + var createNewValue = options.createNewValue; newMap.forEach(function (valueInNewMap, key) { if (!map.has(key)) { map.set(key, createNewValue(key, valueInNewMap)); @@ -10095,7 +10383,7 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 164 && kind <= 184) + return (kind >= 165 && kind <= 185) || kind === 121 || kind === 144 || kind === 136 @@ -10109,18 +10397,18 @@ var ts; || kind === 142 || kind === 97 || kind === 133 - || kind === 212 - || kind === 290 + || kind === 213 || kind === 291 || kind === 292 || kind === 293 || kind === 294 || kind === 295 - || kind === 296; + || kind === 296 + || kind === 297; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 190 || node.kind === 191; + return node.kind === 191 || node.kind === 192; } ts.isAccessExpression = isAccessExpression; function isBundleFileTextLike(section) { @@ -10266,17 +10554,17 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 151) { + if (d && d.kind === 152) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 242) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 243) { return current; } } } } ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 158; + function isParameterPropertyDeclaration(node, parent) { + return ts.hasModifier(node, 92) && parent.kind === 159; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -10306,14 +10594,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 238) { + if (node.kind === 239) { node = node.parent; } - if (node && node.kind === 239) { + if (node && node.kind === 240) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 220) { + if (node && node.kind === 221) { flags |= getFlags(node); } return flags; @@ -10424,27 +10712,30 @@ var ts; return getDeclarationIdentifier(hostNode); } switch (hostNode.kind) { - case 220: + case 221: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 222: + case 223: var expr = hostNode.expression; + if (expr.kind === 206 && expr.operatorToken.kind === 60) { + expr = expr.left; + } switch (expr.kind) { - case 190: - return expr.name; case 191: + return expr.name; + case 192: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 196: { + case 197: { return getDeclarationIdentifier(hostNode.expression); } - case 234: { + case 235: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -10468,16 +10759,16 @@ var ts; switch (declaration.kind) { case 73: return declaration; - case 312: - case 306: { + case 314: + case 308: { var name = declaration.name; - if (name.kind === 149) { + if (name.kind === 150) { return name.right; } break; } - case 192: - case 205: { + case 193: + case 206: { var expr = declaration; switch (ts.getAssignmentDeclarationKind(expr)) { case 1: @@ -10493,9 +10784,11 @@ var ts; return undefined; } } - case 311: + case 313: return getNameOfJSDocTypedef(declaration); - case 255: { + case 307: + return nameForNamelessJSDocTypedef(declaration); + case 256: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } @@ -10638,7 +10931,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 297); + ts.Debug.assert(node.parent.kind === 299); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -10658,10 +10951,9 @@ var ts; } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getEffectiveConstraintOfTypeParameter(node) { - return node.constraint ? node.constraint - : ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] - ? node.parent.constraint - : undefined; + return node.constraint ? node.constraint : + ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint : + undefined; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; })(ts || (ts = {})); @@ -10707,187 +10999,187 @@ var ts; } ts.isIdentifier = isIdentifier; function isQualifiedName(node) { - return node.kind === 149; + return node.kind === 150; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 150; + return node.kind === 151; } ts.isComputedPropertyName = isComputedPropertyName; function isTypeParameterDeclaration(node) { - return node.kind === 151; + return node.kind === 152; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 152; + return node.kind === 153; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 153; + return node.kind === 154; } ts.isDecorator = isDecorator; function isPropertySignature(node) { - return node.kind === 154; + return node.kind === 155; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 155; + return node.kind === 156; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 156; + return node.kind === 157; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 157; + return node.kind === 158; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 158; + return node.kind === 159; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 159; + return node.kind === 160; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 160; + return node.kind === 161; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 161; + return node.kind === 162; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 162; + return node.kind === 163; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 163; + return node.kind === 164; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; function isGetOrSetAccessorDeclaration(node) { - return node.kind === 160 || node.kind === 159; + return node.kind === 161 || node.kind === 160; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isTypePredicateNode(node) { - return node.kind === 164; + return node.kind === 165; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 165; + return node.kind === 166; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 166; + return node.kind === 167; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 167; + return node.kind === 168; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 168; + return node.kind === 169; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 169; + return node.kind === 170; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 170; + return node.kind === 171; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 171; + return node.kind === 172; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 174; + return node.kind === 175; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 175; + return node.kind === 176; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 176; + return node.kind === 177; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 177; + return node.kind === 178; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 178; + return node.kind === 179; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 179; + return node.kind === 180; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 180; + return node.kind === 181; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 181; + return node.kind === 182; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 182; + return node.kind === 183; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 183; + return node.kind === 184; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 184; + return node.kind === 185; } ts.isImportTypeNode = isImportTypeNode; function isObjectBindingPattern(node) { - return node.kind === 185; + return node.kind === 186; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 186; + return node.kind === 187; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 187; + return node.kind === 188; } ts.isBindingElement = isBindingElement; function isArrayLiteralExpression(node) { - return node.kind === 188; + return node.kind === 189; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 189; + return node.kind === 190; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 190; + return node.kind === 191; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 191; + return node.kind === 192; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 192; + return node.kind === 193; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 193; + return node.kind === 194; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 194; + return node.kind === 195; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 195; + return node.kind === 196; } ts.isTypeAssertion = isTypeAssertion; function isConstTypeReference(node) { @@ -10896,368 +11188,368 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function isParenthesizedExpression(node) { - return node.kind === 196; + return node.kind === 197; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 315) { + while (node.kind === 317) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 197; + return node.kind === 198; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 198; + return node.kind === 199; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 199; + return node.kind === 200; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 200; + return node.kind === 201; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 201; + return node.kind === 202; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 202; + return node.kind === 203; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 203; + return node.kind === 204; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 204; + return node.kind === 205; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 205; + return node.kind === 206; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 206; + return node.kind === 207; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 207; + return node.kind === 208; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 208; + return node.kind === 209; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 209; + return node.kind === 210; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 210; + return node.kind === 211; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 211; + return node.kind === 212; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 212; + return node.kind === 213; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 213; + return node.kind === 214; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 214; + return node.kind === 215; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 215; + return node.kind === 216; } ts.isMetaProperty = isMetaProperty; function isTemplateSpan(node) { - return node.kind === 217; + return node.kind === 218; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 218; + return node.kind === 219; } ts.isSemicolonClassElement = isSemicolonClassElement; function isBlock(node) { - return node.kind === 219; + return node.kind === 220; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 220; + return node.kind === 221; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 221; + return node.kind === 222; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 222; + return node.kind === 223; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 223; + return node.kind === 224; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 224; + return node.kind === 225; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 225; + return node.kind === 226; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 226; + return node.kind === 227; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 227; + return node.kind === 228; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 228; + return node.kind === 229; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 229; + return node.kind === 230; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 230; + return node.kind === 231; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 230 || node.kind === 229; + return node.kind === 231 || node.kind === 230; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 231; + return node.kind === 232; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 232; + return node.kind === 233; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 233; + return node.kind === 234; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 234; + return node.kind === 235; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 235; + return node.kind === 236; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 236; + return node.kind === 237; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 237; + return node.kind === 238; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 238; + return node.kind === 239; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 239; + return node.kind === 240; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 240; + return node.kind === 241; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 241; + return node.kind === 242; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 242; + return node.kind === 243; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 243; + return node.kind === 244; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 244; + return node.kind === 245; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 245; + return node.kind === 246; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 246; + return node.kind === 247; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 247; + return node.kind === 248; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 248; + return node.kind === 249; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 249; + return node.kind === 250; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 250; + return node.kind === 251; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 251; + return node.kind === 252; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 252; + return node.kind === 253; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 253; + return node.kind === 254; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 254; + return node.kind === 255; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 255; + return node.kind === 256; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 256; + return node.kind === 257; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 257; + return node.kind === 258; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 258; + return node.kind === 259; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 259; + return node.kind === 260; } ts.isMissingDeclaration = isMissingDeclaration; function isExternalModuleReference(node) { - return node.kind === 260; + return node.kind === 261; } ts.isExternalModuleReference = isExternalModuleReference; function isJsxElement(node) { - return node.kind === 261; + return node.kind === 262; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 262; + return node.kind === 263; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 263; + return node.kind === 264; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 264; + return node.kind === 265; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 265; + return node.kind === 266; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 266; + return node.kind === 267; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 267; + return node.kind === 268; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 268; + return node.kind === 269; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 269; + return node.kind === 270; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 270; + return node.kind === 271; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 271; + return node.kind === 272; } ts.isJsxExpression = isJsxExpression; function isCaseClause(node) { - return node.kind === 272; + return node.kind === 273; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 273; + return node.kind === 274; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 274; + return node.kind === 275; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 275; + return node.kind === 276; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 276; + return node.kind === 277; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 277; + return node.kind === 278; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 278; + return node.kind === 279; } ts.isSpreadAssignment = isSpreadAssignment; function isEnumMember(node) { - return node.kind === 279; + return node.kind === 280; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 285; + return node.kind === 286; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 286; + return node.kind === 287; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 287; + return node.kind === 288; } ts.isUnparsedSource = isUnparsedSource; function isUnparsedPrepend(node) { - return node.kind === 281; + return node.kind === 282; } ts.isUnparsedPrepend = isUnparsedPrepend; function isUnparsedTextLike(node) { switch (node.kind) { - case 282: case 283: + case 284: return true; default: return false; @@ -11266,110 +11558,110 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 280 || - node.kind === 284; + node.kind === 281 || + node.kind === 285; } ts.isUnparsedNode = isUnparsedNode; function isJSDocTypeExpression(node) { - return node.kind === 289; + return node.kind === 290; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 290; + return node.kind === 291; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 291; + return node.kind === 292; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 292; + return node.kind === 293; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 293; + return node.kind === 294; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 294; + return node.kind === 295; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 295; + return node.kind === 296; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 296; + return node.kind === 297; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 297; + return node.kind === 299; } ts.isJSDoc = isJSDoc; function isJSDocAuthorTag(node) { - return node.kind === 302; + return node.kind === 304; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocAugmentsTag(node) { - return node.kind === 301; + return node.kind === 303; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 303; + return node.kind === 305; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 305; + return node.kind === 307; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 308; + return node.kind === 310; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 306; + return node.kind === 308; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 307; + return node.kind === 309; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 309; + return node.kind === 311; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 310; + return node.kind === 312; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 311; + return node.kind === 313; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 312; + return node.kind === 314; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 312 || node.kind === 306; + return node.kind === 314 || node.kind === 308; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 298; + return node.kind === 300; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 304; + return node.kind === 306; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 299; + return node.kind === 301; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); (function (ts) { function isSyntaxList(n) { - return n.kind === 313; + return n.kind === 315; } ts.isSyntaxList = isSyntaxList; function isNode(node) { @@ -11377,11 +11669,11 @@ var ts; } ts.isNode = isNode; function isNodeKind(kind) { - return kind >= 149; + return kind >= 150; } ts.isNodeKind = isNodeKind; function isToken(n) { - return n.kind >= 0 && n.kind <= 148; + return n.kind >= 0 && n.kind <= 149; } ts.isToken = isToken; function isNodeArray(array) { @@ -11454,7 +11746,7 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 149 + return kind === 150 || kind === 73; } ts.isEntityName = isEntityName; @@ -11463,14 +11755,14 @@ var ts; return kind === 73 || kind === 10 || kind === 8 - || kind === 150; + || kind === 151; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; return kind === 73 - || kind === 185 - || kind === 186; + || kind === 186 + || kind === 187; } ts.isBindingName = isBindingName; function isFunctionLike(node) { @@ -11483,13 +11775,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 240: - case 157: + case 241: case 158: case 159: case 160: - case 197: + case 161: case 198: + case 199: return true; default: return false; @@ -11497,14 +11789,14 @@ var ts; } function isFunctionLikeKind(kind) { switch (kind) { - case 156: - case 161: - case 299: + case 157: case 162: + case 301: case 163: - case 166: - case 295: + case 164: case 167: + case 296: + case 168: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -11517,28 +11809,28 @@ var ts; ts.isFunctionOrModuleBlock = isFunctionOrModuleBlock; function isClassElement(node) { var kind = node.kind; - return kind === 158 - || kind === 155 - || kind === 157 - || kind === 159 + return kind === 159 + || kind === 156 + || kind === 158 || kind === 160 - || kind === 163 - || kind === 218; + || kind === 161 + || kind === 164 + || kind === 219; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 241 || node.kind === 210); + return node && (node.kind === 242 || node.kind === 211); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 159 || node.kind === 160); + return node && (node.kind === 160 || node.kind === 161); } ts.isAccessor = isAccessor; function isMethodOrAccessor(node) { switch (node.kind) { - case 157: - case 159: + case 158: case 160: + case 161: return true; default: return false; @@ -11547,11 +11839,11 @@ var ts; ts.isMethodOrAccessor = isMethodOrAccessor; function isTypeElement(node) { var kind = node.kind; - return kind === 162 - || kind === 161 - || kind === 154 - || kind === 156 - || kind === 163; + return kind === 163 + || kind === 162 + || kind === 155 + || kind === 157 + || kind === 164; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -11560,12 +11852,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 276 - || kind === 277 + return kind === 277 || kind === 278 - || kind === 157 - || kind === 159 - || kind === 160; + || kind === 279 + || kind === 158 + || kind === 160 + || kind === 161; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNode(node) { @@ -11574,8 +11866,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 166: case 167: + case 168: return true; } return false; @@ -11584,29 +11876,29 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 186 - || kind === 185; + return kind === 187 + || kind === 186; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 188 - || kind === 189; + return kind === 189 + || kind === 190; } ts.isAssignmentPattern = isAssignmentPattern; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 187 - || kind === 211; + return kind === 188 + || kind === 212; } ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 238: - case 152: - case 187: + case 239: + case 153: + case 188: return true; } return false; @@ -11619,8 +11911,8 @@ var ts; ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 185: - case 189: + case 186: + case 190: return true; } return false; @@ -11628,8 +11920,8 @@ var ts; ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 186: - case 188: + case 187: + case 189: return true; } return false; @@ -11637,25 +11929,25 @@ var ts; ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 190 - || kind === 149 - || kind === 184; + return kind === 191 + || kind === 150 + || kind === 185; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 190 - || kind === 149; + return kind === 191 + || kind === 150; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { + case 264: case 263: - case 262: - case 192: case 193: case 194: - case 153: + case 195: + case 154: return true; default: return false; @@ -11663,12 +11955,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 192 || node.kind === 193; + return node.kind === 193 || node.kind === 194; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 207 + return kind === 208 || kind === 14; } ts.isTemplateLiteral = isTemplateLiteral; @@ -11678,33 +11970,33 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 190: case 191: - case 193: case 192: - case 261: - case 262: - case 265: case 194: - case 188: - case 196: + case 193: + case 262: + case 263: + case 266: + case 195: case 189: - case 210: case 197: + case 190: + case 211: + case 198: case 73: case 13: case 8: case 9: case 10: case 14: - case 207: + case 208: case 88: case 97: case 101: case 103: case 99: - case 214: case 215: + case 216: case 93: return true; default: @@ -11717,13 +12009,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 203: case 204: - case 199: + case 205: case 200: case 201: case 202: - case 195: + case 203: + case 196: return true; default: return isLeftHandSideExpressionKind(kind); @@ -11731,9 +12023,9 @@ var ts; } function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 204: + case 205: return true; - case 203: + case 204: return expr.operator === 44 || expr.operator === 45; default: @@ -11747,15 +12039,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 206: - case 208: - case 198: - case 205: + case 207: case 209: - case 213: - case 211: - case 316: - case 315: + case 199: + case 206: + case 210: + case 214: + case 212: + case 318: + case 317: return true; default: return isUnaryExpressionKind(kind); @@ -11763,16 +12055,16 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 195 - || kind === 213; + return kind === 196 + || kind === 214; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 315; + return node.kind === 317; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 314; + return node.kind === 316; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -11782,20 +12074,20 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 226: case 227: case 228: - case 224: + case 229: case 225: + case 226: return true; - case 234: + case 235: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isForInOrOfStatement(node) { - return node.kind === 227 || node.kind === 228; + return node.kind === 228 || node.kind === 229; } ts.isForInOrOfStatement = isForInOrOfStatement; function isConciseBody(node) { @@ -11814,108 +12106,108 @@ var ts; ts.isForInitializer = isForInitializer; function isModuleBody(node) { var kind = node.kind; - return kind === 246 - || kind === 245 + return kind === 247 + || kind === 246 || kind === 73; } ts.isModuleBody = isModuleBody; function isNamespaceBody(node) { var kind = node.kind; - return kind === 246 - || kind === 245; + return kind === 247 + || kind === 246; } ts.isNamespaceBody = isNamespaceBody; function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 73 - || kind === 245; + || kind === 246; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 253 - || kind === 252; + return kind === 254 + || kind === 253; } ts.isNamedImportBindings = isNamedImportBindings; function isModuleOrEnumDeclaration(node) { - return node.kind === 245 || node.kind === 244; + return node.kind === 246 || node.kind === 245; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 198 - || kind === 187 + return kind === 199 + || kind === 188 + || kind === 242 + || kind === 211 + || kind === 159 + || kind === 245 + || kind === 280 + || kind === 259 || kind === 241 - || kind === 210 + || kind === 198 + || kind === 160 + || kind === 252 + || kind === 250 + || kind === 255 + || kind === 243 + || kind === 269 || kind === 158 - || kind === 244 - || kind === 279 - || kind === 258 - || kind === 240 - || kind === 197 - || kind === 159 - || kind === 251 - || kind === 249 - || kind === 254 - || kind === 242 - || kind === 268 || kind === 157 + || kind === 246 + || kind === 249 + || kind === 253 + || kind === 153 + || kind === 277 || kind === 156 - || kind === 245 - || kind === 248 - || kind === 252 - || kind === 152 - || kind === 276 || kind === 155 - || kind === 154 - || kind === 160 - || kind === 277 - || kind === 243 - || kind === 151 - || kind === 238 - || kind === 311 - || kind === 304 - || kind === 312; + || kind === 161 + || kind === 278 + || kind === 244 + || kind === 152 + || kind === 239 + || kind === 313 + || kind === 306 + || kind === 314; } function isDeclarationStatementKind(kind) { - return kind === 240 - || kind === 259 - || kind === 241 + return kind === 241 + || kind === 260 || kind === 242 || kind === 243 || kind === 244 || kind === 245 + || kind === 246 + || kind === 251 || kind === 250 - || kind === 249 + || kind === 257 || kind === 256 - || kind === 255 - || kind === 248; + || kind === 249; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 230 + return kind === 231 + || kind === 230 + || kind === 238 + || kind === 225 + || kind === 223 + || kind === 222 + || kind === 228 || kind === 229 - || kind === 237 + || kind === 227 || kind === 224 - || kind === 222 + || kind === 235 + || kind === 232 + || kind === 234 + || kind === 236 + || kind === 237 || kind === 221 - || kind === 227 - || kind === 228 || kind === 226 - || kind === 223 - || kind === 234 - || kind === 231 || kind === 233 - || kind === 235 - || kind === 236 - || kind === 220 - || kind === 225 - || kind === 232 - || kind === 314 - || kind === 318 - || kind === 317; + || kind === 316 + || kind === 320 + || kind === 319; } function isDeclaration(node) { - if (node.kind === 151) { - return (node.parent && node.parent.kind !== 310) || ts.isInJSFile(node); + if (node.kind === 152) { + return (node.parent && node.parent.kind !== 312) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -11936,10 +12228,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 219) + if (node.kind !== 220) return false; if (node.parent !== undefined) { - if (node.parent.kind === 236 || node.parent.kind === 275) { + if (node.parent.kind === 237 || node.parent.kind === 276) { return false; } } @@ -11947,8 +12239,8 @@ var ts; } function isModuleReference(node) { var kind = node.kind; - return kind === 260 - || kind === 149 + return kind === 261 + || kind === 150 || kind === 73; } ts.isModuleReference = isModuleReference; @@ -11956,60 +12248,60 @@ var ts; var kind = node.kind; return kind === 101 || kind === 73 - || kind === 190; + || kind === 191; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 261 - || kind === 271 - || kind === 262 + return kind === 262 + || kind === 272 + || kind === 263 || kind === 11 - || kind === 265; + || kind === 266; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 268 - || kind === 270; + return kind === 269 + || kind === 271; } ts.isJsxAttributeLike = isJsxAttributeLike; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 - || kind === 271; + || kind === 272; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 263 - || kind === 262; + return kind === 264 + || kind === 263; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 272 - || kind === 273; + return kind === 273 + || kind === 274; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isJSDocNode(node) { - return node.kind >= 289 && node.kind <= 312; + return node.kind >= 290 && node.kind <= 314; } ts.isJSDocNode = isJSDocNode; function isJSDocCommentContainingNode(node) { - return node.kind === 297 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 299 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; function isJSDocTag(node) { - return node.kind >= 300 && node.kind <= 312; + return node.kind >= 302 && node.kind <= 314; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 160; + return node.kind === 161; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 159; + return node.kind === 160; } ts.isGetAccessor = isGetAccessor; function hasJSDocNodes(node) { @@ -12030,11 +12322,11 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 268 || node.kind === 270 || isObjectLiteralElementLike(node); + return node.kind === 269 || node.kind === 271 || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; function isTypeReferenceType(node) { - return node.kind === 165 || node.kind === 212; + return node.kind === 166 || node.kind === 213; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -12068,7 +12360,7 @@ var ts; })(ts || (ts = {})); (function (ts) { function isNamedImportsOrExports(node) { - return node.kind === 253 || node.kind === 257; + return node.kind === 254 || node.kind === 258; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -12490,7 +12782,7 @@ var ts; var rest = path.substring(rootLength).split(ts.directorySeparator); if (rest.length && !ts.lastOrUndefined(rest)) rest.pop(); - return [root].concat(rest); + return __spreadArrays([root], rest); } function getPathComponents(path, currentDirectory) { if (currentDirectory === void 0) { currentDirectory = ""; } @@ -12569,7 +12861,7 @@ var ts; for (; start < fromComponents.length; start++) { relative.push(".."); } - return [""].concat(relative, components); + return __spreadArrays([""], relative, components); } ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; function getRelativePathFromFile(from, to, getCanonicalFileName) { @@ -12636,7 +12928,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { paths[_i - 1] = arguments[_i]; } - var combined = ts.some(paths) ? combinePaths.apply(void 0, [path].concat(paths)) : ts.normalizeSlashes(path); + var combined = ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : ts.normalizeSlashes(path); var normalized = ts.getPathFromPathComponents(ts.reducePathComponents(ts.getPathComponents(combined))); return normalized && hasTrailingDirectorySeparator(combined) ? ensureTrailingDirectorySeparator(normalized) : normalized; } @@ -13000,14 +13292,14 @@ var ts; ts.supportedTSExtensionsForExtractExtension = [".d.ts", ".ts", ".tsx"]; ts.supportedJSExtensions = [".js", ".jsx"]; ts.supportedJSAndJsonExtensions = [".js", ".jsx", ".json"]; - var allSupportedExtensions = ts.supportedTSExtensions.concat(ts.supportedJSExtensions); - var allSupportedExtensionsWithJson = ts.supportedTSExtensions.concat(ts.supportedJSExtensions, [".json"]); + var allSupportedExtensions = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions); + var allSupportedExtensionsWithJson = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions, [".json"]); function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && options.allowJs; if (!extraFileExtensions || extraFileExtensions.length === 0) { return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; } - var extensions = (needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions).concat(ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); + var extensions = __spreadArrays(needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions, ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); return ts.deduplicate(extensions, ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } ts.getSupportedExtensions = getSupportedExtensions; @@ -13021,7 +13313,7 @@ var ts; if (supportedExtensions === ts.supportedTSExtensions) { return ts.supportedTSExtensionsWithJson; } - return supportedExtensions.concat([".json"]); + return __spreadArrays(supportedExtensions, [".json"]); } ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { @@ -13389,7 +13681,7 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 285) { + if (kind === 286) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 73) { @@ -13427,19 +13719,19 @@ var ts; } ts.isJSDocLikeText = isJSDocLikeText; function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 148) { + if (!node || node.kind <= 149) { return; } switch (node.kind) { - case 149: + case 150: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 151: + case 152: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 277: + case 278: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -13447,9 +13739,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 278: + case 279: return visitNode(cbNode, node.expression); - case 152: + case 153: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -13457,7 +13749,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 155: + case 156: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -13465,51 +13757,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 154: + case 155: 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 276: + case 277: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 238: + case 239: 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 187: + case 188: 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 166: case 167: - case 161: + case 168: case 162: case 163: + case 164: 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 157: - case 156: case 158: + case 157: case 159: case 160: - case 197: - case 240: + case 161: case 198: + case 241: + case 199: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -13521,345 +13813,345 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 165: + case 166: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 164: + case 165: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 168: - return visitNode(cbNode, node.exprName); case 169: - return visitNodes(cbNode, cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 170: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNode, cbNodes, node.members); case 171: + return visitNode(cbNode, node.elementType); + case 172: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 174: case 175: - return visitNodes(cbNode, cbNodes, node.types); case 176: + return visitNodes(cbNode, cbNodes, node.types); + case 177: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 177: + case 178: return visitNode(cbNode, node.typeParameter); - case 184: + case 185: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 178: - case 180: - return visitNode(cbNode, node.type); + case 179: case 181: + return visitNode(cbNode, node.type); + case 182: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 182: + case 183: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 183: + case 184: return visitNode(cbNode, node.literal); - case 185: case 186: - return visitNodes(cbNode, cbNodes, node.elements); - case 188: + case 187: return visitNodes(cbNode, cbNodes, node.elements); case 189: - return visitNodes(cbNode, cbNodes, node.properties); + return visitNodes(cbNode, cbNodes, node.elements); case 190: + return visitNodes(cbNode, cbNodes, node.properties); + case 191: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 191: + case 192: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 192: case 193: + case 194: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 194: + case 195: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 195: + case 196: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 196: - return visitNode(cbNode, node.expression); - case 199: + case 197: return visitNode(cbNode, node.expression); case 200: return visitNode(cbNode, node.expression); case 201: return visitNode(cbNode, node.expression); - case 203: - return visitNode(cbNode, node.operand); - case 208: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 202: return visitNode(cbNode, node.expression); case 204: return visitNode(cbNode, node.operand); + case 209: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 203: + return visitNode(cbNode, node.expression); case 205: + return visitNode(cbNode, node.operand); + case 206: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 213: + case 214: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 214: - return visitNode(cbNode, node.expression); case 215: + return visitNode(cbNode, node.expression); + case 216: return visitNode(cbNode, node.name); - case 206: + case 207: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 209: + case 210: return visitNode(cbNode, node.expression); - case 219: - case 246: + case 220: + case 247: return visitNodes(cbNode, cbNodes, node.statements); - case 285: + case 286: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 220: + case 221: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 239: + case 240: return visitNodes(cbNode, cbNodes, node.declarations); - case 222: - return visitNode(cbNode, node.expression); case 223: + return visitNode(cbNode, node.expression); + case 224: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 224: + case 225: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 225: + case 226: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226: + case 227: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 227: + case 228: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 228: + case 229: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 229: case 230: - return visitNode(cbNode, node.label); case 231: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.label); case 232: + return visitNode(cbNode, node.expression); + case 233: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 233: + case 234: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 247: + case 248: return visitNodes(cbNode, cbNodes, node.clauses); - case 272: + case 273: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 273: + case 274: return visitNodes(cbNode, cbNodes, node.statements); - case 234: + case 235: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 235: - return visitNode(cbNode, node.expression); case 236: + return visitNode(cbNode, node.expression); + case 237: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 275: + case 276: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 153: + case 154: return visitNode(cbNode, node.expression); - case 241: - case 210: + case 242: + case 211: 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 242: + case 243: 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 243: + case 244: 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 244: + case 245: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 279: + case 280: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 245: + case 246: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 249: + case 250: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 250: + case 251: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 251: + case 252: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 248: - return visitNode(cbNode, node.name); - case 252: + case 249: return visitNode(cbNode, node.name); case 253: - case 257: + return visitNode(cbNode, node.name); + case 254: + case 258: return visitNodes(cbNode, cbNodes, node.elements); - case 256: + case 257: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 254: - case 258: + case 255: + case 259: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 255: + case 256: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 207: + case 208: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 217: + case 218: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 150: + case 151: return visitNode(cbNode, node.expression); - case 274: + case 275: return visitNodes(cbNode, cbNodes, node.types); - case 212: + case 213: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 260: + case 261: return visitNode(cbNode, node.expression); - case 259: + case 260: return visitNodes(cbNode, cbNodes, node.decorators); - case 316: + case 318: return visitNodes(cbNode, cbNodes, node.elements); - case 261: + case 262: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 265: + case 266: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 262: case 263: + case 264: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 269: + case 270: return visitNodes(cbNode, cbNodes, node.properties); - case 268: + case 269: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 270: - return visitNode(cbNode, node.expression); case 271: + return visitNode(cbNode, node.expression); + case 272: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 264: + case 265: return visitNode(cbNode, node.tagName); - case 172: case 173: - case 289: - case 293: - case 292: + case 174: + case 290: case 294: - case 296: - return visitNode(cbNode, node.type); + case 293: case 295: + case 297: + return visitNode(cbNode, node.type); + case 296: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 297: + case 299: return visitNodes(cbNode, cbNodes, node.tags); - case 306: - case 312: + case 308: + case 314: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 302: + case 304: return visitNode(cbNode, node.tagName); - case 301: + case 303: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 310: + case 312: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 311: + case 313: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 289 + node.typeExpression.kind === 290 ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 304: + case 306: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 307: case 309: - case 308: - case 305: + case 311: + case 310: + case 307: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 299: + case 301: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 298: - return ts.forEach(node.jsDocPropertyTags, cbNode); case 300: - case 303: + return ts.forEach(node.jsDocPropertyTags, cbNode); + case 302: + case 305: return visitNode(cbNode, node.tagName); - case 315: + case 317: return visitNode(cbNode, node.expression); } } @@ -13868,12 +14160,14 @@ var ts; if (setParentNodes === void 0) { setParentNodes = false; } ts.performance.mark("beforeParse"); var result; + ts.perfLogger.logStartParseSourceFile(fileName); if (languageVersion === 100) { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, 6); } else { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, scriptKind); } + ts.perfLogger.logStopParseSourceFile(); ts.performance.mark("afterParse"); ts.performance.measure("Parse", "beforeParse", "afterParse"); return result; @@ -13927,6 +14221,7 @@ var ts; var identifiers; var identifierCount; var parsingContext; + var notParenthesizedArrow; var contextFlags; var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { @@ -13970,7 +14265,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(222); + var statement = createNode(223); switch (token()) { case 22: statement.expression = parseArrayLiteralExpression(); @@ -14005,6 +14300,9 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; sourceFile.parseDiagnostics = parseDiagnostics; var result = sourceFile; clearState(); @@ -14052,6 +14350,7 @@ var ts; identifiers = undefined; syntaxCursor = undefined; sourceText = undefined; + notParenthesizedArrow = undefined; } function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { var isDeclarationFile = isDeclarationFileName(fileName); @@ -14110,7 +14409,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { - var sourceFile = new SourceFileConstructor(285, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(286, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -14223,9 +14522,15 @@ var ts; function token() { return currentToken; } - function nextToken() { + function nextTokenWithoutCheck() { return currentToken = scanner.scan(); } + function nextToken() { + if (ts.isKeyword(currentToken) && (scanner.hasUnicodeEscape() || scanner.hasExtendedUnicodeEscape())) { + parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), ts.Diagnostics.Keywords_cannot_contain_escape_characters); + } + return nextTokenWithoutCheck(); + } function nextTokenJSDoc() { return currentToken = scanner.scanJsDocToken(); } @@ -14425,7 +14730,7 @@ var ts; node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); - nextToken(); + nextTokenWithoutCheck(); return finishNode(node); } var reportAtCurrentPosition = token() === 1; @@ -14457,7 +14762,7 @@ var ts; return parsePropertyNameWorker(true); } function parseComputedPropertyName() { - var node = createNode(150); + var node = createNode(151); parseExpected(22); node.expression = allowInAnd(parseExpression); parseExpected(23); @@ -14777,14 +15082,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 158: - case 163: case 159: + case 164: case 160: - case 155: - case 218: + case 161: + case 156: + case 219: return true; - case 157: + case 158: var methodDeclaration = node; var nameIsConstructor = methodDeclaration.name.kind === 73 && methodDeclaration.name.originalKeywordKind === 125; @@ -14796,8 +15101,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 272: case 273: + case 274: return true; } } @@ -14806,65 +15111,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 240: + case 241: + case 221: case 220: - case 219: + case 224: case 223: - case 222: - case 235: + case 236: + case 232: + case 234: case 231: - case 233: case 230: + case 228: case 229: case 227: - case 228: case 226: - case 225: - case 232: - case 221: - case 236: - case 234: - case 224: + case 233: + case 222: case 237: + case 235: + case 225: + case 238: + case 251: case 250: - case 249: + case 257: case 256: - case 255: - case 245: - case 241: + case 246: case 242: - case 244: case 243: + case 245: + case 244: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 279; + return node.kind === 280; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 162: - case 156: case 163: - case 154: - case 161: + case 157: + case 164: + case 155: + case 162: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 238) { + if (node.kind !== 239) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 152) { + if (node.kind !== 153) { return false; } var parameter = node; @@ -14925,7 +15230,7 @@ var ts; if (isListTerminator(kind)) { break; } - parseExpected(27); + parseExpected(27, getExpectedCommaDiagnostic(kind)); if (considerSemicolonAsDelimiter && token() === 26 && !scanner.hasPrecedingLineBreak()) { nextToken(); } @@ -14948,6 +15253,9 @@ var ts; } return result; } + function getExpectedCommaDiagnostic(kind) { + return kind === 6 ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + } function createMissingList() { var list = createNodeArray([], getNodePos()); list.isMissingList = true; @@ -14978,7 +15286,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(149, entity.pos); + var node = createNode(150, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -14993,7 +15301,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(207); + var template = createNode(208); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 15, "Template head has wrong token kind"); var list = []; @@ -15005,7 +15313,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(217); + var span = createNode(218); span.expression = allowInAnd(parseExpression); var literal; if (token() === 19) { @@ -15034,6 +15342,16 @@ var ts; function parseLiteralLikeNode(kind) { var node = createNode(kind); node.text = scanner.getTokenValue(); + switch (kind) { + case 14: + case 15: + case 16: + case 17: + var isLast = kind === 14 || kind === 17; + var tokenText = scanner.getTokenText(); + node.rawText = tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); + break; + } if (scanner.hasExtendedUnicodeEscape()) { node.hasExtendedUnicodeEscape = true; } @@ -15048,7 +15366,7 @@ var ts; return node; } function parseTypeReference() { - var node = createNode(165); + var node = createNode(166); node.typeName = parseEntityName(true, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28) { node.typeArguments = parseBracketedList(20, parseType, 28, 30); @@ -15057,14 +15375,14 @@ var ts; } function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 165: - return ts.nodeIsMissing(node.typeName); case 166: - case 167: { + return ts.nodeIsMissing(node.typeName); + case 167: + case 168: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 178: + case 179: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -15072,20 +15390,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(164, lhs.pos); + var node = createNode(165, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(179); + var node = createNode(180); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(290); + var result = createNode(291); if (postFixEquals) { - return createPostfixType(294, result); + return createPostfixType(295, result); } else { nextToken(); @@ -15093,7 +15411,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(293); + var result = createNode(294); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -15107,28 +15425,28 @@ var ts; token() === 30 || token() === 60 || token() === 50) { - var result = createNode(291, pos); + var result = createNode(292, pos); return finishNode(result); } else { - var result = createNode(292, pos); + var result = createNode(293, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(295); + var result = createNodeWithJSDoc(296); nextToken(); fillSignature(57, 4 | 32, result); return finishNode(result); } - var node = createNode(165); + var node = createNode(166); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(152); + var parameter = createNode(153); if (token() === 101 || token() === 96) { parameter.name = parseIdentifierName(); parseExpected(57); @@ -15138,27 +15456,44 @@ var ts; } function parseJSDocType() { scanner.setInJSDocType(true); + var moduleSpecifier = parseOptionalToken(131); + if (moduleSpecifier) { + var moduleTag = createNode(298, moduleSpecifier.pos); + terminate: while (true) { + switch (token()) { + case 19: + case 1: + case 27: + case 5: + break terminate; + default: + nextTokenJSDoc(); + } + } + scanner.setInJSDocType(false); + return finishNode(moduleTag); + } var dotdotdot = parseOptionalToken(25); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(296, dotdotdot.pos); + var variadic = createNode(297, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 60) { - return createPostfixType(294, type); + return createPostfixType(295, type); } return type; } function parseTypeQuery() { - var node = createNode(168); + var node = createNode(169); parseExpected(105); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(151); + var node = createNode(152); node.name = parseIdentifier(); if (parseOptional(87)) { if (isStartOfType() || !isStartOfExpression()) { @@ -15192,7 +15527,7 @@ var ts; isStartOfType(!isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(152); + var node = createNodeWithJSDoc(153); if (token() === 101) { node.name = createIdentifier(true); node.type = parseParameterType(); @@ -15261,7 +15596,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 162) { + if (kind === 163) { parseExpected(96); } fillSignature(57, 4, node); @@ -15298,7 +15633,7 @@ var ts; return token() === 57 || token() === 27 || token() === 23; } function parseIndexSignatureDeclaration(node) { - node.kind = 163; + node.kind = 164; node.parameters = parseBracketedList(16, parseParameter, 22, 23); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -15308,11 +15643,11 @@ var ts; node.name = parsePropertyName(); node.questionToken = parseOptionalToken(56); if (token() === 20 || token() === 28) { - node.kind = 156; + node.kind = 157; fillSignature(57, 4, node); } else { - node.kind = 154; + node.kind = 155; node.type = parseTypeAnnotation(); if (token() === 60) { node.initializer = parseInitializer(); @@ -15349,10 +15684,10 @@ var ts; } function parseTypeMember() { if (token() === 20 || token() === 28) { - return parseSignatureMember(161); + return parseSignatureMember(162); } if (token() === 96 && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(162); + return parseSignatureMember(163); } var node = createNodeWithJSDoc(0); node.modifiers = parseModifiers(); @@ -15378,7 +15713,7 @@ var ts; return false; } function parseTypeLiteral() { - var node = createNode(169); + var node = createNode(170); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -15404,14 +15739,14 @@ var ts; return token() === 22 && nextTokenIsIdentifier() && nextToken() === 94; } function parseMappedTypeParameter() { - var node = createNode(151); + var node = createNode(152); node.name = parseIdentifier(); parseExpected(94); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(182); + var node = createNode(183); parseExpected(18); if (token() === 134 || token() === 38 || token() === 39) { node.readonlyToken = parseTokenNode(); @@ -15436,23 +15771,23 @@ var ts; function parseTupleElementType() { var pos = getNodePos(); if (parseOptional(25)) { - var node = createNode(173, pos); + var node = createNode(174, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152) && type.kind === 292 && type.pos === type.type.pos) { - type.kind = 172; + if (!(contextFlags & 2097152) && type.kind === 293 && type.pos === type.type.pos) { + type.kind = 173; } return type; } function parseTupleType() { - var node = createNode(171); + var node = createNode(172); node.elementTypes = parseBracketedList(21, parseTupleElementType, 22, 23); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(178); + var node = createNode(179); parseExpected(20); node.type = parseType(); parseExpected(21); @@ -15460,7 +15795,7 @@ var ts; } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(96) ? 167 : 166; + var kind = parseOptional(96) ? 168 : 167; var node = createNodeWithJSDoc(kind, pos); fillSignature(37, 4, node); return finishNode(node); @@ -15470,10 +15805,10 @@ var ts; return token() === 24 ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(183); + var node = createNode(184); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(203); + unaryMinusExpression = createNode(204); unaryMinusExpression.operator = 39; nextToken(); } @@ -15494,7 +15829,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288; - var node = createNode(184); + var node = createNode(185); if (parseOptional(105)) { node.isTypeOf = true; } @@ -15583,6 +15918,7 @@ var ts; case 134: case 140: case 143: + case 148: case 107: case 142: case 97: @@ -15627,25 +15963,25 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 52: - type = createPostfixType(293, type); + type = createPostfixType(294, type); break; case 56: if (!(contextFlags & 2097152) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(292, type); + type = createPostfixType(293, type); break; case 22: parseExpected(22); if (isStartOfType()) { - var node = createNode(181, type.pos); + var node = createNode(182, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(23); type = finishNode(node); } else { - var node = createNode(170, type.pos); + var node = createNode(171, type.pos); node.elementType = type; parseExpected(23); type = finishNode(node); @@ -15664,16 +16000,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(180); + var node = createNode(181); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(177); + var node = createNode(178); parseExpected(128); - var typeParameter = createNode(151); + var typeParameter = createNode(152); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -15684,6 +16020,7 @@ var ts; case 130: case 143: case 134: + case 148: return parseTypeOperator(operator); case 128: return parseInferType(); @@ -15706,10 +16043,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(175, parseTypeOperatorOrHigher, 49); + return parseUnionOrIntersectionType(176, parseTypeOperatorOrHigher, 49); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(174, parseIntersectionTypeOrHigher, 50); + return parseUnionOrIntersectionType(175, parseIntersectionTypeOrHigher, 50); } function isStartOfFunctionType() { if (token() === 28) { @@ -15755,7 +16092,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(164, typePredicateVariable.pos); + var node = createNode(165, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -15780,7 +16117,7 @@ var ts; } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(87)) { - var node = createNode(176, type.pos); + var node = createNode(177, type.pos); node.checkType = type; node.extendsType = parseTypeWorker(true); parseExpected(56); @@ -15903,7 +16240,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(208); + var node = createNode(209); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token() === 40 || isStartOfExpression())) { @@ -15919,13 +16256,13 @@ var ts; ts.Debug.assert(token() === 37, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(198, asyncModifier.pos); + node = createNode(199, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(198, identifier.pos); + node = createNode(199, identifier.pos); } - var parameter = createNode(152, identifier.pos); + var parameter = createNode(153, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); @@ -16045,7 +16382,15 @@ var ts; } } function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(false); + var tokenPos = scanner.getTokenPos(); + if (notParenthesizedArrow && notParenthesizedArrow.has(tokenPos.toString())) { + return undefined; + } + var result = parseParenthesizedArrowFunctionExpressionHead(false); + if (!result) { + (notParenthesizedArrow || (notParenthesizedArrow = ts.createMap())).set(tokenPos.toString(), true); + } + return result; } function tryParseAsyncSimpleArrowFunctionExpression() { if (token() === 122) { @@ -16071,7 +16416,7 @@ var ts; return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(198); + var node = createNodeWithJSDoc(199); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256) ? 2 : 0; if (!fillSignature(57, isAsync, node) && !allowAmbiguity) { @@ -16103,7 +16448,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(206, leftOperand.pos); + var node = createNode(207, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -16118,7 +16463,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 94 || t === 148; + return t === 94 || t === 149; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -16155,39 +16500,39 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(205, left.pos); + var node = createNode(206, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(213, left.pos); + var node = createNode(214, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(203); + var node = createNode(204); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(199); + var node = createNode(200); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(200); + var node = createNode(201); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(201); + var node = createNode(202); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -16202,7 +16547,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(202); + var node = createNode(203); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -16219,7 +16564,7 @@ var ts; if (token() === 41) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 195) { + if (simpleUnaryExpression.kind === 196) { 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 { @@ -16272,7 +16617,7 @@ var ts; } function parseUpdateExpression() { if (token() === 44 || token() === 45) { - var node = createNode(203); + var node = createNode(204); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -16284,7 +16629,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 44 || token() === 45) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(204, expression.pos); + var node = createNode(205, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -16303,7 +16648,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); nextToken(); - var node = createNode(215, fullStart); + var node = createNode(216, fullStart); node.keywordToken = 93; node.name = parseIdentifierName(); expression = finishNode(node); @@ -16334,7 +16679,7 @@ var ts; if (token() === 20 || token() === 24 || token() === 22) { return expression; } - var node = createNode(190, expression.pos); + var node = createNode(191, expression.pos); node.expression = expression; parseExpectedToken(24, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -16343,8 +16688,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 263) { - var node = createNode(261, opening.pos); + if (opening.kind === 264) { + var node = createNode(262, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -16353,22 +16698,22 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 266) { - var node = createNode(265, opening.pos); + else if (opening.kind === 267) { + var node = createNode(266, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 262); + ts.Debug.assert(opening.kind === 263); result = opening; } if (inExpressionContext && token() === 28) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(205, result.pos); + var badNode = createNode(206, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -16425,7 +16770,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(269); + var jsxAttributes = createNode(270); jsxAttributes.properties = parseList(13, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -16433,7 +16778,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(28); if (token() === 30) { - var node_1 = createNode(266, fullStart); + var node_1 = createNode(267, fullStart); scanJsxText(); return finishNode(node_1); } @@ -16442,7 +16787,7 @@ var ts; var attributes = parseJsxAttributes(); var node; if (token() === 30) { - node = createNode(263, fullStart); + node = createNode(264, fullStart); scanJsxText(); } else { @@ -16454,7 +16799,7 @@ var ts; parseExpected(30, undefined, false); scanJsxText(); } - node = createNode(262, fullStart); + node = createNode(263, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -16466,7 +16811,7 @@ var ts; var expression = token() === 101 ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24)) { - var propertyAccess = createNode(190, expression.pos); + var propertyAccess = createNode(191, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -16474,7 +16819,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(271); + var node = createNode(272); if (!parseExpected(18)) { return undefined; } @@ -16497,7 +16842,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(268); + var node = createNode(269); node.name = parseIdentifierName(); if (token() === 60) { switch (scanJsxAttributeValue()) { @@ -16512,7 +16857,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(270); + var node = createNode(271); parseExpected(18); parseExpected(25); node.expression = parseExpression(); @@ -16520,7 +16865,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(264); + var node = createNode(265); parseExpected(29); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -16533,7 +16878,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(267); + var node = createNode(268); parseExpected(29); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -16548,7 +16893,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(195); + var node = createNode(196); parseExpected(28); node.type = parseType(); parseExpected(30); @@ -16559,7 +16904,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(24); if (dotToken) { - var propertyAccess = createNode(190, expression.pos); + var propertyAccess = createNode(191, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -16567,13 +16912,13 @@ var ts; } if (token() === 52 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(214, expression.pos); + var nonNullExpression = createNode(215, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } if (!inDecoratorContext() && parseOptional(22)) { - var indexedAccess = createNode(191, expression.pos); + var indexedAccess = createNode(192, expression.pos); indexedAccess.expression = expression; if (token() === 23) { indexedAccess.argumentExpression = createMissingNode(73, true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); @@ -16600,7 +16945,7 @@ var ts; return token() === 14 || token() === 15; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(194, tag.pos); + var tagExpression = createNode(195, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 14 @@ -16620,7 +16965,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(192, expression.pos); + var callExpr = createNode(193, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -16628,7 +16973,7 @@ var ts; continue; } else if (token() === 20) { - var callExpr = createNode(192, expression.pos); + var callExpr = createNode(193, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -16727,28 +17072,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(196); + var node = createNodeWithJSDoc(197); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); return finishNode(node); } function parseSpreadElement() { - var node = createNode(209); + var node = createNode(210); parseExpected(25); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 25 ? parseSpreadElement() : - token() === 27 ? createNode(211) : + token() === 27 ? createNode(212) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(188); + var node = createNode(189); parseExpected(22); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16760,17 +17105,17 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0); if (parseOptionalToken(25)) { - node.kind = 278; + node.kind = 279; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); if (parseContextualModifier(127)) { - return parseAccessorDeclaration(node, 159); + return parseAccessorDeclaration(node, 160); } if (parseContextualModifier(138)) { - return parseAccessorDeclaration(node, 160); + return parseAccessorDeclaration(node, 161); } var asteriskToken = parseOptionalToken(40); var tokenIsIdentifier = isIdentifier(); @@ -16782,7 +17127,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 57); if (isShorthandPropertyAssignment) { - node.kind = 277; + node.kind = 278; var equalsToken = parseOptionalToken(60); if (equalsToken) { node.equalsToken = equalsToken; @@ -16790,14 +17135,14 @@ var ts; } } else { - node.kind = 276; + node.kind = 277; parseExpected(57); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(189); + var node = createNode(190); parseExpected(18); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16811,7 +17156,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNodeWithJSDoc(197); + var node = createNodeWithJSDoc(198); node.modifiers = parseModifiers(); parseExpected(91); node.asteriskToken = parseOptionalToken(40); @@ -16836,7 +17181,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(96); if (parseOptional(24)) { - var node_2 = createNode(215, fullStart); + var node_2 = createNode(216, fullStart); node_2.keywordToken = 96; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -16853,7 +17198,7 @@ var ts; } break; } - var node = createNode(193, fullStart); + var node = createNode(194, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 20) { @@ -16862,7 +17207,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(219); + var node = createNode(220); if (parseExpected(18, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16893,12 +17238,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(221); + var node = createNode(222); parseExpected(26); return finishNode(node); } function parseIfStatement() { - var node = createNode(223); + var node = createNode(224); parseExpected(92); parseExpected(20); node.expression = allowInAnd(parseExpression); @@ -16908,7 +17253,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(224); + var node = createNode(225); parseExpected(83); node.statement = parseStatement(); parseExpected(108); @@ -16919,7 +17264,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(225); + var node = createNode(226); parseExpected(108); parseExpected(20); node.expression = allowInAnd(parseExpression); @@ -16942,8 +17287,8 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(148) : parseOptional(148)) { - var forOfStatement = createNode(228, pos); + if (awaitToken ? parseExpected(149) : parseOptional(149)) { + var forOfStatement = createNode(229, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -16951,14 +17296,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(94)) { - var forInStatement = createNode(227, pos); + var forInStatement = createNode(228, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(21); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(226, pos); + var forStatement = createNode(227, pos); forStatement.initializer = initializer; parseExpected(26); if (token() !== 26 && token() !== 21) { @@ -16976,7 +17321,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 230 ? 74 : 79); + parseExpected(kind === 231 ? 74 : 79); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -16984,7 +17329,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(231); + var node = createNode(232); parseExpected(98); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -16993,7 +17338,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(232); + var node = createNode(233); parseExpected(109); parseExpected(20); node.expression = allowInAnd(parseExpression); @@ -17002,7 +17347,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(272); + var node = createNode(273); parseExpected(75); node.expression = allowInAnd(parseExpression); parseExpected(57); @@ -17010,7 +17355,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(273); + var node = createNode(274); parseExpected(81); parseExpected(57); node.statements = parseList(3, parseStatement); @@ -17020,12 +17365,12 @@ var ts; return token() === 75 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(233); + var node = createNode(234); parseExpected(100); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); - var caseBlock = createNode(247); + var caseBlock = createNode(248); parseExpected(18); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(19); @@ -17033,14 +17378,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(235); + var node = createNode(236); parseExpected(102); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(236); + var node = createNode(237); parseExpected(104); node.tryBlock = parseBlock(false); node.catchClause = token() === 76 ? parseCatchClause() : undefined; @@ -17051,7 +17396,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(275); + var result = createNode(276); parseExpected(76); if (parseOptional(20)) { result.variableDeclaration = parseVariableDeclaration(); @@ -17064,7 +17409,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(237); + var node = createNode(238); parseExpected(80); parseSemicolon(); return finishNode(node); @@ -17073,12 +17418,12 @@ var ts; var node = createNodeWithJSDoc(0); var expression = allowInAnd(parseExpression); if (expression.kind === 73 && parseOptional(57)) { - node.kind = 234; + node.kind = 235; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 222; + node.kind = 223; node.expression = expression; parseSemicolon(); } @@ -17216,16 +17561,16 @@ var ts; case 18: return parseBlock(false); case 106: - return parseVariableStatement(createNodeWithJSDoc(238)); + return parseVariableStatement(createNodeWithJSDoc(239)); case 112: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(238)); + return parseVariableStatement(createNodeWithJSDoc(239)); } break; case 91: - return parseFunctionDeclaration(createNodeWithJSDoc(240)); + return parseFunctionDeclaration(createNodeWithJSDoc(241)); case 77: - return parseClassDeclaration(createNodeWithJSDoc(241)); + return parseClassDeclaration(createNodeWithJSDoc(242)); case 92: return parseIfStatement(); case 83: @@ -17235,9 +17580,9 @@ var ts; case 90: return parseForOrForInOrForOfStatement(); case 79: - return parseBreakOrContinueStatement(229); - case 74: return parseBreakOrContinueStatement(230); + case 74: + return parseBreakOrContinueStatement(231); case 98: return parseReturnStatement(); case 109: @@ -17282,10 +17627,18 @@ var ts; return modifier.kind === 126; } function parseDeclaration() { + var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); }); + var isAmbient = ts.some(modifiers, isDeclareModifier); + if (isAmbient) { + var node_3 = tryReuseAmbientDeclaration(); + if (node_3) { + return node_3; + } + } var node = createNodeWithJSDoc(0); node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (ts.some(node.modifiers, isDeclareModifier)) { + if (isAmbient) { for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var m = _a[_i]; m.flags |= 4194304; @@ -17296,6 +17649,14 @@ var ts; return parseDeclarationWorker(node); } } + function tryReuseAmbientDeclaration() { + return doInsideOfContext(4194304, function () { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + }); + } function parseDeclarationWorker(node) { switch (token()) { case 106: @@ -17331,7 +17692,7 @@ var ts; } default: if (node.decorators || node.modifiers) { - var missing = createMissingNode(259, true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(260, true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -17353,16 +17714,16 @@ var ts; } function parseArrayBindingElement() { if (token() === 27) { - return createNode(211); + return createNode(212); } - var node = createNode(187); + var node = createNode(188); node.dotDotDotToken = parseOptionalToken(25); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(187); + var node = createNode(188); node.dotDotDotToken = parseOptionalToken(25); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -17378,14 +17739,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(185); + var node = createNode(186); parseExpected(18); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(19); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(186); + var node = createNode(187); parseExpected(22); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(23); @@ -17407,7 +17768,7 @@ var ts; return parseVariableDeclaration(true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(238); + var node = createNode(239); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 73 && token() === 52 && !scanner.hasPrecedingLineBreak()) { @@ -17420,7 +17781,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(239); + var node = createNode(240); switch (token()) { case 106: break; @@ -17434,7 +17795,7 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token() === 148 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 149 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -17449,13 +17810,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 21; } function parseVariableStatement(node) { - node.kind = 220; + node.kind = 221; node.declarationList = parseVariableDeclarationList(false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 240; + node.kind = 241; parseExpected(91); node.asteriskToken = parseOptionalToken(40); node.name = ts.hasModifier(node, 512) ? parseOptionalIdentifier() : parseIdentifier(); @@ -17479,7 +17840,7 @@ var ts; function tryParseConstructorDeclaration(node) { return tryParse(function () { if (parseConstructorName()) { - node.kind = 158; + node.kind = 159; fillSignature(57, 0, node); node.body = parseFunctionBlockOrSemicolon(0, ts.Diagnostics.or_expected); return finishNode(node); @@ -17487,7 +17848,7 @@ var ts; }); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 157; + node.kind = 158; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 : 0; var isAsync = ts.hasModifier(node, 256) ? 2 : 0; @@ -17496,7 +17857,7 @@ var ts; return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 155; + node.kind = 156; if (!node.questionToken && token() === 52 && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } @@ -17571,7 +17932,7 @@ var ts; if (!parseOptional(58)) { break; } - var decorator = createNode(153, decoratorStart); + var decorator = createNode(154, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -17612,7 +17973,7 @@ var ts; } function parseClassElement() { if (token() === 26) { - var result = createNode(218); + var result = createNode(219); nextToken(); return finishNode(result); } @@ -17620,10 +17981,10 @@ var ts; node.decorators = parseDecorators(); node.modifiers = parseModifiers(true); if (parseContextualModifier(127)) { - return parseAccessorDeclaration(node, 159); + return parseAccessorDeclaration(node, 160); } if (parseContextualModifier(138)) { - return parseAccessorDeclaration(node, 160); + return parseAccessorDeclaration(node, 161); } if (token() === 125 || token() === 10) { var constructorDeclaration = tryParseConstructorDeclaration(node); @@ -17648,10 +18009,10 @@ var ts; return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0), 210); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0), 211); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 241); + return parseClassDeclarationOrExpression(node, 242); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -17685,22 +18046,21 @@ var ts; function parseHeritageClause() { var tok = token(); ts.Debug.assert(tok === 87 || tok === 110); - var node = createNode(274); + var node = createNode(275); node.token = tok; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(212); + var node = createNode(213); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 28 - ? parseBracketedList(20, parseType, 28, 30) - : undefined; + return token() === 28 ? + parseBracketedList(20, parseType, 28, 30) : undefined; } function isHeritageClause() { return token() === 87 || token() === 110; @@ -17709,7 +18069,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 242; + node.kind = 243; parseExpected(111); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -17718,7 +18078,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 243; + node.kind = 244; parseExpected(141); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -17728,13 +18088,13 @@ var ts; return finishNode(node); } function parseEnumMember() { - var node = createNodeWithJSDoc(279); + var node = createNodeWithJSDoc(280); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 244; + node.kind = 245; parseExpected(85); node.name = parseIdentifier(); if (parseExpected(18)) { @@ -17747,7 +18107,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(246); + var node = createNode(247); if (parseExpected(18)) { node.statements = parseList(1, parseStatement); parseExpected(19); @@ -17758,7 +18118,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 245; + node.kind = 246; var namespaceFlag = flags & 16; node.flags |= flags; node.name = parseIdentifier(); @@ -17768,7 +18128,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 245; + node.kind = 246; if (token() === 146) { node.name = parseIdentifier(); node.flags |= 512; @@ -17812,7 +18172,7 @@ var ts; return nextToken() === 42; } function parseNamespaceExportDeclaration(node) { - node.kind = 248; + node.kind = 249; parseExpected(120); parseExpected(132); node.name = parseIdentifier(); @@ -17829,7 +18189,7 @@ var ts; return parseImportEqualsDeclaration(node, identifier); } } - node.kind = 250; + node.kind = 251; if (identifier || token() === 40 || token() === 18) { @@ -17841,7 +18201,7 @@ var ts; return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 249; + node.kind = 250; node.name = identifier; parseExpected(60); node.moduleReference = parseModuleReference(); @@ -17849,13 +18209,13 @@ var ts; return finishNode(node); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(251, fullStart); + var importClause = createNode(252, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(27)) { - importClause.namedBindings = token() === 40 ? parseNamespaceImport() : parseNamedImportsOrExports(253); + importClause.namedBindings = token() === 40 ? parseNamespaceImport() : parseNamedImportsOrExports(254); } return finishNode(importClause); } @@ -17865,7 +18225,7 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(260); + var node = createNode(261); parseExpected(135); parseExpected(20); node.expression = parseModuleSpecifier(); @@ -17883,7 +18243,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(252); + var namespaceImport = createNode(253); parseExpected(40); parseExpected(120); namespaceImport.name = parseIdentifier(); @@ -17891,14 +18251,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(23, kind === 253 ? parseImportSpecifier : parseExportSpecifier, 18, 19); + node.elements = parseBracketedList(23, kind === 254 ? parseImportSpecifier : parseExportSpecifier, 18, 19); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(258); + return parseImportOrExportSpecifier(259); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(254); + return parseImportOrExportSpecifier(255); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -17917,19 +18277,19 @@ var ts; else { node.name = identifierName; } - if (kind === 254 && checkIdentifierIsKeyword) { + if (kind === 255 && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 256; + node.kind = 257; if (parseOptional(40)) { parseExpected(145); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(257); + node.exportClause = parseNamedImportsOrExports(258); if (token() === 145 || (token() === 10 && !scanner.hasPrecedingLineBreak())) { parseExpected(145); node.moduleSpecifier = parseModuleSpecifier(); @@ -17939,7 +18299,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 255; + node.kind = 256; if (parseOptional(60)) { node.isExportEquals = true; } @@ -17957,12 +18317,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1) - || node.kind === 249 && node.moduleReference.kind === 260 - || node.kind === 250 - || node.kind === 255 + || node.kind === 250 && node.moduleReference.kind === 261 + || node.kind === 251 || node.kind === 256 - ? node - : undefined; + || node.kind === 257 ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { return sourceFile.flags & 1048576 ? @@ -17989,7 +18347,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(289); + var result = createNode(290); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18); result.type = doInsideOfContext(2097152, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -18002,7 +18360,7 @@ var ts; function parseIsolatedJSDocComment(content, start, length) { initializeState(content, 99, undefined, 1); sourceFile = { languageVariant: 0, text: content }; - var jsDoc = parseJSDocCommentWorker(start, length); + var jsDoc = doInsideOfContext(2097152, function () { return parseJSDocCommentWorker(start, length); }); var diagnostics = parseDiagnostics; clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -18013,7 +18371,7 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = parseJSDocCommentWorker(start, length); + var comment = doInsideOfContext(2097152, function () { return parseJSDocCommentWorker(start, length); }); if (comment) { comment.parent = parent; } @@ -18125,7 +18483,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(297, start); + var result = createNode(299, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -18315,7 +18673,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(300, start); + var result = createNode(302, start); result.tagName = tagName; return finishNode(result); } @@ -18359,7 +18717,7 @@ var ts; switch (node.kind) { case 137: return true; - case 170: + case 171: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -18375,8 +18733,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 ? - createNode(312, start) : - createNode(306, start); + createNode(314, start) : + createNode(308, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -18393,20 +18751,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(289, scanner.getTokenPos()); + var typeLiteralExpression = createNode(290, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; - var start_2 = scanner.getStartPos(); + var start_3 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 306 || child.kind === 312) { + if (child.kind === 308 || child.kind === 314) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(298, start_2); + jsdocTypeLiteral = createNode(300, start_3); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 170) { + if (typeExpression.type.kind === 171) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -18418,7 +18776,7 @@ var ts; if (ts.some(tags, ts.isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(307, start); + var result = createNode(309, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); @@ -18427,13 +18785,13 @@ var ts; if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(309, start); + var result = createNode(311, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(true); return finishNode(result); } function parseAuthorTag(start, tagName, indent) { - var result = createNode(302, start); + var result = createNode(304, start); result.tagName = tagName; var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); }); if (!authorInfoWithEmail) { @@ -18487,14 +18845,14 @@ var ts; } } function parseAugmentsTag(start, tagName) { - var result = createNode(301, start); + var result = createNode(303, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18); - var node = createNode(212); + var node = createNode(213); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -18506,7 +18864,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(24)) { - var prop = createNode(190, node.pos); + var prop = createNode(191, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -18514,19 +18872,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(303, start); + var tag = createNode(305, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(308, start); + var tag = createNode(310, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(305, start); + var tag = createNode(307, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(true); skipWhitespace(); @@ -18535,7 +18893,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(311, start); + var typedefTag = createNode(313, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -18549,9 +18907,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(298, start); + jsdocTypeLiteral = createNode(300, start); } - if (child.kind === 309) { + if (child.kind === 311) { if (childTypeTag) { break; } @@ -18564,7 +18922,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 170) { + if (typeExpression && typeExpression.type.kind === 171) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -18582,7 +18940,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(24)) { - var jsDocNamespaceNode = createNode(245, pos); + var jsDocNamespaceNode = createNode(246, pos); if (nested) { jsDocNamespaceNode.flags |= 4; } @@ -18596,14 +18954,14 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(304, start); + var callbackTag = createNode(306, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(299, start); + var jsdocSignature = createNode(301, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -18611,7 +18969,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(58)) { var tag = parseTag(indent); - if (tag && tag.kind === 307) { + if (tag && tag.kind === 309) { return tag; } } @@ -18656,7 +19014,7 @@ var ts; case 58: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 306 || child.kind === 312) && + if (child && (child.kind === 308 || child.kind === 314) && target !== 4 && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -18719,13 +19077,13 @@ var ts; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(151); + var typeParameter = createNode(152); typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); finishNode(typeParameter); skipWhitespace(); typeParameters.push(typeParameter); } while (parseOptionalJsdoc(27)); - var result = createNode(310, start); + var result = createNode(312, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -18757,16 +19115,19 @@ var ts; if (!ts.tokenIsIdentifierOrKeyword(token())) { return createMissingNode(73, !message, message || ts.Diagnostics.Identifier_expected); } + identifierCount++; var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); var result = createNode(73, pos); - result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); + if (token() !== 73) { + result.originalKeywordKind = token(); + } + result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); finishNode(result, end); nextTokenJSDoc(); return result; } } - JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {})); })(Parser || (Parser = {})); var IncrementalParser; @@ -19391,6 +19752,7 @@ var ts; type: "boolean", category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_incremental_compilation, + transpileOptionValue: undefined }, { name: "locale", @@ -19399,7 +19761,7 @@ var ts; description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us }, ]; - ts.optionDeclarations = ts.commonOptionsWithBuild.concat([ + ts.optionDeclarations = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "all", type: "boolean", @@ -19500,7 +19862,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation + description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation, + transpileOptionValue: undefined }, { name: "allowJs", @@ -19537,6 +19900,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "declarationMap", @@ -19545,6 +19909,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "emitDeclarationOnly", @@ -19552,6 +19917,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Only_emit_d_ts_declaration_files, + transpileOptionValue: undefined }, { name: "sourceMap", @@ -19570,6 +19936,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "outDir", @@ -19597,6 +19964,7 @@ var ts; isTSConfigOnly: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_project_compilation, + transpileOptionValue: undefined }, { name: "tsBuildInfoFile", @@ -19606,6 +19974,7 @@ var ts; paramType: ts.Diagnostics.FILE, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, + transpileOptionValue: undefined }, { name: "removeComments", @@ -19622,6 +19991,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Do_not_emit_outputs, + transpileOptionValue: undefined }, { name: "importHelpers", @@ -19641,7 +20011,8 @@ var ts; name: "isolatedModules", type: "boolean", category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule + description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule, + transpileOptionValue: true }, { name: "strict", @@ -19770,7 +20141,8 @@ var ts; affectsModuleResolution: true, isTSConfigOnly: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl + description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl, + transpileOptionValue: undefined }, { name: "rootDirs", @@ -19783,7 +20155,8 @@ var ts; }, affectsModuleResolution: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime + description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime, + transpileOptionValue: undefined }, { name: "typeRoots", @@ -19807,7 +20180,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation, + transpileOptionValue: undefined }, { name: "allowSyntheticDefaultImports", @@ -19900,6 +20274,7 @@ var ts; category: ts.Diagnostics.Advanced_Options, paramType: ts.Diagnostics.FILE, description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "reactNamespace", @@ -19949,14 +20324,16 @@ var ts; type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts + description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts, + transpileOptionValue: true }, { name: "noResolve", type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files + description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files, + transpileOptionValue: true }, { name: "stripInternal", @@ -19992,6 +20369,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + transpileOptionValue: undefined }, { name: "preserveConstEnums", @@ -20007,7 +20385,8 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Output_directory_for_generated_declaration_files + description: ts.Diagnostics.Output_directory_for_generated_declaration_files, + transpileOptionValue: undefined }, { name: "skipLibCheck", @@ -20088,7 +20467,10 @@ var ts; ts.sourceFileAffectingCompilerOptions = ts.optionDeclarations.filter(function (option) { return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics; }); - ts.buildOpts = ts.commonOptionsWithBuild.concat([ + ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) { + return ts.hasProperty(option, "transpileOptionValue"); + }); + ts.buildOpts = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "verbose", shortName: "v", @@ -20592,7 +20974,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 276) { + if (element.kind !== 277) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -20667,13 +21049,13 @@ var ts; case 8: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 203: + case 204: if (valueExpression.operator !== 39 || valueExpression.operand.kind !== 8) { break; } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 189: + case 190: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; if (option) { @@ -20683,7 +21065,7 @@ var ts; else { return convertObjectLiteralExpressionToJson(objectLiteralExpression, undefined, undefined, undefined); } - case 188: + case 189: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -20726,13 +21108,13 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName); }); var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames }); - var config = __assign({ compilerOptions: __assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { + var config = __assign(__assign({ compilerOptions: __assign(__assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { var _a; - return (__assign({}, prev, (_a = {}, _a[cur[0]] = cur[1], _a))); - }, {}), { showConfig: undefined, configFile: undefined, configFilePath: undefined, help: undefined, init: undefined, listFiles: undefined, listEmittedFiles: undefined, project: undefined, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign({}, r, { path: r.originalPath, originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { + return (__assign(__assign({}, prev), (_a = {}, _a[cur[0]] = cur[1], _a))); + }, {})), { showConfig: undefined, configFile: undefined, configFilePath: undefined, help: undefined, init: undefined, listFiles: undefined, listEmittedFiles: undefined, project: undefined, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign(__assign({}, r), { path: r.originalPath ? r.originalPath : "", originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs), exclude: configParseResult.configFileSpecs.validatedExcludeSpecs - } : {}), { compilerOnSave: !!configParseResult.compileOnSave ? true : undefined }); + } : {})), { compileOnSave: !!configParseResult.compileOnSave ? true : undefined }); return config; } ts.convertToTSConfig = convertToTSConfig; @@ -21072,7 +21454,7 @@ var ts; basePath = ts.normalizeSlashes(basePath); var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath); if (resolutionStack.indexOf(resolvedPath) >= 0) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))); + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, __spreadArrays(resolutionStack, [resolvedPath]).join(" -> "))); return { raw: json || convertToObject(sourceFile, errors) }; } var ownConfig = json ? @@ -22004,6 +22386,7 @@ var ts; trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); } } + ts.perfLogger.logStartResolveModule(moduleName); switch (moduleResolution) { case ts.ModuleResolutionKind.NodeJs: result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); @@ -22014,6 +22397,9 @@ var ts; default: return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); } + if (result && result.resolvedModule) + ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, result); if (!ts.isExternalModuleNameRelative(moduleName)) { @@ -22149,7 +22535,7 @@ var ts; ts.tryResolveJSModule = tryResolveJSModule; var jsOnlyExtensions = [Extensions.JavaScript]; var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript]; - var tsPlusJsonExtensions = tsExtensions.concat([Extensions.Json]); + var tsPlusJsonExtensions = __spreadArrays(tsExtensions, [Extensions.Json]); var tsconfigExtensions = [Extensions.TSConfig]; function tryResolveJSModuleWorker(moduleName, initialDir, host) { return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, undefined, jsOnlyExtensions, undefined); @@ -22185,7 +22571,7 @@ var ts; if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) { var path = realPath(resolvedValue.path, host, traceEnabled); var originalPath = path === resolvedValue.path ? undefined : resolvedValue.path; - resolvedValue = __assign({}, resolvedValue, { path: path, originalPath: originalPath }); + resolvedValue = __assign(__assign({}, resolvedValue), { path: path, originalPath: originalPath }); } return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } }; } @@ -22631,21 +23017,21 @@ var ts; ts.getModuleInstanceState = getModuleInstanceState; function getModuleInstanceStateWorker(node) { switch (node.kind) { - case 242: case 243: - return 0; case 244: + return 0; + case 245: if (ts.isEnumConst(node)) { return 2; } break; + case 251: case 250: - case 249: if (!(ts.hasModifier(node, 1))) { return 0; } break; - case 246: { + case 247: { var state_1 = 0; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -22664,7 +23050,7 @@ var ts; }); return state_1; } - case 245: + case 246: return getModuleInstanceState(node); case 73: if (node.isInJSDocNamespace) { @@ -22677,7 +23063,9 @@ var ts; var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); + ts.perfLogger.logStartBindFile("" + file.fileName); binder(file, options); + ts.perfLogger.logStopBindFile(); ts.performance.mark("afterBind"); ts.performance.measure("Bind", "beforeBind", "afterBind"); } @@ -22766,7 +23154,7 @@ var ts; function addDeclarationToSymbol(symbol, node, symbolFlags) { symbol.flags |= symbolFlags; node.symbol = symbol; - symbol.declarations = ts.append(symbol.declarations, node); + symbol.declarations = ts.appendIfUnique(symbol.declarations, node); if (symbolFlags & (32 | 384 | 1536 | 3) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -22776,7 +23164,7 @@ var ts; if (symbol.constEnumOnlyModule && (symbol.flags & (16 | 32 | 256))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 67220415) { + if (symbolFlags & 111551) { setValueDeclaration(symbol, node); } } @@ -22789,7 +23177,7 @@ var ts; } } function getDeclarationName(node) { - if (node.kind === 255) { + if (node.kind === 256) { return node.isExportEquals ? "export=" : "default"; } var name = ts.getNameOfDeclaration(node); @@ -22798,7 +23186,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 150) { + if (name.kind === 151) { var nameExpression = name.expression; if (ts.isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); @@ -22812,31 +23200,31 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 158: + case 159: return "__constructor"; - case 166: - case 161: - case 299: - return "__call"; case 167: case 162: - return "__new"; + case 301: + return "__call"; + case 168: case 163: + return "__new"; + case 164: return "__index"; - case 256: + case 257: return "__export"; - case 285: + case 286: return "export="; - case 205: + case 206: if (ts.getAssignmentDeclarationKind(node) === 2) { return "export="; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 295: + case 296: return (ts.isJSDocConstructSignature(node) ? "__new" : "__call"); - case 152: - ts.Debug.assert(node.parent.kind === 295, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + case 153: + ts.Debug.assert(node.parent.kind === 296, "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; @@ -22891,7 +23279,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (node.kind === 255 && !node.isExportEquals)) { + (node.kind === 256 && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -22909,7 +23297,7 @@ var ts; } }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); - file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInformation_1)) : diag); + file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInformation_1)) : diag); symbol = createSymbol(0, name); } } @@ -22926,7 +23314,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 2097152) { - if (node.kind === 258 || (node.kind === 249 && hasExportModifier)) { + if (node.kind === 259 || (node.kind === 250 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -22937,10 +23325,10 @@ var ts; if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32)) || ts.isJSDocTypeAlias(node)) { - if (ts.hasModifier(node, 512) && !getDeclarationName(node)) { + if (!container.locals || (ts.hasModifier(node, 512) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } - var exportKind = symbolFlags & 67220415 ? 1048576 : 0; + var exportKind = symbolFlags & 111551 ? 1048576 : 0; var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -22956,7 +23344,7 @@ var ts; var saveThisParentContainer = thisParentContainer; var savedBlockScopeContainer = blockScopeContainer; if (containerFlags & 1) { - if (node.kind !== 198) { + if (node.kind !== 199) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -22985,7 +23373,7 @@ var ts; currentFlow.container = node; } } - currentReturnTarget = isIIFE || node.kind === 158 ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 159 ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -22998,13 +23386,13 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 285) { + if (node.kind === 286) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 158) { + if (node.kind === 159) { node.returnFlowNode = currentFlow; } } @@ -23048,8 +23436,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 240 ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 240 ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 241 ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 241 ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -23082,77 +23470,81 @@ var ts; return; } switch (node.kind) { - case 225: + case 226: bindWhileStatement(node); break; - case 224: + case 225: bindDoStatement(node); break; - case 226: + case 227: bindForStatement(node); break; - case 227: case 228: + case 229: bindForInOrForOfStatement(node); break; - case 223: + case 224: bindIfStatement(node); break; - case 231: - case 235: + case 232: + case 236: bindReturnOrThrow(node); break; + case 231: case 230: - case 229: bindBreakOrContinueStatement(node); break; - case 236: + case 237: bindTryStatement(node); break; - case 233: + case 234: bindSwitchStatement(node); break; - case 247: + case 248: bindCaseBlock(node); break; - case 272: + case 273: bindCaseClause(node); break; - case 234: + case 235: bindLabeledStatement(node); break; - case 203: + case 204: bindPrefixUnaryExpressionFlow(node); break; - case 204: + case 205: bindPostfixUnaryExpressionFlow(node); break; - case 205: + case 206: bindBinaryExpressionFlow(node); break; - case 199: + case 200: bindDeleteExpressionFlow(node); break; - case 206: + case 207: bindConditionalExpressionFlow(node); break; - case 238: + case 239: bindVariableDeclarationFlow(node); break; - case 192: + case 193: bindCallExpressionFlow(node); break; - case 311: - case 304: + case 313: + case 306: + case 307: bindJSDocTypeAlias(node); break; - case 285: { + case 305: + bindJSDocClassTag(node); + break; + case 286: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 219: - case 246: + case 220: + case 247: bindEachFunctionsFirst(node.statements); break; default: @@ -23165,18 +23557,18 @@ var ts; switch (expr.kind) { case 73: case 101: - case 190: case 191: - return isNarrowableReference(expr); case 192: + return isNarrowableReference(expr); + case 193: return hasNarrowableArgument(expr); - case 196: + case 197: return isNarrowingExpression(expr.expression); - case 205: + case 206: return isNarrowingBinaryExpression(expr); - case 203: + case 204: return expr.operator === 52 && isNarrowingExpression(expr.operand); - case 200: + case 201: return isNarrowingExpression(expr.expression); } return false; @@ -23184,7 +23576,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 73 || expr.kind === 101 || expr.kind === 99 || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isElementAccessExpression(expr) && expr.argumentExpression && + ts.isElementAccessExpression(expr) && (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && isNarrowableReference(expr.expression); } @@ -23197,7 +23589,7 @@ var ts; } } } - if (expr.expression.kind === 190 && + if (expr.expression.kind === 191 && isNarrowableReference(expr.expression.expression)) { return true; } @@ -23230,9 +23622,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 196: + case 197: return isNarrowableOperand(expr.expression); - case 205: + case 206: switch (expr.operatorToken.kind) { case 60: return isNarrowableOperand(expr.left); @@ -23309,33 +23701,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 223: - case 225: case 224: - return parent.expression === node; case 226: - case 206: + case 225: + return parent.expression === node; + case 227: + case 207: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 196) { + if (node.kind === 197) { node = node.expression; } - else if (node.kind === 203 && node.operator === 52) { + else if (node.kind === 204 && node.operator === 52) { node = node.operand; } else { - return node.kind === 205 && (node.operatorToken.kind === 54 || + return node.kind === 206 && (node.operatorToken.kind === 54 || node.operatorToken.kind === 55); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 196 || - node.parent.kind === 203 && + while (node.parent.kind === 197 || + node.parent.kind === 204 && node.parent.operator === 52) { node = node.parent; } @@ -23377,7 +23769,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 234 + var enclosingLabeledStatement = node.parent.kind === 235 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -23409,13 +23801,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 228) { + if (node.kind === 229) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 239) { + if (node.initializer.kind !== 240) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -23437,7 +23829,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 231) { + if (node.kind === 232) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -23457,7 +23849,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 230 ? breakTarget : continueTarget; + var flowLabel = node.kind === 231 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -23547,7 +23939,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 273; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 274; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -23612,13 +24004,13 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 224) { + if (!node.statement || node.statement.kind !== 225) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 205 && node.operatorToken.kind === 60) { + if (node.kind === 206 && node.operatorToken.kind === 60) { bindAssignmentTargetFlow(node.left); } else { @@ -23629,10 +24021,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 188) { + else if (node.kind === 189) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 209) { + if (e.kind === 210) { bindAssignmentTargetFlow(e.expression); } else { @@ -23640,16 +24032,16 @@ var ts; } } } - else if (node.kind === 189) { + else if (node.kind === 190) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 276) { + if (p.kind === 277) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 277) { + else if (p.kind === 278) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 278) { + else if (p.kind === 279) { bindAssignmentTargetFlow(p.expression); } } @@ -23705,7 +24097,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 60 && node.left.kind === 191) { + if (operator === 60 && node.left.kind === 192) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -23716,7 +24108,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 190) { + if (node.expression.kind === 191) { bindAssignmentTargetFlow(node.expression); } } @@ -23755,16 +24147,23 @@ var ts; } function bindJSDocTypeAlias(node) { node.tagName.parent = node; - if (node.fullName) { + if (node.kind !== 307 && node.fullName) { setParentPointers(node, node.fullName); } } + function bindJSDocClassTag(node) { + bindEachChild(node); + var host = ts.getHostSignatureFromJSDoc(node); + if (host && host.kind !== 158) { + addDeclarationToSymbol(host.symbol, host, 32); + } + } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 196) { + while (expr.kind === 197) { expr = expr.expression; } - if (expr.kind === 197 || expr.kind === 198) { + if (expr.kind === 198 || expr.kind === 199) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -23772,7 +24171,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 190) { + if (node.expression.kind === 191) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -23781,53 +24180,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 210: - case 241: - case 244: - case 189: - case 169: - case 298: - case 269: - return 1; + case 211: case 242: - return 1 | 64; case 245: + case 190: + case 170: + case 300: + case 270: + return 1; case 243: - case 182: + return 1 | 64; + case 246: + case 244: + case 183: return 1 | 32; - case 285: + case 286: return 1 | 4 | 32; - case 157: + case 158: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 158: - case 240: - case 156: case 159: + case 241: + case 157: case 160: case 161: - case 299: - case 295: - case 166: case 162: - case 163: + case 301: + case 296: case 167: + case 163: + case 164: + case 168: return 1 | 4 | 32 | 8; - case 197: case 198: + case 199: return 1 | 4 | 32 | 8 | 16; - case 246: + case 247: return 4; - case 155: + case 156: return node.initializer ? 4 : 0; - case 275: - case 226: + case 276: case 227: case 228: - case 247: + case 229: + case 248: return 2; - case 219: + case 220: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -23840,40 +24239,40 @@ var ts; } function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 245: + case 246: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 285: + case 286: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 210: - case 241: + case 211: + case 242: return declareClassMember(node, symbolFlags, symbolExcludes); - case 244: + case 245: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 169: - case 298: - case 189: - case 242: - case 269: + case 170: + case 300: + case 190: + case 243: + case 270: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 166: case 167: - case 161: + case 168: case 162: - case 299: case 163: - case 157: - case 156: + case 301: + case 164: case 158: + case 157: case 159: case 160: - case 240: - case 197: + case 161: + case 241: case 198: - case 295: - case 311: - case 304: - case 243: - case 182: + case 199: + case 296: + case 313: + case 306: + case 244: + case 183: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -23952,11 +24351,11 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 || prop.name.kind !== 73) { + if (prop.kind === 279 || prop.name.kind !== 73) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 276 || prop.kind === 277 || prop.kind === 157 + var currentKind = prop.kind === 277 || prop.kind === 278 || prop.kind === 158 ? 1 : 2; var existingKind = seen.get(identifier.escapedText); @@ -23988,10 +24387,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 245: + case 246: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 285: + case 286: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -24021,9 +24420,36 @@ var ts; currentFlow = { flags: 2 }; parent = typeAlias; bind(typeAlias.typeExpression); - if (!typeAlias.fullName || typeAlias.fullName.kind === 73) { + var declName = ts.getNameOfDeclaration(typeAlias); + if ((ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName) && declName && ts.isPropertyAccessEntityNameExpression(declName.parent)) { + var isTopLevel = isTopLevelNamespaceAssignment(declName.parent); + if (isTopLevel) { + bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), false); + var oldContainer = container; + switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { + case 1: + case 2: + container = file; + break; + case 4: + container = declName.parent.expression; + break; + case 3: + container = declName.parent.expression.name; + break; + case 5: + container = ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; + break; + case 0: + return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); + } + declareModuleMember(typeAlias, 524288, 788968); + container = oldContainer; + } + } + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 73) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288, 67897832); + bindBlockScopedDeclaration(typeAlias, 524288, 788968); } else { bind(typeAlias.fullName); @@ -24040,7 +24466,8 @@ var ts; node.originalKeywordKind >= 110 && node.originalKeywordKind <= 118 && !ts.isIdentifierName(node) && - !(node.flags & 4194304)) { + !(node.flags & 4194304) && + !(node.flags & 2097152)) { if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); } @@ -24108,8 +24535,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 285 && - blockScopeContainer.kind !== 245 && + if (blockScopeContainer.kind !== 286 && + blockScopeContainer.kind !== 246 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -24161,7 +24588,7 @@ var ts; file.bindDiagnostics.push(diag); } else { - file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } } function bind(node) { @@ -24171,7 +24598,7 @@ var ts; node.parent = parent; var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 148) { + if (node.kind > 149) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -24235,16 +24662,16 @@ var ts; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288, 67897832); + bindBlockScopedDeclaration(parentNode, 524288, 788968); break; } case 101: - if (currentFlow && (ts.isExpression(node) || parent.kind === 277)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 278)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 190: case 191: + case 192: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -24255,10 +24682,10 @@ var ts; file.commonJsModuleIndicator && ts.isModuleExportsPropertyAccessExpression(node) && !lookupSymbolForNameWorker(blockScopeContainer, "module")) { - declareSymbol(file.locals, undefined, node.expression, 1 | 134217728, 67220414); + declareSymbol(file.locals, undefined, node.expression, 1 | 134217728, 111550); } break; - case 205: + case 206: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1: @@ -24285,72 +24712,72 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 275: + case 276: return checkStrictModeCatchClause(node); - case 199: + case 200: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 204: + case 205: return checkStrictModePostfixUnaryExpression(node); - case 203: + case 204: return checkStrictModePrefixUnaryExpression(node); - case 232: + case 233: return checkStrictModeWithStatement(node); - case 234: + case 235: return checkStrictModeLabeledStatement(node); - case 179: + case 180: seenThisKeyword = true; return; - case 164: + case 165: break; - case 151: - return bindTypeParameter(node); case 152: + return bindTypeParameter(node); + case 153: return bindParameter(node); - case 238: + case 239: return bindVariableDeclarationOrBindingElement(node); - case 187: + case 188: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); + case 156: case 155: - case 154: return bindPropertyWorker(node); - case 276: case 277: + case 278: return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 279: - return bindPropertyOrMethodOrAccessor(node, 8, 68008959); - case 161: + case 280: + return bindPropertyOrMethodOrAccessor(node, 8, 900095); case 162: case 163: + case 164: return declareSymbolAndAddToSymbolTable(node, 131072, 0); + case 158: case 157: - case 156: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 16777216 : 0), ts.isObjectLiteralMethod(node) ? 0 : 67212223); - case 240: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 16777216 : 0), ts.isObjectLiteralMethod(node) ? 0 : 103359); + case 241: return bindFunctionDeclaration(node); - case 158: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 159: - return bindPropertyOrMethodOrAccessor(node, 32768, 67154879); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 160: - return bindPropertyOrMethodOrAccessor(node, 65536, 67187647); - case 166: - case 295: - case 299: + return bindPropertyOrMethodOrAccessor(node, 32768, 46015); + case 161: + return bindPropertyOrMethodOrAccessor(node, 65536, 78783); case 167: + case 296: + case 301: + case 168: return bindFunctionOrConstructorType(node); - case 169: - case 298: - case 182: + case 170: + case 300: + case 183: return bindAnonymousTypeWorker(node); - case 189: + case 190: return bindObjectLiteralExpression(node); - case 197: case 198: + case 199: return bindFunctionExpression(node); - case 192: + case 193: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7: @@ -24368,59 +24795,60 @@ var ts; bindCallExpression(node); } break; - case 210: - case 241: + case 211: + case 242: inStrictMode = true; return bindClassLikeDeclaration(node); - case 242: - return bindBlockScopedDeclaration(node, 64, 67897736); case 243: - return bindBlockScopedDeclaration(node, 524288, 67897832); + return bindBlockScopedDeclaration(node, 64, 788872); case 244: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 788968); case 245: + return bindEnumDeclaration(node); + case 246: return bindModuleDeclaration(node); - case 269: + case 270: return bindJsxAttributes(node); - case 268: + case 269: return bindJsxAttribute(node, 4, 0); - case 249: - case 252: - case 254: - case 258: + case 250: + case 253: + case 255: + case 259: return declareSymbolAndAddToSymbolTable(node, 2097152, 2097152); - case 248: + case 249: return bindNamespaceExportDeclaration(node); - case 251: + case 252: return bindImportClause(node); - case 256: + case 257: return bindExportDeclaration(node); - case 255: + case 256: return bindExportAssignment(node); - case 285: + case 286: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 219: + case 220: if (!ts.isFunctionLike(node.parent)) { return; } - case 246: + case 247: return updateStrictModeStatementList(node.statements); - case 306: - if (node.parent.kind === 299) { + case 308: + if (node.parent.kind === 301) { return bindParameter(node); } - if (node.parent.kind !== 298) { + if (node.parent.kind !== 300) { break; } - case 312: + case 314: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 294 ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 295 ? 4 | 16777216 : 4; return declareSymbolAndAddToSymbolTable(propTag, flags, 0); - case 311: - case 304: + case 313: + case 306: + case 307: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -24548,8 +24976,8 @@ var ts; ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, false); switch (thisContainer.kind) { - case 240: - case 197: + case 241: + case 198: var constructorSymbol = thisContainer.symbol; if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 60) { var l = thisContainer.parent.left; @@ -24560,23 +24988,24 @@ var ts; if (constructorSymbol) { constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable(); declareSymbol(constructorSymbol.members, constructorSymbol, node, 4, 0 & ~4); + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32); } break; - case 158: - case 155: - case 157: case 159: + case 156: + case 158: case 160: + case 161: var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4, 0, true); break; - case 285: + case 286: if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 | 1048576, 0); } else { - declareSymbolAndAddToSymbolTable(node, 1, 67220414); + declareSymbolAndAddToSymbolTable(node, 1, 111550); } break; default: @@ -24587,7 +25016,7 @@ var ts; if (node.expression.kind === 101) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 285) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 286) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -24600,7 +25029,7 @@ var ts; node.left.parent = node; node.right.parent = node; var lhs = node.left; - bindPropertyAssignment(lhs.expression, lhs, false); + bindPropertyAssignment(lhs.expression, lhs, false, true); } function bindObjectDefinePrototypeProperty(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); @@ -24612,12 +25041,12 @@ var ts; lhs.parent = parent; constructorFunction.parent = classPrototype; classPrototype.parent = lhs; - bindPropertyAssignment(constructorFunction, lhs, true); + bindPropertyAssignment(constructorFunction, lhs, true, true); } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 285; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, false); + var isToplevel = node.parent.parent.kind === 286; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, false, false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, false); } function bindSpecialPropertyAssignment(node) { @@ -24637,10 +25066,10 @@ var ts; } function bindStaticPropertyAssignment(node) { node.expression.parent = node; - bindPropertyAssignment(node.expression, node, false); + bindPropertyAssignment(node.expression, node, false, false); } - function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { - if (isToplevel && !isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920))) { + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { + if (isToplevel && !isPrototypeProperty) { var flags_1 = 1536 | 67108864; var excludeFlags_1 = 110735 & ~67108864; namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) { @@ -24655,6 +25084,9 @@ var ts; } }); } + if (containerIsClass && namespaceSymbol) { + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32); + } return namespaceSymbol; } function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { @@ -24666,15 +25098,18 @@ var ts; (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); var includes = isMethod ? 8192 : 4; - var excludes = isMethod ? 67212223 : 0; + var excludes = isMethod ? 103359 : 0; declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864, excludes & ~67108864); } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + function isTopLevelNamespaceAssignment(propertyAccess) { + return ts.isBinaryExpression(propertyAccess.parent) + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 286 + : propertyAccess.parent.parent.kind === 286; + } + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); - var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 285 - : propertyAccess.parent.parent.kind === 285; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } function isExpandoSymbol(symbol) { @@ -24731,8 +25166,8 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 241) { - bindBlockScopedDeclaration(node, 32, 68008383); + if (node.kind === 242) { + bindBlockScopedDeclaration(node, 32, 899503); } else { var bindingName = node.name ? node.name.escapedText : "__class"; @@ -24755,30 +25190,27 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128, 68008831) - : bindBlockScopedDeclaration(node, 256, 68008191); + ? bindBlockScopedDeclaration(node, 128, 899967) + : bindBlockScopedDeclaration(node, 256, 899327); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - var isEnum = ts.isInJSFile(node) && !!ts.getJSDocEnumTag(node); - var enumFlags = (isEnum ? 256 : 0); - var enumExcludes = (isEnum ? 68008191 : 0); if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 | enumFlags, 67220415 | enumExcludes); + bindBlockScopedDeclaration(node, 2, 111551); } else if (ts.isParameterDeclaration(node)) { - declareSymbolAndAddToSymbolTable(node, 1, 67220415); + declareSymbolAndAddToSymbolTable(node, 1, 111551); } else { - declareSymbolAndAddToSymbolTable(node, 1 | enumFlags, 67220414 | enumExcludes); + declareSymbolAndAddToSymbolTable(node, 1, 111550); } } } function bindParameter(node) { - if (node.kind === 306 && container.kind !== 299) { + if (node.kind === 308 && container.kind !== 301) { return; } if (inStrictMode && !(node.flags & 4194304)) { @@ -24788,9 +25220,9 @@ var ts; bindAnonymousDeclaration(node, 1, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1, 67220415); + declareSymbolAndAddToSymbolTable(node, 1, 111551); } - if (ts.isParameterPropertyDeclaration(node)) { + if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 | (node.questionToken ? 16777216 : 0), 0); } @@ -24804,10 +25236,10 @@ var ts; checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16, 67219887); + bindBlockScopedDeclaration(node, 16, 110991); } else { - declareSymbolAndAddToSymbolTable(node, 16, 67219887); + declareSymbolAndAddToSymbolTable(node, 16, 110991); } } function bindFunctionExpression(node) { @@ -24845,26 +25277,26 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, undefined, node, 262144, 67635688); + declareSymbol(container_1.locals, undefined, node, 262144, 526824); } else { - declareSymbolAndAddToSymbolTable(node, 262144, 67635688); + declareSymbolAndAddToSymbolTable(node, 262144, 526824); } } - else if (node.parent.kind === 177) { + else if (node.parent.kind === 178) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, undefined, node, 262144, 67635688); + declareSymbol(container_2.locals, undefined, node, 262144, 526824); } else { bindAnonymousDeclaration(node, 262144, getDeclarationName(node)); } } else { - declareSymbolAndAddToSymbolTable(node, 262144, 67635688); + declareSymbolAndAddToSymbolTable(node, 262144, 526824); } } function shouldReportErrorOnModuleDeclaration(node) { @@ -24876,9 +25308,9 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 221) || - node.kind === 241 || - (node.kind === 245 && shouldReportErrorOnModuleDeclaration(node)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 222) || + node.kind === 242 || + (node.kind === 246 && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -24910,12 +25342,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 242: case 243: + case 244: return true; - case 245: + case 246: return getModuleInstanceState(s) !== 1; - case 244: + case 245: return ts.hasModifier(s, 2048); default: return false; @@ -24958,58 +25390,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 192: - return computeCallExpression(node, subtreeFlags); case 193: + return computeCallExpression(node, subtreeFlags); + case 194: return computeNewExpression(node, subtreeFlags); - case 245: + case 246: return computeModuleDeclaration(node, subtreeFlags); - case 196: + case 197: return computeParenthesizedExpression(node, subtreeFlags); - case 205: + case 206: return computeBinaryExpression(node, subtreeFlags); - case 222: + case 223: return computeExpressionStatement(node, subtreeFlags); - case 152: + case 153: return computeParameter(node, subtreeFlags); - case 198: + case 199: return computeArrowFunction(node, subtreeFlags); - case 197: + case 198: return computeFunctionExpression(node, subtreeFlags); - case 240: + case 241: return computeFunctionDeclaration(node, subtreeFlags); - case 238: - return computeVariableDeclaration(node, subtreeFlags); case 239: + return computeVariableDeclaration(node, subtreeFlags); + case 240: return computeVariableDeclarationList(node, subtreeFlags); - case 220: + case 221: return computeVariableStatement(node, subtreeFlags); - case 234: + case 235: return computeLabeledStatement(node, subtreeFlags); - case 241: + case 242: return computeClassDeclaration(node, subtreeFlags); - case 210: + case 211: return computeClassExpression(node, subtreeFlags); - case 274: - return computeHeritageClause(node, subtreeFlags); case 275: + return computeHeritageClause(node, subtreeFlags); + case 276: return computeCatchClause(node, subtreeFlags); - case 212: + case 213: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 158: + case 159: return computeConstructor(node, subtreeFlags); - case 155: + case 156: return computePropertyDeclaration(node, subtreeFlags); - case 157: + case 158: return computeMethod(node, subtreeFlags); - case 159: case 160: + case 161: return computeAccessor(node, subtreeFlags); - case 249: + case 250: return computeImportEquals(node, subtreeFlags); - case 190: - return computePropertyAccess(node, subtreeFlags); case 191: + return computePropertyAccess(node, subtreeFlags); + case 192: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -25050,10 +25482,10 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 60 && leftKind === 189) { + if (operatorTokenKind === 60 && leftKind === 190) { transformFlags |= 16 | 128 | 512; } - else if (operatorTokenKind === 60 && leftKind === 188) { + else if (operatorTokenKind === 60 && leftKind === 189) { transformFlags |= 128 | 512; } else if (operatorTokenKind === 41 @@ -25090,8 +25522,8 @@ var ts; var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (expressionKind === 213 - || expressionKind === 195) { + if (expressionKind === 214 + || expressionKind === 196) { transformFlags |= 1; } node.transformFlags = transformFlags | 536870912; @@ -25366,12 +25798,12 @@ var ts; var excludeFlags = 536870912; switch (kind) { case 122: - case 202: + case 203: transformFlags |= 16 | 32; break; - case 195: - case 213: - case 315: + case 196: + case 214: + case 317: transformFlags |= 1; excludeFlags = 536870912; break; @@ -25381,17 +25813,16 @@ var ts; case 119: case 126: case 78: - case 244: - case 279: - case 214: + case 245: + case 280: + case 215: case 134: transformFlags |= 1; break; - case 261: case 262: case 263: - case 11: case 264: + case 11: case 265: case 266: case 267: @@ -25399,17 +25830,18 @@ var ts; case 269: case 270: case 271: + case 272: transformFlags |= 2; break; case 14: case 15: case 16: case 17: - case 207: - case 194: - case 277: + case 208: + case 195: + case 278: case 117: - case 215: + case 216: transformFlags |= 128; break; case 10: @@ -25425,13 +25857,13 @@ var ts; case 9: transformFlags |= 4; break; - case 228: + case 229: if (node.awaitModifier) { transformFlags |= 16; } transformFlags |= 128; break; - case 208: + case 209: transformFlags |= 16 | 128 | 131072; break; case 121: @@ -25443,10 +25875,9 @@ var ts; case 124: case 140: case 107: - case 151: - case 154: - case 156: - case 161: + case 152: + case 155: + case 157: case 162: case 163: case 164: @@ -25464,24 +25895,25 @@ var ts; case 176: case 177: case 178: - case 242: - case 243: case 179: + case 243: + case 244: case 180: case 181: case 182: case 183: - case 248: + case 184: + case 249: transformFlags = 1; excludeFlags = -2; break; - case 150: + case 151: transformFlags |= 16384; break; - case 209: + case 210: transformFlags |= 128 | 4096; break; - case 278: + case 279: transformFlags |= 16 | 8192; break; case 99: @@ -25491,27 +25923,27 @@ var ts; case 101: transformFlags |= 2048; break; - case 185: + case 186: transformFlags |= 128 | 65536; if (subtreeFlags & 4096) { transformFlags |= 16 | 8192; } excludeFlags = 536875008; break; - case 186: + case 187: transformFlags |= 128 | 65536; excludeFlags = 536875008; break; - case 187: + case 188: transformFlags |= 128; if (node.dotDotDotToken) { transformFlags |= 4096; } break; - case 153: + case 154: transformFlags |= 1 | 1024; break; - case 189: + case 190: excludeFlags = 536896512; if (subtreeFlags & 16384) { transformFlags |= 128; @@ -25520,24 +25952,24 @@ var ts; transformFlags |= 16; } break; - case 188: + case 189: excludeFlags = 536875008; break; - case 224: case 225: case 226: case 227: + case 228: if (subtreeFlags & 32768) { transformFlags |= 128; } break; - case 285: + case 286: break; - case 231: + case 232: transformFlags |= 262144 | 16; break; - case 229: case 230: + case 231: transformFlags |= 262144; break; } @@ -25548,33 +25980,33 @@ var ts; return transformFlags | (node.transformFlags & 2048); } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 164 && kind <= 184) { + if (kind >= 165 && kind <= 185) { return -2; } switch (kind) { - case 192: case 193: - case 188: + case 194: + case 189: return 536875008; - case 245: + case 246: return 537168896; - case 152: + case 153: return 536870912; - case 198: + case 199: return 537371648; - case 197: - case 240: + case 198: + case 241: return 537373696; - case 239: + case 240: return 536944640; - case 241: - case 210: + case 242: + case 211: return 536888320; - case 158: - return 537372672; - case 157: case 159: + return 537372672; + case 158: case 160: + case 161: return 537372672; case 121: case 136: @@ -25585,30 +26017,30 @@ var ts; case 124: case 140: case 107: - case 151: - case 154: - case 156: - case 161: + case 152: + case 155: + case 157: case 162: case 163: - case 242: + case 164: case 243: + case 244: return -2; - case 189: + case 190: return 536896512; - case 275: + case 276: return 536879104; - case 185: case 186: + case 187: return 536875008; - case 195: - case 213: - case 315: case 196: + case 214: + case 317: + case 197: case 99: return 536870912; - case 190: case 191: + case 192: return 536870912; default: return 536870912; @@ -25770,7 +26202,7 @@ var ts; symbol.exports.forEach(visitSymbol); } ts.forEach(symbol.declarations, function (d) { - if (d.type && d.type.kind === 168) { + if (d.type && d.type.kind === 169) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -25789,6 +26221,27 @@ var ts; var nextNodeId = 1; var nextMergeId = 1; var nextFlowId = 1; + var typeofEQFacts = ts.createMapFromTemplate({ + string: 1, + number: 2, + bigint: 4, + boolean: 8, + symbol: 16, + undefined: 65536, + object: 32, + function: 64 + }); + var typeofNEFacts = ts.createMapFromTemplate({ + string: 256, + number: 512, + bigint: 1024, + boolean: 2048, + symbol: 4096, + undefined: 524288, + object: 8192, + function: 16384 + }); + var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); function getNodeId(node) { if (!node.id) { node.id = nextNodeId; @@ -26091,7 +26544,7 @@ var ts; cancellationToken = ct; checkSourceFile(file); ts.Debug.assert(!!(getNodeLinks(file).flags & 1)); - diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.get(file.fileName)); + diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); if (!file.isDeclarationFile && (!unusedIsError(0) || !unusedIsError(1))) { addUnusedDiagnostics(); } @@ -26103,7 +26556,7 @@ var ts; function addUnusedDiagnostics() { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { if (!ts.containsParseError(containingNode) && !unusedIsError(kind)) { - (diagnostics || (diagnostics = [])).push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); } @@ -26132,6 +26585,7 @@ var ts; var literalTypes = ts.createMap(); var indexedAccessTypes = ts.createMap(); var substitutionTypes = ts.createMap(); + var structuralTags = ts.createMap(); var evolvingArrayTypes = []; var undefinedProperties = ts.createMap(); var unknownSymbol = createSymbol(4, "unknown"); @@ -26302,27 +26756,7 @@ var ts; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); - var suggestionDiagnostics = ts.createMultiMap(); - var typeofEQFacts = ts.createMapFromTemplate({ - string: 1, - number: 2, - bigint: 4, - boolean: 8, - symbol: 16, - undefined: 65536, - object: 32, - function: 64 - }); - var typeofNEFacts = ts.createMapFromTemplate({ - string: 256, - number: 512, - bigint: 1024, - boolean: 2048, - symbol: 4096, - undefined: 524288, - object: 8192, - function: 16384 - }); + var suggestionDiagnostics = ts.createDiagnosticCollection(); var typeofTypesByName = ts.createMapFromTemplate({ string: stringType, number: numberType, @@ -26342,7 +26776,6 @@ var ts; var enumRelation = ts.createMap(); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); - var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; function getJsxNamespace(location) { @@ -26405,7 +26838,7 @@ var ts; diagnostics.add(diagnostic); } else { - suggestionDiagnostics.add(diagnostic.file.fileName, __assign({}, diagnostic, { category: ts.DiagnosticCategory.Suggestion })); + suggestionDiagnostics.add(__assign(__assign({}, diagnostic), { category: ts.DiagnosticCategory.Suggestion })); } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { @@ -26431,35 +26864,35 @@ var ts; function getExcludedSymbolFlags(flags) { var result = 0; if (flags & 2) - result |= 67220415; + result |= 111551; if (flags & 1) - result |= 67220414; + result |= 111550; if (flags & 4) result |= 0; if (flags & 8) - result |= 68008959; + result |= 900095; if (flags & 16) - result |= 67219887; + result |= 110991; if (flags & 32) - result |= 68008383; + result |= 899503; if (flags & 64) - result |= 67897736; + result |= 788872; if (flags & 256) - result |= 68008191; + result |= 899327; if (flags & 128) - result |= 68008831; + result |= 899967; if (flags & 512) result |= 110735; if (flags & 8192) - result |= 67212223; + result |= 103359; if (flags & 32768) - result |= 67154879; + result |= 46015; if (flags & 65536) - result |= 67187647; + result |= 78783; if (flags & 262144) - result |= 67635688; + result |= 526824; if (flags & 524288) - result |= 67897832; + result |= 788968; if (flags & 2097152) result |= 2097152; return result; @@ -26657,7 +27090,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 285 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 286 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -26679,8 +27112,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 67220415); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 67220415); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -26703,15 +27136,15 @@ var ts; return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile); } if (declaration.pos <= usage.pos) { - if (declaration.kind === 187) { - var errorBindingElement = ts.getAncestor(usage, 187); + if (declaration.kind === 188) { + var errorBindingElement = ts.getAncestor(usage, 188); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 238), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 239), usage); } - else if (declaration.kind === 238) { + else if (declaration.kind === 239) { return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } else if (ts.isClassDeclaration(declaration)) { @@ -26722,10 +27155,10 @@ var ts; } return true; } - if (usage.parent.kind === 258 || (usage.parent.kind === 255 && usage.parent.isExportEquals)) { + if (usage.parent.kind === 259 || (usage.parent.kind === 256 && usage.parent.isExportEquals)) { return true; } - if (usage.kind === 255 && usage.isExportEquals) { + if (usage.kind === 256 && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -26733,9 +27166,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 220: - case 226: - case 228: + case 221: + case 227: + case 229: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } @@ -26753,16 +27186,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 155 && + current.parent.kind === 156 && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32)) { - if (declaration.kind === 157) { + if (declaration.kind === 158) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 155 && !ts.hasModifier(declaration, 32); + var isDeclarationInstanceProperty = declaration.kind === 156 && !ts.hasModifier(declaration, 32); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -26780,14 +27213,14 @@ var ts; return "quit"; } switch (node.kind) { - case 198: - case 155: + case 199: + case 156: return true; - case 219: + case 220: switch (node.parent.kind) { - case 159: - case 157: case 160: + case 158: + case 161: return true; default: return false; @@ -26819,11 +27252,11 @@ var ts; if (result = lookup(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 67897832 && lastLocation.kind !== 297) { + if (meaning & result.flags & 788968 && lastLocation.kind !== 299) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 152 || - lastLocation.kind === 151 + lastLocation.kind === 153 || + lastLocation.kind === 152 : false; } if (meaning & result.flags & 3) { @@ -26834,13 +27267,13 @@ var ts; } else if (result.flags & 1) { useResult = - lastLocation.kind === 152 || + lastLocation.kind === 153 || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 176) { + else if (location.kind === 177) { useResult = lastLocation === location.trueType; } if (useResult) { @@ -26853,13 +27286,13 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 285: + case 286: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 245: + case 246: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 285 || ts.isAmbientModule(location)) { + if (location.kind === 286 || ts.isAmbientModule(location)) { if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) { @@ -26870,7 +27303,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 && - ts.getDeclarationOfKind(moduleExport, 258)) { + ts.getDeclarationOfKind(moduleExport, 259)) { break; } } @@ -26883,25 +27316,25 @@ var ts; } } break; - case 244: + case 245: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; - case 155: + case 156: if (!ts.hasModifier(location, 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 67220415)) { + if (lookup(ctor.locals, name, meaning & 111551)) { propertyWithInvalidInitializer = location; } } } break; - case 241: - case 210: case 242: - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 67897832)) { + case 211: + case 243: + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { result = undefined; break; @@ -26912,7 +27345,7 @@ var ts; } break loop; } - if (location.kind === 210 && meaning & 32) { + if (location.kind === 211 && meaning & 32) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -26920,10 +27353,10 @@ var ts; } } break; - case 212: + case 213: if (lastLocation === location.expression && location.parent.token === 87) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 67897832))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -26931,30 +27364,30 @@ var ts; } } break; - case 150: + case 151: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 242) { - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67897832)) { + if (ts.isClassLike(grandparent) || grandparent.kind === 243) { + if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 198: + case 199: if (compilerOptions.target >= 2) { break; } - case 157: case 158: case 159: case 160: - case 240: + case 161: + case 241: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 197: + case 198: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -26967,27 +27400,28 @@ var ts; } } break; - case 153: - if (location.parent && location.parent.kind === 152) { + case 154: + if (location.parent && location.parent.kind === 153) { location = location.parent; } - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 241)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 242)) { location = location.parent; } break; - case 311: - case 304: + case 313: + case 306: + case 307: location = ts.getJSDocHost(location); break; - case 152: + case 153: if (lastLocation && lastLocation === location.initializer) { associatedDeclarationForContainingInitializer = location; } break; - case 187: + case 188: if (lastLocation && lastLocation === location.initializer) { var root = ts.getRootDeclaration(location); - if (root.kind === 152) { + if (root.kind === 153) { associatedDeclarationForContainingInitializer = location; } } @@ -27004,7 +27438,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 285); + ts.Debug.assert(lastLocation.kind === 286); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -27056,19 +27490,19 @@ var ts; } if (errorLocation && (meaning & 2 || - ((meaning & 32 || meaning & 384) && (meaning & 67220415) === 67220415))) { + ((meaning & 32 || meaning & 384) && (meaning & 111551) === 111551))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); if (exportOrLocalSymbol.flags & 2 || exportOrLocalSymbol.flags & 32 || exportOrLocalSymbol.flags & 384) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } - if (result && isInExternalModule && (meaning & 67220415) === 67220415 && !(originalLocation.flags & 2097152)) { + if (result && isInExternalModule && (meaning & 111551) === 111551 && !(originalLocation.flags & 2097152)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } - if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 67220415) === 67220415) { + if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 111551) === 111551) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializer); if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializer)) { @@ -27082,9 +27516,9 @@ var ts; return result; } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 198 && location.kind !== 197) { + if (location.kind !== 199 && location.kind !== 198) { return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 155 && !ts.hasModifier(location, 32))) && (!lastLocation || lastLocation !== location.name)); + (location.kind === 156 && !ts.hasModifier(location, 32))) && (!lastLocation || lastLocation !== location.name)); } if (lastLocation && lastLocation === location.name) { return false; @@ -27096,12 +27530,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 240: case 241: case 242: - case 244: case 243: case 245: + case 244: + case 246: return true; default: return false; @@ -27113,7 +27547,7 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 151) { + if (decl.kind === 152) { 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)); @@ -27162,9 +27596,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 73: - case 190: + case 191: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 212: + case 213: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -27173,9 +27607,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 | (ts.isInJSFile(errorLocation) ? 67220415 : 0); + var namespaceMeaning = 1920 | (ts.isInJSFile(errorLocation) ? 111551 : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 & ~namespaceMeaning, undefined, undefined, false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 & ~namespaceMeaning, undefined, undefined, false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -27194,8 +27628,8 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (67897832 & ~1920)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~67897832 & 67220415, undefined, undefined, false)); + if (meaning & (788968 & ~1920)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 & 111551, undefined, undefined, false)); if (symbol && !(symbol.flags & 1920)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here, ts.unescapeLeadingUnderscores(name)); return true; @@ -27204,12 +27638,12 @@ var ts; return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 & ~1024)) { + if (meaning & (111551 & ~1024)) { if (name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never") { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 & ~67220415, undefined, undefined, false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 & ~111551, undefined, undefined, false)); if (symbol && !(symbol.flags & 1024)) { var message = isES2015OrLaterConstructorName(name) ? ts.Diagnostics._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 @@ -27233,15 +27667,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 & ~1024 & ~67897832)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~67220415, undefined, undefined, false)); + if (meaning & (111551 & ~1024 & ~788968)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~111551, undefined, undefined, false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (67897832 & ~1024 & ~67220415)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 | 1024) & ~67897832, undefined, undefined, false)); + else if (meaning & (788968 & ~1024 & ~111551)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 | 1024) & ~788968, undefined, undefined, false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -27251,9 +27685,12 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 || result.flags & 32 || result.flags & 384)); - var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 244) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); + if (result.flags & (16 | 1 | 67108864) && result.flags & 32) { + return; + } + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 245); }); if (declaration === undefined) - return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); + return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); if (!(declaration.flags & 4194304) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); @@ -27282,13 +27719,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 249: + case 250: return node; - case 251: - return node.parent; case 252: + return node.parent; + case 253: return node.parent.parent; - case 254: + case 255: return node.parent.parent.parent; default: return undefined; @@ -27298,7 +27735,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 260) { + if (node.moduleReference.kind === 261) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -27369,7 +27806,7 @@ var ts; if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (67897832 | 1920)) { + if (valueSymbol.flags & (788968 | 1920)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -27456,7 +27893,7 @@ var ts; if (ts.isClassExpression(expression)) { return checkExpression(expression).symbol; } - var aliasLike = resolveEntityName(expression, 67220415 | 67897832 | 1920, true, dontResolveAlias); + var aliasLike = resolveEntityName(expression, 111551 | 788968 | 1920, true, dontResolveAlias); if (aliasLike) { return aliasLike; } @@ -27466,27 +27903,27 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 249: + case 250: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 251: - return getTargetOfImportClause(node, dontRecursivelyResolve); case 252: + return getTargetOfImportClause(node, dontRecursivelyResolve); + case 253: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 254: - return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 258: - return getTargetOfExportSpecifier(node, 67220415 | 67897832 | 1920, dontRecursivelyResolve); case 255: - case 205: + return getTargetOfImportSpecifier(node, dontRecursivelyResolve); + case 259: + return getTargetOfExportSpecifier(node, 111551 | 788968 | 1920, dontRecursivelyResolve); + case 256: + case 206: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 248: + case 249: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); } } function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 67220415 | 67897832 | 1920; } + if (excludes === void 0) { excludes = 111551 | 788968 | 1920; } if (!symbol) return false; return (symbol.flags & (2097152 | excludes)) === 2097152 || !!(symbol.flags & 2097152 && symbol.flags & 67108864); @@ -27520,7 +27957,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 67220415) && !isConstEnumOrConstEnumOnlyModule(target)); + ((target.flags & 111551) && !isConstEnumOrConstEnumOnlyModule(target)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -27533,14 +27970,11 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 255) { - checkExpressionCached(node.expression); - } - else if (node.kind === 258) { - checkExpressionCached(node.propertyName || node.name); - } - else if (ts.isInternalModuleImportEqualsDeclaration(node)) { - checkExpressionCached(node.moduleReference); + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + var target = resolveSymbol(symbol); + if (target === unknownSymbol || target.flags & 111551) { + checkExpressionCached(node.moduleReference); + } } } } @@ -27548,12 +27982,12 @@ var ts; if (entityName.kind === 73 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 73 || entityName.parent.kind === 149) { + if (entityName.kind === 73 || entityName.parent.kind === 150) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 249); - return resolveEntityName(entityName, 67220415 | 67897832 | 1920, false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 250); + return resolveEntityName(entityName, 111551 | 788968 | 1920, false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { @@ -27563,7 +27997,7 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 | (ts.isInJSFile(name) ? meaning & 67220415 : 0); + var namespaceMeaning = 1920 | (ts.isInJSFile(name) ? meaning & 111551 : 0); var symbol; if (name.kind === 73) { var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name)); @@ -27573,9 +28007,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 149 || name.kind === 190) { - var left = name.kind === 149 ? name.left : name.expression; - var right = name.kind === 149 ? name.right : name.name; + else if (name.kind === 150 || name.kind === 191) { + var left = name.kind === 150 ? name.left : name.expression; + var right = name.kind === 150 ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -27658,6 +28092,14 @@ var ts; undefined; return initializer || decl; } + function getExpandoSymbol(symbol) { + var decl = symbol.valueDeclaration; + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288) { + return undefined; + } + var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); + return init && getSymbolOfNode(init) || undefined; + } function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0); } @@ -27669,9 +28111,6 @@ var ts; } function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReference === undefined) { - return; - } if (ts.startsWith(moduleReference, "@types/")) { var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1; var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/"); @@ -27786,7 +28225,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 | 3)) && !ts.getDeclarationOfKind(symbol, 285)) { + if (!(symbol.flags & (1536 | 3)) && !ts.getDeclarationOfKind(symbol, 286)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -28025,13 +28464,13 @@ var ts; return getMergedSymbol(symbol && (symbol.flags & 1048576) !== 0 ? symbol.exportSymbol : symbol); } function symbolIsValue(symbol) { - return !!(symbol.flags & 67220415 || symbol.flags & 2097152 && resolveAlias(symbol).flags & 67220415); + return !!(symbol.flags & 111551 || symbol.flags & 2097152 && resolveAlias(symbol).flags & 111551); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 158 && ts.nodeIsPresent(member.body)) { + if (member.kind === 159 && ts.nodeIsPresent(member.body)) { return member; } } @@ -28112,11 +28551,11 @@ var ts; } } switch (location.kind) { - case 285: + case 286: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 245: + case 246: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -28126,7 +28565,7 @@ var ts; return callback(globals); } function getQualifiedLeftMeaning(rightMeaning) { - return rightMeaning === 67220415 ? 67220415 : 1920; + return rightMeaning === 111551 ? 111551 : 1920; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = ts.createMap(); } @@ -28166,7 +28605,7 @@ var ts; && symbolFromSymbolTable.escapedName !== "default" && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration))) && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) - && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 258))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 259))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -28195,7 +28634,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 258)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 259)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -28209,10 +28648,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 155: - case 157: - case 159: + case 156: + case 158: case 160: + case 161: continue; default: return false; @@ -28223,11 +28662,11 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67897832, false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 788968, false); return access.accessibility === 0; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67220415, false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 111551, false); return access.accessibility === 0; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible) { @@ -28253,7 +28692,7 @@ var ts; } var containers = getContainersOfSymbol(symbol, enclosingDeclaration); var firstDecl = ts.first(symbol.declarations); - if (!ts.length(containers) && meaning & 67220415 && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { + if (!ts.length(containers) && meaning & 111551 && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { if (firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent) && firstDecl === firstDecl.parent.initializer) { containers = [getSymbolOfNode(firstDecl.parent)]; } @@ -28300,10 +28739,10 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 285 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 286 && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 285 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 286 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -28343,17 +28782,17 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 168 || + if (entityName.parent.kind === 169 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 150) { - meaning = 67220415 | 1048576; + entityName.parent.kind === 151) { + meaning = 111551 | 1048576; } - else if (entityName.kind === 149 || entityName.kind === 190 || - entityName.parent.kind === 249) { + else if (entityName.kind === 150 || entityName.kind === 191 || + entityName.parent.kind === 250) { meaning = 1920; } else { - meaning = 67897832; + meaning = 788968; } var firstIdentifier = getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, undefined, undefined, false); @@ -28394,15 +28833,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144) { - sigOutput = kind === 1 ? 167 : 166; + sigOutput = kind === 1 ? 168 : 167; } else { - sigOutput = kind === 1 ? 162 : 161; + sigOutput = kind === 1 ? 163 : 162; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | 512); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4, sig, sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); + printer.writeNode(4, sig, sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); return writer; } } @@ -28425,14 +28864,17 @@ var ts; return result; } function getTypeNamesForErrorDisplay(left, right) { - var leftStr = typeToString(left); - var rightStr = typeToString(right); + var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left); + var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right); if (leftStr === rightStr) { leftStr = typeToString(left, undefined, 64); rightStr = typeToString(right, undefined, 64); } return [leftStr, rightStr]; } + function symbolValueDeclarationIsContextSensitive(symbol) { + return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0; } return flags & 9469291; @@ -28523,14 +28965,14 @@ var ts; } if (type.flags & 1024 && !(type.flags & 1048576)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 67897832); + var parentName = symbolToTypeNode(parentSymbol, context, 788968); var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), undefined)); return enumLiteralName; } if (type.flags & 1056) { - return symbolToTypeNode(type.symbol, context, 67897832); + return symbolToTypeNode(type.symbol, context, 788968); } if (type.flags & 128) { context.approximateLength += (type.value.length + 2); @@ -28553,7 +28995,7 @@ var ts; if (!(context.flags & 1048576)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 67220415); + return symbolToTypeNode(type.symbol, context, 111551); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); @@ -28615,14 +29057,14 @@ var ts; return ts.createTypeReferenceNode(ts.createIdentifier(ts.idText(name)), undefined); } return type.symbol - ? symbolToTypeNode(type.symbol, context, 67897832) + ? symbolToTypeNode(type.symbol, context, 788968) : ts.createTypeReferenceNode(ts.createIdentifier("?"), undefined); } if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32)) return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 67897832, typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968, typeArgumentNodes); } if (type.flags & (1048576 | 2097152)) { var types = type.flags & 1048576 ? formatUnionTypes(type.types) : type.types; @@ -28631,7 +29073,7 @@ var ts; } var typeNodes = mapToTypeNodes(types, context, true); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 ? 174 : 175, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 ? 175 : 176, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -28671,6 +29113,33 @@ var ts; if (type.flags & 33554432) { return typeToTypeNodeHelper(type.typeVariable, context); } + if (type.flags & 134217728) { + var innerType = type.type; + if (innerType.flags & 2097152) { + if (ts.some(innerType.types, function (t) { return !!getStructuralTagForType(t).aliasSymbol; })) { + var aliasingTypes = []; + var nonAliasingTypes = []; + for (var _i = 0, _a = innerType.types; _i < _a.length; _i++) { + var t = _a[_i]; + var taggedVersion = getStructuralTagForType(t); + if (taggedVersion.aliasSymbol && (context.flags & 16384 || isTypeSymbolAccessible(taggedVersion.aliasSymbol, context.enclosingDeclaration))) { + aliasingTypes.push(taggedVersion); + } + else { + nonAliasingTypes.push(t); + } + } + if (ts.length(aliasingTypes)) { + if (ts.length(nonAliasingTypes)) { + aliasingTypes.push(getStructuralTagForType(getIntersectionType(nonAliasingTypes))); + } + return ts.createUnionOrIntersectionTypeNode(176, ts.map(aliasingTypes, function (t) { return typeToTypeNodeHelper(t, context); })); + } + } + } + context.approximateLength += 4; + return ts.createTypeOperatorNode(148, typeToTypeNodeHelper(innerType, context)); + } return ts.Debug.fail("Should be unreachable."); function createMappedTypeNodeFromType(type) { ts.Debug.assert(!!(type.flags & 524288)); @@ -28697,18 +29166,18 @@ var ts; var isConstructorObject = ts.getObjectFlags(type) & 16 && type.symbol && type.symbol.flags & 32; id = (isConstructorObject ? "+" : "") + getSymbolId(symbol); if (isJSConstructor(symbol.valueDeclaration)) { - var isInstanceType = type === getInferredClassType(symbol) ? 67897832 : 67220415; + var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 : 111551; return symbolToTypeNode(symbol, context, isInstanceType); } - else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 210 && context.flags & 2048) || + else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 211 && context.flags & 2048) || symbol.flags & (384 | 512) || shouldWriteTypeOfFunctionSymbol()) { - return symbolToTypeNode(symbol, context, 67220415); + return symbolToTypeNode(symbol, context, 111551); } else if (context.visitedTypes && context.visitedTypes.has(typeId)) { var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { - return symbolToTypeNode(typeAlias, context, 67897832); + return symbolToTypeNode(typeAlias, context, 788968); } else { return createElidedInformationPlaceholder(context); @@ -28742,7 +29211,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 285 || declaration.parent.kind === 246; + return declaration.parent.kind === 286 || declaration.parent.kind === 247; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return (!!(context.flags & 4096) || (context.visitedTypes && context.visitedTypes.has(typeId))) && @@ -28762,12 +29231,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 166, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 167, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 167, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 168, context); return signatureNode; } } @@ -28834,7 +29303,7 @@ var ts; var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_2 = context.flags; context.flags |= 16; - var ref = symbolToTypeNode(parent, context, 67897832, typeArgumentSlice); + var ref = symbolToTypeNode(parent, context, 788968, typeArgumentSlice); context.flags = flags_2; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -28847,7 +29316,7 @@ var ts; } var flags = context.flags; context.flags |= 16; - var finalRef = symbolToTypeNode(type.symbol, context, 67897832, typeArgumentNodes); + var finalRef = symbolToTypeNode(type.symbol, context, 788968, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -28895,11 +29364,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 161, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 162, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 162, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 163, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; @@ -28960,7 +29429,7 @@ var ts; trackComputedName(decl.name, saveEnclosingDeclaration, context); } } - var propertyName = symbolToName(propertySymbol, context, 67220415, true); + var propertyName = symbolToName(propertySymbol, context, 111551, true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; var optionalToken = propertySymbol.flags & 16777216 ? ts.createToken(56) : undefined; @@ -28968,7 +29437,7 @@ var ts; var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768); }), 0); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 156, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 157, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; if (propertySymbol.valueDeclaration) { @@ -29055,7 +29524,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 158); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 159); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -29099,9 +29568,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 152); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 153); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 306); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 308); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -29111,13 +29580,12 @@ var ts; var modifiers = !(context.flags & 8192) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768; var dotDotDotToken = isRest ? ts.createToken(25) : undefined; - var name = parameterDeclaration - ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 73 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216) : - parameterDeclaration.name.kind === 149 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216) : - cloneBindingName(parameterDeclaration.name) : - ts.symbolName(parameterSymbol) - : ts.symbolName(parameterSymbol); + var name = parameterDeclaration ? parameterDeclaration.name ? + parameterDeclaration.name.kind === 73 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216) : + parameterDeclaration.name.kind === 150 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216) : + cloneBindingName(parameterDeclaration.name) : + ts.symbolName(parameterSymbol) : + ts.symbolName(parameterSymbol); var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384; var questionToken = isOptional ? ts.createToken(56) : undefined; var parameterNode = ts.createParameter(undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, undefined); @@ -29131,7 +29599,7 @@ var ts; } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 187) { + if (clone.kind === 188) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 | 16777216); @@ -29142,9 +29610,9 @@ var ts; if (!context.tracker.trackSymbol) return; var firstIdentifier = getFirstIdentifier(node.expression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 67220415 | 1048576, undefined, undefined, true); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 | 1048576, undefined, undefined, true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 67220415); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { @@ -29248,7 +29716,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 285); + var file = ts.getDeclarationOfKind(symbol, 286); if (file && file.moduleName !== undefined) { return file.moduleName; } @@ -29278,7 +29746,7 @@ var ts; if (!specifier) { var isBundle_1 = (compilerOptions.out || compilerOptions.outFile); var moduleResolverHost = context.tracker.moduleResolverHost; - var specifierCompilerOptions = isBundle_1 ? __assign({}, compilerOptions, { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; + var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, host.getSourceFiles(), { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative" }, host.redirectTargetsMap)); links.specifierCache = links.specifierCache || ts.createMap(); links.specifierCache.set(contextFile.path, specifier); @@ -29287,7 +29755,7 @@ var ts; } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384)); - var isTypeOf = meaning === 67220415; + var isTypeOf = meaning === 111551; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context); @@ -29362,7 +29830,7 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context) { - return !!resolveName(context.enclosingDeclaration, escapedName, 67897832, undefined, escapedName, false); + return !!resolveName(context.enclosingDeclaration, escapedName, 788968, undefined, escapedName, false); } function typeParameterToName(type, context) { if (context.flags & 4 && context.typeParameterNames) { @@ -29371,7 +29839,7 @@ var ts; return cached; } } - var result = symbolToName(type.symbol, context, 67897832, true); + var result = symbolToName(type.symbol, context, 788968, true); if (context.flags & 4) { var rawtext = result.escapedText; var i = 0; @@ -29417,9 +29885,6 @@ var ts; function createExpressionFromSymbolChain(chain, index) { var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; - if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { - return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); - } if (index === 0) { context.flags |= 16777216; } @@ -29428,6 +29893,9 @@ var ts; context.flags ^= 16777216; } var firstChar = symbolName.charCodeAt(0); + if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); + } var canUsePropertyAccess = ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216); @@ -29505,8 +29973,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 178; }); - if (node.kind === 243) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 179; }); + if (node.kind === 244) { return getSymbolOfNode(node); } } @@ -29514,11 +29982,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 246 && + node.parent.kind === 247 && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 285 || ts.isAmbientModule(location); + return location.kind === 286 || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -29546,9 +30014,9 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - var name_2 = ts.getNameOfDeclaration(declaration); - if (name_2) { + var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; }); + var name_2 = declaration && ts.getNameOfDeclaration(declaration); + if (declaration && name_2) { if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } @@ -29560,17 +30028,20 @@ var ts; } return ts.declarationNameToString(name_2); } - if (declaration.parent && declaration.parent.kind === 238) { + if (!declaration) { + declaration = symbol.declarations[0]; + } + if (declaration.parent && declaration.parent.kind === 239) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 210: - case 197: + case 211: case 198: + case 199: if (context && !context.encounteredError && !(context.flags & 131072)) { context.encounteredError = true; } - return declaration.kind === 210 ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 211 ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -29587,66 +30058,67 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 304: - case 311: + case 306: + case 313: + case 307: return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 187: + case 188: return isDeclarationVisible(node.parent.parent); - case 238: + case 239: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 245: - case 241: + case 246: case 242: case 243: - case 240: case 244: - case 249: + case 241: + case 245: + case 250: if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 249 && parent.kind !== 285 && parent.flags & 4194304)) { + !(node.kind !== 250 && parent.kind !== 286 && parent.flags & 4194304)) { return isGlobalSourceFile(parent); } return isDeclarationVisible(parent); + case 156: case 155: - case 154: - case 159: case 160: + case 161: + case 158: case 157: - case 156: if (ts.hasModifier(node, 8 | 16)) { return false; } - case 158: - case 162: - case 161: + case 159: case 163: - case 152: - case 246: - case 166: + case 162: + case 164: + case 153: + case 247: case 167: - case 169: - case 165: + case 168: case 170: + case 166: case 171: - case 174: + case 172: case 175: - case 178: + case 176: + case 179: return isDeclarationVisible(node.parent); - case 251: case 252: - case 254: + case 253: + case 255: return false; - case 151: - case 285: - case 248: + case 152: + case 286: + case 249: return true; - case 255: + case 256: return false; default: return false; @@ -29655,11 +30127,11 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 255) { - exportSymbol = resolveName(node, node.escapedText, 67220415 | 67897832 | 1920 | 2097152, undefined, node, false); + if (node.parent && node.parent.kind === 256) { + exportSymbol = resolveName(node, node.escapedText, 111551 | 788968 | 1920 | 2097152, undefined, node, false); } - else if (node.parent.kind === 258) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 67220415 | 67897832 | 1920 | 2097152); + else if (node.parent.kind === 259) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 | 788968 | 1920 | 2097152); } var result; if (exportSymbol) { @@ -29679,7 +30151,7 @@ var ts; if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { var internalModuleReference = declaration.moduleReference; var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 67220415 | 67897832 | 1920, undefined, undefined, false); + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 | 788968 | 1920, undefined, undefined, false); if (importSymbol) { buildVisibleNodeList(importSymbol.declarations); } @@ -29739,12 +30211,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 238: case 239: + case 240: + case 255: case 254: case 253: case 252: - case 251: return false; default: return true; @@ -29770,7 +30242,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); } function isComputedNonLiteralName(name) { - return name.kind === 150 && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 151 && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 98304); }); @@ -29813,7 +30285,7 @@ var ts; if (parentAccess && parentAccess.flowNode) { var propName = getDestructuringPropertyName(node); if (propName) { - var result = ts.createNode(191, node.pos, node.end); + var result = ts.createNode(192, node.pos, node.end); result.parent = node; result.expression = parentAccess; var literal = ts.createNode(10, node.pos, node.end); @@ -29828,23 +30300,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 187: - case 276: - return getSyntheticElementAccess(ancestor); case 188: + case 277: + return getSyntheticElementAccess(ancestor); + case 189: return getSyntheticElementAccess(node.parent); - case 238: + case 239: return ancestor.initializer; - case 205: + case 206: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 187 && parent.kind === 185) { + if (node.kind === 188 && parent.kind === 186) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 276 || node.kind === 277) { + if (node.kind === 277 || node.kind === 278) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -29863,7 +30335,7 @@ var ts; parentType = getNonNullableType(parentType); } var type; - if (pattern.kind === 185) { + if (pattern.kind === 186) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -29926,23 +30398,23 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 188 && expr.elements.length === 0; + return expr.kind === 189 && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function isParameterOfContextuallyTypedFunction(node) { - return node.kind === 152 && - (node.parent.kind === 197 || node.parent.kind === 198) && + return node.kind === 153 && + (node.parent.kind === 198 || node.parent.kind === 199) && !!getContextualType(node.parent); } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 227) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 228) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression))); return indexType.flags & (262144 | 4194304) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 228) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 229) { var forOfStatement = declaration.parent.parent; return checkRightHandSideOfForOf(forOfStatement.expression, forOfStatement.awaitModifier) || anyType; } @@ -29956,7 +30428,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 238 && !ts.isBindingPattern(declaration.name) && + declaration.kind === 239 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !(declaration.flags & 4194304)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -29965,10 +30437,10 @@ var ts; return autoArrayType; } } - if (declaration.kind === 152) { + if (declaration.kind === 153) { var func = declaration.parent; - if (func.kind === 160 && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 159); + if (func.kind === 161 && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 160); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -30164,9 +30636,9 @@ var ts; } function isDeclarationInConstructor(expression) { var thisContainer = ts.getThisContainer(expression, false); - return thisContainer.kind === 158 || - thisContainer.kind === 240 || - (thisContainer.kind === 197 && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 159 || + thisContainer.kind === 241 || + (thisContainer.kind === 198 && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -30234,7 +30706,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 187 && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 188 && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; } @@ -30250,7 +30722,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 185 + return pattern.kind === 186 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -30277,7 +30749,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 152 ? root.parent : root; + var memberDeclaration = root.kind === 153 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -30330,7 +30802,7 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 255) { + if (declaration.kind === 256) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } else if (ts.isInJSFile(declaration) && @@ -30390,7 +30862,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 159) { + if (accessor.kind === 160) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -30417,8 +30889,8 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 159); - var setter = ts.getDeclarationOfKind(symbol, 160); + var getter = ts.getDeclarationOfKind(symbol, 160); + var setter = ts.getDeclarationOfKind(symbol, 161); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -30444,7 +30916,9 @@ var ts; } else { if (setter) { - errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); + 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 existed getter as we are current checking either setter or getter in this function"); @@ -30457,7 +30931,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 159); + var getter_1 = ts.getDeclarationOfKind(symbol, 160); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -30473,18 +30947,9 @@ var ts; if (!links.type) { var jsDeclaration = ts.getDeclarationOfExpando(symbol.valueDeclaration); if (jsDeclaration) { - var jsSymbol = getSymbolOfNode(jsDeclaration); - if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { - symbol = cloneSymbol(symbol); - links = symbol; - if (ts.hasEntries(jsSymbol.exports)) { - symbol.exports = symbol.exports || ts.createSymbolTable(); - mergeSymbolTable(symbol.exports, jsSymbol.exports); - } - if (ts.hasEntries(jsSymbol.members)) { - symbol.members = symbol.members || ts.createSymbolTable(); - mergeSymbolTable(symbol.members, jsSymbol.members); - } + var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration)); + if (merged) { + symbol = links = merged; } } originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol); @@ -30496,8 +30961,8 @@ var ts; if (symbol.flags & 1536 && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 205 || - declaration.kind === 190 && declaration.parent.kind === 205) { + else if (declaration.kind === 206 || + declaration.kind === 191 && declaration.parent.kind === 206) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -30531,7 +30996,7 @@ var ts; var links = getSymbolLinks(symbol); if (!links.type) { var targetSymbol = resolveAlias(symbol); - links.type = targetSymbol.flags & 67220415 + links.type = targetSymbol.flags & 111551 ? getTypeOfSymbol(targetSymbol) : errorType; } @@ -30557,7 +31022,7 @@ var ts; error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); return errorType; } - if (noImplicitAny && (declaration.kind !== 152 || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 153 || 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)); } return anyType; @@ -30630,55 +31095,66 @@ var ts; function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; + if (node && ts.isBinaryExpression(node)) { + var assignmentKind = ts.getAssignmentDeclarationKind(node); + if (assignmentKind === 6 || assignmentKind === 3) { + var symbol = getSymbolOfNode(node.left); + if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { + node = symbol.parent.valueDeclaration; + } + } + } if (!node) { return undefined; } switch (node.kind) { - case 241: - case 210: case 242: - case 161: + case 211: + case 243: case 162: - case 156: - case 166: - case 167: - case 295: - case 240: + case 163: case 157: - case 197: + case 167: + case 168: + case 296: + case 241: + case 158: case 198: - case 243: - case 310: - case 311: - case 304: - case 182: - case 176: + case 199: + case 244: + case 312: + case 313: + case 307: + case 306: + case 183: + case 177: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 182) { + if (node.kind === 183) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 176) { + else if (node.kind === 177) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 241 || node.kind === 210 || node.kind === 242) && + (node.kind === 242 || node.kind === 211 || node.kind === 243 || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 242); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 243); return getOuterTypeParameters(declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 242 || - node.kind === 241 || - node.kind === 210 || + if (node.kind === 243 || + node.kind === 242 || + node.kind === 211 || + isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -30705,7 +31181,7 @@ var ts; var constraint = getBaseConstraintOfType(type); return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } - return isJSConstructorType(type); + return false; } function getBaseTypeNodeOfClass(type) { return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); @@ -30790,9 +31266,7 @@ var ts; var baseTypeNode = getBaseTypeNodeOfClass(type); var typeArgs = typeArgumentsFromTypeReferenceNode(baseTypeNode); var baseType; - var originalBaseType = isJSConstructorType(baseConstructorType) ? baseConstructorType : - baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : - undefined; + var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 && areAllOuterTypeParametersApplied(originalBaseType)) { baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol, typeArgs); @@ -30800,9 +31274,6 @@ var ts; else if (baseConstructorType.flags & 1) { baseType = baseConstructorType; } - else if (isJSConstructorType(baseConstructorType)) { - baseType = !baseTypeNode.typeArguments && getJSClassType(baseConstructorType.symbol) || anyType; - } else { var constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments, baseTypeNode); if (!constructors.length) { @@ -30844,7 +31315,7 @@ var ts; 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 === 242 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 243 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -30873,7 +31344,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242) { + if (declaration.kind === 243) { if (declaration.flags & 64) { return false; } @@ -30882,7 +31353,7 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 67897832, true); + var baseSymbol = resolveEntityName(node.expression, 788968, true); if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } @@ -30895,9 +31366,14 @@ var ts; } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); + var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 ? 1 : 2; - var type = links.declaredType = createObjectType(kind, symbol); + var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + if (merged) { + symbol = links = merged; + } + var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (outerTypeParameters || localTypeParameters || kind === 1 || !isThislessInterface(symbol)) { @@ -30922,9 +31398,10 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return errorType; } - var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 243; - }); + var declaration = ts.find(symbol.declarations, ts.isTypeAlias); + if (!declaration) { + return ts.Debug.fail("Type alias symbol with no valid declaration found"); + } var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; if (popTypeResolution()) { @@ -30937,7 +31414,7 @@ var ts; } else { type = errorType; - error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + error(ts.isJSDocEnumTag(declaration) ? declaration : declaration.name || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } links.declaredType = type; } @@ -30947,7 +31424,7 @@ var ts; if (expr.kind === 10) { return true; } - else if (expr.kind === 205) { + else if (expr.kind === 206) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -30961,12 +31438,12 @@ var ts; case 10: case 8: return true; - case 203: + case 204: return expr.operator === 39 && expr.operand.kind === 8; case 73: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 205: + case 206: return isStringConcatExpression(expr); default: return false; @@ -30980,7 +31457,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244) { + if (declaration.kind === 245) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && member.initializer.kind === 10) { @@ -31007,7 +31484,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244) { + if (declaration.kind === 245) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -31086,11 +31563,11 @@ var ts; case 142: case 97: case 133: - case 183: + case 184: return true; - case 170: + case 171: return isThislessType(node.elementType); - case 165: + case 166: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -31106,7 +31583,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 158 || (!!returnType && isThislessType(returnType))) && + return (node.kind === 159 || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -31115,14 +31592,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { + case 156: case 155: - case 154: return isThislessVariableLikeDeclaration(declaration); - case 157: - case 156: case 158: + case 157: case 159: case 160: + case 161: return isThislessFunctionLikeDeclaration(declaration); } } @@ -31201,7 +31678,7 @@ var ts; else { symbol.declarations.push(member); } - if (symbolFlags & 67220415) { + if (symbolFlags & 111551) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -31452,7 +31929,7 @@ var ts; } var result; for (var i = 0; i < signatureLists.length; i++) { - var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, true, true, true); + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, true, false, true); if (!match) { return undefined; } @@ -31471,7 +31948,7 @@ var ts; } for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { var signature = _a[_i]; - if (!result || !findMatchingSignature(result, signature, false, true, true)) { + if (!result || !findMatchingSignature(result, signature, false, false, true)) { var unionSignatures = findMatchingSignatures(signatureLists, signature, i); if (unionSignatures) { var s = signature; @@ -31479,7 +31956,7 @@ var ts; var thisParameter = signature.thisParameter; var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; }); if (firstThisParameterOfUnionSignatures) { - var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType; }), 2); + var thisType = getIntersectionType(ts.mapDefined(unionSignatures, function (sig) { return sig.thisParameter && getTypeOfSymbol(sig.thisParameter); })); thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType); } s = createUnionSignature(signature, unionSignatures); @@ -31517,7 +31994,7 @@ var ts; if (!left || !right) { return left || right; } - var thisType = getUnionType([getTypeOfSymbol(left), getTypeOfSymbol(right)], 2); + var thisType = getIntersectionType([getTypeOfSymbol(left), getTypeOfSymbol(right)]); return createSymbolWithType(left, thisType); } function combineUnionParameters(left, right) { @@ -31657,7 +32134,7 @@ var ts; return signatures; } function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; + var symbol = getMergedSymbol(type.symbol); if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false); @@ -31708,13 +32185,17 @@ var ts; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); if (symbol.flags & (16 | 8192)) { type.callSignatures = getSignaturesOfSymbol(symbol); - type.constructSignatures = ts.filter(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration); }); } if (symbol.flags & 32) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); + var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor")) : ts.emptyArray; + if (symbol.flags & 16) { + constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes) : + undefined; })); + } if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); + constructSignatures = getDefaultConstructSignatures(classType_1); } type.constructSignatures = constructSignatures; } @@ -31841,7 +32322,7 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); - return constraintDeclaration.kind === 180 && + return constraintDeclaration.kind === 181 && constraintDeclaration.operator === 130; } function getModifiersTypeFromMappedType(type) { @@ -31903,9 +32384,15 @@ var ts; else if (type.flags & 2097152) { resolveIntersectionTypeMembers(type); } + else if (type.flags & 134217728) { + resolveStructuralTagTypeMembers(type); + } } return type; } + function resolveStructuralTagTypeMembers(type) { + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); + } function getPropertiesOfObjectType(type) { if (type.flags & 524288) { return resolveStructuredTypeMembers(type).properties; @@ -32178,6 +32665,9 @@ var ts; if (t.flags & 33554432) { return getBaseConstraint(t.substitute); } + if (t.flags & 134217728) { + return unknownType; + } return t; } } @@ -32389,7 +32879,7 @@ var ts; return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 3670016) { + if (type.flags & 137887744) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 ? resolved.callSignatures : resolved.constructSignatures; } @@ -32399,7 +32889,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 3670016) { + if (type.flags & 137887744) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -32450,10 +32940,10 @@ var ts; return result; } function isJSDocOptionalParameter(node) { - return ts.isInJSFile(node) && (node.type && node.type.kind === 294 + return ts.isInJSFile(node) && (node.type && node.type.kind === 295 || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294; + return isBracketed || !!typeExpression && typeExpression.type.kind === 295; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -32486,7 +32976,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294; + return isBracketed || !!typeExpression && typeExpression.type.kind === 295; } function createIdentifierTypePredicate(parameterName, parameterIndex, type) { return { kind: 1, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -32549,7 +33039,7 @@ var ts; var paramSymbol = param.symbol; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 67220415, undefined, undefined, false); + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551, undefined, undefined, false); paramSymbol = resolvedSymbol; } if (i === 0 && paramSymbol.escapedName === "this") { @@ -32559,7 +33049,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 183) { + if (type && type.kind === 184) { hasLiteralTypes = true; } var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) || @@ -32571,16 +33061,16 @@ var ts; minArgumentCount = parameters.length; } } - if ((declaration.kind === 159 || declaration.kind === 160) && + if ((declaration.kind === 160 || declaration.kind === 161) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 159 ? 160 : 159; + var otherKind = declaration.kind === 160 ? 161 : 160; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 158 ? + var classType = declaration.kind === 159 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -32632,11 +33122,11 @@ var ts; switch (node.kind) { case 73: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 155: - case 157: - case 159: + case 156: + case 158: case 160: - return node.name.kind === 150 + case 161: + return node.name.kind === 151 && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -32723,7 +33213,6 @@ var ts; var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2) : getReturnTypeFromAnnotation(signature.declaration) || - isJSConstructor(signature.declaration) && getJSClassType(getSymbolOfNode(signature.declaration)) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); if (!popTypeResolution()) { if (signature.declaration) { @@ -32749,7 +33238,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 158) { + if (declaration.kind === 159) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -32759,12 +33248,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 159 && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 160 && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 160); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 161); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -32843,7 +33332,7 @@ var ts; function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0; - var isConstructor = kind === 158 || kind === 162 || kind === 167; + var isConstructor = kind === 159 || kind === 163 || kind === 168; var type = createObjectType(16); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -32884,7 +33373,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 151); + var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 152); return decl && ts.getEffectiveConstraintOfTypeParameter(decl); } function getInferredTypeParameterConstraint(typeParameter) { @@ -32892,9 +33381,9 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 177) { + if (declaration.parent.kind === 178) { var grandParent = declaration.parent.parent; - if (grandParent.kind === 165) { + if (grandParent.kind === 166) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -32911,7 +33400,7 @@ var ts; } } } - else if (grandParent.kind === 152 && grandParent.dotDotDotToken) { + else if (grandParent.kind === 153 && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -32934,7 +33423,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 151); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 152); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -33004,13 +33493,13 @@ var ts; var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent); - var diag = minTypeArgumentCount === typeParameters.length - ? missingAugmentsTag - ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : missingAugmentsTag - ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; + var diag = minTypeArgumentCount === typeParameters.length ? + missingAugmentsTag ? + ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + missingAugmentsTag ? + ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; var typeStr = typeToString(type, undefined, 2); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { @@ -33040,9 +33529,9 @@ var ts; var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { - error(node, minTypeArgumentCount === typeParameters.length - ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); + error(node, minTypeArgumentCount === typeParameters.length ? + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } return getTypeAliasInstantiation(symbol, typeArguments); @@ -33051,9 +33540,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 165: + case 166: return node.typeName; - case 212: + case 213: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -33061,33 +33550,23 @@ var ts; } return undefined; } - function resolveTypeReferenceName(typeReferenceName, meaning) { + function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) { if (!typeReferenceName) { return unknownSymbol; } - return resolveEntityName(typeReferenceName, meaning) || unknownSymbol; + return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); if (symbol === unknownSymbol) { return errorType; } - var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); - if (type) { - return type; + symbol = getExpandoSymbol(symbol) || symbol; + if (symbol.flags & (32 | 64)) { + return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); } - var enumTag = ts.isInJSFile(node) && symbol.valueDeclaration && ts.getJSDocEnumTag(symbol.valueDeclaration); - if (enumTag) { - var links = getNodeLinks(enumTag); - if (!pushTypeResolution(enumTag, 5)) { - return errorType; - } - var type_4 = enumTag.typeExpression ? getTypeFromTypeNode(enumTag.typeExpression) : errorType; - if (!popTypeResolution()) { - type_4 = errorType; - error(node, ts.Diagnostics.Enum_type_0_circularly_references_itself, symbolToString(symbol)); - } - return (links.resolvedEnumType = type_4); + if (symbol.flags & 524288) { + return getTypeFromTypeAliasReference(node, symbol, typeArguments); } var res = tryGetDeclaredTypeOfSymbol(symbol); if (res) { @@ -33095,46 +33574,26 @@ var ts; res.flags & 262144 ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } - if (!(symbol.flags & 67220415 && isJSDocTypeReference(node))) { - return errorType; - } - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; - } - resolveTypeReferenceName(getTypeReferenceName(node), 67897832); - return getTypeOfSymbol(symbol); - } - function getJSDocTypeReference(node, symbol, typeArguments) { - var staticType = getTypeOfSymbol(symbol); - var instanceType = staticType.symbol && - staticType.symbol !== symbol && - getTypeReferenceTypeWorker(node, staticType.symbol, typeArguments); - if (instanceType) { - return getSymbolLinks(symbol).resolvedJSDocType = instanceType; - } - } - function getTypeReferenceTypeWorker(node, symbol, typeArguments) { - if (symbol.flags & (32 | 64)) { - if (symbol.valueDeclaration && symbol.valueDeclaration.parent && ts.isBinaryExpression(symbol.valueDeclaration.parent)) { - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; - } + if (symbol.flags & 111551 && isJSDocTypeReference(node)) { + var jsdocType = getTypeFromJSAlias(node, symbol); + if (jsdocType) { + return jsdocType; } - return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); - } - if (symbol.flags & 524288) { - return getTypeFromTypeAliasReference(node, symbol, typeArguments); - } - if (symbol.flags & 16 && - isJSDocTypeReference(node) && - isJSConstructor(symbol.valueDeclaration)) { - var resolved = resolveStructuredTypeMembers(getTypeOfSymbol(symbol)); - if (resolved.callSignatures.length === 1) { - return getReturnTypeOfSignature(resolved.callSignatures[0]); + else { + resolveTypeReferenceName(getTypeReferenceName(node), 788968); + return getTypeOfSymbol(symbol); } } + return errorType; + } + function getTypeFromJSAlias(node, symbol) { + var valueType = getTypeOfSymbol(symbol); + var typeType = valueType.symbol && + valueType.symbol !== symbol && + getTypeReferenceType(node, valueType.symbol); + if (typeType) { + return getSymbolLinks(symbol).resolvedJSDocType = typeType; + } } function getSubstitutionType(typeVariable, substitute) { if (substitute.flags & 3 || substitute === typeVariable) { @@ -33152,7 +33611,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 171 && node.elementTypes.length === 1; + return node.kind === 172 && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -33161,9 +33620,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 297) { + while (node && !ts.isStatement(node) && node.kind !== 299) { var parent = node.parent; - if (parent.kind === 176 && node === parent.trueType) { + if (parent.kind === 177 && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -33174,7 +33633,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152) && (node.kind === 165 || node.kind === 184); + return !!(node.flags & 2097152) && (node.kind === 166 || node.kind === 185); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -33211,10 +33670,10 @@ var ts; return globalFunctionType; case "Array": case "array": - return !typeArgs || !typeArgs.length ? anyArrayType : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined; case "Promise": case "promise": - return !typeArgs || !typeArgs.length ? createPromiseType(anyType) : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined; case "Object": if (typeArgs && typeArgs.length === 2) { if (ts.isJSDocIndexSignature(node)) { @@ -33226,7 +33685,7 @@ var ts; return anyType; } checkNoTypeArguments(node); - return anyType; + return !noImplicitAny ? anyType : undefined; } } } @@ -33239,10 +33698,19 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - var meaning = 67897832; + var meaning = 788968; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); - meaning |= 67220415; + if (!type) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, true); + if (symbol === unknownSymbol) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551); + } + else { + resolveTypeReferenceName(getTypeReferenceName(node), meaning); + } + type = getTypeReferenceType(node, symbol); + } } if (!type) { symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning); @@ -33269,9 +33737,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 241: case 242: - case 244: + case 243: + case 245: return declaration; } } @@ -33291,10 +33759,10 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67220415, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67897832, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { return resolveName(undefined, name, meaning, diagnostic, name, false); @@ -33362,7 +33830,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 67897832, undefined); + var symbol = getGlobalSymbol(name, 788968, undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -33462,8 +33930,8 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 173 ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 172 && n !== restElement_1; }) + 1; + var restElement_1 = lastElement && lastElement.kind === 174 ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 173 && n !== restElement_1; }) + 1; var elementTypes = ts.map(node.elementTypes, function (n) { var type = getTypeFromTypeNode(n); return n === restElement_1 && getIndexTypeOfType(type, 1) || type; @@ -33504,7 +33972,7 @@ var ts; } if (!(flags & 131072)) { includes |= flags & 68943871; - if (flags & 66846720) + if (flags & 201064448) includes |= 262144; if (type === wildcardType) includes |= 4194304; @@ -33622,7 +34090,7 @@ var ts; neverType; } } - return getUnionTypeFromSortedList(typeSet, includes & 66994211 ? 0 : 131072, aliasSymbol, aliasTypeArguments); + return getUnionTypeFromSortedList(typeSet, includes & 201211939 ? 0 : 131072, aliasSymbol, aliasTypeArguments); } function getUnionTypePredicate(signatures) { var first; @@ -33683,10 +34151,10 @@ var ts; } return links.resolvedType; } - function addTypeToIntersection(typeSet, includes, type) { + function addTypeToIntersection(typeSet, includes, type, tagSet) { var flags = type.flags; if (flags & 2097152) { - return addTypesToIntersection(typeSet, includes, type.types); + return addTypesToIntersection(typeSet, includes, type.types, tagSet); } if (isEmptyAnonymousObjectType(type)) { if (!(includes & 8388608)) { @@ -33699,6 +34167,9 @@ var ts; if (type === wildcardType) includes |= 4194304; } + else if (flags & 134217728) { + tagSet.set(type.id.toString(), type); + } else if ((strictNullChecks || !(flags & 98304)) && !typeSet.has(type.id.toString())) { if (type.flags & 109440 && includes & 109440) { includes |= 67108864; @@ -33709,10 +34180,27 @@ var ts; } return includes; } - function addTypesToIntersection(typeSet, includes, types) { + function addTypesToIntersection(typeSet, includes, types, tagSet) { + var isTopLevel = !tagSet; + tagSet = tagSet || ts.createMap(); for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { var type = types_8[_i]; - includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); + includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type), tagSet); + } + if (isTopLevel && tagSet.size) { + var tag = void 0; + if (tagSet.size === 1) { + tag = tagSet.values().next().value; + } + else { + var tagTypes_1 = []; + tagSet.forEach(function (t) { return tagTypes_1.push(t.type); }); + tag = getStructuralTagForType(getIntersectionType(tagTypes_1)); + if (tag.flags & 1048576) { + includes |= 1048576; + } + } + typeSet.set(tag.id.toString(), tag); } return includes; } @@ -33746,6 +34234,15 @@ var ts; } return true; } + function extractIrreducible(types, flag) { + if (ts.every(types, function (t) { return !!(t.flags & 1048576) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); })) { + for (var i = 0; i < types.length; i++) { + types[i] = filterType(types[i], function (t) { return !(t.flags & flag); }); + } + return true; + } + return false; + } function intersectUnionsOfPrimitiveTypes(types) { var unionTypes; var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 131072); }); @@ -33832,6 +34329,12 @@ var ts; if (intersectUnionsOfPrimitiveTypes(typeSet)) { result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } + else if (extractIrreducible(typeSet, 32768)) { + result = getUnionType([getIntersectionType(typeSet), undefinedType], 1, aliasSymbol, aliasTypeArguments); + } + else if (extractIrreducible(typeSet, 65536)) { + result = getUnionType([getIntersectionType(typeSet), nullType], 1, aliasSymbol, aliasTypeArguments); + } else { var size = ts.reduceLeft(typeSet, function (n, t) { return n * (t.flags & 1048576 ? t.types.length : 1); }, 1); if (size >= 100000) { @@ -33944,6 +34447,13 @@ var ts; case 134: links.resolvedType = getTypeFromTypeNode(node.type); break; + case 148: + var aliasSymbol = getAliasSymbolForTypeNode(node); + var aliasParams = getTypeArgumentsForAliasSymbol(aliasSymbol); + links.resolvedType = getStructuralTagForType(getTypeFromTypeNode(node.type), aliasSymbol, aliasParams); + break; + default: + throw ts.Debug.assertNever(node.operator); } } return links.resolvedType; @@ -33954,6 +34464,26 @@ var ts; type.indexType = indexType; return type; } + function getStructuralTagForType(type, aliasSymbol, aliasTypeArguments) { + if (typeof aliasSymbol === "number") { + aliasSymbol = undefined; + } + var tid = "" + getTypeId(type); + if (structuralTags.has(tid)) { + return structuralTags.get(tid); + } + if (type.flags & 1048576) { + var union = getUnionType(ts.map(type.types, getStructuralTagForType), 2, aliasSymbol, aliasTypeArguments); + structuralTags.set(tid, union); + return union; + } + var tag = createType(134217728); + tag.type = type; + tag.aliasSymbol = aliasSymbol; + tag.aliasTypeArguments = aliasTypeArguments; + structuralTags.set(tid, tag); + return tag; + } function isJSLiteralType(type) { if (noImplicitAny) { return false; @@ -33973,7 +34503,7 @@ var ts; return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 191 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 192 ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ? @@ -33983,7 +34513,7 @@ var ts; undefined; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) { - var accessExpression = accessNode && accessNode.kind === 191 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 192 ? accessNode : undefined; var propName = getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); @@ -34120,13 +34650,10 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 191 - ? accessNode.argumentExpression - : accessNode.kind === 181 - ? accessNode.indexType - : accessNode.kind === 150 - ? accessNode.expression - : accessNode; + return accessNode.kind === 192 ? accessNode.argumentExpression : + accessNode.kind === 182 ? accessNode.indexType : + accessNode.kind === 151 ? accessNode.expression : + accessNode; } function isGenericObjectType(type) { return maybeTypeOfKind(type, 58982400 | 131072); @@ -34219,7 +34746,7 @@ var ts; if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304) && isTypeAssignableToKind(indexType, 4 | 8)) { indexType = stringType; } - if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 181) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 182) && isGenericObjectType(objectType)) { if (objectType.flags & 3) { return objectType; } @@ -34407,7 +34934,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 67220415 : node.flags & 2097152 ? 67220415 | 67897832 : 67897832; + var targetMeaning = node.isTypeOf ? 111551 : node.flags & 2097152 ? 111551 | 788968 : 788968; var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { links.resolvedSymbol = unknownSymbol; @@ -34429,14 +34956,14 @@ var ts; getNodeLinks(current.parent).resolvedSymbol = next; currentNamespace = next; } - resolveImportSymbolType(node, links, currentNamespace, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning); } else { if (moduleSymbol.flags & targetMeaning) { - resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 67220415 + var errorMessage = targetMeaning === 111551 ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -34450,11 +34977,11 @@ var ts; function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 67220415) { - return links.resolvedType = getTypeOfSymbol(symbol); + if (meaning === 111551) { + return getTypeOfSymbol(symbol); } else { - return links.resolvedType = getTypeReferenceType(node, resolvedSymbol); + return getTypeReferenceType(node, resolvedSymbol); } } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { @@ -34477,7 +35004,11 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined; + var host = node.parent; + while (ts.isParenthesizedTypeNode(host)) { + host = host.parent; + } + return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; } function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; @@ -34652,12 +35183,22 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 242)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 243)) { if (!ts.hasModifier(container, 32) && - (container.kind !== 158 || ts.isNodeDescendantOf(node, container.body))) { + (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; + } + var host = node.flags & 2097152 ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; + } + if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType; + } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); return errorType; } @@ -34671,8 +35212,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 121: - case 290: case 291: + case 292: return anyType; case 144: return unknownType; @@ -34696,61 +35237,61 @@ var ts; return neverType; case 137: return node.flags & 65536 ? anyType : nonPrimitiveType; - case 179: + case 180: case 101: return getTypeFromThisTypeNode(node); - case 183: + case 184: return getTypeFromLiteralTypeNode(node); - case 165: + case 166: return getTypeFromTypeReference(node); - case 164: + case 165: return booleanType; - case 212: + case 213: return getTypeFromTypeReference(node); - case 168: + case 169: return getTypeFromTypeQueryNode(node); - case 170: - return getTypeFromArrayTypeNode(node); case 171: - return getTypeFromTupleTypeNode(node); + return getTypeFromArrayTypeNode(node); case 172: + return getTypeFromTupleTypeNode(node); + case 173: return getTypeFromOptionalTypeNode(node); - case 174: - return getTypeFromUnionTypeNode(node); case 175: + return getTypeFromUnionTypeNode(node); + case 176: return getTypeFromIntersectionTypeNode(node); - case 292: + case 293: return getTypeFromJSDocNullableTypeNode(node); - case 294: + case 295: return addOptionality(getTypeFromTypeNode(node.type)); - case 178: - case 173: - case 293: - case 289: + case 179: + case 174: + case 294: + case 290: return getTypeFromTypeNode(node.type); - case 296: + case 297: return getTypeFromJSDocVariadicType(node); - case 166: case 167: - case 169: - case 298: - case 295: - case 299: + case 168: + case 170: + case 300: + case 296: + case 301: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 180: - return getTypeFromTypeOperatorNode(node); case 181: - return getTypeFromIndexedAccessTypeNode(node); + return getTypeFromTypeOperatorNode(node); case 182: + return getTypeFromIndexedAccessTypeNode(node); + case 183: return getTypeFromMappedTypeNode(node); - case 176: - return getTypeFromConditionalTypeNode(node); case 177: + return getTypeFromConditionalTypeNode(node); + case 178: return getTypeFromInferTypeNode(node); - case 184: + case 185: return getTypeFromImportTypeNode(node); case 73: - case 149: + case 150: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -34867,7 +35408,7 @@ var ts; } function instantiateSymbol(symbol, mapper) { var links = getSymbolLinks(symbol); - if (links.type && !maybeTypeOfKind(links.type, 524288 | 63176704)) { + if (links.type && !maybeTypeOfKind(links.type, 524288 | 63176704 | 134217728)) { return symbol; } if (ts.getCheckFlags(symbol) & 1) { @@ -34933,14 +35474,15 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 149 || - node.parent.kind === 165 && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 150 || + node.parent.kind === 166 && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 185 && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { 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 === 219 || n.kind === 176 && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 220 || n.kind === 177 && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -34949,12 +35491,12 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 179: + case 180: return !!tp.isThisType; case 73: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 168: + case 169: return true; } return !!ts.forEachChild(node, containsReference); @@ -35125,6 +35667,10 @@ var ts; return sub; } } + if (flags & 134217728) { + var newType = instantiateType(type.type, mapper); + return newType !== type ? getStructuralTagForType(newType, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; + } return type; } function getPermissiveInstantiation(type) { @@ -35146,34 +35692,34 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 157 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 197: case 198: - case 157: - case 240: + case 199: + case 158: + case 241: return isContextSensitiveFunctionLikeDeclaration(node); - case 189: + case 190: return ts.some(node.properties, isContextSensitive); - case 188: + case 189: return ts.some(node.elements, isContextSensitive); - case 206: + case 207: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 205: + case 206: return node.operatorToken.kind === 55 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 276: + case 277: return isContextSensitive(node.initializer); - case 196: + case 197: return isContextSensitive(node.expression); - case 269: + case 270: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 268: { + case 269: { var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 271: { + case 272: { var expression = node.expression; return !!expression && isContextSensitive(expression); } @@ -35190,7 +35736,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 198) { + if (node.kind !== 199) { var parameter = ts.firstOrUndefined(node.parameters); if (!(parameter && ts.parameterIsThisKeyword(parameter))) { return true; @@ -35199,7 +35745,7 @@ var ts; return hasContextSensitiveReturnExpression(node); } function hasContextSensitiveReturnExpression(node) { - return !!node.body && node.body.kind !== 219 && isContextSensitive(node.body); + return !!node.body && node.body.kind !== 220 && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -35279,23 +35825,23 @@ var ts; return true; } switch (node.kind) { - case 271: - case 196: + case 272: + case 197: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 205: + case 206: switch (node.operatorToken.kind) { case 60: case 27: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 189: + case 190: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 188: + case 189: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 269: + case 270: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 198: + case 199: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -35456,16 +36002,16 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 271: + case 272: return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11: if (child.containsOnlyTriviaWhiteSpaces) { break; } return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 261: case 262: - case 265: + case 263: + case 266: return { errorNode: child, innerExpression: child, nameType: nameType }; default: return ts.Debug.assertNever(child, "Found invalid jsx child"); @@ -35536,7 +36082,7 @@ var ts; var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName); var childrenTargetType = getIndexedAccessType(target, getLiteralType(childrenPropName)); var diagnostic = ts.Diagnostics._0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2; - invalidTextDiagnostic = __assign({}, diagnostic, { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); + invalidTextDiagnostic = __assign(__assign({}, diagnostic), { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); } return invalidTextDiagnostic; } @@ -35602,11 +36148,11 @@ var ts; } _b = prop.kind; switch (_b) { + case 161: return [3, 2]; case 160: return [3, 2]; - case 159: return [3, 2]; - case 157: return [3, 2]; - case 277: return [3, 2]; - case 276: return [3, 4]; + case 158: return [3, 2]; + case 278: return [3, 2]; + case 277: return [3, 4]; } return [3, 6]; case 2: return [4, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -35665,8 +36211,8 @@ var ts; return 0; } var kind = target.declaration ? target.declaration.kind : 0; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 157 && - kind !== 156 && kind !== 158; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 158 && + kind !== 157 && kind !== 159; var result = -1; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -35704,13 +36250,15 @@ var ts; result &= related; } if (!ignoreReturnTypes) { - var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType : (target.declaration && isJSConstructor(target.declaration)) ? - getJSClassType(target.declaration.symbol) : getReturnTypeOfSignature(target); + var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType + : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(target.declaration.symbol) + : getReturnTypeOfSignature(target); if (targetReturnType === voidType) { return result; } - var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType : (source.declaration && isJSConstructor(source.declaration)) ? - getJSClassType(source.declaration.symbol) : getReturnTypeOfSignature(source); + var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType + : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(source.declaration.symbol) + : getReturnTypeOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); if (targetTypePredicate) { var sourceTypePredicate = getTypePredicateOfSignature(source); @@ -35888,7 +36436,7 @@ var ts; return related === 1; } } - if (source.flags & 66846720 || target.flags & 66846720) { + if (source.flags & 201064448 || target.flags & 201064448) { return checkTypeRelatedTo(source, target, relation, undefined); } return false; @@ -35936,7 +36484,7 @@ var ts; } var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); if (relatedInfo) { - ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInfo)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInfo)); } if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -35981,8 +36529,8 @@ var ts; reportError(message, sourceType, targetType); } function tryElaborateErrorsForPrimitivesAndObjects(source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); + var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source); + var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target); if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || @@ -36049,7 +36597,7 @@ var ts; isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1; var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096); - var isPerformingExcessPropertyChecks = (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768); + var isPerformingExcessPropertyChecks = !isApparentIntersectionConstituent && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768); if (isPerformingExcessPropertyChecks) { var discriminantType = target.flags & 1048576 ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { @@ -36059,11 +36607,11 @@ var ts; return 0; } } - if (relation !== comparableRelation && !isApparentIntersectionConstituent && + var isPerformingCommonPropertyChecks = relation !== comparableRelation && !isApparentIntersectionConstituent && source.flags & (131068 | 524288 | 2097152) && source !== globalObjectType && target.flags & (524288 | 2097152) && isWeakType(target) && - (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)) && - !hasCommonProperties(source, target, isComparingJsxAttributes)) { + (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); + if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var calls = getSignaturesOfType(source, 0); var constructs = getSignaturesOfType(source, 1); @@ -36082,15 +36630,15 @@ var ts; var isIntersectionConstituent = !!isApparentIntersectionConstituent; if (source.flags & 1048576) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068)) : + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), isIntersectionConstituent) : eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068)); } else { if (target.flags & 1048576) { result = typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068) && !(target.flags & 131068)); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { var discriminantType = findMatchingDiscriminantType(source, target) || filterPrimitivesIfContainsNonPrimitive(target); - if (!propertiesRelatedTo(source, discriminantType, reportErrors, undefined)) { + if (!propertiesRelatedTo(source, discriminantType, reportErrors, undefined, isIntersectionConstituent)) { return 0; } } @@ -36098,16 +36646,16 @@ var ts; else if (target.flags & 2097152) { isIntersectionConstituent = true; result = typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors); - if (result && isPerformingExcessPropertyChecks) { - if (!propertiesRelatedTo(source, target, reportErrors, undefined)) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { + if (!propertiesRelatedTo(source, target, reportErrors, undefined, false)) { return 0; } } } else if (source.flags & 2097152) { - result = someTypeRelatedToType(source, target, false); + result = someTypeRelatedToType(source, target, false, true); } - if (!result && (source.flags & 66846720 || target.flags & 66846720)) { + if (!result && (source.flags & 201064448 || target.flags & 201064448)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { errorInfo = saveErrorInfo; } @@ -36348,14 +36896,14 @@ var ts; } return result; } - function someTypeRelatedToType(source, target, reportErrors) { + function someTypeRelatedToType(source, target, reportErrors, isIntersectionConstituent) { var sourceTypes = source.types; if (source.flags & 1048576 && containsType(sourceTypes, target)) { return -1; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, undefined, isIntersectionConstituent); if (related) { return related; } @@ -36375,7 +36923,7 @@ var ts; } return result; } - function typeArgumentsRelatedTo(sources, targets, variances, reportErrors) { + function typeArgumentsRelatedTo(sources, targets, variances, reportErrors, isIntersectionConstituent) { if (sources === void 0) { sources = ts.emptyArray; } if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } @@ -36395,21 +36943,21 @@ var ts; related = relation === identityRelation ? isRelatedTo(s, t, false) : compareTypesIdentical(s, t); } else if (variance === 1) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, undefined, isIntersectionConstituent); } else if (variance === 2) { - related = isRelatedTo(t, s, reportErrors); + related = isRelatedTo(t, s, reportErrors, undefined, isIntersectionConstituent); } else if (variance === 3) { related = isRelatedTo(t, s, false); if (!related) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, undefined, isIntersectionConstituent); } } else { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, undefined, isIntersectionConstituent); if (related) { - related &= isRelatedTo(t, s, reportErrors); + related &= isRelatedTo(t, s, reportErrors, undefined, isIntersectionConstituent); } } if (!related) { @@ -36527,6 +37075,9 @@ var ts; if (flags & 33554432) { return isRelatedTo(source.substitute, target.substitute, false); } + if (flags & 134217728) { + return isRelatedTo(source.type, target.type, false); + } return 0; } var result; @@ -36537,7 +37088,7 @@ var ts; source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) { var variances = getAliasVariances(source.aliasSymbol); - var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances); + var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -36610,6 +37161,12 @@ var ts; } } } + else if (target.flags & 134217728) { + if (source.flags & 134217728) { + return isRelatedTo(source.type, target.type, reportErrors); + } + return 0; + } if (source.flags & 8650752) { if (source.flags & 8388608 && target.flags & 8388608) { if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) { @@ -36646,9 +37203,18 @@ var ts; } else if (source.flags & 16777216) { if (target.flags & 16777216) { - if (isTypeIdenticalTo(source.extendsType, target.extendsType) && + var sourceParams = source.root.inferTypeParameters; + var sourceExtends = source.extendsType; + var mapper = void 0; + if (sourceParams) { + var ctx = createInferenceContext(sourceParams, undefined, 0, isRelatedTo); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 64 | 128); + sourceExtends = instantiateType(sourceExtends, ctx.mapper); + mapper = ctx.mapper; + } + if (isTypeIdenticalTo(sourceExtends, target.extendsType) && (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { - if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } if (result) { @@ -36697,7 +37263,7 @@ var ts; if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && source.target === target.target && !(ts.getObjectFlags(source) & 8192 || ts.getObjectFlags(target) & 8192)) { var variances = getVariances(source.target); - var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances); + var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -36715,7 +37281,7 @@ var ts; } if (source.flags & (524288 | 2097152) && target.flags & 524288) { var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; - result = propertiesRelatedTo(source, target, reportStructuralErrors, undefined); + result = propertiesRelatedTo(source, target, reportStructuralErrors, undefined, isIntersectionConstituent); if (result) { result &= signaturesRelatedTo(source, target, 0, reportStructuralErrors); if (result) { @@ -36746,8 +37312,8 @@ var ts; } } return 0; - function relateVariances(sourceTypeArguments, targetTypeArguments, variances) { - if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors)) { + function relateVariances(sourceTypeArguments, targetTypeArguments, variances, isIntersectionConstituent) { + if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, isIntersectionConstituent)) { return result; } if (ts.some(variances, function (v) { return !!(v & 24); })) { @@ -36828,7 +37394,7 @@ var ts; return "continue-outer"; if (sourceProperty === targetProperty) return "continue"; - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, false); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, false, false); if (!related) { return "continue-outer"; } @@ -36855,7 +37421,7 @@ var ts; var result = -1; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, false, excludedProperties); + result &= propertiesRelatedTo(source, type, false, excludedProperties, false); if (result) { result &= signaturesRelatedTo(source, type, 0, false); if (result) { @@ -36890,7 +37456,7 @@ var ts; } return result || properties; } - function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48); var source = getTypeOfSourceProperty(sourceProp); if (ts.getCheckFlags(targetProp) & 65536 && !getSymbolLinks(targetProp).type) { @@ -36924,10 +37490,10 @@ var ts; return result_7; } else { - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, undefined, isIntersectionConstituent); } } - function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 || targetPropFlags & 8) { @@ -36964,7 +37530,7 @@ var ts; } return 0; } - var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors); + var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); @@ -36979,7 +37545,7 @@ var ts; } return related; } - function propertiesRelatedTo(source, target, reportErrors, excludedProperties) { + function propertiesRelatedTo(source, target, reportErrors, excludedProperties, isIntersectionConstituent) { if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } @@ -36995,7 +37561,7 @@ var ts; } if (props.length === 1) { var propName = symbolToString(unmatchedProperty); - reportError.apply(void 0, [ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName].concat(getTypeNamesForErrorDisplay(source, target))); + reportError.apply(void 0, __spreadArrays([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target))); if (ts.length(unmatchedProperty.declarations)) { associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); } @@ -37065,7 +37631,7 @@ var ts; if (!(targetProp.flags & 4194304)) { var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp && sourceProp !== targetProp) { - var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors); + var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, isIntersectionConstituent); if (!related) { return 0; } @@ -37223,7 +37789,7 @@ var ts; return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); } if (isGenericMappedType(source)) { - return (kind === 0 && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); + return kind === 0 ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) : 0; } if (isObjectTypeWithInferableIndex(source)) { var related = -1; @@ -37276,23 +37842,24 @@ var ts; } } function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue) { - var match; + var discriminable = target.types.map(function (_) { return undefined; }); for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; + var i = 0; for (var _b = 0, _c = target.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, propertyName); if (targetType && related(getDiscriminatingType(), targetType)) { - if (match) { - if (type === match) - continue; - return defaultValue; - } - match = type; + discriminable[i] = discriminable[i] === undefined ? true : discriminable[i]; + } + else { + discriminable[i] = false; } + i++; } } - return match || defaultValue; + var match = discriminable.indexOf(true); + return match === -1 || discriminable.indexOf(true, match + 1) !== -1 ? defaultValue : target.types[match]; } function isWeakType(type) { if (type.flags & 524288) { @@ -37466,8 +38033,27 @@ var ts; } } } + if (depth >= 5 && type.flags & 8388608) { + var root = getRootObjectTypeFromIndexedAccessChain(type); + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (getRootObjectTypeFromIndexedAccessChain(t) === root) { + count++; + if (count >= 5) + return true; + } + } + } return false; } + function getRootObjectTypeFromIndexedAccessChain(type) { + var t = type; + while (t.flags & 8388608) { + t = t.objectType; + } + return t; + } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0; } @@ -37771,8 +38357,8 @@ var ts; && ((target.flags & (8 | 4 | 16)) !== 0); } function isObjectTypeWithInferableIndex(type) { - return type.symbol && (type.symbol.flags & (4096 | 2048 | 384 | 512)) !== 0 && - !typeHasCallOrConstructSignatures(type); + return !!(type.symbol && (type.symbol.flags & (4096 | 2048 | 384 | 512)) !== 0 && + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8); @@ -37969,17 +38555,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 205: + case 206: + case 156: case 155: - case 154: 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 152: + case 153: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 67897832, undefined, param.name.escapedText, true) || + (resolveName(param, param.name.escapedText, 788968, undefined, param.name.escapedText, true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, ts.declarationNameToString(param.name)); @@ -37989,22 +38575,22 @@ 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 187: + case 188: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { return; } break; - case 295: + case 296: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 240: + case 241: + case 158: case 157: - case 156: - case 159: case 160: - case 197: + case 161: case 198: + case 199: if (noImplicitAny && !declaration.name) { if (wideningKind === 1) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); @@ -38018,7 +38604,7 @@ var ts; wideningKind === 1 ? 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 182: + case 183: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -38135,10 +38721,11 @@ var ts; function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); return !!(type.flags & 63176704 || + type.flags & 134217728 && couldContainTypeVariables(type.type) || objectFlags & 4 && ts.forEach(type.typeArguments, couldContainTypeVariables) || objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && type.symbol.declarations || objectFlags & 32 || - type.flags & 3145728 && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 3145728 && !(type.flags & 1024) && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { @@ -38274,8 +38861,7 @@ var ts; var visited; var bivariant = false; var propagationType; - var inferenceCount = 0; - var inferenceIncomplete = false; + var inferencePriority = 256; var allowComplexConstraintInference = true; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { @@ -38293,38 +38879,37 @@ var ts; inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); return; } - if (source.flags & 1048576 && target.flags & 1048576 && !(source.flags & 1024 && target.flags & 1024) || - source.flags & 2097152 && target.flags & 2097152) { - if (source === target) { - for (var _i = 0, _a = source.types; _i < _a.length; _i++) { - var t = _a[_i]; - inferFromTypes(t, t); - } - return; + if (source === target && source.flags & 3145728) { + for (var _i = 0, _a = source.types; _i < _a.length; _i++) { + var t = _a[_i]; + inferFromTypes(t, t); } - var matchingTypes = void 0; - for (var _b = 0, _c = source.types; _b < _c.length; _b++) { - var t = _c[_b]; - var matched = findMatchedType(t, target); - if (matched) { - (matchingTypes || (matchingTypes = [])).push(matched); - inferFromTypes(matched, matched); - } + return; + } + if (target.flags & 1048576) { + var _b = inferFromMatchingTypes(source.flags & 1048576 ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + var _c = inferFromMatchingTypes(tempSources, tempTargets, isTypeCloselyMatchedBy), sources = _c[0], targets = _c[1]; + if (targets.length === 0) { + return; } - if (matchingTypes) { - var s = removeTypesFromUnionOrIntersection(source, matchingTypes); - var t = removeTypesFromUnionOrIntersection(target, matchingTypes); - if (!(s && t)) - return; - source = s; - target = t; + target = getUnionType(targets); + if (sources.length === 0) { + var savePriority = priority; + priority |= 1; + inferFromTypes(source, target); + priority = savePriority; + return; } + source = getUnionType(sources); } - else if (target.flags & 1048576 && !(target.flags & 1024) || target.flags & 2097152) { - var matched = findMatchedType(source, target); - if (matched) { - inferFromTypes(matched, matched); - return; + else if (target.flags & 2097152 && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + if (!(source.flags & 1048576)) { + var _d = inferFromMatchingTypes(source.flags & 2097152 ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + if (sources.length === 0 || targets.length === 0) { + return; + } + source = getIntersectionType(sources); + target = getIntersectionType(targets); } } else if (target.flags & (8388608 | 33554432)) { @@ -38361,7 +38946,7 @@ var ts; clearCachedInferences(inferences); } } - inferenceCount++; + inferencePriority = Math.min(inferencePriority, priority); return; } else { @@ -38388,6 +38973,9 @@ var ts; inferFromTypes(source.type, target.type); contravariant = !contravariant; } + else if (source.flags & 134217728 && target.flags & 134217728) { + inferFromTypes(source.type, target.type); + } else if ((isLiteralType(source) || source.flags & 4) && target.flags & 4194304) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; @@ -38414,10 +39002,16 @@ var ts; else if (target.flags & 3145728) { inferToMultipleTypes(source, target.types, target.flags); } + else if (target.flags & 134217728 && source.flags & 2097152) { + var tagsOnly = getIntersectionType(ts.filter(source.types, function (t) { return !!(t.flags & 134217728); })); + if (tagsOnly !== source) { + inferFromTypes(tagsOnly, target); + } + } else if (source.flags & 1048576) { var sourceTypes = source.types; - for (var _d = 0, sourceTypes_3 = sourceTypes; _d < sourceTypes_3.length; _d++) { - var sourceType = sourceTypes_3[_d]; + for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { + var sourceType = sourceTypes_3[_e]; inferFromTypes(sourceType, target); } } @@ -38437,15 +39031,36 @@ var ts; } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; - var count = visited && visited.get(key); - if (count !== undefined) { - inferenceCount += count; + var status = visited && visited.get(key); + if (status !== undefined) { + inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = ts.createMap())).set(key, 0); - var startCount = inferenceCount; + (visited || (visited = ts.createMap())).set(key, -1); + var saveInferencePriority = inferencePriority; + inferencePriority = 256; action(source, target); - visited.set(key, inferenceCount - startCount); + visited.set(key, inferencePriority); + inferencePriority = Math.min(inferencePriority, saveInferencePriority); + } + function inferFromMatchingTypes(sources, targets, matches) { + var matchedSources; + var matchedTargets; + for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { + var t = targets_1[_i]; + for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) { + var s = sources_1[_a]; + if (matches(s, t)) { + inferFromTypes(s, t); + matchedSources = ts.appendIfUnique(matchedSources, s); + matchedTargets = ts.appendIfUnique(matchedTargets, t); + } + } + } + return [ + matchedSources ? ts.filter(sources, function (t) { return !ts.contains(matchedSources, t); }) : sources, + matchedTargets ? ts.filter(targets, function (t) { return !ts.contains(matchedTargets, t); }) : targets, + ]; } function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; @@ -38485,26 +39100,26 @@ var ts; var nakedTypeVariable = void 0; var sources = source.flags & 1048576 ? source.types : [source]; var matched_1 = new Array(sources.length); - var saveInferenceIncomplete = inferenceIncomplete; - inferenceIncomplete = false; - for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { - var t = targets_1[_i]; + var inferenceCircularity = false; + for (var _i = 0, targets_2 = targets; _i < targets_2.length; _i++) { + var t = targets_2[_i]; if (getInferenceInfoForType(t)) { nakedTypeVariable = t; typeVariableCount++; } else { for (var i = 0; i < sources.length; i++) { - var count = inferenceCount; + var saveInferencePriority = inferencePriority; + inferencePriority = 256; inferFromTypes(sources[i], t); - if (count !== inferenceCount) + if (inferencePriority === priority) matched_1[i] = true; + inferenceCircularity = inferenceCircularity || inferencePriority === -1; + inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } } - var inferenceComplete = !inferenceIncomplete; - inferenceIncomplete = inferenceIncomplete || saveInferenceIncomplete; - if (typeVariableCount === 1 && inferenceComplete) { + if (typeVariableCount === 1 && !inferenceCircularity) { var unmatched = ts.flatMap(sources, function (s, i) { return matched_1[i] ? undefined : s; }); if (unmatched.length) { inferFromTypes(getUnionType(unmatched), nakedTypeVariable); @@ -38513,8 +39128,8 @@ var ts; } } else { - for (var _a = 0, targets_2 = targets; _a < targets_2.length; _a++) { - var t = targets_2[_a]; + for (var _a = 0, targets_3 = targets; _a < targets_3.length; _a++) { + var t = targets_3[_a]; if (getInferenceInfoForType(t)) { typeVariableCount++; } @@ -38526,8 +39141,8 @@ var ts; if (targetFlags & 2097152 ? typeVariableCount === 1 : typeVariableCount > 0) { var savePriority = priority; priority |= 1; - for (var _b = 0, targets_3 = targets; _b < targets_3.length; _b++) { - var t = targets_3[_b]; + for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { + var t = targets_4[_b]; if (getInferenceInfoForType(t)) { inferFromTypes(source, t); } @@ -38582,7 +39197,7 @@ var ts; var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { if (ts.contains(symbolStack, symbol)) { - inferenceIncomplete = true; + inferencePriority = -1; return; } (symbolStack || (symbolStack = [])).push(symbol); @@ -38662,7 +39277,7 @@ var ts; if (!skipParameters) { var saveBivariant = bivariant; var kind = target.declaration ? target.declaration.kind : 0; - bivariant = bivariant || kind === 157 || kind === 156 || kind === 158; + bivariant = bivariant || kind === 158 || kind === 157 || kind === 159; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -38688,39 +39303,12 @@ var ts; } } } - function isMatchableType(type) { - return !(type.flags & 524288) || !!(ts.getObjectFlags(type) & 16); + function isTypeOrBaseIdenticalTo(s, t) { + return isTypeIdenticalTo(s, t) || !!(s.flags & (128 | 256)) && isTypeIdenticalTo(getBaseTypeOfLiteralType(s), t); } - function typeMatchedBySomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; - if (t === type || isMatchableType(t) && isMatchableType(type) && isTypeIdenticalTo(t, type)) { - return true; - } - } - return false; - } - function findMatchedType(type, target) { - if (typeMatchedBySomeType(type, target.types)) { - return type; - } - if (type.flags & (256 | 128) && target.flags & 1048576) { - var base = getBaseTypeOfLiteralType(type); - if (typeMatchedBySomeType(base, target.types)) { - return base; - } - } - return undefined; - } - function removeTypesFromUnionOrIntersection(type, typesToRemove) { - var reducedTypes = []; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (!typeMatchedBySomeType(t, typesToRemove)) { - reducedTypes.push(t); - } - } - return reducedTypes.length ? type.flags & 1048576 ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes) : undefined; + function isTypeCloselyMatchedBy(s, t) { + return !!(s.flags & 524288 && t.flags & 524288 && s.symbol && s.symbol === t.symbol || + s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); @@ -38841,7 +39429,7 @@ var ts; case "AsyncIterator": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later; default: - if (node.parent.kind === 277) { + if (node.parent.kind === 278) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -38853,12 +39441,12 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 67220415 | 1048576, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), false, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; + resolveName(node, node.escapedText, 111551 | 1048576, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), false, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; } return links.resolvedSymbol; } function isInTypeQuery(node) { - return !!ts.findAncestor(node, function (n) { return n.kind === 168 ? true : n.kind === 73 || n.kind === 149 ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 169 ? true : n.kind === 73 || n.kind === 150 ? false : "quit"; }); } function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { @@ -38867,11 +39455,11 @@ var ts; return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; case 101: return "0"; - case 214: - case 196: + case 215: + case 197: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 190: case 191: + case 192: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -38882,24 +39470,24 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 196: - case 214: + case 197: + case 215: return isMatchingReference(source, target.expression); } switch (source.kind) { case 73: return target.kind === 73 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 238 || target.kind === 187) && + (target.kind === 239 || target.kind === 188) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 101: return target.kind === 101; case 99: return target.kind === 99; - case 214: - case 196: + case 215: + case 197: return isMatchingReference(source.expression, target); - case 190: case 191: + case 192: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); @@ -38907,7 +39495,7 @@ var ts; return false; } function getAccessedPropertyName(access) { - return access.kind === 190 ? access.name.escapedText : + return access.kind === 191 ? access.name.escapedText : ts.isStringLiteral(access.argumentExpression) || ts.isNumericLiteral(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } @@ -38987,7 +39575,7 @@ var ts; } } } - if (callExpression.expression.kind === 190 && + if (callExpression.expression.kind === 191 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -39029,8 +39617,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; result |= getTypeFacts(t); } return result; @@ -39133,15 +39721,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65, type, undefinedType, undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 188 && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 276 && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 189 && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 277 && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 205 && parent.parent.left === parent || - parent.parent.kind === 228 && parent.parent.initializer === parent; + return parent.parent.kind === 206 && parent.parent.left === parent || + parent.parent.kind === 229 && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -39158,21 +39746,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 227: - return stringType; case 228: + return stringType; + case 229: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 205: + case 206: return getAssignedTypeOfBinaryExpression(parent); - case 199: + case 200: return undefinedType; - case 188: + case 189: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 209: + case 210: return getAssignedTypeOfSpreadExpression(parent); - case 276: - return getAssignedTypeOfPropertyAssignment(parent); case 277: + return getAssignedTypeOfPropertyAssignment(parent); + case 278: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -39180,7 +39768,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 185 ? + var type = pattern.kind === 186 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -39195,35 +39783,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 227) { + if (node.parent.parent.kind === 228) { return stringType; } - if (node.parent.parent.kind === 228) { + if (node.parent.parent.kind === 229) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 238 ? + return node.kind === 239 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 238 || node.kind === 187 ? + return getConstraintForLocation(node.kind === 239 || node.kind === 188 ? getInitialType(node) : getAssignedType(node), reference); } function isEmptyArrayAssignment(node) { - return node.kind === 238 && node.initializer && + return node.kind === 239 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 187 && node.parent.kind === 205 && + node.kind !== 188 && node.parent.kind === 206 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 196: + case 197: return getReferenceCandidate(node.expression); - case 205: + case 206: switch (node.operatorToken.kind) { case 60: return getReferenceCandidate(node.left); @@ -39235,13 +39823,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 196 || - parent.kind === 205 && parent.operatorToken.kind === 60 && parent.left === node || - parent.kind === 205 && parent.operatorToken.kind === 27 && parent.right === node ? + return parent.kind === 197 || + parent.kind === 206 && parent.operatorToken.kind === 60 && parent.left === node || + parent.kind === 206 && parent.operatorToken.kind === 27 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 272) { + if (clause.kind === 273) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -39261,7 +39849,7 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 272) { + if (clause.kind === 273) { if (clause.expression.kind === 10) { witnesses.push(clause.expression.text); continue; @@ -39342,8 +39930,7 @@ var ts; return mapType(typeWithPrimitives, function (t) { return t.flags & 4 ? extractTypesOfKind(typeWithLiterals, 4 | 128) : t.flags & 8 ? extractTypesOfKind(typeWithLiterals, 8 | 256) : - t.flags & 64 ? extractTypesOfKind(typeWithLiterals, 64 | 2048) : - t; + t.flags & 64 ? extractTypesOfKind(typeWithLiterals, 64 | 2048) : t; }); } return typeWithPrimitives; @@ -39387,8 +39974,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; if (!(t.flags & 131072)) { if (!(ts.getObjectFlags(t) & 256)) { return false; @@ -39406,11 +39993,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 190 && (parent.name.escapedText === "length" || - parent.parent.kind === 192 && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 191 && + var isLengthPushOrUnshift = parent.kind === 191 && (parent.name.escapedText === "length" || + parent.parent.kind === 193 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 192 && parent.expression === root && - parent.parent.kind === 205 && + parent.parent.kind === 206 && parent.parent.operatorToken.kind === 60 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -39448,14 +40035,14 @@ var ts; if (flowAnalysisDisabled) { return errorType; } - if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 268188671)) { return declaredType; } var sharedFlowStart = sharedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); sharedFlowCount = sharedFlowStart; var resultType = ts.getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 214 && getTypeWithFacts(resultType, 2097152).flags & 131072) { + if (reference.parent && reference.parent.kind === 215 && getTypeWithFacts(resultType, 2097152).flags & 131072) { return declaredType; } return resultType; @@ -39543,8 +40130,8 @@ var ts; else if (flags & 2) { var container = flow.container; if (container && container !== flowContainer && - reference.kind !== 190 && reference.kind !== 191 && + reference.kind !== 192 && reference.kind !== 101) { flow = container.flowNode; continue; @@ -39585,13 +40172,13 @@ var ts; if (containsMatchingReference(reference, node)) { if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 197 || init.kind === 198)) { + if (init && (init.kind === 198 || init.kind === 199)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } - if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 227 && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 228 && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } return undefined; @@ -39599,7 +40186,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 192 ? + var expr = node.kind === 193 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -39607,7 +40194,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256) { var evolvedType_1 = type; - if (node.kind === 192) { + if (node.kind === 193) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -39652,7 +40239,7 @@ var ts; else if (isMatchingReferenceDiscriminant(expr, type)) { type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); } - else if (expr.kind === 200 && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 201 && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else if (containsMatchingReferenceDiscriminant(reference, expr)) { @@ -39793,10 +40380,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 200 && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 201 && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 200 && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 201 && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -40091,16 +40678,16 @@ var ts; case 73: case 101: case 99: - case 190: case 191: - return narrowTypeByTruthiness(type, expr, assumeTrue); case 192: + return narrowTypeByTruthiness(type, expr, assumeTrue); + case 193: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 196: + case 197: return narrowType(type, expr.expression, assumeTrue); - case 205: + case 206: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 203: + case 204: if (expr.operator === 52) { return narrowType(type, expr.operand, !assumeTrue); } @@ -40127,9 +40714,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 246 || - node.kind === 285 || - node.kind === 155; + node.kind === 247 || + node.kind === 286 || + node.kind === 156; }); } function isParameterAssigned(symbol) { @@ -40150,7 +40737,7 @@ var ts; if (node.kind === 73) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 152) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 153) { symbol.isAssigned = true; } } @@ -40164,7 +40751,7 @@ var ts; } function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 152 && + declaration.kind === 153 && declaration.initializer && getFalsyFlags(declaredType) & 32768 && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768); @@ -40172,10 +40759,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 190 || + return parent.kind === 191 || + parent.kind === 193 && parent.expression === node || parent.kind === 192 && parent.expression === node || - parent.kind === 191 && parent.expression === node || - parent.kind === 187 && parent.name === node && !!parent.initializer; + parent.kind === 188 && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 58982400 && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304); @@ -40186,8 +40773,11 @@ var ts; } return type; } + function isExportOrExportExpression(location) { + return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); + } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, 67220415) && !isInTypeQuery(location) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { + if (isNonLocalAlias(symbol, 111551) && !isInTypeQuery(location) && ((compilerOptions.preserveConstEnums && isExportOrExportExpression(location)) || !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol)))) { markAliasSymbolAsReferenced(symbol); } } @@ -40199,7 +40789,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 198) { + if (container.kind === 199) { 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.hasModifier(container, 256)) { @@ -40215,7 +40805,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); var declaration = localOrExportSymbol.valueDeclaration; if (localOrExportSymbol.flags & 32) { - if (declaration.kind === 241 + if (declaration.kind === 242 && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -40227,11 +40817,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 210) { + else if (declaration.kind === 211) { var container = ts.getThisContainer(node, false); - while (container.kind !== 285) { + while (container.kind !== 286) { if (container.parent === declaration) { - if (container.kind === 155 && ts.hasModifier(container, 32)) { + if (container.kind === 156 && ts.hasModifier(container, 32)) { getNodeLinks(declaration).flags |= 16777216; getNodeLinks(node).flags |= 33554432; } @@ -40275,22 +40865,22 @@ var ts; if (!declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 152; + var isParameter = ts.getRootDeclaration(declaration).kind === 153; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); var isModuleExports = symbol.flags & 134217728; - while (flowContainer !== declarationContainer && (flowContainer.kind === 197 || - flowContainer.kind === 198 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 198 || + flowContainer.kind === 199 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3) !== 0 || - isInTypeQuery(node) || node.parent.kind === 258) || - node.parent.kind === 214 || - declaration.kind === 238 && declaration.exclamationToken || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 | 16384)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 259) || + node.parent.kind === 215 || + declaration.kind === 239 && declaration.exclamationToken || declaration.flags & 4194304; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -40321,7 +40911,7 @@ var ts; if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 275) { + symbol.valueDeclaration.parent.kind === 276) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -40339,7 +40929,7 @@ var ts; if (usedInFunction) { var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container) && - ts.getAncestor(symbol.valueDeclaration, 239).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 240).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -40355,8 +40945,8 @@ var ts; getNodeLinks(current).flags |= 65536; } } - if (container.kind === 226 && - ts.getAncestor(symbol.valueDeclaration, 239).parent === container && + if (container.kind === 227 && + ts.getAncestor(symbol.valueDeclaration, 240).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304; } @@ -40372,14 +40962,14 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 196) { + while (current.parent.kind === 197) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 203 || current.parent.kind === 204)) { + else if ((current.parent.kind === 204 || current.parent.kind === 205)) { var expr = current.parent; isAssigned = expr.operator === 44 || expr.operator === 45; } @@ -40390,7 +40980,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 155 || container.kind === 158) { + if (container.kind === 156 || container.kind === 159) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -40434,32 +41024,32 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var capturedByArrowFunction = false; - if (container.kind === 158) { + if (container.kind === 159) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } - if (container.kind === 198) { + if (container.kind === 199) { container = ts.getThisContainer(container, false); capturedByArrowFunction = true; } switch (container.kind) { - case 245: + case 246: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 244: + case 245: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 158: + case 159: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 156: case 155: - case 154: if (ts.hasModifier(container, 32)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 150: + case 151: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -40494,19 +41084,15 @@ var ts; if (isInJS && className) { var classSymbol = checkExpression(className).symbol; if (classSymbol && classSymbol.members && (classSymbol.flags & 16)) { - var classType = getJSClassType(classSymbol); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(classSymbol).thisType; + return getFlowTypeOfReference(node, classType); } } else if (isInJS && - (container.kind === 197 || container.kind === 240) && + (container.kind === 198 || container.kind === 241) && ts.getJSDocClassTag(container)) { - var classType = getJSClassType(getMergedSymbol(container.symbol)); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType; + return getFlowTypeOfReference(node, classType); } var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { @@ -40535,7 +41121,7 @@ var ts; } } function getClassNameFromPrototypeMethod(container) { - if (container.kind === 197 && + if (container.kind === 198 && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3) { return container.parent @@ -40543,20 +41129,20 @@ var ts; .expression .expression; } - else if (container.kind === 157 && - container.parent.kind === 189 && + else if (container.kind === 158 && + container.parent.kind === 190 && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6) { return container.parent.parent.left.expression; } - else if (container.kind === 197 && - container.parent.kind === 276 && - container.parent.parent.kind === 189 && + else if (container.kind === 198 && + container.parent.kind === 277 && + container.parent.parent.kind === 190 && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6) { return container.parent.parent.parent.left.expression; } - else if (container.kind === 197 && + else if (container.kind === 198 && ts.isPropertyAssignment(container.parent) && ts.isIdentifier(container.parent.name) && (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") && @@ -40578,7 +41164,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 295) { + if (jsdocType && jsdocType.kind === 296) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -40592,14 +41178,14 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 152 && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 153 && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 192 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 193 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 198) { + while (container && container.kind === 199) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -40607,14 +41193,14 @@ var ts; var canUseSuperExpression = isLegalUsageOfSuperExpression(container); var nodeCheckFlag = 0; if (!canUseSuperExpression) { - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 150; }); - if (current && current.kind === 150) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 151; }); + if (current && current.kind === 151) { 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 === 189)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 190)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -40622,7 +41208,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 158) { + if (!isCallExpression && container.kind === 159) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.hasModifier(container, 32) || isCallExpression) { @@ -40632,7 +41218,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 157 && ts.hasModifier(container, 256)) { + if (container.kind === 158 && ts.hasModifier(container, 256)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -40643,7 +41229,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 189) { + if (container.parent.kind === 190) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -40662,7 +41248,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 158 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 159 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return errorType; } @@ -40674,24 +41260,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 158; + return container.kind === 159; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 189) { + if (ts.isClassLike(container.parent) || container.parent.kind === 190) { if (ts.hasModifier(container, 32)) { - return container.kind === 157 || - container.kind === 156 || - container.kind === 159 || - container.kind === 160; + return container.kind === 158 || + container.kind === 157 || + container.kind === 160 || + container.kind === 161; } else { - return container.kind === 157 || - container.kind === 156 || - container.kind === 159 || + return container.kind === 158 || + container.kind === 157 || container.kind === 160 || + container.kind === 161 || + container.kind === 156 || container.kind === 155 || - container.kind === 154 || - container.kind === 158; + container.kind === 159; } } } @@ -40699,10 +41285,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 157 || - func.kind === 159 || - func.kind === 160) && func.parent.kind === 189 ? func.parent : - func.kind === 197 && func.parent.kind === 276 ? func.parent.parent : + return (func.kind === 158 || + func.kind === 160 || + func.kind === 161) && func.parent.kind === 190 ? func.parent : + func.kind === 198 && func.parent.kind === 277 ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -40714,7 +41300,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 198) { + if (func.kind === 199) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -40738,7 +41324,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 276) { + if (literal.parent.kind !== 277) { break; } literal = literal.parent.parent; @@ -40747,9 +41333,9 @@ var ts; return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral)); } var parent = func.parent; - if (parent.kind === 205 && parent.operatorToken.kind === 60) { + if (parent.kind === 206 && parent.operatorToken.kind === 60) { var target = parent.left; - if (target.kind === 190 || target.kind === 191) { + if (target.kind === 191 || target.kind === 192) { var expression = target.expression; if (inJs && ts.isIdentifier(expression)) { var sourceFile = ts.getSourceFileOfNode(parent); @@ -40806,9 +41392,9 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 152: + case 153: return getContextuallyTypedParameterType(declaration, false); - case 187: + case 188: return getContextualTypeForBindingElement(declaration); } } @@ -40889,6 +41475,15 @@ var ts; } return false; } + function getContextualIterationType(kind, functionDecl) { + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2); + var contextualReturnType = getContextualReturnType(functionDecl); + if (contextualReturnType) { + return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) + || undefined; + } + return undefined; + } function getContextualReturnType(functionDecl) { var returnType = getReturnTypeFromAnnotation(functionDecl); if (returnType) { @@ -40913,7 +41508,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 194) { + if (template.parent.kind === 195) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -40966,7 +41561,7 @@ var ts; } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 67220415, undefined, id.escapedText, true); + var parentSymbol = resolveName(id, id.escapedText, 111551, undefined, id.escapedText, true); if (parentSymbol) { var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated) { @@ -41017,7 +41612,7 @@ var ts; return substituteIndexedMappedType(t, propertyNameType); } } - else if (t.flags & 3670016) { + else if (t.flags & 137887744) { var prop = getPropertyOfType(t, name); if (prop) { return getTypeOfSymbol(prop); @@ -41118,24 +41713,27 @@ var ts; case 73: case 142: return true; - case 190: - case 196: + case 191: + case 197: return isPossiblyDiscriminantValue(node.expression); - case 271: + case 272: 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 === 276 && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 277 && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 268 && 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.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 269 && 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); } function getApparentTypeOfContextualType(node, contextFlags) { - var contextualType = instantiateContextualType(getContextualType(node, contextFlags), node, contextFlags); - if (contextualType) { - var apparentType = mapType(contextualType, getApparentType, true); + var contextualType = ts.isObjectLiteralMethod(node) ? + getContextualTypeForObjectLiteralMethod(node, contextFlags) : + getContextualType(node, contextFlags); + var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); + if (instantiatedType) { + var apparentType = mapType(instantiatedType, getApparentType, true); if (apparentType.flags & 1048576) { if (ts.isObjectLiteralExpression(node)) { return discriminateContextualTypeByObjectMembers(node, apparentType); @@ -41162,7 +41760,7 @@ var ts; return contextualType; } function instantiateInstantiableTypes(type, mapper) { - if (type.flags & 63176704) { + if (type.flags & (63176704 | 134217728)) { return instantiateType(type, mapper); } if (type.flags & 1048576) { @@ -41182,56 +41780,56 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 238: - case 152: + case 239: + case 153: + case 156: case 155: - case 154: - case 187: + case 188: return getContextualTypeForInitializerExpression(node); - case 198: - case 231: + case 199: + case 232: return getContextualTypeForReturnExpression(node); - case 208: + case 209: return getContextualTypeForYieldOperand(parent); - case 202: + case 203: return getContextualTypeForAwaitOperand(parent); - case 192: + case 193: if (parent.expression.kind === 93) { return stringType; } - case 193: + case 194: return getContextualTypeForArgument(parent, node); - case 195: - case 213: + case 196: + case 214: return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type); - case 205: + case 206: return getContextualTypeForBinaryOperand(node, contextFlags); - case 276: case 277: - return getContextualTypeForObjectLiteralElement(parent, contextFlags); case 278: + return getContextualTypeForObjectLiteralElement(parent, contextFlags); + case 279: return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 188: { + case 189: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 206: + case 207: return getContextualTypeForConditionalOperand(node, contextFlags); - case 217: - ts.Debug.assert(parent.parent.kind === 207); + case 218: + ts.Debug.assert(parent.parent.kind === 208); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 196: { + case 197: { var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags); } - case 271: + case 272: return getContextualTypeForJsxExpression(parent); - case 268: - case 270: + case 269: + case 271: return getContextualTypeForJsxAttribute(parent); + case 264: case 263: - case 262: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -41369,7 +41967,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 197 || node.kind === 198; + return node.kind === 198 || node.kind === 199; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -41377,14 +41975,12 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 157 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = ts.isObjectLiteralMethod(node) ? - getContextualTypeForObjectLiteralMethod(node, 1) : - getApparentTypeOfContextualType(node, 1); + var type = getApparentTypeOfContextualType(node, 1); if (!type) { return undefined; } @@ -41393,8 +41989,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var current = types_13[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -41420,8 +42016,8 @@ var ts; return checkIteratedTypeOrElementType(33, arrayOrIterableType, undefinedType, node.expression); } function hasDefaultValue(node) { - return (node.kind === 187 && !!node.initializer) || - (node.kind === 205 && node.operatorToken.kind === 60); + return (node.kind === 188 && !!node.initializer) || + (node.kind === 206 && node.operatorToken.kind === 60); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -41433,7 +42029,7 @@ var ts; var inConstContext = isConstContext(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 209) { + if (inDestructuringPattern && e.kind === 210) { var restArrayType = checkExpression(e.expression, checkMode, forceTuple); var restElementType = getIndexTypeOfType(restArrayType, 1) || getIteratedTypeOrElementType(65, restArrayType, undefinedType, undefined, false); @@ -41446,12 +42042,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 209) { + if (index < elementCount - 1 && e.kind === 210) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 209; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 210; var minLength = elementCount - (hasRestElement ? 1 : 0); var tupleResult = void 0; if (inDestructuringPattern && minLength > 0) { @@ -41490,7 +42086,7 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 150: + case 151: return isNumericComputedName(name); case 73: return isNumericLiteralName(name.escapedText); @@ -41554,7 +42150,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 185 || contextualType.pattern.kind === 189); + (contextualType.pattern.kind === 186 || contextualType.pattern.kind === 190); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -41569,13 +42165,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 150 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 151 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 276 || - memberDecl.kind === 277 || + if (memberDecl.kind === 277 || + memberDecl.kind === 278 || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 276 ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 277 ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 277 ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 278 ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -41596,8 +42192,8 @@ var ts; prop.nameType = nameType; } if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 276 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 277 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 277 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 278 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216; } @@ -41620,7 +42216,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 278) { + else if (memberDecl.kind === 279) { if (languageVersion < 2) { checkExternalEmitHelpers(memberDecl, 2); } @@ -41641,7 +42237,7 @@ var ts; continue; } else { - ts.Debug.assert(memberDecl.kind === 159 || memberDecl.kind === 160); + ts.Debug.assert(memberDecl.kind === 160 || memberDecl.kind === 161); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576)) { @@ -41699,7 +42295,13 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (3 | 67108864 | 524288 | 58982400) || + if (type.flags & 63176704) { + var constraint = getBaseConstraintOfType(type); + if (constraint !== undefined) { + return isValidSpreadType(constraint); + } + } + return !!(type.flags & (1 | 67108864 | 524288 | 134217728 | 58982400) || getFalsyFlags(type) & 117632 && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 3145728 && ts.every(type.types, isValidSpreadType)); } @@ -41774,7 +42376,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 270); + ts.Debug.assert(attributeDecl.kind === 271); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false); attributesTable = ts.createSymbolTable(); @@ -41796,7 +42398,7 @@ var ts; spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false); } } - var parent = openingLikeElement.parent.kind === 261 ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 262 ? openingLikeElement.parent : undefined; if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") { @@ -41852,7 +42454,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 67897832); + var typeSymbol = exports && getSymbol(exports, name, 788968); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } function getIntrinsicTagSymbol(node) { @@ -41908,7 +42510,7 @@ var ts; return getGlobalSymbol(JsxNames.JSX, 1920, undefined); } function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 67897832); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968); var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); var propertiesOfJsxElementAttribPropInterface = jsxElementAttribPropInterfaceType && getPropertiesOfType(jsxElementAttribPropInterfaceType); if (propertiesOfJsxElementAttribPropInterface) { @@ -41925,7 +42527,7 @@ var ts; return undefined; } function getJsxLibraryManagedAttributes(jsxNamespace) { - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67897832); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968); } function getJsxElementPropertiesName(jsxNamespace) { return getNameFromJsxElementAttributesContainer(JsxNames.ElementAttributesPropertyNameContainer, jsxNamespace); @@ -42052,10 +42654,10 @@ var ts; var reactRefErr = diagnostics && compilerOptions.jsx === 2 ? ts.Diagnostics.Cannot_find_name_0 : undefined; var reactNamespace = getJsxNamespace(node); var reactLocation = isNodeOpeningLikeElement ? node.tagName : node; - var reactSym = resolveName(reactLocation, reactNamespace, 67220415, reactRefErr, reactNamespace, true); + var reactSym = resolveName(reactLocation, reactNamespace, 111551, reactRefErr, reactNamespace, true); if (reactSym) { reactSym.isReferenced = 67108863; - if (reactSym.flags & 2097152 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { + if (reactSym.flags & 2097152) { markAliasSymbolAsReferenced(reactSym); } } @@ -42118,7 +42720,7 @@ var ts; } function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 149 ? node.right : node.kind === 184 ? node : node.name; + var errorNode = node.kind === 150 ? node.right : node.kind === 185 ? node : node.name; if (ts.getCheckFlags(prop) & 1024) { error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); return false; @@ -42228,7 +42830,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } function isMethodAccessForCall(node) { - while (node.parent.kind === 196) { + while (node.parent.kind === 197) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -42291,7 +42893,7 @@ var ts; } function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) { var assignmentKind = ts.getAssignmentTargetKind(node); - if (node.kind !== 191 && node.kind !== 190 || + if (node.kind !== 192 && node.kind !== 191 || assignmentKind === 1 || prop && !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 1048576)) { return propType; @@ -42301,7 +42903,7 @@ var ts; var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 158 && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 159 && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -42321,7 +42923,7 @@ var ts; } function checkPropertyNotUsedBeforeDeclaration(prop, node, right) { var valueDeclaration = prop.valueDeclaration; - if (!valueDeclaration) { + if (!valueDeclaration || ts.getSourceFileOfNode(node).isDeclarationFile) { return; } var diagnosticMessage; @@ -42331,8 +42933,8 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 241 && - node.parent.kind !== 165 && + else if (valueDeclaration.kind === 242 && + node.parent.kind !== 166 && !(valueDeclaration.flags & 4194304) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -42344,22 +42946,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 155: + case 156: return true; - case 276: - case 157: - case 159: + case 277: + case 158: case 160: - case 278: - case 150: - case 217: - case 271: - case 268: + case 161: + case 279: + case 151: + case 218: + case 272: case 269: case 270: - case 263: - case 212: - case 274: + case 271: + case 264: + case 213: + case 275: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -42395,7 +42997,7 @@ var ts; if (containingType.flags & 1048576 && !(containingType.flags & 131068)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; - if (!getPropertyOfType(subtype, propNode.escapedText)) { + if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0)) { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); break; } @@ -42433,7 +43035,7 @@ var ts; return prop !== undefined && prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 32); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { - return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67220415); + return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -42508,16 +43110,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 190: + case 191: return isValidPropertyAccessWithType(node, node.expression.kind === 99, propertyName, getWidenedType(checkExpression(node.expression))); - case 149: + case 150: return isValidPropertyAccessWithType(node, false, propertyName, getWidenedType(checkExpression(node.left))); - case 184: + case 185: return isValidPropertyAccessWithType(node, false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 190 && node.expression.kind === 99, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 191 && node.expression.kind === 99, property.escapedName, type); } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { if (type === errorType || isTypeAny(type)) { @@ -42529,7 +43131,7 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 239) { + if (initializer.kind === 240) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -42551,7 +43153,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 227 && + if (node.kind === 228 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -42568,20 +43170,6 @@ var ts; var exprType = checkNonNullExpression(node.expression); var objectType = ts.getAssignmentTargetKind(node) !== 0 || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; - if (!indexExpression) { - var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 193 && node.parent.expression === node) { - var start = ts.skipTrivia(sourceFile.text, node.expression.end); - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - return errorType; - } var indexType = checkExpression(indexExpression); if (objectType === errorType || objectType === silentNeverType) { return objectType; @@ -42634,13 +43222,13 @@ var ts; if (callLikeExpressionMayHaveTypeArguments(node)) { ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 194) { + if (node.kind === 195) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 153) { + else if (node.kind !== 154) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -42689,7 +43277,7 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 209 || arg.kind === 216 && arg.isSpread); + return !!arg && (arg.kind === 210 || arg.kind === 217 && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -42703,9 +43291,9 @@ var ts; var callIsIncomplete = false; var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 194) { + if (node.kind === 195) { argCount = args.length; - if (node.template.kind === 207) { + if (node.template.kind === 208) { var lastSpan = ts.last(node.template.templateSpans); callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated; } @@ -42715,7 +43303,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 153) { + else if (node.kind === 154) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -42729,7 +43317,7 @@ var ts; } else { if (!node.arguments) { - ts.Debug.assert(node.kind === 193); + ts.Debug.assert(node.kind === 194); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -42805,7 +43393,7 @@ var ts; if (ts.isJsxOpeningLikeElement(node)) { return inferJsxTypeArguments(node, signature, checkMode, context); } - if (node.kind !== 153) { + if (node.kind !== 154) { var contextualType = getContextualType(node); if (contextualType) { var outerContext = getInferenceContext(node); @@ -42833,7 +43421,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 !== 211) { + if (arg.kind !== 212) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -42855,7 +43443,7 @@ var ts; if (index >= argCount - 1) { var arg = args[argCount - 1]; if (isSpreadArgument(arg)) { - return arg.kind === 216 ? + return arg.kind === 217 ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0)); } @@ -42920,19 +43508,19 @@ var ts; if (ts.isJsxOpeningLikeElement(node)) { if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 193) { + if (thisType && thisType !== voidType && node.kind !== 194) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; @@ -42940,14 +43528,14 @@ 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 !== 211) { + if (arg.kind !== 212) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, undefined, checkMode); var checkArgType = checkMode & 4 ? getRegularTypeOfObjectLiteral(argType) : argType; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } } @@ -42957,7 +43545,7 @@ var ts; if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, undefined, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(errorNode, spreadType, restType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } return undefined; @@ -42974,32 +43562,32 @@ var ts; } } function getThisArgumentOfCall(node) { - if (node.kind === 192) { + if (node.kind === 193) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 190 || callee.kind === 191) { + if (callee.kind === 191 || callee.kind === 192) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(216, parent.pos, parent.end); + var result = ts.createNode(217, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; return result; } function getEffectiveCallArguments(node) { - if (node.kind === 194) { + if (node.kind === 195) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 207) { + if (template.kind === 208) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 153) { + if (node.kind === 154) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -43023,23 +43611,23 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 241: - case 210: + case 242: + case 211: return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 152: + case 153: var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 158 ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 159 ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 155: - case 157: - case 159: + case 156: + case 158: case 160: - var hasPropDesc = parent.kind !== 155 && languageVersion !== 0; + case 161: + var hasPropDesc = parent.kind !== 156 && languageVersion !== 0; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -43050,16 +43638,16 @@ var ts; } function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 241: - case 210: + case 242: + case 211: return 1; - case 155: + case 156: return 2; - case 157: - case 159: + case 158: case 160: + case 161: return languageVersion === 0 || signature.parameters.length <= 2 ? 2 : 3; - case 152: + case 153: return 3; default: return ts.Debug.fail(); @@ -43182,8 +43770,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, fallbackError) { - var isTaggedTemplate = node.kind === 194; - var isDecorator = node.kind === 153; + var isTaggedTemplate = node.kind === 195; + var isDecorator = node.kind === 154; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; @@ -43208,7 +43796,7 @@ var ts; var candidateForArgumentArityError; var candidateForTypeArgumentError; var result; - var signatureHelpTrailingComma = !!(checkMode & 16) && node.kind === 192 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16) && node.kind === 193 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -43646,8 +44234,8 @@ var ts; if (apparentType.flags & 1048576) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var constituent = types_15[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var constituent = types_14[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -43735,16 +44323,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 241: - case 210: + case 242: + case 211: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 152: + case 153: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 155: + case 156: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 157: - case 159: + case 158: case 160: + case 161: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -43783,8 +44371,8 @@ var ts; function createSignatureForJSXIntrinsic(node, result) { var namespace = getJsxNamespaceAt(node); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 67897832); - var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 67897832, node); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968, node); var declaration = ts.createFunctionTypeNode(undefined, [ts.createParameter(undefined, undefined, undefined, "props", undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, undefined) : ts.createKeywordTypeNode(121)); var parameterSymbol = createSymbol(1, "props"); parameterSymbol.type = result; @@ -43821,16 +44409,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 192: - return resolveCallExpression(node, candidatesOutArray, checkMode); case 193: - return resolveNewExpression(node, candidatesOutArray, checkMode); + return resolveCallExpression(node, candidatesOutArray, checkMode); case 194: + return resolveNewExpression(node, candidatesOutArray, checkMode); + case 195: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 153: + case 154: return resolveDecorator(node, candidatesOutArray, checkMode); + case 264: case 263: - case 262: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -43859,43 +44447,45 @@ var ts; if (ts.getJSDocClassTag(node)) return true; var symbol = getSymbolOfNode(func); - return !!symbol && (symbol.members !== undefined || symbol.exports !== undefined && symbol.exports.get("prototype") !== undefined); - } - return false; - } - function isJSConstructorType(type) { - if (type.flags & 524288) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); + return !!symbol && ts.hasEntries(symbol.members); } return false; } - function getJSClassType(symbol) { - var inferred; - if (isJSConstructor(symbol.valueDeclaration)) { - inferred = getInferredClassType(symbol); + function mergeJSSymbols(target, source) { + if (source && (ts.hasEntries(source.exports) || ts.hasEntries(source.members))) { + var links = getSymbolLinks(source); + if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) { + var inferred = isTransientSymbol(target) ? target : cloneSymbol(target); + inferred.exports = inferred.exports || ts.createSymbolTable(); + inferred.members = inferred.members || ts.createSymbolTable(); + inferred.flags |= source.flags & 32; + if (ts.hasEntries(source.exports)) { + mergeSymbolTable(inferred.exports, source.exports); + } + if (ts.hasEntries(source.members)) { + mergeSymbolTable(inferred.members, source.members); + } + (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred); + return inferred; + } + return links.inferredClassSymbol.get("" + getSymbolId(target)); } - var assigned = getAssignedClassType(symbol); - return assigned && inferred ? - getIntersectionType([inferred, assigned]) : - assigned || inferred; } - function getAssignedClassType(symbol) { - var decl = symbol.valueDeclaration; + function getAssignedClassSymbol(decl) { var assignmentSymbol = decl && decl.parent && (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype"); var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration); - return init ? getWidenedType(checkExpressionCached(init)) : undefined; + return init ? getSymbolOfNode(init) : undefined; } function getAssignedJSPrototype(node) { if (!node.parent) { return false; } var parent = node.parent; - while (parent && parent.kind === 190) { + while (parent && parent.kind === 191) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 60) { @@ -43903,13 +44493,6 @@ var ts; return ts.isObjectLiteralExpression(right) && right; } } - function getInferredClassType(symbol) { - var links = getSymbolLinks(symbol); - if (!links.inferredClassType) { - links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol) || emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - } - return links.inferredClassType; - } function checkCallExpression(node, checkMode) { if (!checkGrammarTypeArguments(node, node.typeArguments)) checkGrammarArguments(node.arguments); @@ -43920,12 +44503,12 @@ var ts; if (node.expression.kind === 99) { return voidType; } - if (node.kind === 193) { + if (node.kind === 194) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 158 && - declaration.kind !== 162 && - declaration.kind !== 167 && + declaration.kind !== 159 && + declaration.kind !== 163 && + declaration.kind !== 168 && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { if (noImplicitAny) { @@ -43968,7 +44551,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 67220415, undefined, undefined, false); + return globalESSymbol === resolveName(left, "Symbol", 111551, undefined, undefined, false); } function checkImportCallExpression(node) { if (!checkGrammarArguments(node.arguments)) @@ -44024,7 +44607,7 @@ var ts; } if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 67220415, undefined, undefined, true); + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551, undefined, undefined, true); if (resolvedRequire === requireSymbol) { return true; } @@ -44032,9 +44615,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 240 + ? 241 : resolvedRequire.flags & 3 - ? 238 + ? 239 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -44060,18 +44643,18 @@ var ts; case 9: case 103: case 88: - case 188: case 189: + case 190: return true; - case 196: + case 197: return isValidConstAssertionArgument(node.expression); - case 203: + case 204: var op = node.operator; var arg = node.operand; return op === 39 && (arg.kind === 8 || arg.kind === 9) || op === 38 && arg.kind === 8; - case 190: case 191: + case 192: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -44121,7 +44704,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 === 158) { + else if (container.kind === 159) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -44131,8 +44714,8 @@ var ts; } } function checkImportMetaProperty(node) { - if (languageVersion < 99 || moduleKind < ts.ModuleKind.ESNext) { - error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options); + if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) { + error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system); } var file = ts.getSourceFileOfNode(node); ts.Debug.assert(!!(file.flags & 1048576), "Containing file is missing import meta node flag."); @@ -44361,7 +44944,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 219) { + if (func.body.kind !== 220) { returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8); if (isAsync) { returnType = checkAwaitedType(returnType, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); @@ -44426,7 +45009,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2, func) || unknownType, isAsync); } else { return isAsync @@ -44512,12 +45095,12 @@ var ts; if (!node.possiblyExhaustive) { return false; } - if (node.expression.kind === 200) { + if (node.expression.kind === 201) { var operandType = getTypeOfExpression(node.expression.expression); var witnesses = getSwitchClauseTypeOfWitnesses(node); var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, true); - var type_5 = getBaseConstraintOfType(operandType) || operandType; - return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072); + var type_4 = getBaseConstraintOfType(operandType) || operandType; + return !!(filterType(type_4, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -44533,7 +45116,7 @@ var ts; if (!(func.flags & 128)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 233 && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 234 && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -44570,11 +45153,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 197: case 198: + case 199: return true; - case 157: - return func.parent.kind === 189; + case 158: + return func.parent.kind === 190; default: return false; } @@ -44588,7 +45171,7 @@ var ts; if (type && maybeTypeOfKind(type, 1 | 16384)) { return; } - if (func.kind === 156 || ts.nodeIsMissing(func.body) || func.body.kind !== 219 || !functionHasImplicitReturn(func)) { + if (func.kind === 157 || ts.nodeIsMissing(func.body) || func.body.kind !== 220 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -44615,7 +45198,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 157 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); if (checkMode && checkMode & 4 && isContextSensitive(node)) { if (!ts.getEffectiveReturnTypeNode(node) && hasContextSensitiveReturnExpression(node)) { @@ -44632,7 +45215,7 @@ var ts; return anyFunctionType; } var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 197) { + if (!hasGrammarError && node.kind === 198) { checkGrammarForGenerator(node); } var type = getTypeOfSymbol(getMergedSymbol(node.symbol)); @@ -44682,7 +45265,7 @@ var ts; type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 157 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -44690,7 +45273,7 @@ var ts; if (!ts.getEffectiveReturnTypeNode(node)) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 219) { + if (node.body.kind === 220) { checkSourceElement(node.body); } else { @@ -44755,10 +45338,10 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 190 || expr.kind === 191) && + (expr.kind === 191 || expr.kind === 192) && expr.expression.kind === 101) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 158)) { + if (!(func && func.kind === 159)) { return true; } return !symbol.valueDeclaration || !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); @@ -44768,13 +45351,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 190 || expr.kind === 191) { + if (expr.kind === 191 || expr.kind === 192) { var node = ts.skipParentheses(expr.expression); if (node.kind === 73) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 252; + return !!declaration && declaration.kind === 253; } } } @@ -44782,7 +45365,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage) { var node = ts.skipOuterExpressions(expr, 2 | 1); - if (node.kind !== 73 && node.kind !== 190 && node.kind !== 191) { + if (node.kind !== 73 && node.kind !== 191 && node.kind !== 192) { error(expr, invalidReferenceMessage); return false; } @@ -44791,7 +45374,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 190 && expr.kind !== 191) { + if (expr.kind !== 191 && expr.kind !== 192) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -44818,7 +45401,7 @@ var ts; var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); var func = ts.getContainingFunction(node); - if (func && func.kind !== 158) { + if (func && func.kind !== 159) { ts.Debug.assert((ts.getFunctionFlags(func) & 2) === 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); @@ -44831,7 +45414,11 @@ var ts; } } var operandType = checkExpression(node.expression); - return checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + var awaitedType = checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + if (awaitedType === operandType && awaitedType !== errorType && !(operandType.flags & 3)) { + addErrorOrSuggestion(false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); + } + return awaitedType; } function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); @@ -44865,7 +45452,7 @@ var ts; } if (node.operator === 38) { if (maybeTypeOfKind(operandType, 2112)) { - error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(operandType)); + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } @@ -44911,8 +45498,8 @@ var ts; } if (type.flags & 3145728) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -44990,7 +45577,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 276 || property.kind === 277) { + if (property.kind === 277 || property.kind === 278) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -45003,9 +45590,9 @@ var ts; } var elementType = getIndexedAccessType(objectLiteralType, exprType, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 277 ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 278 ? property : property.initializer, type); } - else if (property.kind === 278) { + else if (property.kind === 279) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -45045,8 +45632,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 211) { - if (element.kind !== 209) { + if (element.kind !== 212) { + if (element.kind !== 210) { var indexType = getLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { var accessFlags = hasDefaultValue(element) ? 8 : 0; @@ -45062,7 +45649,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 205 && restExpression.operatorToken.kind === 60) { + if (restExpression.kind === 206 && restExpression.operatorToken.kind === 60) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -45078,7 +45665,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 277) { + if (exprOrAssignment.kind === 278) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -45092,21 +45679,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 205 && target.operatorToken.kind === 60) { + if (target.kind === 206 && target.operatorToken.kind === 60) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 189) { + if (target.kind === 190) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 188) { + if (target.kind === 189) { 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 === 278 ? + var error = target.parent.kind === 279 ? 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; if (checkReferenceExpression(target, error)) { @@ -45120,8 +45707,8 @@ var ts; case 73: case 10: case 13: - case 194: - case 207: + case 195: + case 208: case 14: case 8: case 9: @@ -45129,27 +45716,27 @@ var ts; case 88: case 97: case 142: - case 197: - case 210: case 198: - case 188: + case 211: + case 199: case 189: - case 200: - case 214: + case 190: + case 201: + case 215: + case 263: case 262: - case 261: return true; - case 206: + case 207: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 205: + case 206: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 203: case 204: + case 205: switch (node.operator) { case 52: case 38: @@ -45158,9 +45745,9 @@ var ts; return true; } return false; - case 201: - case 195: - case 213: + case 202: + case 196: + case 214: default: return false; } @@ -45176,7 +45763,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 60 && (left.kind === 189 || left.kind === 188)) { + if (operator === 60 && (left.kind === 190 || left.kind === 189)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 101); } var leftType; @@ -45230,7 +45817,7 @@ var ts; !(maybeTypeOfKind(leftType, 2112) || maybeTypeOfKind(rightType, 2112))) { resultType_1 = numberType; } - else if (isTypeAssignableToKind(leftType, 2112) && isTypeAssignableToKind(rightType, 2112)) { + else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { case 48: case 69: @@ -45239,7 +45826,7 @@ var ts; resultType_1 = bigintType; } else { - reportOperatorError(function (awaitedLeft, awaitedRight) { return isTypeAssignableToKind(awaitedLeft, 2112) && isTypeAssignableToKind(awaitedRight, 2112); }); + reportOperatorError(bothAreBigIntLike); resultType_1 = errorType; } if (leftOk && rightOk) { @@ -45274,9 +45861,9 @@ var ts; } if (!resultType) { var closeEnoughKind_1 = 296 | 2112 | 132 | 3; - reportOperatorError(function (awaitedLeft, awaitedRight) { - return isTypeAssignableToKind(awaitedLeft, closeEnoughKind_1) && - isTypeAssignableToKind(awaitedRight, closeEnoughKind_1); + reportOperatorError(function (left, right) { + return isTypeAssignableToKind(left, closeEnoughKind_1) && + isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } @@ -45340,6 +45927,9 @@ var ts; default: return ts.Debug.fail(); } + function bothAreBigIntLike(left, right) { + return isTypeAssignableToKind(left, 2112) && isTypeAssignableToKind(right, 2112); + } function checkAssignmentDeclaration(kind, rightType) { if (kind === 2) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { @@ -45347,7 +45937,7 @@ var ts; var propType = getTypeOfSymbol(prop); if (propType.symbol && propType.symbol.flags & 32) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 67897832, undefined, name, false); + var symbol = resolveName(prop.valueDeclaration, name, 788968, undefined, name, false); if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) { grammarErrorOnNode(symbol.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); return grammarErrorOnNode(prop.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); @@ -45416,17 +46006,23 @@ var ts; } return false; } - function reportOperatorError(awaitedTypesAreCompatible) { + function reportOperatorError(isRelated) { + var _a; var wouldWorkWithAwait = false; var errNode = errorNode || operatorToken; - var _a = getTypeNamesForErrorDisplay(leftType, rightType), leftStr = _a[0], rightStr = _a[1]; - if (awaitedTypesAreCompatible) { + if (isRelated) { var awaitedLeftType = getAwaitedType(leftType); var awaitedRightType = getAwaitedType(rightType); wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType) && !!(awaitedLeftType && awaitedRightType) - && awaitedTypesAreCompatible(awaitedLeftType, awaitedRightType); + && isRelated(awaitedLeftType, awaitedRightType); + } + var effectiveLeft = leftType; + var effectiveRight = rightType; + if (!wouldWorkWithAwait && isRelated) { + _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1]; } + var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1]; if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) { errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); } @@ -45448,6 +46044,17 @@ var ts; return undefined; } } + function getBaseTypesIfUnrelated(leftType, rightType, isRelated) { + var effectiveLeft = leftType; + var effectiveRight = rightType; + var leftBase = getBaseTypeOfLiteralType(leftType); + var rightBase = getBaseTypeOfLiteralType(rightType); + if (!isRelated(leftBase, rightBase)) { + effectiveLeft = leftBase; + effectiveRight = rightBase; + } + return [effectiveLeft, effectiveRight]; + } function isYieldExpressionInClass(node) { var current = node; var parent = node.parent; @@ -45507,12 +46114,7 @@ var ts; return getIterationTypeOfGeneratorFunctionReturnType(2, returnType, isAsync) || anyType; } - var contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2, contextualReturnType, isAsync) - || anyType; - } - return anyType; + return getContextualIterationType(2, func) || anyType; } function checkConditionalExpression(node, checkMode) { checkTruthinessExpression(node.condition); @@ -45529,7 +46131,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 269 && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 270 && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; } return node; @@ -45562,12 +46164,12 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 195 || node.kind === 213; + return node.kind === 196 || node.kind === 214; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, true); - var padded = ts.isParameter(declaration) && declaration.name.kind === 186 && + var padded = ts.isParameter(declaration) && declaration.name.kind === 187 && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; var widened = ts.getCombinedNodeFlags(declaration) & 2 || @@ -45592,7 +46194,7 @@ var ts; var elementTypes = arity ? type.typeArguments.slice() : []; for (var i = arity; i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 187 && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 188 && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, false, false) : anyType); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); @@ -45636,14 +46238,14 @@ var ts; getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node)); } function checkPropertyAssignment(node, checkMode) { - if (node.name.kind === 150) { + if (node.name.kind === 151) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); } function checkObjectLiteralMethod(node, checkMode) { checkGrammarMethod(node); - if (node.name.kind === 150) { + if (node.name.kind === 151) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -45761,7 +46363,7 @@ var ts; } function getTypeOfExpression(node, cache) { var expr = ts.skipParentheses(node); - if (expr.kind === 192 && expr.expression.kind !== 99 && !ts.isRequireCall(expr, true) && !isSymbolOrSymbolForCall(expr)) { + if (expr.kind === 193 && expr.expression.kind !== 99 && !ts.isRequireCall(expr, true) && !isSymbolOrSymbolForCall(expr)) { var funcType = checkNonNullExpression(expr.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -45797,10 +46399,11 @@ var ts; return type; } function checkConstEnumAccess(node, type) { - var ok = (node.parent.kind === 190 && node.parent.expression === node) || - (node.parent.kind === 191 && node.parent.expression === node) || - ((node.kind === 73 || node.kind === 149) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 168 && node.parent.exprName === node)); + var ok = (node.parent.kind === 191 && node.parent.expression === node) || + (node.parent.kind === 192 && node.parent.expression === node) || + ((node.kind === 73 || node.kind === 150) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 169 && node.parent.exprName === node)) || + (node.parent.kind === 259 && (compilerOptions.preserveConstEnums || node.flags & 4194304)); 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); } @@ -45820,7 +46423,16 @@ var ts; return checkExpression(node.expression, checkMode); } function checkExpressionWorker(node, checkMode, forceTuple) { - switch (node.kind) { + var kind = node.kind; + if (cancellationToken) { + switch (kind) { + case 211: + case 198: + case 199: + cancellationToken.throwIfCancellationRequested(); + } + } + switch (kind) { case 73: return checkIdentifier(node); case 101: @@ -45842,77 +46454,77 @@ var ts; return trueType; case 88: return falseType; - case 207: + case 208: return checkTemplateExpression(node); case 13: return globalRegExpType; - case 188: - return checkArrayLiteral(node, checkMode, forceTuple); case 189: - return checkObjectLiteral(node, checkMode); + return checkArrayLiteral(node, checkMode, forceTuple); case 190: + return checkObjectLiteral(node, checkMode); + case 191: return checkPropertyAccessExpression(node); - case 149: + case 150: return checkQualifiedName(node); - case 191: - return checkIndexedAccess(node); case 192: + return checkIndexedAccess(node); + case 193: if (node.expression.kind === 93) { return checkImportCallExpression(node); } - case 193: - return checkCallExpression(node, checkMode); case 194: + return checkCallExpression(node, checkMode); + case 195: return checkTaggedTemplateExpression(node); - case 196: + case 197: return checkParenthesizedExpression(node, checkMode); - case 210: + case 211: return checkClassExpression(node); - case 197: case 198: + case 199: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 200: + case 201: return checkTypeOfExpression(node); - case 195: - case 213: - return checkAssertion(node); + case 196: case 214: - return checkNonNullAssertion(node); + return checkAssertion(node); case 215: + return checkNonNullAssertion(node); + case 216: return checkMetaProperty(node); - case 199: + case 200: return checkDeleteExpression(node); - case 201: - return checkVoidExpression(node); case 202: - return checkAwaitExpression(node); + return checkVoidExpression(node); case 203: - return checkPrefixUnaryExpression(node); + return checkAwaitExpression(node); case 204: - return checkPostfixUnaryExpression(node); + return checkPrefixUnaryExpression(node); case 205: - return checkBinaryExpression(node, checkMode); + return checkPostfixUnaryExpression(node); case 206: + return checkBinaryExpression(node, checkMode); + case 207: return checkConditionalExpression(node, checkMode); - case 209: + case 210: return checkSpreadExpression(node, checkMode); - case 211: + case 212: return undefinedWideningType; - case 208: + case 209: return checkYieldExpression(node); - case 216: + case 217: return node.type; - case 271: + case 272: return checkJsxExpression(node, checkMode); - case 261: - return checkJsxElement(node, checkMode); case 262: + return checkJsxElement(node, checkMode); + case 263: return checkJsxSelfClosingElement(node, checkMode); - case 265: + case 266: return checkJsxFragment(node); - case 269: + case 270: return checkJsxAttributes(node, checkMode); - case 263: + case 264: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -45942,7 +46554,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92)) { - if (!(func.kind === 158 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 159 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -45953,10 +46565,10 @@ 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 === 158 || func.kind === 162 || func.kind === 167) { + if (func.kind === 159 || func.kind === 163 || func.kind === 168) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 198) { + if (func.kind === 199) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -46008,13 +46620,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { + case 199: + case 162: + case 241: case 198: - case 161: - case 240: - case 197: - case 166: + case 167: + case 158: case 157: - case 156: var parent = node.parent; if (node === parent.type) { return parent; @@ -46032,7 +46644,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 === 186 || name.kind === 185) { + else if (name.kind === 187 || name.kind === 186) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -46040,12 +46652,12 @@ var ts; } } function checkSignatureDeclaration(node) { - if (node.kind === 163) { + if (node.kind === 164) { checkGrammarIndexSignature(node); } - else if (node.kind === 166 || node.kind === 240 || node.kind === 167 || - node.kind === 161 || node.kind === 158 || - node.kind === 162) { + else if (node.kind === 167 || node.kind === 241 || node.kind === 168 || + node.kind === 162 || node.kind === 159 || + node.kind === 163) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -46070,10 +46682,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 162: + case 163: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 161: + case 162: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -46097,7 +46709,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 163 && node.kind !== 295) { + if (node.kind !== 164 && node.kind !== 296) { registerForUnusedIdentifiersCheck(node); } } @@ -46107,10 +46719,10 @@ var ts; var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 158) { + if (member.kind === 159) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; - if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { + if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { addName(instanceNames, param.name, param.name.escapedText, 3); } } @@ -46122,17 +46734,17 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 159: + case 160: addName(names, name, memberName, 1); break; - case 160: + case 161: addName(names, name, memberName, 2); break; - case 155: + case 156: addName(names, name, memberName, 3); break; - case 157: - addName(names, name, memberName, 4); + case 158: + addName(names, name, memberName, 8); break; } } @@ -46141,8 +46753,8 @@ var ts; function addName(names, location, name, meaning) { var prev = names.get(name); if (prev) { - if (prev & 4) { - if (meaning !== 4) { + if (prev & 8) { + if (meaning !== 8) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } } @@ -46183,7 +46795,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154) { + if (member.kind === 155) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -46208,7 +46820,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 242) { + if (node.kind === 243) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -46253,7 +46865,7 @@ var ts; if (!checkGrammarMethod(node)) checkGrammarComputedPropertyName(node.name); checkFunctionOrMethodDeclaration(node); - if (ts.hasModifier(node, 128) && node.kind === 157 && node.body) { + if (ts.hasModifier(node, 128) && node.kind === 158 && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -46274,7 +46886,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 155 && + return n.kind === 156 && !ts.hasModifier(n, 32) && !!n.initializer; } @@ -46294,7 +46906,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 222 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 223 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -46318,18 +46930,18 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 159) { + if (node.kind === 160) { if (!(node.flags & 4194304) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 150) { + if (node.name.kind === 151) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { - var otherKind = node.kind === 159 ? 160 : 159; + var otherKind = node.kind === 160 ? 161 : 160; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -46345,7 +46957,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 159) { + if (node.kind === 160) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -46393,7 +47005,7 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 165 && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 166 && 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); } var type = getTypeFromTypeReference(node); @@ -46440,7 +47052,7 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 173) { + if (e.kind === 174) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; @@ -46449,7 +47061,7 @@ var ts; error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 172) { + else if (e.kind === 173) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -46469,7 +47081,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, false))) { - if (accessNode.kind === 191 && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 192 && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 && getMappedTypeModifiers(objectType) & 1) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -46518,7 +47130,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 176 && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 177 && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -46533,9 +47145,9 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 242 && - n.parent.kind !== 241 && - n.parent.kind !== 210 && + if (n.parent.kind !== 243 && + n.parent.kind !== 242 && + n.parent.kind !== 211 && n.flags & 4194304) { if (!(flags & 2) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { flags |= 1; @@ -46615,7 +47227,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 157 || node.kind === 156) && + var reportError = (node.kind === 158 || node.kind === 157) && ts.hasModifier(node, 32) !== ts.hasModifier(subsequentNode, 32); if (reportError) { var diagnostic = ts.hasModifier(node, 32) ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -46644,15 +47256,19 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; + var hasNonAmbientClass = false; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304; - var inAmbientContextOrInterface = node.parent.kind === 242 || node.parent.kind === 169 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 243 || node.parent.kind === 170 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 240 || node.kind === 157 || node.kind === 156 || node.kind === 158) { + if ((node.kind === 242 || node.kind === 211) && !inAmbientContext) { + hasNonAmbientClass = true; + } + if (node.kind === 241 || node.kind === 158 || node.kind === 157 || node.kind === 159) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -46693,6 +47309,11 @@ var ts; error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Duplicate_function_implementation); }); } + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16) { + ts.forEach(declarations, function (declaration) { + addDuplicateDeclarationError(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), ts.filter(declarations, function (d) { return d !== declaration; })); + }); + } if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && !ts.hasModifier(lastSeenNonAmbientDeclaration, 128) && !lastSeenNonAmbientDeclaration.questionToken) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); @@ -46765,36 +47386,37 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 242: case 243: - case 311: - case 304: + case 244: + case 313: + case 306: + case 307: return 2; - case 245: + case 246: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4 | 1 : 4; - case 241: - case 244: + case 242: + case 245: return 2 | 1; - case 285: + case 286: return 2 | 1 | 4; - case 255: + case 256: if (!ts.isEntityNameExpression(d.expression)) { return 1; } d = d.expression; - case 249: + case 250: + case 253: case 252: - case 251: var result_8 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_8 |= getDeclarationSpaces(d); }); return result_8; - case 238: - case 187: - case 240: - case 254: + case 239: + case 188: + case 241: + case 255: return 1; default: return ts.Debug.failBadSyntaxKind(d); @@ -46842,9 +47464,6 @@ var ts; } function checkAwaitedType(type, errorNode, diagnosticMessage, arg0) { var awaitedType = getAwaitedType(type, errorNode, diagnosticMessage, arg0); - if (awaitedType === type && !(type.flags & 3)) { - addErrorOrSuggestion(false, ts.createDiagnosticForNode(errorNode, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); - } return awaitedType || errorType; } function getAwaitedType(type, errorNode, diagnosticMessage, arg0) { @@ -46915,7 +47534,7 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67220415, true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551, true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { if (promiseConstructorName.kind === 73 && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(false)) { @@ -46935,7 +47554,7 @@ var ts; return; } var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 67220415); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -46953,22 +47572,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 241: + case 242: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 152: + case 153: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 155: + case 156: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 157: - case 159: + case 158: case 160: + case 161: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -46985,7 +47604,7 @@ var ts; if (!typeName) return; var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 73 ? 67897832 : 1920) | 2097152; + var meaning = (typeName.kind === 73 ? 788968 : 1920) | 2097152; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, undefined, undefined, true); if (rootSymbol && rootSymbol.flags & 2097152 @@ -47003,23 +47622,23 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { + case 176: case 175: - case 174: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 176: + case 177: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 178: + case 179: return getEntityNameForDecoratorMetadata(node.type); - case 165: + case 166: return node.typeName; } } } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var typeNode = types_17[_i]; - while (typeNode.kind === 178) { + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var typeNode = types_16[_i]; + while (typeNode.kind === 179) { typeNode = typeNode.type; } if (typeNode.kind === 133) { @@ -47061,13 +47680,13 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8); - if (node.kind === 152) { + if (node.kind === 153) { checkExternalEmitHelpers(firstDecorator, 32); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 241: + case 242: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -47076,23 +47695,23 @@ var ts; } } break; - case 159: case 160: - var otherKind = node.kind === 159 ? 160 : 159; + case 161: + var otherKind = node.kind === 160 ? 161 : 160; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 157: + case 158: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 155: + case 156: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 152: + case 153: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -47151,7 +47770,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 === 149 ? 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 === 150 ? node.name.right : node.name)); } } } @@ -47186,7 +47805,7 @@ var ts; switch (node.kind) { case 73: return node; - case 190: + case 191: return node.name; default: return undefined; @@ -47196,7 +47815,7 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var functionFlags = ts.getFunctionFlags(node); - if (node.name && node.name.kind === 150) { + if (node.name && node.name.kind === 151) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { @@ -47212,7 +47831,7 @@ var ts; } } } - var body = node.kind === 156 ? undefined : node.body; + var body = node.kind === 157 ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -47245,42 +47864,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 241: - case 210: + case 242: + case 211: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 285: - case 245: - case 219: - case 247: - case 226: + case 286: + case 246: + case 220: + case 248: case 227: case 228: + case 229: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 158: - case 197: - case 240: - case 198: - case 157: case 159: + case 198: + case 241: + case 199: + case 158: case 160: + case 161: if (node.body) { checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 156: - case 161: + case 157: case 162: - case 166: + case 163: case 167: + case 168: + case 244: case 243: - case 242: checkUnusedTypeParameters(node, addDiagnostic); break; - case 177: + case 178: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -47300,11 +47919,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 157: - case 155: - case 159: + case 158: + case 156: case 160: - if (member.kind === 160 && member.symbol.flags & 32768) { + case 161: + if (member.kind === 161 && member.symbol.flags & 32768) { break; } var symbol = getSymbolOfNode(member); @@ -47312,7 +47931,7 @@ var ts; addDiagnostic(member, 0, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 158: + case 159: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8)) { @@ -47320,8 +47939,8 @@ var ts; } } break; - case 163: - case 218: + case 164: + case 219: break; default: ts.Debug.fail(); @@ -47345,7 +47964,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 177 && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 178 && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) ? ts.rangeOfNode(parent) @@ -47409,7 +48028,7 @@ var ts; var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(parameter, 1, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -47424,7 +48043,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 252 ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 253 ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0, unuseds.length === 1 @@ -47442,7 +48061,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 : 0; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 238 && bindingPattern.parent.parent.kind === 239) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 239 && bindingPattern.parent.parent.kind === 240) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -47463,7 +48082,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(declarationList, 0, 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 === 220 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 221 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -47477,21 +48096,21 @@ var ts; switch (name.kind) { case 73: return ts.idText(name); + case 187: case 186: - case 185: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 251 || node.kind === 254 || node.kind === 252; + return node.kind === 252 || node.kind === 255 || node.kind === 253; } function importClauseFromImported(decl) { - return decl.kind === 251 ? decl : decl.kind === 252 ? decl.parent : decl.parent.parent; + return decl.kind === 252 ? decl : decl.kind === 253 ? decl.parent : decl.parent.parent; } function checkBlock(node) { - if (node.kind === 219) { + if (node.kind === 220) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -47520,19 +48139,19 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 155 || - node.kind === 154 || + if (node.kind === 156 || + node.kind === 155 || + node.kind === 158 || node.kind === 157 || - node.kind === 156 || - node.kind === 159 || - node.kind === 160) { + node.kind === 160 || + node.kind === 161) { return false; } if (node.flags & 4194304) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 152 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 153 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -47578,7 +48197,7 @@ var ts; return; } var parent = getDeclarationContainer(node); - if (parent.kind === 285 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 286 && ts.isExternalOrCommonJsModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -47590,7 +48209,7 @@ var ts; return; } var parent = getDeclarationContainer(node); - if (parent.kind === 285 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 286 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { error(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)); } } @@ -47598,7 +48217,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 238 && !node.initializer) { + if (node.kind === 239 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -47610,15 +48229,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 239); - var container = varDeclList.parent.kind === 220 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 240); + var container = varDeclList.parent.kind === 221 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 219 && ts.isFunctionLike(container.parent) || + (container.kind === 220 && ts.isFunctionLike(container.parent) || + container.kind === 247 || container.kind === 246 || - container.kind === 245 || - container.kind === 285); + container.kind === 286); if (!namesShareScope) { var name = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name); @@ -47638,17 +48257,17 @@ var ts; if (!node.name) { return; } - if (node.name.kind === 150) { + if (node.name.kind === 151) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 187) { - if (node.parent.kind === 185 && languageVersion < 99) { + if (node.kind === 188) { + if (node.parent.kind === 186 && languageVersion < 99) { checkExternalEmitHelpers(node, 4); } - if (node.propertyName && node.propertyName.kind === 150) { + if (node.propertyName && node.propertyName.kind === 151) { checkComputedPropertyName(node.propertyName); } var parent = node.parent.parent; @@ -47667,17 +48286,17 @@ var ts; } } if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 186 && languageVersion < 2 && compilerOptions.downlevelIteration) { + if (node.name.kind === 187 && languageVersion < 2 && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512); } ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 152 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 153 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 227; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 228; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { var widenedType = getWidenedTypeForVariableLikeDeclaration(node); @@ -47710,7 +48329,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 227) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 228) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, undefined); } } @@ -47734,9 +48353,9 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 155 && node.kind !== 154) { + if (node.kind !== 156 && node.kind !== 155) { checkExportsOnMergedDeclarations(node); - if (node.kind === 238 || node.kind === 187) { + if (node.kind === 239 || node.kind === 188) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -47745,7 +48364,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 155 || nextDeclaration.kind === 154 + var message = nextDeclaration.kind === 156 || nextDeclaration.kind === 155 ? 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); @@ -47755,8 +48374,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 152 && right.kind === 238) || - (left.kind === 238 && right.kind === 152)) { + if ((left.kind === 153 && right.kind === 239) || + (left.kind === 239 && right.kind === 153)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -47791,7 +48410,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkTruthinessExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 221) { + if (node.thenStatement.kind === 222) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -47815,12 +48434,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 239) { + if (node.initializer && node.initializer.kind === 240) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 239) { + if (node.initializer.kind === 240) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -47847,13 +48466,13 @@ var ts; else if (compilerOptions.downlevelIteration && languageVersion < 2) { checkExternalEmitHelpers(node, 256); } - if (node.initializer.kind === 239) { + if (node.initializer.kind === 240) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); - if (varExpr.kind === 188 || varExpr.kind === 189) { + if (varExpr.kind === 189 || varExpr.kind === 190) { checkDestructuringAssignment(varExpr, iteratedType || errorType); } else { @@ -47872,7 +48491,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = getNonNullableTypeIfNeeded(checkExpression(node.expression)); - if (node.initializer.kind === 239) { + if (node.initializer.kind === 240) { 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); @@ -47882,7 +48501,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 188 || varExpr.kind === 189) { + if (varExpr.kind === 189 || varExpr.kind === 190) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -48348,12 +48967,12 @@ var ts; var functionFlags = ts.getFunctionFlags(func); if (strictNullChecks || node.expression || returnType.flags & 131072) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 160) { + if (func.kind === 161) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 158) { + else if (func.kind === 159) { 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); } @@ -48368,7 +48987,7 @@ var ts; } } } - else if (func.kind !== 158 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 159 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } @@ -48393,7 +49012,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 273 && !hasDuplicateDefaultClause) { + if (clause.kind === 274 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -48405,7 +49024,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 272) { + if (produceDiagnostics && clause.kind === 273) { var caseType = checkExpression(clause.expression); var caseIsLiteral = isLiteralType(caseType); var comparedExpressionType = expressionType; @@ -48429,7 +49048,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 234 && current.label.escapedText === node.label.escapedText) { + if (current.kind === 235 && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -48524,8 +49143,8 @@ var ts; } var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 205 || - name.kind === 150 || + (propDeclaration.kind === 206 || + name.kind === 151 || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -48590,7 +49209,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 165) { + if (node.kind === 166) { var type = getTypeFromTypeReference(node); if (type.flags & 262144) { for (var i = index; i < typeParameters.length; i++) { @@ -48816,12 +49435,12 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 241 || d.kind === 242; + return d.kind === 242 || d.kind === 243; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { var baseProperties = getPropertiesOfType(baseType); - for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { + basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); if (base.flags & 4194304) { @@ -48830,43 +49449,51 @@ var ts; var derived = getTargetSymbol(getPropertyOfObjectType(type, base.escapedName)); var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base); ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); - if (derived) { - if (derived === base) { - var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); - if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128))) { - if (derivedClassDecl.kind === 210) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); - } - else { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + if (derived === base) { + var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); + if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128))) { + for (var _a = 0, _b = getBaseTypes(type); _a < _b.length; _a++) { + var otherBaseType = _b[_a]; + if (otherBaseType === baseType) + continue; + var baseSymbol = getPropertyOfObjectType(otherBaseType, base.escapedName); + var derivedElsewhere = baseSymbol && getTargetSymbol(baseSymbol); + if (derivedElsewhere && derivedElsewhere !== base) { + continue basePropertyCheck; } } - } - else { - var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 || derivedDeclarationFlags & 8) { - continue; + if (derivedClassDecl.kind === 211) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } - if (isPrototypeProperty(base) || base.flags & 98308 && derived.flags & 98308) { - continue; - } - var errorMessage = void 0; - if (isPrototypeProperty(base)) { - if (derived.flags & 98304) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } - else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); } - else if (base.flags & 98304) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + } + else { + var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); + if (baseDeclarationFlags & 8 || derivedDeclarationFlags & 8) { + continue; + } + if (isPrototypeProperty(base) || base.flags & 98308 && derived.flags & 98308) { + continue; + } + var errorMessage = void 0; + if (isPrototypeProperty(base)) { + if (derived.flags & 98304) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } - error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } + else if (base.flags & 98304) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } @@ -48923,7 +49550,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 155 && + return node.kind === 156 && !ts.hasModifier(node, 32 | 128) && !node.exclamationToken && !node.initializer; @@ -48945,7 +49572,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 242); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 243); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -49041,7 +49668,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 203: + case 204: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -49051,7 +49678,7 @@ var ts; } } break; - case 205: + case 206: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -49079,7 +49706,7 @@ var ts; case 8: checkGrammarNumericLiteral(expr); return +expr.text; - case 196: + case 197: return evaluate(expr.expression); case 73: var identifier = expr; @@ -49087,20 +49714,18 @@ var ts; return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); + case 192: case 191: - case 190: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384) { var name = void 0; - if (ex.kind === 190) { + if (ex.kind === 191) { name = ex.name.escapedText; } else { - var argument = ex.argumentExpression; - ts.Debug.assert(ts.isLiteralExpression(argument)); - name = ts.escapeLeadingUnderscores(argument.text); + name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text); } return evaluateEnumMember(expr, type.symbol, name); } @@ -49126,8 +49751,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 73 || - node.kind === 190 && isConstantMemberAccess(node.expression) || - node.kind === 191 && isConstantMemberAccess(node.expression) && + node.kind === 191 && isConstantMemberAccess(node.expression) || + node.kind === 192 && isConstantMemberAccess(node.expression) && node.argumentExpression.kind === 10; } function checkEnumDeclaration(node) { @@ -49153,7 +49778,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 244) { + if (declaration.kind !== 245) { return false; } var enumDeclaration = declaration; @@ -49176,8 +49801,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 241 || - (declaration.kind === 240 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 242 || + (declaration.kind === 241 && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304)) { return declaration; } @@ -49235,7 +49860,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 241); + var mergedClass = ts.getDeclarationOfKind(symbol, 242); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -49278,22 +49903,22 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 220: + case 221: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 255: case 256: + case 257: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 249: case 250: + case 251: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 187: - case 238: + case 188: + case 239: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -49302,12 +49927,12 @@ var ts; } break; } - case 241: - case 244: - case 240: case 242: case 245: + case 241: case 243: + case 246: + case 244: if (isGlobalAugmentation) { return; } @@ -49325,12 +49950,12 @@ var ts; switch (node.kind) { case 73: return node; - case 149: + case 150: do { node = node.left; } while (node.kind !== 73); return node; - case 190: + case 191: do { node = node.expression; } while (node.kind !== 73); @@ -49346,9 +49971,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 246 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 285 && !inAmbientExternalModule) { - error(moduleName, node.kind === 256 ? + var inAmbientExternalModule = node.parent.kind === 247 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 286 && !inAmbientExternalModule) { + error(moduleName, node.kind === 257 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -49364,19 +49989,20 @@ var ts; function checkAliasSymbol(node) { var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); - if (target !== unknownSymbol) { - var excludedMeanings = (symbol.flags & (67220415 | 1048576) ? 67220415 : 0) | - (symbol.flags & 67897832 ? 67897832 : 0) | + var shouldSkipWithJSExpandoTargets = symbol.flags & 67108864; + if (!shouldSkipWithJSExpandoTargets && target !== unknownSymbol) { + var excludedMeanings = (symbol.flags & (111551 | 1048576) ? 111551 : 0) | + (symbol.flags & 788968 ? 788968 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 258 ? + var message = node.kind === 259 ? 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)); } if (compilerOptions.isolatedModules - && node.kind === 258 - && !(target.flags & 67220415) + && node.kind === 259 + && !(target.flags & 111551) && !(node.flags & 4194304)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); } @@ -49401,7 +50027,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252) { + if (importClause.namedBindings.kind === 253) { checkImportBinding(importClause.namedBindings); } else { @@ -49424,16 +50050,16 @@ var ts; if (ts.hasModifier(node, 1)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 260) { + if (node.moduleReference.kind !== 261) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 67220415) { + if (target.flags & 111551) { var moduleName = getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 67220415 | 1920).flags & 1920)) { + if (!(resolveEntityName(moduleName, 111551 | 1920).flags & 1920)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 67897832) { + if (target.flags & 788968) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } @@ -49455,10 +50081,10 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 246 && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 246 && + var inAmbientExternalModule = node.parent.kind === 247 && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 247 && !node.moduleSpecifier && node.flags & 4194304; - if (node.parent.kind !== 285 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 286 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -49474,7 +50100,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 285 || node.parent.kind === 246 || node.parent.kind === 245; + var isInAppropriateContext = node.parent.kind === 286 || node.parent.kind === 247 || node.parent.kind === 246; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -49487,12 +50113,16 @@ var ts; } if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; - var symbol = resolveName(exportedName, exportedName.escapedText, 67220415 | 67897832 | 1920 | 2097152, undefined, undefined, true); + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 | 788968 | 1920 | 2097152, undefined, undefined, true); if (symbol && (symbol === undefinedSymbol || 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 { markExportAsReferenced(node); + var target = symbol && (symbol.flags & 2097152 ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551) { + checkExpressionCached(node.propertyName || node.name); + } } } } @@ -49500,8 +50130,8 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 285 ? node.parent : node.parent.parent; - if (container.kind === 245 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 286 ? node.parent : node.parent.parent; + if (container.kind === 246 && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -49514,7 +50144,15 @@ var ts; grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 73) { - markExportAsReferenced(node); + var id = node.expression; + var sym = resolveEntityName(id, 67108863, true, true, node); + if (sym) { + markAliasReferenced(sym, id); + var target = sym.flags & 2097152 ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551) { + checkExpressionCached(node.expression); + } + } if (ts.getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression, true); } @@ -49576,13 +50214,6 @@ var ts; links.exportsChecked = true; } } - function isNotAccessor(declaration) { - return !ts.isAccessor(declaration); - } - function isNotOverload(declaration) { - return (declaration.kind !== 240 && declaration.kind !== 157) || - !!declaration.body; - } function checkSourceElement(node) { if (node) { var saveCurrentNode = currentNode; @@ -49602,157 +50233,158 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 245: - case 241: + case 246: case 242: - case 240: + case 243: + case 241: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 151: - return checkTypeParameter(node); case 152: + return checkTypeParameter(node); + case 153: return checkParameter(node); + case 156: case 155: - case 154: return checkPropertyDeclaration(node); - case 166: case 167: - case 161: + case 168: case 162: case 163: + case 164: return checkSignatureDeclaration(node); + case 158: case 157: - case 156: return checkMethodDeclaration(node); - case 158: - return checkConstructorDeclaration(node); case 159: + return checkConstructorDeclaration(node); case 160: + case 161: return checkAccessorDeclaration(node); - case 165: + case 166: return checkTypeReferenceNode(node); - case 164: + case 165: return checkTypePredicate(node); - case 168: - return checkTypeQuery(node); case 169: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 170: - return checkArrayType(node); + return checkTypeLiteral(node); case 171: + return checkArrayType(node); + case 172: return checkTupleType(node); - case 174: case 175: + case 176: return checkUnionOrIntersectionType(node); - case 178: - case 172: + case 179: case 173: + case 174: return checkSourceElement(node.type); - case 179: - return checkThisType(node); case 180: + return checkThisType(node); + case 181: return checkTypeOperator(node); - case 176: - return checkConditionalType(node); case 177: + return checkConditionalType(node); + case 178: return checkInferType(node); - case 184: + case 185: return checkImportType(node); - case 301: + case 303: return checkJSDocAugmentsTag(node); - case 311: - case 304: + case 313: + case 306: + case 307: return checkJSDocTypeAliasTag(node); - case 310: + case 312: return checkJSDocTemplateTag(node); - case 309: + case 311: return checkJSDocTypeTag(node); - case 306: + case 308: return checkJSDocParameterTag(node); - case 295: + case 296: checkJSDocFunctionType(node); + case 294: case 293: - case 292: - case 290: case 291: - case 298: + case 292: + case 300: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 296: + case 297: checkJSDocVariadicType(node); return; - case 289: + case 290: return checkSourceElement(node.type); - case 181: - return checkIndexedAccessType(node); case 182: + return checkIndexedAccessType(node); + case 183: return checkMappedType(node); - case 240: + case 241: return checkFunctionDeclaration(node); - case 219: - case 246: - return checkBlock(node); case 220: + case 247: + return checkBlock(node); + case 221: return checkVariableStatement(node); - case 222: - return checkExpressionStatement(node); case 223: - return checkIfStatement(node); + return checkExpressionStatement(node); case 224: - return checkDoStatement(node); + return checkIfStatement(node); case 225: - return checkWhileStatement(node); + return checkDoStatement(node); case 226: - return checkForStatement(node); + return checkWhileStatement(node); case 227: - return checkForInStatement(node); + return checkForStatement(node); case 228: - return checkForOfStatement(node); + return checkForInStatement(node); case 229: + return checkForOfStatement(node); case 230: - return checkBreakOrContinueStatement(node); case 231: - return checkReturnStatement(node); + return checkBreakOrContinueStatement(node); case 232: - return checkWithStatement(node); + return checkReturnStatement(node); case 233: - return checkSwitchStatement(node); + return checkWithStatement(node); case 234: - return checkLabeledStatement(node); + return checkSwitchStatement(node); case 235: - return checkThrowStatement(node); + return checkLabeledStatement(node); case 236: + return checkThrowStatement(node); + case 237: return checkTryStatement(node); - case 238: + case 239: return checkVariableDeclaration(node); - case 187: + case 188: return checkBindingElement(node); - case 241: - return checkClassDeclaration(node); case 242: - return checkInterfaceDeclaration(node); + return checkClassDeclaration(node); case 243: - return checkTypeAliasDeclaration(node); + return checkInterfaceDeclaration(node); case 244: - return checkEnumDeclaration(node); + return checkTypeAliasDeclaration(node); case 245: + return checkEnumDeclaration(node); + case 246: return checkModuleDeclaration(node); - case 250: + case 251: return checkImportDeclaration(node); - case 249: + case 250: return checkImportEqualsDeclaration(node); - case 256: + case 257: return checkExportDeclaration(node); - case 255: + case 256: return checkExportAssignment(node); - case 221: - case 237: + case 222: + case 238: checkGrammarStatementInAmbientContext(node); return; - case 259: + case 260: return checkMissingDeclaration(node); } } @@ -49828,23 +50460,23 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 197: case 198: + case 199: + case 158: case 157: - case 156: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 159: case 160: + case 161: checkAccessorDeclaration(node); break; - case 210: + case 211: checkClassExpressionDeferred(node); break; - case 262: + case 263: checkJsxSelfClosingElementDeferred(node); break; - case 261: + case 262: checkJsxElementDeferred(node); break; } @@ -49958,27 +50590,27 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 285: + case 286: if (!ts.isExternalOrCommonJsModule(location)) break; - case 245: + case 246: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475); break; - case 244: + case 245: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 210: + case 211: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 241: case 242: + case 243: if (!isStatic) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67897832); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968); } break; - case 197: + case 198: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -50016,27 +50648,27 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 151: - case 241: + case 152: case 242: case 243: case 244: + case 245: return true; default: return false; } } function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 149) { + while (node.parent.kind === 150) { node = node.parent; } - return node.parent.kind === 165; + return node.parent.kind === 166; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 190) { + while (node.parent.kind === 191) { node = node.parent; } - return node.parent.kind === 212; + return node.parent.kind === 213; } function forEachEnclosingClass(node, callback) { var result; @@ -50064,13 +50696,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 149) { + while (nodeOnRightSide.parent.kind === 150) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 249) { + if (nodeOnRightSide.parent.kind === 250) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 255) { + if (nodeOnRightSide.parent.kind === 256) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -50096,7 +50728,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 184 && parent.qualifier === node) { + if (parent && parent.kind === 185 && parent.qualifier === node) { return parent; } return undefined; @@ -50106,21 +50738,21 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 190 && + entityName.parent.kind === 191 && entityName.parent === entityName.parent.parent.left) { var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); if (specialPropertyAssignmentSymbol) { return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 255 && ts.isEntityNameExpression(entityName)) { - var success = resolveEntityName(entityName, 67220415 | 67897832 | 1920 | 2097152, true); + if (entityName.parent.kind === 256 && ts.isEntityNameExpression(entityName)) { + var success = resolveEntityName(entityName, 111551 | 788968 | 1920 | 2097152, true); if (success && success !== unknownSymbol) { return success; } } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 249); + var importEqualsDeclaration = ts.getAncestor(entityName, 250); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -50137,10 +50769,10 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 212) { - meaning = 67897832; + if (entityName.parent.kind === 213) { + meaning = 788968; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { - meaning |= 67220415; + meaning |= 111551; } } else { @@ -50152,10 +50784,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 306) { + if (entityName.parent.kind === 308) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 151 && entityName.parent.parent.kind === 310) { + if (entityName.parent.kind === 152 && entityName.parent.parent.kind === 312) { ts.Debug.assert(!ts.isInJSFile(entityName)); var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -50169,14 +50801,14 @@ var ts; var symbol = getIntrinsicTagSymbol(entityName.parent); return symbol === unknownSymbol ? undefined : symbol; } - return resolveEntityName(entityName, 67220415, false, true); + return resolveEntityName(entityName, 111551, false, true); } - else if (entityName.kind === 190 || entityName.kind === 149) { + else if (entityName.kind === 191 || entityName.kind === 150) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 190) { + if (entityName.kind === 191) { checkPropertyAccessExpression(entityName); } else { @@ -50186,16 +50818,16 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 165 ? 67897832 : 1920; + var meaning = entityName.parent.kind === 166 ? 788968 : 1920; return resolveEntityName(entityName, meaning, false, true); } - if (entityName.parent.kind === 164) { + if (entityName.parent.kind === 165) { return resolveEntityName(entityName, 1); } return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 285) { + if (node.kind === 286) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -50216,8 +50848,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 187 && - grandParent.kind === 185 && + else if (parent.kind === 188 && + grandParent.kind === 186 && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -50228,8 +50860,8 @@ var ts; } switch (node.kind) { case 73: - case 190: - case 149: + case 191: + case 150: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 101: var container = ts.getThisContainer(node, false); @@ -50242,20 +50874,20 @@ var ts; if (ts.isInExpressionContext(node)) { return checkExpression(node).symbol; } - case 179: + case 180: return getTypeFromThisTypeNode(node).symbol; case 99: return checkExpression(node).symbol; case 125: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 158) { + if (constructorDeclaration && constructorDeclaration.kind === 159) { return constructorDeclaration.parent.symbol; } return undefined; case 10: case 14: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 250 || node.parent.kind === 256) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 251 || node.parent.kind === 257) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node); @@ -50275,7 +50907,7 @@ var ts; case 37: case 77: return getSymbolOfNode(node.parent); - case 184: + case 185: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; case 86: return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; @@ -50284,15 +50916,15 @@ var ts; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 277) { - return resolveEntityName(location.name, 67220415 | 2097152); + if (location && location.kind === 278) { + return resolveEntityName(location.name, 111551 | 2097152); } return undefined; } function getExportSpecifierLocalTargetSymbol(node) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 67220415 | 67897832 | 1920 | 2097152); + resolveEntityName(node.propertyName || node.name, 111551 | 788968 | 1920 | 2097152); } function getTypeOfNode(node) { if (node.flags & 8388608) { @@ -50340,20 +50972,20 @@ var ts; return errorType; } function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 189 || expr.kind === 188); - if (expr.parent.kind === 228) { + ts.Debug.assert(expr.kind === 190 || expr.kind === 189); + if (expr.parent.kind === 229) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } - if (expr.parent.kind === 205) { + if (expr.parent.kind === 206) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } - if (expr.parent.kind === 276) { - 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); + if (expr.parent.kind === 277) { + var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); + var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType; + var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex); } var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType; @@ -50384,7 +51016,7 @@ var ts; case 8: case 10: return getLiteralType(name.text); - case 150: + case 151: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288) ? nameType : stringType; default: @@ -50438,7 +51070,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 190 && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 191 && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -50454,13 +51086,13 @@ var ts; var symbolLinks = getSymbolLinks(moduleSymbol); if (symbolLinks.exportsSomeValue === undefined) { symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 67220415) + ? !!(moduleSymbol.flags & 111551) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 67220415); + return s && !!(s.flags & 111551); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -50480,7 +51112,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 285) { + if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 286) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -50495,7 +51127,7 @@ var ts; var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { var symbol = getReferencedValueSymbol(node); - if (isNonLocalAlias(symbol, 67220415)) { + if (isNonLocalAlias(symbol, 111551)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -50503,7 +51135,7 @@ var ts; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 276; } function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 && !ts.isSourceFile(symbol.valueDeclaration)) { @@ -50512,13 +51144,13 @@ var ts; var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 67220415, undefined, undefined, false)) { + if (resolveName(container.parent, symbol.escapedName, 111551, undefined, undefined, false)) { links.isDeclarationWithCollidingName = true; } else if (nodeLinks_1.flags & 262144) { var isDeclaredInLoop = nodeLinks_1.flags & 524288; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 219 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 220 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -50554,26 +51186,25 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 249: - case 251: + case 250: case 252: - case 254: - case 258: + case 253: + case 255: + case 259: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 256: + case 257: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 255: - return node.expression - && node.expression.kind === 73 - ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) - : true; + case 256: + return node.expression && node.expression.kind === 73 ? + isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : + true; } return false; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 285 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 286 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -50584,7 +51215,7 @@ var ts; if (target === unknownSymbol) { return true; } - return !!(target.flags & 67220415) && + return !!(target.flags & 111551) && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -50598,7 +51229,7 @@ var ts; } var target = getSymbolLinks(symbol).target; if (target && ts.getModifierFlags(node) & 1 && - target.flags & 67220415 && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { + target.flags & 111551 && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { return true; } } @@ -50640,7 +51271,7 @@ var ts; if (!symbol || !(symbol.flags & 16)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 67220415 && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -50659,15 +51290,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 279: - case 190: + case 280: case 191: + case 192: return true; } return false; } function getConstantValue(node) { - if (node.kind === 279) { + if (node.kind === 280) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -50691,8 +51322,8 @@ var ts; if (!location) return ts.TypeReferenceSerializationKind.Unknown; } - var valueSymbol = resolveEntityName(typeName, 67220415, true, false, location); - var typeSymbol = resolveEntityName(typeName, 67897832, true, false, location); + var valueSymbol = resolveEntityName(typeName, 111551, true, false, location); + var typeSymbol = resolveEntityName(typeName, 788968, true, false, location); if (valueSymbol && valueSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(false); if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { @@ -50793,7 +51424,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 67220415 | 1048576 | 2097152, undefined, undefined, true); + return resolveName(location, reference.escapedText, 111551 | 1048576 | 2097152, undefined, undefined, true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -50814,7 +51445,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 ? nodeBuilder.symbolToExpression(type.symbol, 67220415, enclosing, undefined, tracker) + var enumResult = type.flags & 1024 ? nodeBuilder.symbolToExpression(type.symbol, 111551, enclosing, undefined, tracker) : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse(); return enumResult || ts.createLiteral(type.value); } @@ -50888,12 +51519,12 @@ var ts; getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); - var otherKind = accessor.kind === 160 ? 159 : 160; + var otherKind = accessor.kind === 161 ? 160 : 161; 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 === 160 ? accessor : otherAccessor; - var getAccessor = accessor.kind === 159 ? accessor : otherAccessor; + var setAccessor = accessor.kind === 161 ? accessor : otherAccessor; + var getAccessor = accessor.kind === 160 ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -50909,15 +51540,15 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 212 && node.parent.parent && node.parent.parent.kind === 274; + return node.parent && node.parent.kind === 213 && node.parent.parent && node.parent.parent.kind === 275; } function getTypeReferenceDirectivesForEntityName(node) { if (!fileToDirective) { return undefined; } - var meaning = 67897832 | 1920; - if ((node.kind === 73 && isInTypeQuery(node)) || (node.kind === 190 && !isInHeritageClause(node))) { - meaning = 67220415 | 1048576; + var meaning = 788968 | 1920; + if ((node.kind === 73 && isInTypeQuery(node)) || (node.kind === 191 && !isInHeritageClause(node))) { + meaning = 111551 | 1048576; } var symbol = resolveEntityName(node, meaning, true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -50959,7 +51590,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 285 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 286 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -50986,12 +51617,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 245 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 246 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, undefined); if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 285); + return ts.getDeclarationOfKind(moduleSymbol, 286); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -51111,7 +51742,7 @@ var ts; for (var helper = 1; helper <= 131072; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 67220415); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551); if (!symbol) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); } @@ -51159,14 +51790,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 157 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 158 && !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 === 159 || node.kind === 160) { + else if (node.kind === 160 || node.kind === 161) { 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); @@ -51184,16 +51815,16 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 134) { - if (node.kind === 154 || node.kind === 156) { + if (node.kind === 155 || node.kind === 157) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 163) { + if (node.kind === 164) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 78: - if (node.kind !== 244) { + if (node.kind !== 245) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(78)); } break; @@ -51213,7 +51844,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 246 || node.parent.kind === 285) { + else if (node.parent.kind === 247 || node.parent.kind === 286) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -51236,10 +51867,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 246 || node.parent.kind === 285) { + else if (node.parent.kind === 247 || node.parent.kind === 286) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 152) { + else if (node.kind === 153) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -51252,7 +51883,7 @@ var ts; if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 155 && node.kind !== 154 && node.kind !== 163 && node.kind !== 152) { + else if (node.kind !== 156 && node.kind !== 155 && node.kind !== 164 && node.kind !== 153) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; @@ -51271,17 +51902,17 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 241) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 152) { + else if (node.kind === 153) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; case 81: - var container = node.parent.kind === 285 ? node.parent : node.parent.parent; - if (container.kind === 245 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 286 ? node.parent : node.parent.parent; + if (container.kind === 246 && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512; @@ -51293,13 +51924,13 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 241) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 152) { + else if (node.kind === 153) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304) && node.parent.kind === 246) { + else if ((node.parent.flags & 4194304) && node.parent.kind === 247) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -51309,14 +51940,14 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 241) { - if (node.kind !== 157 && - node.kind !== 155 && - node.kind !== 159 && - node.kind !== 160) { + if (node.kind !== 242) { + if (node.kind !== 158 && + node.kind !== 156 && + node.kind !== 160 && + node.kind !== 161) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 241 && ts.hasModifier(node.parent, 128))) { + if (!(node.parent.kind === 242 && ts.hasModifier(node.parent, 128))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -51335,7 +51966,7 @@ var ts; else if (flags & 2 || node.parent.flags & 4194304) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 152) { + else if (node.kind === 153) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -51343,7 +51974,7 @@ var ts; break; } } - if (node.kind === 158) { + if (node.kind === 159) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -51358,13 +51989,13 @@ var ts; } return false; } - else if ((node.kind === 250 || node.kind === 249) && flags & 2) { + else if ((node.kind === 251 || node.kind === 250) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 152 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 153 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 152 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 153 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -51381,37 +52012,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 159: case 160: - case 158: + case 161: + case 159: + case 156: case 155: - case 154: + case 158: case 157: - case 156: - case 163: - case 245: + case 164: + case 246: + case 251: case 250: - case 249: + case 257: case 256: - case 255: - case 197: case 198: - case 152: + case 199: + case 153: return false; default: - if (node.parent.kind === 246 || node.parent.kind === 285) { + if (node.parent.kind === 247 || node.parent.kind === 286) { return false; } switch (node.kind) { - case 240: - return nodeHasAnyModifiersExcept(node, 122); case 241: - return nodeHasAnyModifiersExcept(node, 119); + return nodeHasAnyModifiersExcept(node, 122); case 242: - case 220: + return nodeHasAnyModifiersExcept(node, 119); case 243: - return true; + case 221: case 244: + return true; + case 245: return nodeHasAnyModifiersExcept(node, 78); default: ts.Debug.fail(); @@ -51424,10 +52055,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 157: - case 240: - case 197: + case 158: + case 241: case 198: + case 199: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -51490,7 +52121,7 @@ var ts; ts.addRelatedInfo(error(parameter, ts.Diagnostics.This_parameter_is_not_allowed_with_use_strict_directive), ts.createDiagnosticForNode(useStrictDirective_1, ts.Diagnostics.use_strict_directive_used_here)); }); var diagnostics_1 = nonSimpleParameters.map(function (parameter, index) { return (index === 0 ? ts.createDiagnosticForNode(parameter, ts.Diagnostics.Non_simple_parameter_declared_here) : ts.createDiagnosticForNode(parameter, ts.Diagnostics.and_here)); }); - ts.addRelatedInfo.apply(void 0, [error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)].concat(diagnostics_1)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)], diagnostics_1)); return true; } } @@ -51576,7 +52207,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 === 211) { + if (arg.kind === 212) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -51650,20 +52281,20 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 150) { + if (node.kind !== 151) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 205 && computedPropertyName.expression.operatorToken.kind === 27) { + if (computedPropertyName.expression.kind === 206 && computedPropertyName.expression.operatorToken.kind === 27) { 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 === 240 || - node.kind === 197 || - node.kind === 157); + ts.Debug.assert(node.kind === 241 || + node.kind === 198 || + node.kind === 158); if (node.flags & 4194304) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -51682,7 +52313,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278) { + if (prop.kind === 279) { if (inDestructuring) { var expression = ts.skipParentheses(prop.expression); if (ts.isArrayLiteralExpression(expression) || ts.isObjectLiteralExpression(expression)) { @@ -51692,37 +52323,39 @@ var ts; continue; } var name = prop.name; - if (name.kind === 150) { + if (name.kind === 151) { checkGrammarComputedPropertyName(name); } - if (prop.kind === 277 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 278 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 122 || prop.kind !== 157) { + if (mod.kind !== 122 || prop.kind !== 158) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; switch (prop.kind) { - case 277: + case 278: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); - case 276: + case 277: checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8) { checkGrammarNumericLiteral(name); } - case 157: - currentKind = 1; + currentKind = 4; break; - case 159: - currentKind = 2; + case 158: + currentKind = 8; break; case 160: - currentKind = 4; + currentKind = 1; + break; + case 161: + currentKind = 2; break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); @@ -51736,11 +52369,11 @@ var ts; seen.set(effectiveName, currentKind); } else { - if (currentKind === 1 && existingKind === 1) { + if ((currentKind & 12) && (existingKind & 12)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 6) && (existingKind & 6)) { - if (existingKind !== 6 && currentKind !== existingKind) { + else if ((currentKind & 3) && (existingKind & 3)) { + if (existingKind !== 3 && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -51758,7 +52391,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 270) { + if (attr.kind === 271) { continue; } var name = attr.name, initializer = attr.initializer; @@ -51768,7 +52401,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 271 && !initializer.expression) { + if (initializer && initializer.kind === 272 && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -51782,13 +52415,13 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 228 && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 229 && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384) === 0) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 158) { + if (func && func.kind !== 159) { ts.Debug.assert((ts.getFunctionFlags(func) & 2) === 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); @@ -51799,7 +52432,7 @@ var ts; return false; } } - if (forInOrOfStatement.initializer.kind === 239) { + if (forInOrOfStatement.initializer.kind === 240) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -51807,20 +52440,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 227 + var diagnostic = forInOrOfStatement.kind === 228 ? 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 === 227 + var diagnostic = forInOrOfStatement.kind === 228 ? 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 === 227 + var diagnostic = forInOrOfStatement.kind === 228 ? 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); @@ -51830,51 +52463,47 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - var kind = accessor.kind; - if (languageVersion < 1) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (accessor.flags & 4194304) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); - } - else if (accessor.body === undefined && !ts.hasModifier(accessor, 128)) { - return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + if (!(accessor.flags & 4194304)) { + if (languageVersion < 1) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + if (accessor.body === undefined && !ts.hasModifier(accessor, 128)) { + return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + } } - else if (accessor.body && ts.hasModifier(accessor, 128)) { + if (accessor.body && ts.hasModifier(accessor, 128)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - else if (accessor.typeParameters) { + if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 159 ? + if (!doesAccessorHaveCorrectParameterCount(accessor)) { + return grammarErrorOnNode(accessor.name, accessor.kind === 160 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 160) { + if (accessor.kind === 161) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } - else { - var parameter = accessor.parameters[0]; - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); - } - else if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); - } - else if (parameter.initializer) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); - } + var parameter = ts.Debug.assertDefined(ts.getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion."); + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); + } + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); + } + if (parameter.initializer) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); } } return false; } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 159 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 160 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 159 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 160 ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -51885,7 +52514,7 @@ var ts; } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 238: + case 239: var decl = parent; if (decl.name.kind !== 73) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); @@ -51897,13 +52526,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 155: + case 156: if (!ts.hasModifier(parent, 32) || !ts.hasModifier(parent, 64)) { 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 154: + case 155: if (!ts.hasModifier(parent, 64)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } @@ -51913,7 +52542,7 @@ var ts; } } else if (node.operator === 134) { - if (node.type.kind !== 170 && node.type.kind !== 171) { + if (node.type.kind !== 171 && node.type.kind !== 172) { return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(140)); } } @@ -51927,8 +52556,8 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 157) { - if (node.parent.kind === 189) { + if (node.kind === 158) { + if (node.parent.kind === 190) { if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 122)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } @@ -51950,14 +52579,14 @@ var ts; if (node.flags & 4194304) { 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 === 157 && !node.body) { + else if (node.kind === 158 && !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 === 242) { + else if (node.parent.kind === 243) { 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 === 169) { + else if (node.parent.kind === 170) { 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); } } @@ -51968,9 +52597,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 234: + case 235: if (node.label && current.label.escapedText === node.label.escapedText) { - var isMisplacedContinueLabel = node.kind === 229 + var isMisplacedContinueLabel = node.kind === 230 && !ts.isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -51978,8 +52607,8 @@ var ts; return false; } break; - case 233: - if (node.kind === 230 && !node.label) { + case 234: + if (node.kind === 231 && !node.label) { return false; } break; @@ -51992,13 +52621,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 230 + var message = node.kind === 231 ? 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 === 230 + var message = node.kind === 231 ? 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); @@ -52021,12 +52650,12 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 10 || expr.kind === 8 || - expr.kind === 203 && expr.operator === 39 && + expr.kind === 204 && expr.operator === 39 && expr.operand.kind === 8; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 || - expr.kind === 203 && expr.operator === 39 && + expr.kind === 204 && expr.operator === 39 && expr.operand.kind === 9; } function isSimpleLiteralEnumReference(expr) { @@ -52056,7 +52685,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 227 && node.parent.parent.kind !== 228) { + if (node.parent.parent.kind !== 228 && node.parent.parent.kind !== 229) { if (node.flags & 4194304) { checkAmbientInitializer(node); } @@ -52069,7 +52698,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 220 || !node.type || node.initializer || node.flags & 4194304)) { + if (node.exclamationToken && (node.parent.parent.kind !== 221 || !node.type || node.initializer || node.flags & 4194304)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && @@ -52125,15 +52754,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 223: case 224: case 225: - case 232: case 226: + case 233: case 227: case 228: + case 229: return false; - case 234: + case 235: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -52214,7 +52843,7 @@ var ts; return true; } } - else if (node.parent.kind === 242) { + else if (node.parent.kind === 243) { 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; } @@ -52222,7 +52851,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 169) { + else if (node.parent.kind === 170) { 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; } @@ -52239,13 +52868,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 242 || - node.kind === 243 || + if (node.kind === 243 || + node.kind === 244 || + node.kind === 251 || node.kind === 250 || - node.kind === 249 || + node.kind === 257 || node.kind === 256 || - node.kind === 255 || - node.kind === 248 || + node.kind === 249 || ts.hasModifier(node, 2 | 1 | 512)) { return false; } @@ -52254,7 +52883,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 === 220) { + if (ts.isDeclaration(decl) || decl.kind === 221) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -52267,14 +52896,11 @@ var ts; } function checkGrammarStatementInAmbientContext(node) { if (node.flags & 4194304) { - if (ts.isAccessor(node.parent)) { - return getNodeLinks(node).hasReportedStatementInAmbientContext = true; - } var links = getNodeLinks(node); - if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { + if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 219 || node.parent.kind === 246 || node.parent.kind === 285) { + if (node.parent.kind === 220 || node.parent.kind === 247 || node.parent.kind === 286) { var links_1 = getNodeLinks(node.parent); if (!links_1.hasReportedStatementInAmbientContext) { return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -52291,10 +52917,10 @@ var ts; if (languageVersion >= 1) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 183)) { + else if (ts.isChildOfNodeWithKind(node, 184)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 279)) { + else if (ts.isChildOfNodeWithKind(node, 280)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -52303,8 +52929,19 @@ var ts; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + checkNumericLiteralValueSize(node); return false; } + function checkNumericLiteralValueSize(node) { + if (node.numericLiteralFlags & 16 || node.text.length <= 15 || node.text.indexOf(".") !== -1) { + return; + } + var apparentValue = +ts.getTextOfNode(node); + if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) { + return; + } + addErrorOrSuggestion(false, ts.createDiagnosticForNode(node, ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers)); + } function checkGrammarBigIntLiteral(node) { var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); @@ -52356,10 +52993,17 @@ var ts; } } ts.createTypeChecker = createTypeChecker; + function isNotAccessor(declaration) { + return !ts.isAccessor(declaration); + } + function isNotOverload(declaration) { + return (declaration.kind !== 241 && declaration.kind !== 158) || + !!declaration.body; + } function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 254: - case 258: + case 255: + case 259: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -52367,13 +53011,13 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 251: - case 249: case 252: - case 254: + case 250: + case 253: + case 255: return true; case 73: - return decl.parent.kind === 254; + return decl.parent.kind === 255; default: return false; } @@ -52633,7 +53277,7 @@ var ts; } ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; function createQualifiedName(left, right) { - var node = createSynthesizedNode(149); + var node = createSynthesizedNode(150); node.left = left; node.right = asName(right); return node; @@ -52652,7 +53296,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(150); + var node = createSynthesizedNode(151); node.expression = parenthesizeForComputedName(expression); return node; } @@ -52664,7 +53308,7 @@ var ts; } ts.updateComputedPropertyName = updateComputedPropertyName; function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(151); + var node = createSynthesizedNode(152); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -52680,7 +53324,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(152); + var node = createSynthesizedNode(153); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -52704,7 +53348,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(153); + var node = createSynthesizedNode(154); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -52716,7 +53360,7 @@ var ts; } ts.updateDecorator = updateDecorator; function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(154); + var node = createSynthesizedNode(155); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -52736,7 +53380,7 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(155); + var node = createSynthesizedNode(156); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -52760,7 +53404,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(156, typeParameters, parameters, type); + var node = createSignatureDeclaration(157, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -52777,7 +53421,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(157); + var node = createSynthesizedNode(158); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -52805,7 +53449,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(158); + var node = createSynthesizedNode(159); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -52825,7 +53469,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(159); + var node = createSynthesizedNode(160); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -52848,7 +53492,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(160); + var node = createSynthesizedNode(161); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -52869,7 +53513,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(161, typeParameters, parameters, type); + return createSignatureDeclaration(162, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -52877,7 +53521,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(162, typeParameters, parameters, type); + return createSignatureDeclaration(163, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -52885,7 +53529,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(163); + var node = createSynthesizedNode(164); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -52923,7 +53567,7 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(164); + var node = createSynthesizedNode(165); node.parameterName = asName(parameterName); node.type = type; return node; @@ -52937,7 +53581,7 @@ var ts; } ts.updateTypePredicateNode = updateTypePredicateNode; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(165); + var node = createSynthesizedNode(166); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -52951,7 +53595,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(166, typeParameters, parameters, type); + return createSignatureDeclaration(167, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -52959,7 +53603,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(167, typeParameters, parameters, type); + return createSignatureDeclaration(168, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -52967,7 +53611,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(168); + var node = createSynthesizedNode(169); node.exprName = exprName; return node; } @@ -52979,7 +53623,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(169); + var node = createSynthesizedNode(170); node.members = createNodeArray(members); return node; } @@ -52991,7 +53635,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(170); + var node = createSynthesizedNode(171); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -53003,7 +53647,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(171); + var node = createSynthesizedNode(172); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -53015,7 +53659,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(172); + var node = createSynthesizedNode(173); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -53027,7 +53671,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(173); + var node = createSynthesizedNode(174); node.type = type; return node; } @@ -53039,7 +53683,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(174, types); + return createUnionOrIntersectionTypeNode(175, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -53047,7 +53691,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(175, types); + return createUnionOrIntersectionTypeNode(176, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -53066,7 +53710,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(176); + var node = createSynthesizedNode(177); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -53084,7 +53728,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(177); + var node = createSynthesizedNode(178); node.typeParameter = typeParameter; return node; } @@ -53096,7 +53740,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(184); + var node = createSynthesizedNode(185); node.argument = argument; node.qualifier = qualifier; node.typeArguments = ts.parenthesizeTypeParameters(typeArguments); @@ -53114,7 +53758,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(178); + var node = createSynthesizedNode(179); node.type = type; return node; } @@ -53126,11 +53770,11 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(179); + return createSynthesizedNode(180); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(180); + var node = createSynthesizedNode(181); node.operator = typeof operatorOrType === "number" ? operatorOrType : 130; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; @@ -53141,7 +53785,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(181); + var node = createSynthesizedNode(182); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -53155,7 +53799,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(182); + var node = createSynthesizedNode(183); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -53173,7 +53817,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(183); + var node = createSynthesizedNode(184); node.literal = literal; return node; } @@ -53185,7 +53829,7 @@ var ts; } ts.updateLiteralTypeNode = updateLiteralTypeNode; function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(185); + var node = createSynthesizedNode(186); node.elements = createNodeArray(elements); return node; } @@ -53197,7 +53841,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(186); + var node = createSynthesizedNode(187); node.elements = createNodeArray(elements); return node; } @@ -53209,7 +53853,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(187); + var node = createSynthesizedNode(188); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -53227,7 +53871,7 @@ var ts; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(188); + var node = createSynthesizedNode(189); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -53241,7 +53885,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(189); + var node = createSynthesizedNode(190); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -53255,7 +53899,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(190); + var node = createSynthesizedNode(191); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072); @@ -53270,7 +53914,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(191); + var node = createSynthesizedNode(192); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -53284,7 +53928,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(192); + var node = createSynthesizedNode(193); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -53300,7 +53944,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(193); + var node = createSynthesizedNode(194); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -53316,7 +53960,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(194); + var node = createSynthesizedNode(195); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -53339,7 +53983,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(195); + var node = createSynthesizedNode(196); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -53353,7 +53997,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(196); + var node = createSynthesizedNode(197); node.expression = expression; return node; } @@ -53365,7 +54009,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(197); + var node = createSynthesizedNode(198); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -53389,7 +54033,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(198); + var node = createSynthesizedNode(199); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); @@ -53411,7 +54055,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(199); + var node = createSynthesizedNode(200); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53423,7 +54067,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(200); + var node = createSynthesizedNode(201); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53435,7 +54079,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(201); + var node = createSynthesizedNode(202); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53447,7 +54091,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(202); + var node = createSynthesizedNode(203); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53459,7 +54103,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(203); + var node = createSynthesizedNode(204); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -53472,7 +54116,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(204); + var node = createSynthesizedNode(205); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -53485,7 +54129,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(205); + var node = createSynthesizedNode(206); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, true, undefined); @@ -53502,7 +54146,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(206); + var node = createSynthesizedNode(207); node.condition = ts.parenthesizeForConditionalHead(condition); node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); @@ -53522,7 +54166,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(207); + var node = createSynthesizedNode(208); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -53535,32 +54179,91 @@ var ts; : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createTemplateHead(text) { - var node = createSynthesizedNode(15); + var rawTextScanner; + var invalidValueSentinel = {}; + function getCookedText(kind, rawText) { + if (!rawTextScanner) { + rawTextScanner = ts.createScanner(99, false, 0); + } + switch (kind) { + case 14: + rawTextScanner.setText("`" + rawText + "`"); + break; + case 15: + rawTextScanner.setText("`" + rawText + "${"); + break; + case 16: + rawTextScanner.setText("}" + rawText + "${"); + break; + case 17: + rawTextScanner.setText("}" + rawText + "`"); + break; + } + var token = rawTextScanner.scan(); + if (token === 23) { + token = rawTextScanner.reScanTemplateToken(); + } + if (rawTextScanner.isUnterminated()) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + var tokenValue; + switch (token) { + case 14: + case 15: + case 16: + case 17: + tokenValue = rawTextScanner.getTokenValue(); + break; + } + if (rawTextScanner.scan() !== 1) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + rawTextScanner.setText(undefined); + return tokenValue; + } + function createTemplateLiteralLikeNode(kind, text, rawText) { + var node = createSynthesizedNode(kind); + node.text = text; + if (rawText === undefined || text === rawText) { + node.rawText = rawText; + } + else { + var cooked = getCookedText(kind, rawText); + if (typeof cooked === "object") { + return ts.Debug.fail("Invalid raw text"); + } + ts.Debug.assert(text === cooked, "Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'."); + node.rawText = rawText; + } + return node; + } + function createTemplateHead(text, rawText) { + var node = createTemplateLiteralLikeNode(15, text, rawText); node.text = text; return node; } ts.createTemplateHead = createTemplateHead; - function createTemplateMiddle(text) { - var node = createSynthesizedNode(16); + function createTemplateMiddle(text, rawText) { + var node = createTemplateLiteralLikeNode(16, text, rawText); node.text = text; return node; } ts.createTemplateMiddle = createTemplateMiddle; - function createTemplateTail(text) { - var node = createSynthesizedNode(17); + function createTemplateTail(text, rawText) { + var node = createTemplateLiteralLikeNode(17, text, rawText); node.text = text; return node; } ts.createTemplateTail = createTemplateTail; - function createNoSubstitutionTemplateLiteral(text) { - var node = createSynthesizedNode(14); - node.text = text; + function createNoSubstitutionTemplateLiteral(text, rawText) { + var node = createTemplateLiteralLikeNode(14, text, rawText); return node; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(208); + var node = createSynthesizedNode(209); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 ? asteriskTokenOrExpression : undefined; node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 ? asteriskTokenOrExpression : expression; return node; @@ -53574,7 +54277,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(209); + var node = createSynthesizedNode(210); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -53586,7 +54289,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(210); + var node = createSynthesizedNode(211); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -53607,11 +54310,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(211); + return createSynthesizedNode(212); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(212); + var node = createSynthesizedNode(213); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -53625,7 +54328,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(213); + var node = createSynthesizedNode(214); node.expression = expression; node.type = type; return node; @@ -53639,7 +54342,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(214); + var node = createSynthesizedNode(215); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -53651,7 +54354,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(215); + var node = createSynthesizedNode(216); node.keywordToken = keywordToken; node.name = name; return node; @@ -53664,7 +54367,7 @@ var ts; } ts.updateMetaProperty = updateMetaProperty; function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(217); + var node = createSynthesizedNode(218); node.expression = expression; node.literal = literal; return node; @@ -53678,11 +54381,11 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(218); + return createSynthesizedNode(219); } ts.createSemicolonClassElement = createSemicolonClassElement; function createBlock(statements, multiLine) { - var block = createSynthesizedNode(219); + var block = createSynthesizedNode(220); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -53696,7 +54399,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(220); + var node = createSynthesizedNode(221); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -53711,11 +54414,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(221); + return createSynthesizedNode(222); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(222); + var node = createSynthesizedNode(223); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -53729,7 +54432,7 @@ var ts; ts.createStatement = createExpressionStatement; ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(223); + var node = createSynthesizedNode(224); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -53745,7 +54448,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(224); + var node = createSynthesizedNode(225); node.statement = asEmbeddedStatement(statement); node.expression = expression; return node; @@ -53759,7 +54462,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(225); + var node = createSynthesizedNode(226); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -53773,7 +54476,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(226); + var node = createSynthesizedNode(227); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -53791,7 +54494,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(227); + var node = createSynthesizedNode(228); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -53807,7 +54510,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(228); + var node = createSynthesizedNode(229); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -53825,7 +54528,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(229); + var node = createSynthesizedNode(230); node.label = asName(label); return node; } @@ -53837,7 +54540,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(230); + var node = createSynthesizedNode(231); node.label = asName(label); return node; } @@ -53849,7 +54552,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(231); + var node = createSynthesizedNode(232); node.expression = expression; return node; } @@ -53861,7 +54564,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(232); + var node = createSynthesizedNode(233); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -53875,7 +54578,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(233); + var node = createSynthesizedNode(234); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -53889,7 +54592,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(234); + var node = createSynthesizedNode(235); node.label = asName(label); node.statement = asEmbeddedStatement(statement); return node; @@ -53903,7 +54606,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(235); + var node = createSynthesizedNode(236); node.expression = expression; return node; } @@ -53915,7 +54618,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(236); + var node = createSynthesizedNode(237); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -53931,11 +54634,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(237); + return createSynthesizedNode(238); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(238); + var node = createSynthesizedNode(239); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -53952,7 +54655,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0; } - var node = createSynthesizedNode(239); + var node = createSynthesizedNode(240); node.flags |= flags & 3; node.declarations = createNodeArray(declarations); return node; @@ -53965,7 +54668,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(240); + var node = createSynthesizedNode(241); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -53991,7 +54694,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(241); + var node = createSynthesizedNode(242); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54013,7 +54716,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(242); + var node = createSynthesizedNode(243); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54035,7 +54738,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(243); + var node = createSynthesizedNode(244); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54055,7 +54758,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(244); + var node = createSynthesizedNode(245); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54074,7 +54777,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0; } - var node = createSynthesizedNode(245); + var node = createSynthesizedNode(246); node.flags |= flags & (16 | 4 | 512); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -54093,7 +54796,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(246); + var node = createSynthesizedNode(247); node.statements = createNodeArray(statements); return node; } @@ -54105,7 +54808,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(247); + var node = createSynthesizedNode(248); node.clauses = createNodeArray(clauses); return node; } @@ -54117,7 +54820,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(248); + var node = createSynthesizedNode(249); node.name = asName(name); return node; } @@ -54129,7 +54832,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(249); + var node = createSynthesizedNode(250); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54147,7 +54850,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(250); + var node = createSynthesizedNode(251); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -54165,7 +54868,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(251); + var node = createSynthesizedNode(252); node.name = name; node.namedBindings = namedBindings; return node; @@ -54179,7 +54882,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(252); + var node = createSynthesizedNode(253); node.name = name; return node; } @@ -54191,7 +54894,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(253); + var node = createSynthesizedNode(254); node.elements = createNodeArray(elements); return node; } @@ -54203,7 +54906,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(254); + var node = createSynthesizedNode(255); node.propertyName = propertyName; node.name = name; return node; @@ -54217,7 +54920,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(255); + var node = createSynthesizedNode(256); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -54234,7 +54937,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(256); + var node = createSynthesizedNode(257); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -54252,7 +54955,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(257); + var node = createSynthesizedNode(258); node.elements = createNodeArray(elements); return node; } @@ -54264,7 +54967,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(258); + var node = createSynthesizedNode(259); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -54278,7 +54981,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createExternalModuleReference(expression) { - var node = createSynthesizedNode(260); + var node = createSynthesizedNode(261); node.expression = expression; return node; } @@ -54290,33 +54993,33 @@ var ts; } ts.updateExternalModuleReference = updateExternalModuleReference; function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(289); + var node = createSynthesizedNode(290); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(309, "type"); + var tag = createJSDocTag(311, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; } ts.createJSDocTypeTag = createJSDocTypeTag; function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(307, "returns"); + var tag = createJSDocTag(309, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; } ts.createJSDocReturnTag = createJSDocReturnTag; function createJSDocThisTag(typeExpression) { - var tag = createJSDocTag(308, "this"); + var tag = createJSDocTag(310, "this"); tag.typeExpression = typeExpression; return tag; } ts.createJSDocThisTag = createJSDocThisTag; function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(306, "param"); + var tag = createJSDocTag(308, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -54325,7 +55028,7 @@ var ts; } ts.createJSDocParamTag = createJSDocParamTag; function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(297); + var node = createSynthesizedNode(299); node.comment = comment; node.tags = tags; return node; @@ -54337,7 +55040,7 @@ var ts; return node; } function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(261); + var node = createSynthesizedNode(262); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -54353,7 +55056,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(262); + var node = createSynthesizedNode(263); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -54369,7 +55072,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(263); + var node = createSynthesizedNode(264); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -54385,7 +55088,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(264); + var node = createSynthesizedNode(265); node.tagName = tagName; return node; } @@ -54397,7 +55100,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(265); + var node = createSynthesizedNode(266); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -54419,11 +55122,11 @@ var ts; } ts.updateJsxText = updateJsxText; function createJsxOpeningFragment() { - return createSynthesizedNode(266); + return createSynthesizedNode(267); } ts.createJsxOpeningFragment = createJsxOpeningFragment; function createJsxJsxClosingFragment() { - return createSynthesizedNode(267); + return createSynthesizedNode(268); } ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment; function updateJsxFragment(node, openingFragment, children, closingFragment) { @@ -54435,7 +55138,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(268); + var node = createSynthesizedNode(269); node.name = name; node.initializer = initializer; return node; @@ -54449,7 +55152,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(269); + var node = createSynthesizedNode(270); node.properties = createNodeArray(properties); return node; } @@ -54461,7 +55164,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(270); + var node = createSynthesizedNode(271); node.expression = expression; return node; } @@ -54473,7 +55176,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(271); + var node = createSynthesizedNode(272); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -54486,7 +55189,7 @@ var ts; } ts.updateJsxExpression = updateJsxExpression; function createCaseClause(expression, statements) { - var node = createSynthesizedNode(272); + var node = createSynthesizedNode(273); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -54500,7 +55203,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(273); + var node = createSynthesizedNode(274); node.statements = createNodeArray(statements); return node; } @@ -54512,7 +55215,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(274); + var node = createSynthesizedNode(275); node.token = token; node.types = createNodeArray(types); return node; @@ -54525,7 +55228,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(275); + var node = createSynthesizedNode(276); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -54539,7 +55242,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(276); + var node = createSynthesizedNode(277); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -54554,7 +55257,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(277); + var node = createSynthesizedNode(278); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -54568,7 +55271,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(278); + var node = createSynthesizedNode(279); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -54580,7 +55283,7 @@ var ts; } ts.updateSpreadAssignment = updateSpreadAssignment; function createEnumMember(name, initializer) { - var node = createSynthesizedNode(279); + var node = createSynthesizedNode(280); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -54600,7 +55303,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(285); + var updated = createSynthesizedNode(286); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -54674,28 +55377,28 @@ var ts; } ts.getMutableClone = getMutableClone; function createNotEmittedStatement(original) { - var node = createSynthesizedNode(314); + var node = createSynthesizedNode(316); node.original = original; setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(318); + var node = createSynthesizedNode(320); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(317); + var node = createSynthesizedNode(319); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(315); + var node = createSynthesizedNode(317); node.expression = expression; node.original = original; setTextRange(node, original); @@ -54711,7 +55414,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 316) { + if (node.kind === 318) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27) { @@ -54721,7 +55424,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(316); + var node = createSynthesizedNode(318); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -54734,7 +55437,7 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(286); + var node = ts.createNode(287); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -54765,7 +55468,7 @@ var ts; ], function (helper) { return helper.name; })); } function createUnparsedSource() { - var node = ts.createNode(287); + var node = ts.createNode(288); node.prologues = ts.emptyArray; node.referencedFiles = ts.emptyArray; node.libReferenceDirectives = ts.emptyArray; @@ -54895,10 +55598,10 @@ var ts; } function mapBundleFileSectionKindToSyntaxKind(kind) { switch (kind) { - case "prologue": return 280; - case "prepend": return 281; - case "internal": return 283; - case "text": return 282; + case "prologue": return 281; + case "prepend": return 282; + case "internal": return 284; + case "text": return 283; case "emitHelpers": case "no-default-lib": case "reference": @@ -54916,14 +55619,14 @@ var ts; return node; } function createUnparsedSyntheticReference(section, parent) { - var node = ts.createNode(284, section.pos, section.end); + var node = ts.createNode(285, section.pos, section.end); node.parent = parent; node.data = section.data; node.section = section; return node; } function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { - var node = ts.createNode(288); + var node = ts.createNode(289); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -54969,8 +55672,8 @@ var ts; node.declarationMapPath = declarationMapPath; node.declarationMapText = declarationMapTextOrBuildInfoPath; node.javascriptPath = javascriptPath; - node.declarationPath = declarationPath, - node.buildInfoPath = buildInfoPath; + node.declarationPath = declarationPath; + node.buildInfoPath = buildInfoPath; node.buildInfo = buildInfo; node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } @@ -55079,7 +55782,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 285) { + if (node.kind === 286) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -55364,9 +56067,9 @@ var ts; } ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createFunctionCall(func, thisArg, argumentsList, location) { - return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), undefined, [ + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), undefined, __spreadArrays([ thisArg - ].concat(argumentsList)), location); + ], argumentsList)), location); } ts.createFunctionCall = createFunctionCall; function createFunctionApply(func, thisArg, argumentsExpression, location) { @@ -55456,51 +56159,55 @@ var ts; return ts.setTextRange(ts.createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList), location); } ts.createExpressionForJsxFragment = createExpressionForJsxFragment; - function getHelperName(name) { + function getUnscopedHelperName(name) { return ts.setEmitFlags(ts.createIdentifier(name), 4096 | 2); } - ts.getHelperName = getHelperName; + ts.getUnscopedHelperName = getUnscopedHelperName; ts.valuesHelper = { name: "typescript:values", + importName: "__values", scoped: false, - text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };" + text: "\n var __values = (this && this.__values) || function(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n };" }; function createValuesHelper(context, expression, location) { context.requestEmitHelper(ts.valuesHelper); - return ts.setTextRange(ts.createCall(getHelperName("__values"), undefined, [expression]), location); + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__values"), undefined, [expression]), location); } ts.createValuesHelper = createValuesHelper; ts.readHelper = { name: "typescript:read", + importName: "__read", scoped: false, text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };" }; function createReadHelper(context, iteratorRecord, count, location) { context.requestEmitHelper(ts.readHelper); - return ts.setTextRange(ts.createCall(getHelperName("__read"), undefined, count !== undefined + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__read"), undefined, count !== undefined ? [iteratorRecord, ts.createLiteral(count)] : [iteratorRecord]), location); } ts.createReadHelper = createReadHelper; ts.spreadHelper = { name: "typescript:spread", + importName: "__spread", scoped: false, text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" }; function createSpreadHelper(context, argumentList, location) { context.requestEmitHelper(ts.readHelper); context.requestEmitHelper(ts.spreadHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spread"), undefined, argumentList), location); + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spread"), undefined, argumentList), location); } ts.createSpreadHelper = createSpreadHelper; ts.spreadArraysHelper = { name: "typescript:spreadArrays", + importName: "__spreadArrays", scoped: false, text: "\n var __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n };" }; function createSpreadArraysHelper(context, argumentList, location) { context.requestEmitHelper(ts.spreadArraysHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spreadArrays"), undefined, argumentList), location); + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spreadArrays"), undefined, argumentList), location); } ts.createSpreadArraysHelper = createSpreadArraysHelper; function createForOfBindingStatement(node, boundValue) { @@ -55517,7 +56224,7 @@ var ts; ts.createForOfBindingStatement = createForOfBindingStatement; function insertLeadingStatement(dest, source) { if (ts.isBlock(dest)) { - return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray([source].concat(dest.statements)), dest.statements)); + return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray(__spreadArrays([source], dest.statements)), dest.statements)); } else { return ts.createBlock(ts.createNodeArray([dest, source]), true); @@ -55528,7 +56235,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 234 + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 235 ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -55547,13 +56254,13 @@ var ts; case 9: case 10: return false; - case 188: + case 189: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 189: + case 190: return target.properties.length > 0; default: return true; @@ -55580,7 +56287,7 @@ var ts; } else { switch (callee.kind) { - case 190: { + case 191: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name); @@ -55592,7 +56299,7 @@ var ts; } break; } - case 191: { + case 192: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression); @@ -55645,14 +56352,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 159: case 160: + case 161: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 276: - return createExpressionForPropertyAssignment(property, receiver); case 277: + return createExpressionForPropertyAssignment(property, receiver); + case 278: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 157: + case 158: return createExpressionForMethodDeclaration(property, receiver); } } @@ -55848,16 +56555,16 @@ var ts; function ensureUseStrict(statements) { var foundUseStrict = findUseStrictPrologue(statements); if (!foundUseStrict) { - return ts.setTextRange(ts.createNodeArray([ + return ts.setTextRange(ts.createNodeArray(__spreadArrays([ startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) - ].concat(statements)), statements); + ], statements)), statements); } return statements; } ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 196) { + if (skipped.kind === 197) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -55866,10 +56573,10 @@ var ts; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(205, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(205, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(206, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(206, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 198 && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 199 && binaryOperatorPrecedence > 4) { return true; } var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); @@ -55877,7 +56584,7 @@ var ts; case -1: if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 - && operand.kind === 208) { + && operand.kind === 209) { return false; } return true; @@ -55916,22 +56623,20 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 205 && node.operatorToken.kind === 38) { + if (node.kind === 206 && node.operatorToken.kind === 38) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0; + var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind : + 0; node.cachedLiteralKind = literalKind; return literalKind; } return 0; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(206, 56); + var conditionalPrecedence = ts.getOperatorPrecedence(207, 56); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { @@ -55952,8 +56657,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, false).kind) { - case 210: - case 197: + case 211: + case 198: needsParens = true; } } @@ -55963,9 +56668,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, true); switch (leftmostExpr.kind) { - case 192: - return ts.createParen(expression); case 193: + return ts.createParen(expression); + case 194: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -55976,7 +56681,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 193 || emittedExpression.arguments)) { + && (emittedExpression.kind !== 194 || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -56014,7 +56719,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(205, 27); + var commaPrecedence = ts.getOperatorPrecedence(206, 27); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -56025,29 +56730,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 197 || kind === 198) { + if (kind === 198 || kind === 199) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, false).kind; - if (leftmostExpressionKind === 189 || leftmostExpressionKind === 197) { + if (leftmostExpressionKind === 190 || leftmostExpressionKind === 198) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 176 ? ts.createParenthesizedType(member) : member; + return member.kind === 177 ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 174: case 175: - case 166: + case 176: case 167: + case 168: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -56055,9 +56760,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 168: - case 180: - case 177: + case 169: + case 181: + case 178: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -56083,27 +56788,27 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 204: + case 205: node = node.operand; continue; - case 205: + case 206: node = node.left; continue; - case 206: + case 207: node = node.condition; continue; - case 194: + case 195: node = node.tag; continue; - case 192: + case 193: if (stopAtCallExpressions) { return node; } - case 213: - case 191: - case 190: case 214: - case 315: + case 192: + case 191: + case 215: + case 317: node = node.expression; continue; } @@ -56112,27 +56817,27 @@ var ts; } ts.getLeftmostExpression = getLeftmostExpression; function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, false).kind === 189)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, false).kind === 190)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 205 && node.operatorToken.kind === 27 || - node.kind === 316; + return node.kind === 206 && node.operatorToken.kind === 27 || + node.kind === 318; } ts.isCommaSequence = isCommaSequence; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7; } switch (node.kind) { - case 196: + case 197: return (kinds & 1) !== 0; - case 195: - case 213: + case 196: case 214: + case 215: return (kinds & 2) !== 0; - case 315: + case 317: return (kinds & 4) !== 0; } return false; @@ -56157,7 +56862,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 214) { + while (ts.isAssertionExpression(node) || node.kind === 215) { node = node.expression; } return node; @@ -56165,15 +56870,15 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 196: return ts.updateParen(outerExpression, expression); - case 195: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 213: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 214: return ts.updateNonNullExpression(outerExpression, expression); - case 315: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 197: return ts.updateParen(outerExpression, expression); + case 196: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 214: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 215: return ts.updateNonNullExpression(outerExpression, expression); + case 317: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } function isIgnorableParen(node) { - return node.kind === 196 + return node.kind === 197 && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -56198,6 +56903,54 @@ var ts; return emitNode && emitNode.externalHelpersModuleName; } ts.getExternalHelpersModuleName = getExternalHelpersModuleName; + function hasRecordedExternalHelpers(sourceFile) { + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = parseNode && parseNode.emitNode; + return !!emitNode && (!!emitNode.externalHelpersModuleName || !!emitNode.externalHelpers); + } + ts.hasRecordedExternalHelpers = hasRecordedExternalHelpers; + function createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault) { + if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + var namedBindings = void 0; + var moduleKind = ts.getEmitModuleKind(compilerOptions); + if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) { + var helpers = ts.getEmitHelpers(sourceFile); + if (helpers) { + var helperNames = []; + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; + if (!helper.scoped) { + var importName = helper.importName; + if (importName) { + ts.pushIfUnique(helperNames, importName); + } + } + } + if (ts.some(helperNames)) { + helperNames.sort(ts.compareStringsCaseSensitive); + namedBindings = ts.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name) + ? ts.createImportSpecifier(undefined, ts.createIdentifier(name)) + : ts.createImportSpecifier(ts.createIdentifier(name), getUnscopedHelperName(name)); })); + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = ts.getOrCreateEmitNode(parseNode); + emitNode.externalHelpers = true; + } + } + } + else { + var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar || hasImportDefault); + if (externalHelpersModuleName) { + namedBindings = ts.createNamespaceImport(externalHelpersModuleName); + } + } + if (namedBindings) { + var externalHelpersImportDeclaration = ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, namedBindings), ts.createLiteral(ts.externalHelpersModuleNameText)); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864); + return externalHelpersImportDeclaration; + } + } + } + ts.createExternalHelpersImportDeclarationIfNeeded = createExternalHelpersImportDeclarationIfNeeded; function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault) { if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(node, compilerOptions)) { var externalHelpersModuleName = getExternalHelpersModuleName(node); @@ -56212,8 +56965,8 @@ var ts; if (!create) { var helpers = ts.getEmitHelpers(node); if (helpers) { - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; + for (var _i = 0, helpers_3 = helpers; _i < helpers_3.length; _i++) { + var helper = helpers_3[_i]; if (!helper.scoped) { create = true; break; @@ -56235,10 +56988,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 250 && node.importClause) { + if (node.kind === 251 && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 256 && node.moduleSpecifier) { + if (node.kind === 257 && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -56301,11 +57054,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 276: - return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 277: - return bindingElement.name; + return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 278: + return bindingElement.name; + case 279: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -56321,11 +57074,11 @@ var ts; ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 152: - case 187: + case 153: + case 188: return bindingElement.dotDotDotToken; - case 209: - case 278: + case 210: + case 279: return bindingElement; } return undefined; @@ -56333,7 +57086,7 @@ var ts; ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement; function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 187: + case 188: if (bindingElement.propertyName) { var propertyName = bindingElement.propertyName; return ts.isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression) @@ -56341,7 +57094,7 @@ var ts; : propertyName; } break; - case 276: + case 277: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression) @@ -56349,7 +57102,7 @@ var ts; : propertyName; } break; - case 278: + case 279: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -56368,11 +57121,11 @@ var ts; } function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 185: case 186: - case 188: - return name.elements; + case 187: case 189: + return name.elements; + case 190: return name.properties; } } @@ -56411,11 +57164,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 186: - case 188: - return convertToArrayAssignmentPattern(node); - case 185: + case 187: case 189: + return convertToArrayAssignmentPattern(node); + case 186: + case 190: return convertToObjectAssignmentPattern(node); } } @@ -56519,11 +57272,9 @@ var ts; function visitLexicalEnvironment(statements, visitor, context, start, ensureUseStrict) { context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); - if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); - } - var declarations = context.endLexicalEnvironment(); - return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); + if (ensureUseStrict) + statements = ts.ensureUseStrict(statements); + return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment()); } ts.visitLexicalEnvironment = visitLexicalEnvironment; function visitParameterList(nodes, visitor, context, nodesVisitor) { @@ -56552,261 +57303,261 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 148) || kind === 179) { + if ((kind > 0 && kind <= 149) || kind === 180) { return node; } switch (kind) { case 73: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 149: - return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); case 150: - return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); case 151: - return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); + return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); case 152: - return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); case 153: - return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); case 154: - return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); case 155: - return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); case 156: - return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); + return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); case 157: - return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); case 158: - return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); + return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 159: - return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); case 160: - return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); + return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 161: - return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); case 162: - return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 163: - return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 164: - return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 165: - return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); + return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); case 166: - return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); case 167: - return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 168: - return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); + return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 169: - return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); + return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); case 170: - return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); + return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); case 171: - return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); + return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); case 172: - return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); case 173: - return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); case 174: - return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); + return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); case 175: - return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); + return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); case 176: - return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); + return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); case 177: + return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); + case 178: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 184: + case 185: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 178: + case 179: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 180: - return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); case 181: - return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); + return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); case 182: - return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); case 183: + return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); + case 184: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); - case 185: - return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); case 186: - return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); + return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); case 187: - return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); case 188: - return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); + return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); case 189: - return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); + return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); case 190: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); case 191: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); case 192: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); case 193: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); case 194: - return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); case 195: - return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); case 196: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 197: - return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 198: - return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); + return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 199: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); case 200: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); case 201: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); case 202: - return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); case 203: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); case 204: - return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); case 205: - return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); case 206: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); case 207: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); case 208: - return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); case 209: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); case 210: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 211: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 212: - return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 213: - return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 214: - return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); case 215: + return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + case 216: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 217: + case 218: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 219: - return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); case 220: + return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + case 221: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 222: - return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 223: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 224: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); case 225: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); case 226: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 227: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 228: - return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 229: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); + return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 230: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); case 231: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); case 232: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); case 233: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 234: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); case 235: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 236: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 237: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 238: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); case 239: - return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); case 240: - return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); case 241: - return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); + return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 242: - return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); + return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); case 243: - return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); case 244: - return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); + return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 245: - return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); + return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); case 246: - return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); case 247: - return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); + return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); case 248: - return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); case 249: - return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); + return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); case 250: - return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); case 251: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); + return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 252: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); case 253: - return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 254: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); case 255: - return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); case 256: - return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); case 257: - return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 258: + return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); + case 259: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 260: - return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); case 261: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); + return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); case 262: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 263: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); case 264: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); case 265: + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + case 266: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 268: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 269: - return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 270: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); case 271: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); case 272: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 273: - return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); case 274: - return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); case 275: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); case 276: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); case 277: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); case 278: - return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); case 279: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + case 280: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 285: + case 286: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 315: + case 317: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 316: + case 318: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: return node; @@ -56832,52 +57583,52 @@ var ts; var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; - if ((kind > 0 && kind <= 148)) { + if ((kind > 0 && kind <= 149)) { return initial; } - if ((kind >= 164 && kind <= 183)) { + if ((kind >= 165 && kind <= 184)) { return initial; } var result = initial; switch (node.kind) { - case 218: - case 221: - case 211: - case 237: - case 314: + case 219: + case 222: + case 212: + case 238: + case 316: break; - case 149: + case 150: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 150: + case 151: result = reduceNode(node.expression, cbNode, result); break; - case 152: + case 153: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 153: + case 154: result = reduceNode(node.expression, cbNode, result); break; - case 154: + case 155: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 155: + case 156: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 157: + case 158: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -56886,12 +57637,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 158: + case 159: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 159: + case 160: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -56899,56 +57650,56 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 160: + case 161: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 185: case 186: + case 187: result = reduceNodes(node.elements, cbNodes, result); break; - case 187: + case 188: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 188: + case 189: result = reduceNodes(node.elements, cbNodes, result); break; - case 189: + case 190: result = reduceNodes(node.properties, cbNodes, result); break; - case 190: + case 191: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 191: + case 192: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 192: + case 193: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 193: + case 194: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 194: + case 195: result = reduceNode(node.tag, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 195: + case 196: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 197: + case 198: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -56956,121 +57707,121 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 198: + case 199: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 196: - case 199: + case 197: case 200: case 201: case 202: - case 208: + case 203: case 209: - case 214: + case 210: + case 215: result = reduceNode(node.expression, cbNode, result); break; - case 203: case 204: + case 205: result = reduceNode(node.operand, cbNode, result); break; - case 205: + case 206: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 206: + case 207: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 207: + case 208: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 210: + case 211: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 212: + case 213: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 213: + case 214: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; - case 217: + case 218: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; - case 219: + case 220: result = reduceNodes(node.statements, cbNodes, result); break; - case 220: + case 221: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 222: + case 223: result = reduceNode(node.expression, cbNode, result); break; - case 223: + case 224: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 224: + case 225: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 225: - case 232: + case 226: + case 233: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 226: + case 227: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 227: case 228: + case 229: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 231: - case 235: + case 232: + case 236: result = reduceNode(node.expression, cbNode, result); break; - case 233: + case 234: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 234: + case 235: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 236: + case 237: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 238: + case 239: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 239: + case 240: result = reduceNodes(node.declarations, cbNodes, result); break; - case 240: + case 241: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57079,7 +57830,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 241: + case 242: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57087,132 +57838,132 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 244: + case 245: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.members, cbNodes, result); break; - case 245: + case 246: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 246: + case 247: result = reduceNodes(node.statements, cbNodes, result); break; - case 247: + case 248: result = reduceNodes(node.clauses, cbNodes, result); break; - case 249: + case 250: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 250: + case 251: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 251: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.namedBindings, cbNode, result); - break; case 252: result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.namedBindings, cbNode, result); break; case 253: - case 257: - result = reduceNodes(node.elements, cbNodes, result); + result = reduceNode(node.name, cbNode, result); break; case 254: case 258: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 255: + case 259: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 255: + case 256: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 256: + case 257: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 260: + case 261: result = reduceNode(node.expression, cbNode, result); break; - case 261: + case 262: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 265: + case 266: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 262: case 263: + case 264: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 269: + case 270: result = reduceNodes(node.properties, cbNodes, result); break; - case 264: + case 265: result = reduceNode(node.tagName, cbNode, result); break; - case 268: + case 269: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270: - result = reduceNode(node.expression, cbNode, result); - break; case 271: result = reduceNode(node.expression, cbNode, result); break; case 272: result = reduceNode(node.expression, cbNode, result); + break; case 273: + result = reduceNode(node.expression, cbNode, result); + case 274: result = reduceNodes(node.statements, cbNodes, result); break; - case 274: + case 275: result = reduceNodes(node.types, cbNodes, result); break; - case 275: + case 276: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; - case 276: + case 277: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 277: + case 278: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 278: + case 279: result = reduceNode(node.expression, cbNode, result); break; - case 279: + case 280: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 285: + case 286: result = reduceNodes(node.statements, cbNodes, result); break; - case 315: + case 317: result = reduceNode(node.expression, cbNode, result); break; - case 316: + case 318: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -57265,7 +58016,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 212)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 213)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -57888,7 +58639,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 285 ? transformSourceFile(node) : transformBundle(node); + return node.kind === 286 ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -57928,20 +58679,26 @@ var ts; var hasExportDefault = false; var exportEquals; var hasExportStarsToExportValues = false; - var hasImportStarOrImportDefault = false; + var hasImportStar = false; + var hasImportDefault = false; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 250: + case 251: externalImports.push(node); - hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); + if (!hasImportStar && getImportNeedsImportStarHelper(node)) { + hasImportStar = true; + } + if (!hasImportDefault && getImportNeedsImportDefaultHelper(node)) { + hasImportDefault = true; + } break; - case 249: - if (node.moduleReference.kind === 260) { + case 250: + if (node.moduleReference.kind === 261) { externalImports.push(node); } break; - case 256: + case 257: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -57968,12 +58725,12 @@ var ts; } } break; - case 255: + case 256: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 220: + case 221: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -57981,7 +58738,7 @@ var ts; } } break; - case 240: + case 241: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -57999,7 +58756,7 @@ var ts; } } break; - case 241: + case 242: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -58019,10 +58776,8 @@ var ts; break; } } - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault); - var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault); if (externalHelpersImportDeclaration) { - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864); externalImports.unshift(externalHelpersImportDeclaration); } return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames, externalHelpersImportDeclaration: externalHelpersImportDeclaration }; @@ -58076,7 +58831,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 222 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 223 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -58114,7 +58869,7 @@ var ts; } ts.isInstanceInitializedProperty = isInstanceInitializedProperty; function isInitializedProperty(member) { - return member.kind === 155 + return member.kind === 156 && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; @@ -58443,6 +59198,7 @@ var ts; } ts.restHelper = { name: "typescript:rest", + importName: "__rest", scoped: false, text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n };" }; @@ -58463,7 +59219,7 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), undefined, [ + return ts.createCall(ts.getUnscopedHelperName("__rest"), undefined, [ value, ts.setTextRange(ts.createArrayLiteral(propertyNames), location) ]); @@ -58483,8 +59239,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(190); context.enableSubstitution(191); + context.enableSubstitution(192); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -58497,14 +59253,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 286) { + if (node.kind === 287) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288) { + if (prepend.kind === 289) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -58537,16 +59293,16 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 285: + case 286: + case 248: case 247: - case 246: - case 219: + case 220: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; + case 242: case 241: - case 240: if (ts.hasModifier(node, 2)) { break; } @@ -58554,7 +59310,7 @@ var ts; recordEmittedDeclarationInScope(node); } else { - ts.Debug.assert(node.kind === 241 || ts.hasModifier(node, 512)); + ts.Debug.assert(node.kind === 242 || ts.hasModifier(node, 512)); } if (ts.isClassDeclaration(node)) { currentNameScope = node; @@ -58576,10 +59332,10 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { + case 251: case 250: - case 249: - case 255: case 256: + case 257: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -58594,13 +59350,13 @@ var ts; return node; } switch (node.kind) { - case 250: + case 251: return visitImportDeclaration(node); - case 249: + case 250: return visitImportEqualsDeclaration(node); - case 255: - return visitExportAssignment(node); case 256: + return visitExportAssignment(node); + case 257: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -58610,11 +59366,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 256 || - node.kind === 250 || + if (node.kind === 257 || node.kind === 251 || - (node.kind === 249 && - node.moduleReference.kind === 260)) { + node.kind === 252 || + (node.kind === 250 && + node.moduleReference.kind === 261)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -58627,16 +59383,16 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 158: + case 159: return visitConstructor(node); - case 155: + case 156: return visitPropertyDeclaration(node); - case 163: - case 159: + case 164: case 160: - case 157: + case 161: + case 158: return visitorWorker(node); - case 218: + case 219: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -58666,13 +59422,13 @@ var ts; case 78: case 126: case 134: - case 170: case 171: case 172: case 173: - case 169: - case 164: - case 151: + case 174: + case 170: + case 165: + case 152: case 121: case 144: case 124: @@ -58681,75 +59437,75 @@ var ts; case 133: case 107: case 140: + case 168: case 167: + case 169: case 166: - case 168: - case 165: - case 174: case 175: case 176: - case 178: + case 177: case 179: case 180: case 181: case 182: case 183: - case 163: - case 153: - case 243: + case 184: + case 164: + case 154: + case 244: return undefined; - case 155: + case 156: return visitPropertyDeclaration(node); - case 248: + case 249: return undefined; - case 158: + case 159: return visitConstructor(node); - case 242: + case 243: return ts.createNotEmittedStatement(node); - case 241: + case 242: return visitClassDeclaration(node); - case 210: + case 211: return visitClassExpression(node); - case 274: + case 275: return visitHeritageClause(node); - case 212: + case 213: return visitExpressionWithTypeArguments(node); - case 157: + case 158: return visitMethodDeclaration(node); - case 159: - return visitGetAccessor(node); case 160: + return visitGetAccessor(node); + case 161: return visitSetAccessor(node); - case 240: + case 241: return visitFunctionDeclaration(node); - case 197: - return visitFunctionExpression(node); case 198: + return visitFunctionExpression(node); + case 199: return visitArrowFunction(node); - case 152: + case 153: return visitParameter(node); - case 196: + case 197: return visitParenthesizedExpression(node); - case 195: - case 213: + case 196: + case 214: return visitAssertionExpression(node); - case 192: - return visitCallExpression(node); case 193: - return visitNewExpression(node); + return visitCallExpression(node); case 194: + return visitNewExpression(node); + case 195: return visitTaggedTemplateExpression(node); - case 214: + case 215: return visitNonNullExpression(node); - case 244: + case 245: return visitEnumDeclaration(node); - case 220: + case 221: return visitVariableStatement(node); - case 238: + case 239: return visitVariableDeclaration(node); - case 245: + case 246: return visitModuleDeclaration(node); - case 249: + case 250: return visitImportEqualsDeclaration(node); default: return ts.visitEachChild(node, visitor, context); @@ -58907,7 +59663,7 @@ var ts; var members = []; var constructor = ts.getFirstConstructorWithBody(node); var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (parametersWithPropertyAssignments) { for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) { var parameter = parametersWithPropertyAssignments_1[_i]; @@ -58964,12 +59720,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 159: case 160: + case 161: return getAllDecoratorsOfAccessors(node, member); - case 157: + case 158: return getAllDecoratorsOfMethod(member); - case 155: + case 156: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -59048,7 +59804,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 155 + ? member.kind === 156 ? ts.createVoidZero() : ts.createNull() : undefined; @@ -59132,22 +59888,22 @@ var ts; } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 157 - || kind === 159 + return kind === 158 || kind === 160 - || kind === 155; + || kind === 161 + || kind === 156; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 157; + return node.kind === 158; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 241: - case 210: + case 242: + case 211: return ts.getFirstConstructorWithBody(node) !== undefined; - case 157: - case 159: + case 158: case 160: + case 161: return true; } return false; @@ -59159,15 +59915,15 @@ var ts; } function serializeTypeOfNode(node) { switch (node.kind) { - case 155: - case 152: + case 156: + case 153: return serializeTypeNode(node.type); + case 161: case 160: - case 159: return serializeTypeNode(getAccessorTypeNode(node)); - case 241: - case 210: - case 157: + case 242: + case 211: + case 158: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -59199,7 +59955,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 159) { + if (container && node.kind === 160) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -59226,26 +59982,26 @@ var ts; case 97: case 133: return ts.createVoidZero(); - case 178: + case 179: return serializeTypeNode(node.type); - case 166: case 167: + case 168: return ts.createIdentifier("Function"); - case 170: case 171: + case 172: return ts.createIdentifier("Array"); - case 164: + case 165: case 124: return ts.createIdentifier("Boolean"); case 139: return ts.createIdentifier("String"); case 137: return ts.createIdentifier("Object"); - case 183: + case 184: switch (node.literal.kind) { case 10: return ts.createIdentifier("String"); - case 203: + case 204: case 8: return ts.createIdentifier("Number"); case 9: @@ -59264,26 +60020,26 @@ var ts; return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 165: + case 166: return serializeTypeReferenceNode(node); + case 176: case 175: - case 174: return serializeTypeList(node.types); - case 176: + case 177: return serializeTypeList([node.trueType, node.falseType]); - case 180: + case 181: if (node.operator === 134) { return serializeTypeNode(node.type); } break; - case 168: - case 181: - case 182: case 169: + case 182: + case 183: + case 170: case 121: case 144: - case 179: - case 184: + case 180: + case 185: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -59292,9 +60048,9 @@ var ts; } function serializeTypeList(types) { var serializedUnion; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var typeNode = types_18[_i]; - while (typeNode.kind === 178) { + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var typeNode = types_17[_i]; + while (typeNode.kind === 179) { typeNode = typeNode.type; } if (typeNode.kind === 133) { @@ -59381,7 +60137,7 @@ var ts; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); return name; - case 149: + case 150: return serializeQualifiedNameAsExpression(node); } } @@ -59451,7 +60207,7 @@ var ts; } function transformConstructorBody(body, constructor) { var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (!ts.some(parametersWithPropertyAssignments)) { return ts.visitFunctionBody(body, visitor, context); } @@ -59709,11 +60465,11 @@ var ts; function addVarForEnumOrModuleDeclaration(statements, node) { var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, false, true)) - ], currentLexicalScope.kind === 285 ? 0 : 1)); + ], currentLexicalScope.kind === 286 ? 0 : 1)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 244) { + if (node.kind === 245) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -59779,7 +60535,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 246) { + if (body.kind === 247) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -59803,13 +60559,13 @@ var ts; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true); ts.setTextRange(block, blockLocation); - if (body.kind !== 246) { + if (body.kind !== 247) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 245) { + if (moduleDeclaration.body.kind === 246) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -59829,7 +60585,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 252) { + if (node.kind === 253) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -59964,15 +60720,15 @@ var ts; if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(73); - context.enableSubstitution(277); - context.enableEmitNotification(245); + context.enableSubstitution(278); + context.enableEmitNotification(246); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 245; + return ts.getOriginalNode(node).kind === 246; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 244; + return ts.getOriginalNode(node).kind === 245; } function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -60018,9 +60774,9 @@ var ts; switch (node.kind) { case 73: return substituteExpressionIdentifier(node); - case 190: - return substitutePropertyAccessExpression(node); case 191: + return substitutePropertyAccessExpression(node); + case 192: return substituteElementAccessExpression(node); } return node; @@ -60050,9 +60806,9 @@ var ts; function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container && container.kind !== 285) { - var substitute = (applicableSubstitutions & 2 && container.kind === 245) || - (applicableSubstitutions & 8 && container.kind === 244); + if (container && container.kind !== 286) { + var substitute = (applicableSubstitutions & 2 && container.kind === 246) || + (applicableSubstitutions & 8 && container.kind === 245); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), node); } @@ -60100,36 +60856,39 @@ var ts; } } context.requestEmitHelper(ts.decorateHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), undefined, argumentsArray), location); + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__decorate"), undefined, argumentsArray), location); } ts.decorateHelper = { name: "typescript:decorate", + importName: "__decorate", scoped: false, priority: 2, text: "\n var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n };" }; function createMetadataHelper(context, metadataKey, metadataValue) { context.requestEmitHelper(ts.metadataHelper); - return ts.createCall(ts.getHelperName("__metadata"), undefined, [ + return ts.createCall(ts.getUnscopedHelperName("__metadata"), undefined, [ ts.createLiteral(metadataKey), metadataValue ]); } ts.metadataHelper = { name: "typescript:metadata", + importName: "__metadata", scoped: false, priority: 3, text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(ts.paramHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), undefined, [ + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__param"), undefined, [ ts.createLiteral(parameterOffset), expression ]), location); } ts.paramHelper = { name: "typescript:param", + importName: "__param", scoped: false, priority: 4, text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" @@ -60159,28 +60918,28 @@ var ts; if (!(node.transformFlags & 1048576)) return node; switch (node.kind) { - case 210: + case 211: return visitClassExpression(node); - case 241: + case 242: return visitClassDeclaration(node); - case 220: + case 221: return visitVariableStatement(node); } return ts.visitEachChild(node, visitor, context); } function classElementVisitor(node) { switch (node.kind) { - case 158: - return undefined; case 159: + return undefined; case 160: - case 157: + case 161: + case 158: return ts.visitEachChild(node, classElementVisitor, context); - case 155: + case 156: return visitPropertyDeclaration(node); - case 150: + case 151: return visitComputedPropertyName(node); - case 218: + case 219: return node; default: return visitor(node); @@ -60190,7 +60949,7 @@ var ts; var savedPendingStatements = pendingStatements; pendingStatements = []; var visitedNode = ts.visitEachChild(node, visitor, context); - var statement = ts.some(pendingStatements) ? [visitedNode].concat(pendingStatements) : + var statement = ts.some(pendingStatements) ? __spreadArrays([visitedNode], pendingStatements) : visitedNode; pendingStatements = savedPendingStatements; return statement; @@ -60318,7 +61077,7 @@ var ts; if (constructor && constructor.body) { var parameterPropertyDeclarationCount = 0; for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) { - if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]))) { + if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) { parameterPropertyDeclarationCount++; } else { @@ -60439,6 +61198,7 @@ var ts; var capturedSuperProperties; var hasSuperElementAccess; var substitutedSuperAccessors = []; + var topLevel; var previousOnEmitNode = context.onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; @@ -60448,10 +61208,23 @@ var ts; if (node.isDeclarationFile) { return node; } + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitor(node) { if ((node.transformFlags & 32) === 0) { return node; @@ -60459,26 +61232,32 @@ var ts; switch (node.kind) { case 122: return undefined; - case 202: + case 203: return visitAwaitExpression(node); - case 157: - return visitMethodDeclaration(node); - case 240: - return visitFunctionDeclaration(node); - case 197: - return visitFunctionExpression(node); + case 158: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 241: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); case 198: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 199: return visitArrowFunction(node); - case 190: + case 191: if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191: + case 192: if (capturedSuperProperties && node.expression.kind === 99) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 160: + case 161: + case 159: + case 242: + case 211: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -60486,27 +61265,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 220: + case 221: return visitVariableStatementInAsyncBody(node); - case 226: - return visitForStatementInAsyncBody(node); case 227: - return visitForInStatementInAsyncBody(node); + return visitForStatementInAsyncBody(node); case 228: + return visitForInStatementInAsyncBody(node); + case 229: return visitForOfStatementInAsyncBody(node); - case 275: + case 276: return visitCatchClauseInAsyncBody(node); - case 219: - case 233: - case 247: - case 272: + case 220: + case 234: + case 248: case 273: - case 236: - case 224: + case 274: + case 237: case 225: - case 223: - case 232: - case 234: + case 226: + case 224: + case 233: + case 235: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -60655,7 +61434,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 198; + var isArrowFunction = node.kind === 199; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames; enclosingFunctionParameterNames = ts.createUnderscoreEscapedMap(); @@ -60673,7 +61452,7 @@ var ts; if (!isArrowFunction) { var statements = []; var statementOffset = ts.addPrologue(statements, node.body.statements, false, visitor); - statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); + statements.push(ts.createReturn(createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var emitSuperHelpers = languageVersion >= 2 && resolver.getNodeCheckFlags(node) & (4096 | 2048); if (emitSuperHelpers) { @@ -60697,7 +61476,7 @@ var ts; result = block; } else { - var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); + var expression = createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); @@ -60736,15 +61515,15 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(192); - context.enableSubstitution(190); + context.enableSubstitution(193); context.enableSubstitution(191); - context.enableEmitNotification(241); - context.enableEmitNotification(157); - context.enableEmitNotification(159); - context.enableEmitNotification(160); + context.enableSubstitution(192); + context.enableEmitNotification(242); context.enableEmitNotification(158); - context.enableEmitNotification(220); + context.enableEmitNotification(160); + context.enableEmitNotification(161); + context.enableEmitNotification(159); + context.enableEmitNotification(221); } } function onEmitNode(hint, node, emitCallback) { @@ -60776,11 +61555,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190: - return substitutePropertyAccessExpression(node); case 191: - return substituteElementAccessExpression(node); + return substitutePropertyAccessExpression(node); case 192: + return substituteElementAccessExpression(node); + case 193: return substituteCallExpression(node); } return node; @@ -60803,19 +61582,19 @@ var ts; var argumentExpression = ts.isPropertyAccessExpression(expression) ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); - return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 - || kind === 158 - || kind === 157 + return kind === 242 || kind === 159 - || kind === 160; + || kind === 158 + || kind === 160 + || kind === 161; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096) { @@ -60851,16 +61630,17 @@ var ts; ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; ts.awaiterHelper = { name: "typescript:awaiter", + importName: "__awaiter", scoped: false, priority: 5, text: "\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };" }; - function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { + function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression(undefined, ts.createToken(40), undefined, undefined, [], undefined, body); (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 | 524288; - return ts.createCall(ts.getHelperName("__awaiter"), undefined, [ - ts.createThis(), + return ts.createCall(ts.getUnscopedHelperName("__awaiter"), undefined, [ + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), generatorFunc @@ -60888,9 +61668,11 @@ var ts; context.onEmitNode = onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; + var exportedVariableStatement = false; var enabledSubstitutions; var enclosingFunctionFlags; var enclosingSuperContainerFlags = 0; + var topLevel; var capturedSuperProperties; var hasSuperElementAccess; var substitutedSuperAccessors = []; @@ -60899,6 +61681,8 @@ var ts; if (node.isDeclarationFile) { return node; } + exportedVariableStatement = false; + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -60915,63 +61699,80 @@ var ts; } return node; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitorWorker(node, noDestructuringValue) { if ((node.transformFlags & 16) === 0) { return node; } switch (node.kind) { - case 202: + case 203: return visitAwaitExpression(node); - case 208: + case 209: return visitYieldExpression(node); - case 231: + case 232: return visitReturnStatement(node); - case 234: + case 235: return visitLabeledStatement(node); - case 189: + case 190: return visitObjectLiteralExpression(node); - case 205: + case 206: return visitBinaryExpression(node, noDestructuringValue); - case 275: + case 276: return visitCatchClause(node); - case 238: + case 221: + return visitVariableStatement(node); + case 239: return visitVariableDeclaration(node); - case 228: + case 229: return visitForOfStatement(node, undefined); - case 226: + case 227: return visitForStatement(node); - case 201: + case 202: return visitVoidExpression(node); - case 158: - return visitConstructorDeclaration(node); - case 157: - return visitMethodDeclaration(node); case 159: - return visitGetAccessorDeclaration(node); + return doOutsideOfTopLevel(visitConstructorDeclaration, node); + case 158: + return doOutsideOfTopLevel(visitMethodDeclaration, node); case 160: - return visitSetAccessorDeclaration(node); - case 240: - return visitFunctionDeclaration(node); - case 197: - return visitFunctionExpression(node); + return doOutsideOfTopLevel(visitGetAccessorDeclaration, node); + case 161: + return doOutsideOfTopLevel(visitSetAccessorDeclaration, node); + case 241: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); case 198: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 199: return visitArrowFunction(node); - case 152: + case 153: return visitParameter(node); - case 222: + case 223: return visitExpressionStatement(node); - case 196: + case 197: return visitParenthesizedExpression(node, noDestructuringValue); - case 190: + case 191: if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191: + case 192: if (capturedSuperProperties && node.expression.kind === 99) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 242: + case 211: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -61003,7 +61804,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 228 && statement.awaitModifier) { + if (statement.kind === 229 && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -61015,7 +61816,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 === 278) { + if (e.kind === 279) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -61024,7 +61825,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 276 + chunkObject = ts.append(chunkObject, e.kind === 277 ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -61037,7 +61838,7 @@ var ts; function visitObjectLiteralExpression(node) { if (node.transformFlags & 8192) { var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 189) { + if (objects.length && objects[0].kind !== 190) { objects.unshift(ts.createObjectLiteral()); } var expression = objects[0]; @@ -61077,17 +61878,37 @@ var ts; var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { - block = ts.updateBlock(block, [ + block = ts.updateBlock(block, __spreadArrays([ ts.createVariableStatement(undefined, visitedBindings) - ].concat(block.statements)); + ], block.statements)); } return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, undefined, undefined), block); } return ts.visitEachChild(node, visitor, context); } + function visitVariableStatement(node) { + if (ts.hasModifier(node, 1)) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = true; + var visited = ts.visitEachChild(node, visitor, context); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return ts.visitEachChild(node, visitor, context); + } function visitVariableDeclaration(node) { + if (exportedVariableStatement) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = false; + var visited = visitVariableDeclarationWorker(node, true); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return visitVariableDeclarationWorker(node, false); + } + function visitVariableDeclarationWorker(node, exportedVariableStatement) { if (ts.isBindingPattern(node.name) && node.name.transformFlags & 8192) { - return ts.flattenDestructuringBinding(node, visitor, context, 1); + return ts.flattenDestructuringBinding(node, visitor, context, 1, undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); } @@ -61266,7 +62087,7 @@ var ts; var savedHasSuperElementAccess = hasSuperElementAccess; capturedSuperProperties = ts.createUnderscoreEscapedMap(); hasSuperElementAccess = false; - var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression(undefined, ts.createToken(40), node.name && ts.getGeneratedNameForNode(node.name), undefined, [], undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))))); + var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression(undefined, ts.createToken(40), node.name && ts.getGeneratedNameForNode(node.name), undefined, [], undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !topLevel)); var emitSuperHelpers = languageVersion >= 2 && resolver.getNodeCheckFlags(node) & (4096 | 2048); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); @@ -61325,15 +62146,15 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(192); - context.enableSubstitution(190); + context.enableSubstitution(193); context.enableSubstitution(191); - context.enableEmitNotification(241); - context.enableEmitNotification(157); - context.enableEmitNotification(159); - context.enableEmitNotification(160); + context.enableSubstitution(192); + context.enableEmitNotification(242); context.enableEmitNotification(158); - context.enableEmitNotification(220); + context.enableEmitNotification(160); + context.enableEmitNotification(161); + context.enableEmitNotification(159); + context.enableEmitNotification(221); } } function onEmitNode(hint, node, emitCallback) { @@ -61365,11 +62186,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190: - return substitutePropertyAccessExpression(node); case 191: - return substituteElementAccessExpression(node); + return substitutePropertyAccessExpression(node); case 192: + return substituteElementAccessExpression(node); + case 193: return substituteCallExpression(node); } return node; @@ -61392,19 +62213,19 @@ var ts; var argumentExpression = ts.isPropertyAccessExpression(expression) ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); - return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 - || kind === 158 - || kind === 157 + return kind === 242 || kind === 159 - || kind === 160; + || kind === 158 + || kind === 160 + || kind === 161; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096) { @@ -61418,6 +62239,7 @@ var ts; ts.transformES2018 = transformES2018; ts.assignHelper = { name: "typescript:assign", + importName: "__assign", scoped: false, priority: 1, text: "\n var __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n };" @@ -61427,51 +62249,55 @@ var ts; return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), undefined, attributesSegments); } context.requestEmitHelper(ts.assignHelper); - return ts.createCall(ts.getHelperName("__assign"), undefined, attributesSegments); + return ts.createCall(ts.getUnscopedHelperName("__assign"), undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; ts.awaitHelper = { name: "typescript:await", + importName: "__await", scoped: false, text: "\n var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }" }; function createAwaitHelper(context, expression) { context.requestEmitHelper(ts.awaitHelper); - return ts.createCall(ts.getHelperName("__await"), undefined, [expression]); + return ts.createCall(ts.getUnscopedHelperName("__await"), undefined, [expression]); } ts.asyncGeneratorHelper = { name: "typescript:asyncGenerator", + importName: "__asyncGenerator", scoped: false, text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n };" }; - function createAsyncGeneratorHelper(context, generatorFunc) { + function createAsyncGeneratorHelper(context, generatorFunc, hasLexicalThis) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144; - return ts.createCall(ts.getHelperName("__asyncGenerator"), undefined, [ - ts.createThis(), + return ts.createCall(ts.getUnscopedHelperName("__asyncGenerator"), undefined, [ + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), ts.createIdentifier("arguments"), generatorFunc ]); } ts.asyncDelegator = { name: "typescript:asyncDelegator", + importName: "__asyncDelegator", scoped: false, text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\n };" }; function createAsyncDelegatorHelper(context, expression, location) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncDelegator); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), undefined, [expression]), location); + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncDelegator"), undefined, [expression]), location); } ts.asyncValues = { name: "typescript:asyncValues", + importName: "__asyncValues", scoped: false, text: "\n var __asyncValues = (this && this.__asyncValues) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n };" }; function createAsyncValuesHelper(context, expression, location) { context.requestEmitHelper(ts.asyncValues); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), undefined, [expression]), location); + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncValues"), undefined, [expression]), location); } })(ts || (ts = {})); var ts; @@ -61489,7 +62315,7 @@ var ts; return node; } switch (node.kind) { - case 275: + case 276: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -61551,13 +62377,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 261: - return visitJsxElement(node, false); case 262: + return visitJsxElement(node, false); + case 263: return visitJsxSelfClosingElement(node, false); - case 265: + case 266: return visitJsxFragment(node, false); - case 271: + case 272: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -61567,13 +62393,13 @@ var ts; switch (node.kind) { case 11: return visitJsxText(node); - case 271: + case 272: return visitJsxExpression(node); - case 261: - return visitJsxElement(node, true); case 262: + return visitJsxElement(node, true); + case 263: return visitJsxSelfClosingElement(node, true); - case 265: + case 266: return visitJsxFragment(node, true); default: return ts.Debug.failBadSyntaxKind(node); @@ -61637,7 +62463,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 271) { + else if (node.kind === 272) { if (node.expression === undefined) { return ts.createTrue(); } @@ -61697,7 +62523,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 261) { + if (node.kind === 262) { return getTagName(node.openingElement); } else { @@ -61997,7 +62823,7 @@ var ts; return node; } switch (node.kind) { - case 205: + case 206: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -62087,13 +62913,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192) !== 0 - && node.kind === 231 + && node.kind === 232 && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 && (ts.isStatement(node) || (node.kind === 219))) + || (hierarchyFacts & 8192 && (ts.isStatement(node) || (node.kind === 220))) || (ts.isIterationStatement(node, false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432) !== 0; } @@ -62115,63 +62941,63 @@ var ts; switch (node.kind) { case 117: return undefined; - case 241: + case 242: return visitClassDeclaration(node); - case 210: + case 211: return visitClassExpression(node); - case 152: + case 153: return visitParameter(node); - case 240: + case 241: return visitFunctionDeclaration(node); - case 198: + case 199: return visitArrowFunction(node); - case 197: + case 198: return visitFunctionExpression(node); - case 238: + case 239: return visitVariableDeclaration(node); case 73: return visitIdentifier(node); - case 239: + case 240: return visitVariableDeclarationList(node); - case 233: + case 234: return visitSwitchStatement(node); - case 247: + case 248: return visitCaseBlock(node); - case 219: + case 220: return visitBlock(node, false); + case 231: case 230: - case 229: return visitBreakOrContinueStatement(node); - case 234: + case 235: return visitLabeledStatement(node); - case 224: case 225: - return visitDoOrWhileStatement(node, undefined); case 226: - return visitForStatement(node, undefined); + return visitDoOrWhileStatement(node, undefined); case 227: - return visitForInStatement(node, undefined); + return visitForStatement(node, undefined); case 228: + return visitForInStatement(node, undefined); + case 229: return visitForOfStatement(node, undefined); - case 222: + case 223: return visitExpressionStatement(node); - case 189: + case 190: return visitObjectLiteralExpression(node); - case 275: + case 276: return visitCatchClause(node); - case 277: + case 278: return visitShorthandPropertyAssignment(node); - case 150: + case 151: return visitComputedPropertyName(node); - case 188: + case 189: return visitArrayLiteralExpression(node); - case 192: - return visitCallExpression(node); case 193: + return visitCallExpression(node); + case 194: return visitNewExpression(node); - case 196: + case 197: return visitParenthesizedExpression(node, true); - case 205: + case 206: return visitBinaryExpression(node, true); case 14: case 15: @@ -62182,28 +63008,28 @@ var ts; return visitStringLiteral(node); case 8: return visitNumericLiteral(node); - case 194: + case 195: return visitTaggedTemplateExpression(node); - case 207: - return visitTemplateExpression(node); case 208: - return visitYieldExpression(node); + return visitTemplateExpression(node); case 209: + return visitYieldExpression(node); + case 210: return visitSpreadElement(node); case 99: return visitSuperKeyword(false); case 101: return visitThisKeyword(node); - case 215: + case 216: return visitMetaProperty(node); - case 157: + case 158: return visitMethodDeclaration(node); - case 159: case 160: + case 161: return visitAccessorDeclaration(node); - case 220: + case 221: return visitVariableStatement(node); - case 231: + case 232: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -62288,14 +63114,14 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 230 ? 2 : 4; + var jump = node.kind === 231 ? 2 : 4; 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 === 230) { + if (node.kind === 231) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -62305,7 +63131,7 @@ var ts; } } else { - if (node.kind === 230) { + if (node.kind === 231) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, true, ts.idText(label), labelMarker); } @@ -62491,17 +63317,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 231) { + if (statement.kind === 232) { return true; } - else if (statement.kind === 223) { + else if (statement.kind === 224) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 219) { + else if (statement.kind === 220) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -62609,7 +63435,7 @@ var ts; return true; } function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 && node.kind !== 198) { + if (hierarchyFacts & 32768 && node.kind !== 199) { insertCaptureThisForNode(statements, node, ts.createThis()); return true; } @@ -62628,18 +63454,18 @@ var ts; if (hierarchyFacts & 16384) { var newTarget = void 0; switch (node.kind) { - case 198: + case 199: return statements; - case 157: - case 159: + case 158: case 160: + case 161: newTarget = ts.createVoidZero(); break; - case 158: + case 159: newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); break; - case 240: - case 197: + case 241: + case 198: newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 95, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); break; default: @@ -62660,20 +63486,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 218: + case 219: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 157: + case 158: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 159: case 160: + case 161: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 158: + case 159: break; default: ts.Debug.failBadSyntaxKind(member, currentSourceFile && currentSourceFile.fileName); @@ -62793,7 +63619,7 @@ var ts; : enterSubtree(16286, 65); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 && !name && (node.kind === 240 || node.kind === 197)) { + if (hierarchyFacts & 16384 && !name && (node.kind === 241 || node.kind === 198)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152, 0); @@ -62824,7 +63650,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 198); + ts.Debug.assert(node.kind === 199); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -62877,9 +63703,9 @@ var ts; } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 196: + case 197: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, false)); - case 205: + case 206: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -62887,9 +63713,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (!needsDestructuringValue) { switch (node.expression.kind) { - case 196: + case 197: return ts.updateParen(node, visitParenthesizedExpression(node.expression, false)); - case 205: + case 206: return ts.updateParen(node, visitBinaryExpression(node.expression, false)); } } @@ -63020,14 +63846,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 224: case 225: - return visitDoOrWhileStatement(node, outermostLabeledStatement); case 226: - return visitForStatement(node, outermostLabeledStatement); + return visitDoOrWhileStatement(node, outermostLabeledStatement); case 227: - return visitForInStatement(node, outermostLabeledStatement); + return visitForStatement(node, outermostLabeledStatement); case 228: + return visitForInStatement(node, outermostLabeledStatement); + case 229: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -63154,7 +63980,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 150) { + if (property.name.kind === 151) { numInitialProperties = i; break; } @@ -63265,11 +64091,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 226: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 227: return convertForInStatement(node, convertedLoopBody); - case 228: return convertForOfStatement(node, convertedLoopBody); - case 224: return convertDoStatement(node, convertedLoopBody); - case 225: return convertWhileStatement(node, convertedLoopBody); + case 227: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 228: return convertForInStatement(node, convertedLoopBody); + case 229: return convertForOfStatement(node, convertedLoopBody); + case 225: return convertDoStatement(node, convertedLoopBody); + case 226: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -63293,11 +64119,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 226: case 227: case 228: + case 229: var initializer = node.initializer; - if (initializer && initializer.kind === 239) { + if (initializer && initializer.kind === 240) { loopInitializer = initializer; } break; @@ -63556,20 +64382,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 159: case 160: + case 161: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 157: + case 158: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 276: + case 277: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 277: + case 278: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -63624,7 +64450,7 @@ var ts; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); - return ts.updateBlock(block, [statement].concat(transformedStatements)); + return ts.updateBlock(block, __spreadArrays([statement], transformedStatements)); } function visitMethodDeclaration(node) { ts.Debug.assert(!ts.isComputedPropertyName(node.name)); @@ -63640,7 +64466,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 159) { + if (node.kind === 160) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -63745,7 +64571,7 @@ var ts; function visitNewExpression(node) { if (ts.some(node.arguments, ts.isSpreadElement)) { var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray(__spreadArrays([ts.createVoidZero()], node.arguments)), false, false, false)), undefined, []); } return ts.visitEachChild(node, visitor, context); } @@ -63851,9 +64677,12 @@ var ts; return ts.createCall(tag, undefined, templateArguments); } function getRawLiteral(node) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 14 || node.kind === 17; - text = text.substring(1, text.length - (isLast ? 1 : 2)); + var text = node.rawText; + if (text === undefined) { + text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + var isLast = node.kind === 14 || node.kind === 17; + text = text.substring(1, text.length - (isLast ? 1 : 2)); + } text = text.replace(/\r\n?/g, "\n"); return ts.setTextRange(ts.createLiteral(text), node); } @@ -63888,10 +64717,8 @@ var ts; } } function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 - && !isExpressionOfCall - ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") - : ts.createFileLevelUniqueName("_super"); + return hierarchyFacts & 8 && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") : + ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { if (node.keywordToken === 96 && node.name.escapedText === "target") { @@ -63921,13 +64748,13 @@ var ts; if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; context.enableSubstitution(101); - context.enableEmitNotification(158); - context.enableEmitNotification(157); context.enableEmitNotification(159); + context.enableEmitNotification(158); context.enableEmitNotification(160); + context.enableEmitNotification(161); + context.enableEmitNotification(199); context.enableEmitNotification(198); - context.enableEmitNotification(197); - context.enableEmitNotification(240); + context.enableEmitNotification(241); } } function onSubstituteNode(hint, node) { @@ -63951,10 +64778,10 @@ var ts; } function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 187: - case 241: - case 244: - case 238: + case 188: + case 242: + case 245: + case 239: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -64015,11 +64842,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 222) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 223) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 192) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 193) { return false; } var callTarget = statementExpression.expression; @@ -64027,7 +64854,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 209) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 210) { return false; } var expression = callArgument.expression; @@ -64037,26 +64864,28 @@ var ts; ts.transformES2015 = transformES2015; function createExtendsHelper(context, name) { context.requestEmitHelper(ts.extendsHelper); - return ts.createCall(ts.getHelperName("__extends"), undefined, [ + return ts.createCall(ts.getUnscopedHelperName("__extends"), undefined, [ name, ts.createFileLevelUniqueName("_super") ]); } function createTemplateObjectHelper(context, cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); - return ts.createCall(ts.getHelperName("__makeTemplateObject"), undefined, [ + return ts.createCall(ts.getUnscopedHelperName("__makeTemplateObject"), undefined, [ cooked, raw ]); } ts.extendsHelper = { name: "typescript:extends", + importName: "__extends", scoped: false, priority: 0, text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; ts.templateObjectHelper = { name: "typescript:makeTemplateObject", + importName: "__makeTemplateObject", scoped: false, priority: 0, text: "\n var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n };" @@ -64071,24 +64900,24 @@ var ts; if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(263); context.enableEmitNotification(264); - context.enableEmitNotification(262); + context.enableEmitNotification(265); + context.enableEmitNotification(263); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(190); - context.enableSubstitution(276); + context.enableSubstitution(191); + context.enableSubstitution(277); return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { return node; } function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 263: case 264: - case 262: + case 265: + case 263: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -64205,13 +65034,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 224: - return visitDoStatement(node); case 225: + return visitDoStatement(node); + case 226: return visitWhileStatement(node); - case 233: - return visitSwitchStatement(node); case 234: + return visitSwitchStatement(node); + case 235: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -64219,24 +65048,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 240: + case 241: return visitFunctionDeclaration(node); - case 197: + case 198: return visitFunctionExpression(node); - case 159: case 160: + case 161: return visitAccessorDeclaration(node); - case 220: + case 221: return visitVariableStatement(node); - case 226: - return visitForStatement(node); case 227: + return visitForStatement(node); + case 228: return visitForInStatement(node); - case 230: + case 231: return visitBreakStatement(node); - case 229: + case 230: return visitContinueStatement(node); - case 231: + case 232: return visitReturnStatement(node); default: if (node.transformFlags & 131072) { @@ -64252,21 +65081,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 205: - return visitBinaryExpression(node); case 206: + return visitBinaryExpression(node); + case 207: return visitConditionalExpression(node); - case 208: + case 209: return visitYieldExpression(node); - case 188: - return visitArrayLiteralExpression(node); case 189: + return visitArrayLiteralExpression(node); + case 190: return visitObjectLiteralExpression(node); - case 191: - return visitElementAccessExpression(node); case 192: - return visitCallExpression(node); + return visitElementAccessExpression(node); case 193: + return visitCallExpression(node); + case 194: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -64274,9 +65103,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 240: + case 241: return visitFunctionDeclaration(node); - case 197: + case 198: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -64433,10 +65262,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 190: + case 191: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 191: + case 192: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -64541,13 +65370,13 @@ var ts; temp = declareLocal(); var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements); emitAssignment(temp, ts.createArrayLiteral(leadingElement - ? [leadingElement].concat(initialElements) : initialElements)); + ? __spreadArrays([leadingElement], initialElements) : initialElements)); leadingElement = undefined; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return temp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { var hasAssignedTemp = temp !== undefined; @@ -64556,7 +65385,7 @@ var ts; } emitAssignment(temp, hasAssignedTemp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); + : ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine)); leadingElement = undefined; expressions = []; } @@ -64637,35 +65466,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 219: + case 220: return transformAndEmitBlock(node); - case 222: - return transformAndEmitExpressionStatement(node); case 223: - return transformAndEmitIfStatement(node); + return transformAndEmitExpressionStatement(node); case 224: - return transformAndEmitDoStatement(node); + return transformAndEmitIfStatement(node); case 225: - return transformAndEmitWhileStatement(node); + return transformAndEmitDoStatement(node); case 226: - return transformAndEmitForStatement(node); + return transformAndEmitWhileStatement(node); case 227: + return transformAndEmitForStatement(node); + case 228: return transformAndEmitForInStatement(node); - case 229: - return transformAndEmitContinueStatement(node); case 230: - return transformAndEmitBreakStatement(node); + return transformAndEmitContinueStatement(node); case 231: - return transformAndEmitReturnStatement(node); + return transformAndEmitBreakStatement(node); case 232: - return transformAndEmitWithStatement(node); + return transformAndEmitReturnStatement(node); case 233: - return transformAndEmitSwitchStatement(node); + return transformAndEmitWithStatement(node); case 234: - return transformAndEmitLabeledStatement(node); + return transformAndEmitSwitchStatement(node); case 235: - return transformAndEmitThrowStatement(node); + return transformAndEmitLabeledStatement(node); case 236: + return transformAndEmitThrowStatement(node); + case 237: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -64959,7 +65788,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 273 && defaultClauseIndex === -1) { + if (clause.kind === 274 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -64969,7 +65798,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 272) { + if (clause.kind === 273) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -65102,11 +65931,10 @@ var ts; return node; } function cacheExpression(node) { - var temp; if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096) { return node; } - temp = ts.createTempVariable(hoistVariableDeclaration); + var temp = ts.createTempVariable(hoistVariableDeclaration); emitAssignment(temp, node, node); return temp; } @@ -65755,10 +66583,11 @@ var ts; ts.transformGenerators = transformGenerators; function createGeneratorHelper(context, body) { context.requestEmitHelper(ts.generatorHelper); - return ts.createCall(ts.getHelperName("__generator"), undefined, [ts.createThis(), body]); + return ts.createCall(ts.getUnscopedHelperName("__generator"), undefined, [ts.createThis(), body]); } ts.generatorHelper = { name: "typescript:generator", + importName: "__generator", scoped: false, priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" @@ -65785,11 +66614,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(73); - context.enableSubstitution(205); - context.enableSubstitution(203); + context.enableSubstitution(206); context.enableSubstitution(204); - context.enableSubstitution(277); - context.enableEmitNotification(285); + context.enableSubstitution(205); + context.enableSubstitution(278); + context.enableEmitNotification(286); var moduleInfoMap = []; var deferredExports = []; var currentSourceFile; @@ -65845,17 +66674,17 @@ var ts; var jsonSourceFile = ts.isJsonSourceFile(node) && node; var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createExpressionStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ - ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : [ + ts.createExpressionStatement(ts.createCall(define, undefined, __spreadArrays((moduleName ? [moduleName] : []), [ + ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : __spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), jsonSourceFile ? jsonSourceFile.statements.length ? jsonSourceFile.statements[0].expression : ts.createObjectLiteral() : - ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createFunctionExpression(undefined, undefined, undefined, undefined, __spreadArrays([ ts.createParameter(undefined, undefined, undefined, "require"), ts.createParameter(undefined, undefined, undefined, "exports") - ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) + ], importAliasNames), undefined, transformAsynchronousModuleBody(node)) ]))) ]), node.statements)); ts.addEmitHelpers(updated, context.readEmitHelpers()); @@ -65874,21 +66703,21 @@ var ts; ]), ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ - ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), undefined, (moduleName ? [moduleName] : []).concat([ - ts.createArrayLiteral([ + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), undefined, __spreadArrays((moduleName ? [moduleName] : []), [ + ts.createArrayLiteral(__spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), ts.createIdentifier("factory") ]))) ]))) ], true), undefined)); var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createExpressionStatement(ts.createCall(umdHeader, undefined, [ - ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createFunctionExpression(undefined, undefined, undefined, undefined, __spreadArrays([ ts.createParameter(undefined, undefined, undefined, "require"), ts.createParameter(undefined, undefined, undefined, "exports") - ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) + ], importAliasNames), undefined, transformAsynchronousModuleBody(node)) ])) ]), node.statements)); ts.addEmitHelpers(updated, context.readEmitHelpers()); @@ -65980,23 +66809,23 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 250: + case 251: return visitImportDeclaration(node); - case 249: + case 250: return visitImportEqualsDeclaration(node); - case 256: + case 257: return visitExportDeclaration(node); - case 255: + case 256: return visitExportAssignment(node); - case 220: + case 221: return visitVariableStatement(node); - case 240: - return visitFunctionDeclaration(node); case 241: + return visitFunctionDeclaration(node); + case 242: return visitClassDeclaration(node); - case 317: + case 319: return visitMergeDeclarationMarker(node); - case 318: + case 320: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -66021,24 +66850,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 276: + case 277: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 277: + case 278: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 278: + case 279: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 157: - case 159: + case 158: case 160: + case 161: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -66115,7 +66944,7 @@ var ts; var promise = ts.createNew(ts.createIdentifier("Promise"), undefined, [func]); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), undefined, [ts.getHelperName("__importStar")]); + return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), undefined, [ts.getUnscopedHelperName("__importStar")]); } return promise; } @@ -66124,7 +66953,7 @@ var ts; var requireCall = ts.createCall(ts.createIdentifier("require"), undefined, arg ? [arg] : []); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - requireCall = ts.createCall(ts.getHelperName("__importStar"), undefined, [requireCall]); + requireCall = ts.createCall(ts.getUnscopedHelperName("__importStar"), undefined, [requireCall]); } var func; if (languageVersion >= 2) { @@ -66144,11 +66973,11 @@ var ts; } if (ts.getImportNeedsImportStarHelper(node)) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.getHelperName("__importStar"), undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importStar"), undefined, [innerExpr]); } if (ts.getImportNeedsImportDefaultHelper(node)) { context.requestEmitHelper(ts.importDefaultHelper); - return ts.createCall(ts.getHelperName("__importDefault"), undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importDefault"), undefined, [innerExpr]); } return innerExpr; } @@ -66353,7 +67182,7 @@ var ts; } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 221) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -66385,10 +67214,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252: + case 253: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253: + case 254: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -66496,7 +67325,7 @@ var ts; return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285) { + if (node.kind === 286) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -66538,10 +67367,10 @@ var ts; switch (node.kind) { case 73: return substituteExpressionIdentifier(node); - case 205: + case 206: return substituteBinaryExpression(node); + case 205: case 204: - case 203: return substituteUnaryExpression(node); } return node; @@ -66556,7 +67385,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 285) { + if (exportContainer && exportContainer.kind === 286) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); @@ -66599,7 +67428,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 + var expression = node.kind === 205 ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 ? 61 : 62), ts.createLiteral(1)), node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -66632,7 +67461,7 @@ var ts; function createExportStarHelper(context, module) { var compilerOptions = context.getCompilerOptions(); return compilerOptions.importHelpers - ? ts.createCall(ts.getHelperName("__exportStar"), undefined, [module, ts.createIdentifier("exports")]) + ? ts.createCall(ts.getUnscopedHelperName("__exportStar"), undefined, [module, ts.createIdentifier("exports")]) : ts.createCall(ts.createIdentifier("__export"), undefined, [module]); } var dynamicImportUMDHelper = { @@ -66642,11 +67471,13 @@ var ts; }; ts.importStarHelper = { name: "typescript:commonjsimportstar", + importName: "__importStar", scoped: false, text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};" }; ts.importDefaultHelper = { name: "typescript:commonjsimportdefault", + importName: "__importDefault", scoped: false, text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};" }; @@ -66663,15 +67494,17 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(73); - context.enableSubstitution(277); - context.enableSubstitution(205); - context.enableSubstitution(203); + context.enableSubstitution(278); + context.enableSubstitution(206); context.enableSubstitution(204); - context.enableEmitNotification(285); + context.enableSubstitution(205); + context.enableSubstitution(216); + context.enableEmitNotification(286); var moduleInfoMap = []; var deferredExports = []; var exportFunctionsMap = []; var noSubstitutionMap = []; + var contextObjectMap = []; var currentSourceFile; var moduleInfo; var exportFunction; @@ -66690,7 +67523,7 @@ var ts; moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); exportFunction = ts.createUniqueName("exports"); exportFunctionsMap[id] = exportFunction; - contextObject = ts.createUniqueName("context"); + contextObject = contextObjectMap[id] = ts.createUniqueName("context"); var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups); var moduleBodyFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ @@ -66771,7 +67604,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 256 && externalImport.exportClause) { + if (externalImport.kind === 257 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -66794,7 +67627,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 256) { + if (externalImport.kind !== 257) { continue; } if (!externalImport.exportClause) { @@ -66845,15 +67678,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 250: + case 251: if (!entry.importClause) { break; } - case 249: + case 250: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 256: + case 257: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -66875,13 +67708,13 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 250: + case 251: return visitImportDeclaration(node); - case 249: + case 250: return visitImportEqualsDeclaration(node); - case 256: + case 257: return undefined; - case 255: + case 256: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -67002,7 +67835,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 2097152) === 0 - && (enclosingBlockScopedContainer.kind === 285 + && (enclosingBlockScopedContainer.kind === 286 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -67024,7 +67857,7 @@ var ts; : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 221) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -67063,10 +67896,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252: + case 253: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253: + case 254: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -67166,43 +67999,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 220: + case 221: return visitVariableStatement(node); - case 240: - return visitFunctionDeclaration(node); case 241: + return visitFunctionDeclaration(node); + case 242: return visitClassDeclaration(node); - case 226: - return visitForStatement(node); case 227: - return visitForInStatement(node); + return visitForStatement(node); case 228: + return visitForInStatement(node); + case 229: return visitForOfStatement(node); - case 224: - return visitDoStatement(node); case 225: + return visitDoStatement(node); + case 226: return visitWhileStatement(node); - case 234: + case 235: return visitLabeledStatement(node); - case 232: - return visitWithStatement(node); case 233: + return visitWithStatement(node); + case 234: return visitSwitchStatement(node); - case 247: + case 248: return visitCaseBlock(node); - case 272: - return visitCaseClause(node); case 273: + return visitCaseClause(node); + case 274: return visitDefaultClause(node); - case 236: + case 237: return visitTryStatement(node); - case 275: + case 276: return visitCatchClause(node); - case 219: + case 220: return visitBlock(node); - case 317: + case 319: return visitMergeDeclarationMarker(node); - case 318: + case 320: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -67338,7 +68171,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 285; + return container !== undefined && container.kind === 286; } else { return false; @@ -67353,12 +68186,13 @@ var ts; return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285) { + if (node.kind === 286) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; exportFunction = exportFunctionsMap[id]; noSubstitution = noSubstitutionMap[id]; + contextObject = contextObjectMap[id]; if (noSubstitution) { delete noSubstitutionMap[id]; } @@ -67366,6 +68200,7 @@ var ts; currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; + contextObject = undefined; noSubstitution = undefined; } else { @@ -67387,7 +68222,7 @@ var ts; } function substituteUnspecified(node) { switch (node.kind) { - case 277: + case 278: return substituteShorthandPropertyAssignment(node); } return node; @@ -67411,11 +68246,13 @@ var ts; switch (node.kind) { case 73: return substituteExpressionIdentifier(node); - case 205: + case 206: return substituteBinaryExpression(node); - case 203: case 204: + case 205: return substituteUnaryExpression(node); + case 216: + return substituteMetaProperty(node); } return node; } @@ -67466,14 +68303,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 + var expression = node.kind === 205 ? ts.setTextRange(ts.createPrefix(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 === 204) { + if (node.kind === 205) { expression = node.operator === 44 ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -67483,6 +68320,12 @@ var ts; } return node; } + function substituteMetaProperty(node) { + if (ts.isImportMeta(node)) { + return ts.createPropertyAccess(contextObject, ts.createIdentifier("meta")); + } + return node; + } function getExports(name) { var exportedNames; if (!ts.isGeneratedIdentifier(name)) { @@ -67490,7 +68333,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 285) { + if (exportContainer && exportContainer.kind === 286) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -67518,22 +68361,20 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(285); + context.enableEmitNotification(286); context.enableSubstitution(73); - var currentSourceFile; + var helperNameSubstitutions; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { return node; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); - if (externalHelpersModuleName) { + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(node, compilerOptions); + if (externalHelpersImportDeclaration) { var statements = []; var statementOffset = ts.addPrologue(statements, node.statements); - var tslibImport = ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); - ts.addEmitFlags(tslibImport, 67108864); - ts.append(statements, tslibImport); + ts.append(statements, externalHelpersImportDeclaration); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } @@ -67545,9 +68386,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 249: + case 250: return undefined; - case 255: + case 256: return visitExportAssignment(node); } return node; @@ -67557,9 +68398,9 @@ var ts; } function onEmitNode(hint, node, emitCallback) { if (ts.isSourceFile(node)) { - currentSourceFile = node; + helperNameSubstitutions = ts.createMap(); previousOnEmitNode(hint, node, emitCallback); - currentSourceFile = undefined; + helperNameSubstitutions = undefined; } else { previousOnEmitNode(hint, node, emitCallback); @@ -67567,19 +68408,18 @@ var ts; } function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (ts.isIdentifier(node) && hint === 1) { - return substituteExpressionIdentifier(node); + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096) { + return substituteHelperName(node); } return node; } - function substituteExpressionIdentifier(node) { - if (ts.getEmitFlags(node) & 4096) { - var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); - if (externalHelpersModuleName) { - return ts.createPropertyAccess(externalHelpersModuleName, node); - } + function substituteHelperName(node) { + var name = ts.idText(node); + var substitution = helperNameSubstitutions.get(name); + if (!substitution) { + helperNameSubstitutions.set(name, substitution = ts.createFileLevelUniqueName(name)); } - return node; + return substitution; } } ts.transformES2015Module = transformES2015Module; @@ -67634,7 +68474,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 === 241) { + else if (node.parent.kind === 242) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -67663,7 +68503,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 === 241) { + else if (node.parent.kind === 242) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -67689,7 +68529,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node) && ts.hasModifier(node.parent, 8)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -67710,15 +68550,15 @@ 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 === 238 || node.kind === 187) { + if (node.kind === 239 || node.kind === 188) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 155 || node.kind === 190 || node.kind === 154 || - (node.kind === 152 && ts.hasModifier(node.parent, 8))) { + else if (node.kind === 156 || node.kind === 191 || node.kind === 155 || + (node.kind === 153 && ts.hasModifier(node.parent, 8))) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -67726,7 +68566,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 === 241 || node.kind === 152) { + else if (node.parent.kind === 242 || node.kind === 153) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -67750,7 +68590,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 160) { + if (node.kind === 161) { if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -67787,23 +68627,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 162: + case 163: 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 161: + case 162: 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 163: + case 164: 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 158: case 157: - case 156: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -67811,7 +68651,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 === 241) { + else if (node.parent.kind === 242) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -67824,7 +68664,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 240: + case 241: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -67849,27 +68689,27 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 158: + case 159: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? 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 162: - case 167: + case 163: + case 168: 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 161: + case 162: 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 163: + case 164: 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 158: case 157: - case 156: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -67877,7 +68717,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 === 241) { + else if (node.parent.parent.kind === 242) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -67889,8 +68729,8 @@ 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 240: - case 166: + case 241: + case 167: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -67903,39 +68743,39 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 241: + case 242: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 242: + case 243: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 182: + case 183: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 167: - case 162: + case 168: + case 163: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 161: + case 162: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 158: case 157: - case 156: if (ts.hasModifier(node.parent, 32)) { 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 === 241) { + else if (node.parent.parent.kind === 242) { 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 166: - case 240: + case 167: + case 241: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 243: + case 244: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -67949,7 +68789,7 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 241) { + if (node.parent.parent.kind === 242) { diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 110 ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -67997,7 +68837,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 152) { + if (parseTreeNode && parseTreeNode.kind === 153) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -68048,6 +68888,7 @@ var ts; var currentSourceFile; var refs; var libs; + var emittedImports; var resolver = context.getEmitResolver(); var options = context.getCompilerOptions(); var newLine = ts.getNewLineCharacter(options); @@ -68132,10 +68973,10 @@ var ts; return ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([]), undefined); } function transformRoot(node) { - if (node.kind === 285 && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 286 && (node.isDeclarationFile || ts.isSourceFileJS(node))) { return node; } - if (node.kind === 286) { + if (node.kind === 287) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); @@ -68165,7 +69006,7 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), true, [], [], false, []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288) { + if (prepend.kind === 289) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -68204,9 +69045,9 @@ var ts; var statements = ts.visitNodes(node.statements, visitDeclarationStatements); var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); refs.forEach(referenceVisitor); - var emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { - combinedStatements = ts.setTextRange(ts.createNodeArray(combinedStatements.concat([createEmptyExports()])), combinedStatements); + combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [createEmptyExports()])), combinedStatements); } var updated = ts.updateSourceFileNode(node, combinedStatements, true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences()); updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit; @@ -68247,6 +69088,11 @@ 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, host.getSourceFiles(), undefined, host.redirectTargetsMap); + if (!ts.pathIsRelative(specifier)) { + recordTypeReferenceDirectivesIfNecessary([specifier]); + return; + } var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); if (ts.startsWith(fileName, "./") && ts.hasExtension(fileName)) { fileName = fileName.substring(2); @@ -68284,7 +69130,7 @@ var ts; return name; } else { - if (name.kind === 186) { + if (name.kind === 187) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -68292,19 +69138,19 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 211) { + if (elem.kind === 212) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); } } - function ensureParameter(p, modifierMask) { + function ensureParameter(p, modifierMask, type) { var oldDiag; if (!suppressNewDiagnosticContexts) { oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } - var newParam = ts.updateParameter(p, undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(56)) : undefined, ensureType(p, p.type, true), ensureNoInitializer(p)); + var newParam = ts.updateParameter(p, undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(56)) : undefined, ensureType(p, type || p.type, true), ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } @@ -68326,7 +69172,7 @@ var ts; if (shouldPrintWithInitializer(node)) { return; } - var shouldUseResolverType = node.kind === 152 && + var shouldUseResolverType = node.kind === 153 && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { @@ -68335,7 +69181,7 @@ var ts; if (!ts.getParseTreeNode(node)) { return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(121); } - if (node.kind === 160) { + if (node.kind === 161) { return ts.createKeywordTypeNode(121); } errorNameNode = node.name; @@ -68344,12 +69190,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 238 || node.kind === 187) { + if (node.kind === 239 || node.kind === 188) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 152 - || node.kind === 155 - || node.kind === 154) { + if (node.kind === 153 + || node.kind === 156 + || node.kind === 155) { 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)); @@ -68366,19 +69212,19 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 240: - case 245: - case 242: case 241: + case 246: case 243: + case 242: case 244: + case 245: return !resolver.isDeclarationVisible(node); - case 238: + case 239: return !getBindingNameVisible(node); - case 249: case 250: + case 251: + case 257: case 256: - case 255: return false; } return false; @@ -68404,6 +69250,30 @@ var ts; } return ts.createNodeArray(newParams, params.hasTrailingComma); } + function updateAccessorParamsList(input, isPrivate) { + var newParams; + if (!isPrivate) { + var thisParameter = ts.getThisParameter(input); + if (thisParameter) { + newParams = [ensureParameter(thisParameter)]; + } + } + if (ts.isSetAccessorDeclaration(input)) { + var newValueParameter = void 0; + if (!isPrivate) { + var valueParameter = ts.getSetAccessorValueParameter(input); + if (valueParameter) { + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + newValueParameter = ensureParameter(valueParameter, undefined, accessorType); + } + } + if (!newValueParameter) { + newValueParameter = ts.createParameter(undefined, undefined, undefined, "value"); + } + newParams = ts.append(newParams, newValueParameter); + } + return ts.createNodeArray(newParams || ts.emptyArray); + } function ensureTypeParams(node, params) { return ts.hasModifier(node, 8) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } @@ -68431,7 +69301,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 245 && parent.kind !== 184); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 246 && parent.kind !== 185); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -68451,7 +69321,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 260) { + if (decl.moduleReference.kind === 261) { var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, undefined, decl.modifiers, decl.name, ts.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier))); } @@ -68471,7 +69341,7 @@ var ts; if (!decl.importClause.namedBindings) { return visibleDefaultBinding && ts.updateImportDeclaration(decl, undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 252) { + if (decl.importClause.namedBindings.kind === 253) { var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; } @@ -68539,6 +69409,9 @@ var ts; enclosingDeclaration = input; } var oldDiag = getSymbolAccessibilityDiagnostic; + var canProduceDiagnostic = ts.canProduceDiagnostics(input); + var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 170 || input.kind === 183) && input.parent.kind !== 244); if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { if (ts.hasModifier(input, 8)) { if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) @@ -68546,69 +69419,74 @@ var ts; return cleanup(ts.createProperty(undefined, ensureModifiers(input), input.name, undefined, undefined, undefined)); } } - var canProdiceDiagnostic = ts.canProduceDiagnostics(input); - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input); } if (ts.isTypeQueryNode(input)) { checkEntityNameVisibility(input.exprName, enclosingDeclaration); } - var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 169 || input.kind === 182) && input.parent.kind !== 243); if (shouldEnterSuppressNewDiagnosticsContextContext) { suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 212: { + case 213: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 165: { + case 166: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 162: + case 163: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 158: { + case 159: { var isPrivate = ts.hasModifier(input, 8); - var ctor = ts.createSignatureDeclaration(158, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), isPrivate ? undefined : updateParamsList(input, input.parameters, 0), undefined); + var ctor = ts.createSignatureDeclaration(159, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), isPrivate ? undefined : updateParamsList(input, input.parameters, 0), undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 157: { - var sig = ts.createSignatureDeclaration(156, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 158: { + var sig = ts.createSignatureDeclaration(157, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 159: { + case 160: { + if (input.flags & 4194304) { + var isPrivate = ts.hasModifier(input, 8); + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + return cleanup(ts.updateGetAccessor(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, undefined)); + } var newNode = ensureAccessor(input); return cleanup(newNode); } - case 160: { + case 161: { + if (input.flags & 4194304) { + return cleanup(ts.updateSetAccessor(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8)), undefined)); + } var newNode = ensureAccessor(input); return cleanup(newNode); } - case 155: + case 156: return cleanup(ts.updateProperty(input, undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 154: + case 155: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 156: { + case 157: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 161: { + case 162: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 163: { + case 164: { return cleanup(ts.updateIndexSignature(input, undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(121))); } - case 238: { + case 239: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -68616,13 +69494,13 @@ var ts; suppressNewDiagnosticContexts = true; return cleanup(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 151: { + case 152: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, undefined, undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 176: { + case 177: { var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); var extendsType = ts.visitNode(input.extendsType, visitDeclarationSubtree); var oldEnclosingDecl = enclosingDeclaration; @@ -68632,13 +69510,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 166: { + case 167: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 167: { + case 168: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 184: { + case 185: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -68648,13 +69526,13 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { - if (returnValue && canProdiceDiagnostic && ts.hasDynamicName(input)) { + if (returnValue && canProduceDiagnostic && ts.hasDynamicName(input)) { checkName(input); } if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; } - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } if (shouldEnterSuppressNewDiagnosticsContextContext) { @@ -68667,7 +69545,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 157 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 158 && ts.hasModifier(node.parent, 8); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -68676,14 +69554,14 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 256: { + case 257: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; return ts.updateExportDeclaration(input, undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 255: { + case 256: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -68720,10 +69598,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249: { + case 250: { return transformImportEqualsDeclaration(input); } - case 250: { + case 251: { return transformImportDeclaration(input); } } @@ -68743,12 +69621,12 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 243: + case 244: return cleanup(ts.updateTypeAliasDeclaration(input, undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 242: { + case 243: { return cleanup(ts.updateInterfaceDeclaration(input, undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 240: { + case 241: { var clean = cleanup(ts.updateFunctionDeclaration(input, undefined, ensureModifiers(input), undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), undefined)); if (clean && resolver.isExpandoFunctionDeclaration(input)) { var props = resolver.getPropertiesOfContainerFunction(input); @@ -68785,10 +69663,10 @@ var ts; return clean; } } - case 245: { + case 246: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 246) { + if (inner && inner.kind === 247) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; @@ -68800,7 +69678,7 @@ var ts; } if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) { if (needsScopeFixMarker) { - lateStatements = ts.createNodeArray(lateStatements.concat([createEmptyExports()])); + lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [createEmptyExports()])); } else { lateStatements = ts.visitNodes(lateStatements, stripExportModifiers); @@ -68824,7 +69702,7 @@ var ts; return cleanup(ts.updateModuleDeclaration(input, undefined, mods, input.name, body)); } } - case 241: { + case 242: { var modifiers = ts.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -68887,10 +69765,10 @@ var ts; return cleanup(ts.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 220: { + case 221: { return cleanup(transformVariableStatement(input)); } - case 244: { + case 245: { return cleanup(ts.updateEnumDeclaration(input, undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -68907,7 +69785,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 245) { + if (input.kind === 246) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -68928,7 +69806,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 211) { + if (e.kind === 212) { return; } if (e.name) { @@ -68978,23 +69856,31 @@ var ts; function ensureModifierFlags(node) { var mask = 3071 ^ (4 | 256); var additions = (needsDeclare && !isAlwaysType(node)) ? 2 : 0; - var parentIsFile = node.parent.kind === 285; + var parentIsFile = node.parent.kind === 286; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2; additions = 0; } return maskModifierFlags(node, mask, additions); } + function getTypeAnnotationFromAllAccessorDeclarations(node, accessors) { + var accessorType = getTypeAnnotationFromAccessor(node); + if (!accessorType && node !== accessors.firstAccessor) { + accessorType = getTypeAnnotationFromAccessor(accessors.firstAccessor); + getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.firstAccessor); + } + if (!accessorType && accessors.secondAccessor && node !== accessors.secondAccessor) { + accessorType = getTypeAnnotationFromAccessor(accessors.secondAccessor); + getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.secondAccessor); + } + return accessorType; + } function ensureAccessor(node) { var accessors = resolver.getAllAccessorDeclarations(node); if (node.kind !== accessors.firstAccessor.kind) { return; } - var accessorType = getTypeAnnotationFromAccessor(node); - if (!accessorType && accessors.secondAccessor) { - accessorType = getTypeAnnotationFromAccessor(accessors.secondAccessor); - getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.secondAccessor); - } + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(node, accessors); var prop = ts.createProperty(undefined, maskModifiers(node, undefined, (!accessors.setAccessor) ? 64 : 0), node.name, node.questionToken, ensureType(node, accessorType), undefined); var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); if (leadingsSyntheticCommentRanges) { @@ -69005,7 +69891,7 @@ var ts; if (lines.length > 1) { var lastLines = lines.slice(1); var indentation_1 = ts.guessIndentation(lastLines); - text = [lines[0]].concat(ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); + text = __spreadArrays([lines[0]], ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); } ts.addSyntheticLeadingComment(prop, range.kind, text, range.hasTrailingNewLine); } @@ -69025,7 +69911,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 242) { + if (node.kind === 243) { return true; } return false; @@ -69047,7 +69933,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 159 + return accessor.kind === 160 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -69056,52 +69942,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { + case 156: case 155: - case 154: return !ts.hasModifier(node, 8); - case 152: - case 238: + case 153: + case 239: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 240: - case 245: - case 249: - case 242: case 241: + case 246: + case 250: case 243: + case 242: case 244: - case 220: - case 250: + case 245: + case 221: + case 251: + case 257: case 256: - case 255: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 162: - case 158: - case 157: + case 163: case 159: + case 158: case 160: - case 155: - case 154: - case 156: case 161: - case 163: - case 238: - case 151: - case 212: - case 165: - case 176: + case 156: + case 155: + case 157: + case 162: + case 164: + case 239: + case 152: + case 213: case 166: + case 177: case 167: - case 184: + case 168: + case 185: return true; } return false; @@ -69199,7 +70085,7 @@ var ts; } ts.noEmitNotification = noEmitNotification; function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(319); + var enabledSyntaxKindFeatures = new Array(321); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -69352,7 +70238,7 @@ var ts; var statements; if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) { if (lexicalEnvironmentFunctionDeclarations) { - statements = lexicalEnvironmentFunctionDeclarations.slice(); + statements = __spreadArrays(lexicalEnvironmentFunctionDeclarations); } if (lexicalEnvironmentVariableDeclarations) { var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations)); @@ -69414,15 +70300,15 @@ var ts; return ts.fileExtensionIs(file, ".tsbuildinfo"); } ts.isBuildInfoFile = isBuildInfoFile; - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) { + if (forceDtsEmit === void 0) { forceDtsEmit = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { var prepends = host.getPrependNodes(); if (sourceFiles.length || prepends.length) { var bundle = ts.createBundle(sourceFiles, prepends); - var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); + var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle); if (result) { return result; } @@ -69432,7 +70318,7 @@ var ts; if (!onlyBuildInfo) { for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { var sourceFile = sourceFiles_1[_a]; - var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); + var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile); if (result) { return result; } @@ -69482,7 +70368,7 @@ var ts; ts.getOutputPathsForBundle = getOutputPathsForBundle; function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 286) { + if (sourceFile.kind === 287) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -69532,6 +70418,8 @@ var ts; } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; function getOutputJSFileName(inputFileName, configFile, ignoreCase) { + if (configFile.options.emitDeclarationOnly) + return undefined; var isJsonFile = ts.fileExtensionIs(inputFileName, ".json"); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ? ".json" : @@ -69562,7 +70450,7 @@ var ts; addOutput(js); if (ts.fileExtensionIs(inputFileName, ".json")) continue; - if (configFile.options.sourceMap) { + if (js && configFile.options.sourceMap) { addOutput(js + ".map"); } if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { @@ -69590,6 +70478,11 @@ var ts; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase); if (jsFilePath) return jsFilePath; + if (ts.fileExtensionIs(inputFileName, ".json")) + continue; + if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { + return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + } } var buildInfoPath = getOutputPathForBuildInfo(configFile.options); if (buildInfoPath) @@ -69597,7 +70490,7 @@ var ts; return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); } ts.getFirstProjectOutput = getFirstProjectOutput; - function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo) { + function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) { var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers; var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; @@ -69610,7 +70503,7 @@ var ts; var emitSkipped = false; var exportedModulesFromDeclarationEmit; enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), forceDtsEmit, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -69736,7 +70629,7 @@ var ts; }); var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit; emitSkipped = emitSkipped || declBlocked; - if (!declBlocked || emitOnlyDtsFiles) { + 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, @@ -69744,7 +70637,7 @@ var ts; mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 285) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 286) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -69767,8 +70660,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 286 ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 285 ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 287 ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 286 ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -69806,7 +70699,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 285 || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json")); + && (sourceFileOrBundle.kind !== 286 || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json")); } function getSourceRoot(mapOptions) { var sourceRoot = ts.normalizeSlashes(mapOptions.sourceRoot || ""); @@ -69900,7 +70793,7 @@ var ts; }; function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) { var sourceFiles = bundle.sourceFiles.map(function (fileName) { - var sourceFile = ts.createNode(285, 0, 0); + var sourceFile = ts.createNode(286, 0, 0); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = ""; sourceFile.statements = ts.createNodeArray(); @@ -69912,7 +70805,7 @@ var ts; sourceFile.text = prologueInfo.text; sourceFile.end = prologueInfo.text.length; sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { - var statement = ts.createNode(222, directive.pos, directive.end); + var statement = ts.createNode(223, directive.pos, directive.end); statement.expression = ts.createNode(10, directive.expression.pos, directive.expression.end); statement.expression.text = directive.expression.text; return statement; @@ -69946,7 +70839,7 @@ var ts; var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); }); var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host); var emitHost = { - getPrependNodes: ts.memoize(function () { return prependNodes.concat([ownPrependInput]); }), + getPrependNodes: ts.memoize(function () { return __spreadArrays(prependNodes, [ownPrependInput]); }), getCanonicalFileName: host.getCanonicalFileName, getCommonSourceDirectory: function () { return ts.getNormalizedAbsolutePath(buildInfo.bundle.commonSourceDirectory, buildInfoDirectory); }, getCompilerOptions: function () { return config.options; }, @@ -69999,6 +70892,7 @@ var ts; useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: ts.returnUndefined, getSourceFileFromReference: ts.returnUndefined, + redirectTargetsMap: ts.createMultiMap() }; emitFiles(ts.notImplementedResolver, emitHost, undefined, ts.getTransformers(config.options, customTransformers)); return outputFiles; @@ -70066,9 +70960,9 @@ var ts; break; } switch (node.kind) { - case 285: return printFile(node); - case 286: return printBundle(node); - case 287: return printUnparsedSource(node); + case 286: return printFile(node); + case 287: return printBundle(node); + case 288: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -70248,7 +71142,7 @@ var ts; } function setWriter(_writer, _sourceMapGenerator) { if (_writer && printerOptions.omitTrailingSemicolon) { - _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + _writer = ts.getTrailingSemicolonDeferringWriter(_writer); } writer = _writer; sourceMapGenerator = _sourceMapGenerator; @@ -70300,11 +71194,11 @@ var ts; return pipelineEmitWithSubstitution; } case 2: - if (!commentsDisabled && node.kind !== 285) { + if (!commentsDisabled && node.kind !== 286) { return pipelineEmitWithComments; } case 3: - if (!sourceMapsDisabled && node.kind !== 285 && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 286 && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } case 4: @@ -70339,256 +71233,256 @@ var ts; case 16: case 17: return emitLiteral(node); - case 287: - case 281: + case 288: + case 282: return emitUnparsedSourceOrPrepend(node); - case 280: + case 281: return writeUnparsedNode(node); - case 282: case 283: - return emitUnparsedTextLike(node); case 284: + return emitUnparsedTextLike(node); + case 285: return emitUnparsedSyntheticReference(node); case 73: return emitIdentifier(node); - case 149: - return emitQualifiedName(node); case 150: - return emitComputedPropertyName(node); + return emitQualifiedName(node); case 151: - return emitTypeParameter(node); + return emitComputedPropertyName(node); case 152: - return emitParameter(node); + return emitTypeParameter(node); case 153: - return emitDecorator(node); + return emitParameter(node); case 154: - return emitPropertySignature(node); + return emitDecorator(node); case 155: - return emitPropertyDeclaration(node); + return emitPropertySignature(node); case 156: - return emitMethodSignature(node); + return emitPropertyDeclaration(node); case 157: - return emitMethodDeclaration(node); + return emitMethodSignature(node); case 158: - return emitConstructor(node); + return emitMethodDeclaration(node); case 159: + return emitConstructor(node); case 160: - return emitAccessorDeclaration(node); case 161: - return emitCallSignature(node); + return emitAccessorDeclaration(node); case 162: - return emitConstructSignature(node); + return emitCallSignature(node); case 163: - return emitIndexSignature(node); + return emitConstructSignature(node); case 164: - return emitTypePredicate(node); + return emitIndexSignature(node); case 165: - return emitTypeReference(node); + return emitTypePredicate(node); case 166: + return emitTypeReference(node); + case 167: return emitFunctionType(node); - case 295: + case 296: return emitJSDocFunctionType(node); - case 167: - return emitConstructorType(node); case 168: - return emitTypeQuery(node); + return emitConstructorType(node); case 169: - return emitTypeLiteral(node); + return emitTypeQuery(node); case 170: - return emitArrayType(node); + return emitTypeLiteral(node); case 171: - return emitTupleType(node); + return emitArrayType(node); case 172: + return emitTupleType(node); + case 173: return emitOptionalType(node); - case 174: - return emitUnionType(node); case 175: - return emitIntersectionType(node); + return emitUnionType(node); case 176: - return emitConditionalType(node); + return emitIntersectionType(node); case 177: - return emitInferType(node); + return emitConditionalType(node); case 178: + return emitInferType(node); + case 179: return emitParenthesizedType(node); - case 212: + case 213: return emitExpressionWithTypeArguments(node); - case 179: - return emitThisType(); case 180: - return emitTypeOperator(node); + return emitThisType(); case 181: - return emitIndexedAccessType(node); + return emitTypeOperator(node); case 182: - return emitMappedType(node); + return emitIndexedAccessType(node); case 183: - return emitLiteralType(node); + return emitMappedType(node); case 184: + return emitLiteralType(node); + case 185: return emitImportTypeNode(node); - case 290: + case 291: writePunctuation("*"); return; - case 291: + case 292: writePunctuation("?"); return; - case 292: - return emitJSDocNullableType(node); case 293: - return emitJSDocNonNullableType(node); + return emitJSDocNullableType(node); case 294: + return emitJSDocNonNullableType(node); + case 295: return emitJSDocOptionalType(node); - case 173: - case 296: + case 174: + case 297: return emitRestOrJSDocVariadicType(node); - case 185: - return emitObjectBindingPattern(node); case 186: - return emitArrayBindingPattern(node); + return emitObjectBindingPattern(node); case 187: + return emitArrayBindingPattern(node); + case 188: return emitBindingElement(node); - case 217: - return emitTemplateSpan(node); case 218: - return emitSemicolonClassElement(); + return emitTemplateSpan(node); case 219: - return emitBlock(node); + return emitSemicolonClassElement(); case 220: - return emitVariableStatement(node); + return emitBlock(node); case 221: - return emitEmptyStatement(false); + return emitVariableStatement(node); case 222: - return emitExpressionStatement(node); + return emitEmptyStatement(false); case 223: - return emitIfStatement(node); + return emitExpressionStatement(node); case 224: - return emitDoStatement(node); + return emitIfStatement(node); case 225: - return emitWhileStatement(node); + return emitDoStatement(node); case 226: - return emitForStatement(node); + return emitWhileStatement(node); case 227: - return emitForInStatement(node); + return emitForStatement(node); case 228: - return emitForOfStatement(node); + return emitForInStatement(node); case 229: - return emitContinueStatement(node); + return emitForOfStatement(node); case 230: - return emitBreakStatement(node); + return emitContinueStatement(node); case 231: - return emitReturnStatement(node); + return emitBreakStatement(node); case 232: - return emitWithStatement(node); + return emitReturnStatement(node); case 233: - return emitSwitchStatement(node); + return emitWithStatement(node); case 234: - return emitLabeledStatement(node); + return emitSwitchStatement(node); case 235: - return emitThrowStatement(node); + return emitLabeledStatement(node); case 236: - return emitTryStatement(node); + return emitThrowStatement(node); case 237: - return emitDebuggerStatement(node); + return emitTryStatement(node); case 238: - return emitVariableDeclaration(node); + return emitDebuggerStatement(node); case 239: - return emitVariableDeclarationList(node); + return emitVariableDeclaration(node); case 240: - return emitFunctionDeclaration(node); + return emitVariableDeclarationList(node); case 241: - return emitClassDeclaration(node); + return emitFunctionDeclaration(node); case 242: - return emitInterfaceDeclaration(node); + return emitClassDeclaration(node); case 243: - return emitTypeAliasDeclaration(node); + return emitInterfaceDeclaration(node); case 244: - return emitEnumDeclaration(node); + return emitTypeAliasDeclaration(node); case 245: - return emitModuleDeclaration(node); + return emitEnumDeclaration(node); case 246: - return emitModuleBlock(node); + return emitModuleDeclaration(node); case 247: - return emitCaseBlock(node); + return emitModuleBlock(node); case 248: - return emitNamespaceExportDeclaration(node); + return emitCaseBlock(node); case 249: - return emitImportEqualsDeclaration(node); + return emitNamespaceExportDeclaration(node); case 250: - return emitImportDeclaration(node); + return emitImportEqualsDeclaration(node); case 251: - return emitImportClause(node); + return emitImportDeclaration(node); case 252: - return emitNamespaceImport(node); + return emitImportClause(node); case 253: - return emitNamedImports(node); + return emitNamespaceImport(node); case 254: - return emitImportSpecifier(node); + return emitNamedImports(node); case 255: - return emitExportAssignment(node); + return emitImportSpecifier(node); case 256: - return emitExportDeclaration(node); + return emitExportAssignment(node); case 257: - return emitNamedExports(node); + return emitExportDeclaration(node); case 258: - return emitExportSpecifier(node); + return emitNamedExports(node); case 259: - return; + return emitExportSpecifier(node); case 260: + return; + case 261: return emitExternalModuleReference(node); case 11: return emitJsxText(node); - case 263: - case 266: - return emitJsxOpeningElementOrFragment(node); case 264: case 267: - return emitJsxClosingElementOrFragment(node); + return emitJsxOpeningElementOrFragment(node); + case 265: case 268: - return emitJsxAttribute(node); + return emitJsxClosingElementOrFragment(node); case 269: - return emitJsxAttributes(node); + return emitJsxAttribute(node); case 270: - return emitJsxSpreadAttribute(node); + return emitJsxAttributes(node); case 271: - return emitJsxExpression(node); + return emitJsxSpreadAttribute(node); case 272: - return emitCaseClause(node); + return emitJsxExpression(node); case 273: - return emitDefaultClause(node); + return emitCaseClause(node); case 274: - return emitHeritageClause(node); + return emitDefaultClause(node); case 275: - return emitCatchClause(node); + return emitHeritageClause(node); case 276: - return emitPropertyAssignment(node); + return emitCatchClause(node); case 277: - return emitShorthandPropertyAssignment(node); + return emitPropertyAssignment(node); case 278: - return emitSpreadAssignment(node); + return emitShorthandPropertyAssignment(node); case 279: + return emitSpreadAssignment(node); + case 280: return emitEnumMember(node); - case 306: - case 312: + case 308: + case 314: return emitJSDocPropertyLikeTag(node); - case 307: case 309: - case 308: - case 305: + case 311: + case 310: + case 307: return emitJSDocSimpleTypedTag(node); - case 301: + case 303: return emitJSDocAugmentsTag(node); - case 310: + case 312: return emitJSDocTemplateTag(node); - case 311: + case 313: return emitJSDocTypedefTag(node); - case 304: + case 306: return emitJSDocCallbackTag(node); - case 299: + case 301: return emitJSDocSignature(node); - case 298: - return emitJSDocTypeLiteral(node); - case 303: case 300: + return emitJSDocTypeLiteral(node); + case 305: + case 302: return emitJSDocSimpleTag(node); - case 297: + case 299: return emitJSDoc(node); } if (ts.isExpression(node)) { @@ -70620,69 +71514,69 @@ var ts; case 93: writeTokenNode(node, writeKeyword); return; - case 188: - return emitArrayLiteralExpression(node); case 189: - return emitObjectLiteralExpression(node); + return emitArrayLiteralExpression(node); case 190: - return emitPropertyAccessExpression(node); + return emitObjectLiteralExpression(node); case 191: - return emitElementAccessExpression(node); + return emitPropertyAccessExpression(node); case 192: - return emitCallExpression(node); + return emitElementAccessExpression(node); case 193: - return emitNewExpression(node); + return emitCallExpression(node); case 194: - return emitTaggedTemplateExpression(node); + return emitNewExpression(node); case 195: - return emitTypeAssertionExpression(node); + return emitTaggedTemplateExpression(node); case 196: - return emitParenthesizedExpression(node); + return emitTypeAssertionExpression(node); case 197: - return emitFunctionExpression(node); + return emitParenthesizedExpression(node); case 198: - return emitArrowFunction(node); + return emitFunctionExpression(node); case 199: - return emitDeleteExpression(node); + return emitArrowFunction(node); case 200: - return emitTypeOfExpression(node); + return emitDeleteExpression(node); case 201: - return emitVoidExpression(node); + return emitTypeOfExpression(node); case 202: - return emitAwaitExpression(node); + return emitVoidExpression(node); case 203: - return emitPrefixUnaryExpression(node); + return emitAwaitExpression(node); case 204: - return emitPostfixUnaryExpression(node); + return emitPrefixUnaryExpression(node); case 205: - return emitBinaryExpression(node); + return emitPostfixUnaryExpression(node); case 206: - return emitConditionalExpression(node); + return emitBinaryExpression(node); case 207: - return emitTemplateExpression(node); + return emitConditionalExpression(node); case 208: - return emitYieldExpression(node); + return emitTemplateExpression(node); case 209: - return emitSpreadExpression(node); + return emitYieldExpression(node); case 210: - return emitClassExpression(node); + return emitSpreadExpression(node); case 211: + return emitClassExpression(node); + case 212: return; - case 213: - return emitAsExpression(node); case 214: - return emitNonNullExpression(node); + return emitAsExpression(node); case 215: + return emitNonNullExpression(node); + case 216: return emitMetaProperty(node); - case 261: - return emitJsxElement(node); case 262: + return emitJsxElement(node); + case 263: return emitJsxSelfClosingElement(node); - case 265: + case 266: return emitJsxFragment(node); - case 315: + case 317: return emitPartiallyEmittedExpression(node); - case 316: + case 318: return emitCommaList(node); } } @@ -70710,8 +71604,8 @@ var ts; var helpers = getSortedEmitHelpers(sourceFile); if (!helpers) continue; - for (var _c = 0, helpers_3 = helpers; _c < helpers_3.length; _c++) { - var helper = helpers_3[_c]; + for (var _c = 0, helpers_4 = helpers; _c < helpers_4.length; _c++) { + var helper = helpers_4[_c]; if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) { bundledHelpers.set(helper.name, true); (result || (result = [])).push(helper.name); @@ -70722,7 +71616,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 286 ? node : undefined; + var bundle = node.kind === 287 ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -70731,12 +71625,12 @@ var ts; for (var i = 0; i < numNodes; i++) { var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node; var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile; - var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.hasRecordedExternalHelpers(sourceFile)); var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit; var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode); if (helpers) { - for (var _a = 0, helpers_4 = helpers; _a < helpers_4.length; _a++) { - var helper = helpers_4[_a]; + for (var _a = 0, helpers_5 = helpers; _a < helpers_5.length; _a++) { + var helper = helpers_5[_a]; if (!helper.scoped) { if (shouldSkip) continue; @@ -70796,7 +71690,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 282 ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 283 ? "text" : "internal"); } @@ -70855,7 +71749,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 295 && !node.name) { + if (node.parent && node.parent.kind === 296 && !node.name) { emit(node.type); } else { @@ -70913,7 +71807,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 159 ? "get" : "set"); + writeKeyword(node.kind === 160 ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -71290,7 +72184,7 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 203 + return operand.kind === 204 && ((node.operator === 38 && (operand.operator === 38 || operand.operator === 44)) || (node.operator === 39 && (operand.operator === 39 || operand.operator === 45))); } @@ -71409,7 +72303,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); emitTokenWithComment(84, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 223) { + if (node.elseStatement.kind === 224) { writeSpace(); emit(node.elseStatement); } @@ -71435,7 +72329,7 @@ var ts; writeLineOrSpace(node); } emitWhileClause(node, node.statement.end); - writePunctuation(";"); + writeTrailingSemicolon(); } function emitWhileStatement(node) { emitWhileClause(node, node.pos); @@ -71472,7 +72366,7 @@ var ts; emitTokenWithComment(20, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(148, node.initializer.end, writeKeyword, node); + emitTokenWithComment(149, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21, node.expression.end, writePunctuation, node); @@ -71480,7 +72374,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 239) { + if (node.kind === 240) { emit(node); } else { @@ -71765,7 +72659,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 245) { + while (body.kind === 246) { writePunctuation("."); emit(body.name); body = body.body; @@ -72059,7 +72953,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 309 && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 311 && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -72093,7 +72987,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 289) { + if (tag.typeExpression.kind === 290) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -72112,7 +73006,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 298) { + if (tag.typeExpression && tag.typeExpression.kind === 300) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -72241,8 +73135,8 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference", data: directive.fileName }); writeLine(); } - for (var _d = 0, types_19 = types; _d < types_19.length; _d++) { - var directive = types_19[_d]; + for (var _d = 0, types_18 = types; _d < types_18.length; _d++) { + var directive = types_18[_d]; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) @@ -72842,7 +73736,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 196 && ts.nodeIsSynthesized(node)) { + while (node.kind === 197 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -72901,81 +73795,81 @@ var ts; if (!node) return; switch (node.kind) { - case 219: + case 220: ts.forEach(node.statements, generateNames); break; - case 234: - case 232: - case 224: + case 235: + case 233: case 225: + case 226: generateNames(node.statement); break; - case 223: + case 224: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 226: - case 228: case 227: + case 229: + case 228: generateNames(node.initializer); generateNames(node.statement); break; - case 233: + case 234: generateNames(node.caseBlock); break; - case 247: + case 248: ts.forEach(node.clauses, generateNames); break; - case 272: case 273: + case 274: ts.forEach(node.statements, generateNames); break; - case 236: + case 237: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 275: + case 276: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 220: + case 221: generateNames(node.declarationList); break; - case 239: + case 240: ts.forEach(node.declarations, generateNames); break; - case 238: - case 152: - case 187: - case 241: + case 239: + case 153: + case 188: + case 242: generateNameIfNeeded(node.name); break; - case 240: + case 241: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 185: case 186: + case 187: ts.forEach(node.elements, generateNames); break; - case 250: + case 251: generateNames(node.importClause); break; - case 251: + case 252: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 252: + case 253: generateNameIfNeeded(node.name); break; - case 253: + case 254: ts.forEach(node.elements, generateNames); break; - case 254: + case 255: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -72984,12 +73878,12 @@ var ts; if (!node) return; switch (node.kind) { - case 276: case 277: - case 155: - case 157: - case 159: + case 278: + case 156: + case 158: case 160: + case 161: generateNameIfNeeded(node.name); break; } @@ -73029,7 +73923,7 @@ var ts; for (var node = container; ts.isNodeDescendantOf(node, container); node = node.nextContainer) { if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); - if (local && local.flags & (67220415 | 1048576 | 2097152)) { + if (local && local.flags & (111551 | 1048576 | 2097152)) { return false; } } @@ -73123,23 +74017,23 @@ var ts; switch (node.kind) { case 73: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16), !!(flags & 8)); + case 246: case 245: - case 244: return generateNameForModuleOrEnum(node); - case 250: - case 256: + case 251: + case 257: return generateNameForImportOrExportDeclaration(node); - case 240: case 241: - case 255: + case 242: + case 256: return generateNameForExportDefault(); - case 210: + case 211: return generateNameForClassExpression(); - case 157: - case 159: + case 158: case 160: + case 161: return generateNameForMethodOrAccessor(node); - case 150: + case 151: return makeTempVariableName(0, true); default: return makeTempVariableName(0); @@ -73176,7 +74070,7 @@ var ts; hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 314; + var isEmittedNode = node.kind !== 316; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0 || node.kind === 11; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0 || node.kind === 11; var savedContainerPos = containerPos; @@ -73191,7 +74085,7 @@ var ts; } if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024) !== 0)) { containerEnd = end; - if (node.kind === 239) { + if (node.kind === 240) { declarationListContainerEnd = end; } } @@ -73425,7 +74319,7 @@ var ts; 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 !== 314 + if (node.kind !== 316 && (emitFlags & 16) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -73438,7 +74332,7 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 314 + if (node.kind !== 316 && (emitFlags & 32) === 0 && end >= 0) { emitSourcePos(source, end); @@ -73745,6 +74639,9 @@ var ts; var createFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile); var createFilePathWatcher = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher; var createDirectoryWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory); + if (watchLogLevel === WatchLogLevel.Verbose && ts.sysLog === ts.noop) { + ts.sysLog = function (s) { return log(s); }; + } return { watchFile: function (host, file, callback, pollingInterval, detailInfo1, detailInfo2) { return createFileWatcher(host, file, callback, pollingInterval, undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo); @@ -74086,7 +74983,7 @@ var ts; } ts.changeCompilerHostLikeToUseCache = changeCompilerHostLikeToUseCache; function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { - var diagnostics = program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (ts.getEmitDeclarations(program.getCompilerOptions())) { ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } @@ -74264,8 +75161,8 @@ var ts; } var resolutions = []; var cache = ts.createMap(); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name = names_1[_i]; + for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { + var name = names_2[_i]; var result = void 0; if (cache.has(name)) { result = cache.get(name); @@ -74334,7 +75231,7 @@ var ts; } ts.isProgramUptoDate = isProgramUptoDate; function getConfigFileParsingDiagnostics(configFileParseResult) { - return configFileParseResult.options.configFile ? configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : + return configFileParseResult.options.configFile ? __spreadArrays(configFileParseResult.options.configFile.parseDiagnostics, configFileParseResult.errors) : configFileParseResult.errors; } ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; @@ -74359,7 +75256,6 @@ var ts; var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; var oldProgram = createProgramOptions.oldProgram; - var program; var processingDefaultLibFiles; var processingOtherFiles; var files; @@ -74368,6 +75264,7 @@ var ts; var noDiagnosticsTypeChecker; var classifiableNames; var ambientModuleNameToUnmodifiedFileName = ts.createMap(); + var refFileMap; var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -74392,7 +75289,7 @@ var ts; var resolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference).map(function (resolved) { + resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).map(function (resolved) { if (!resolved || resolved.extension !== undefined) { return resolved; } @@ -74408,7 +75305,7 @@ var ts; } var resolveTypeReferenceDirectiveNamesWorker; if (host.resolveTypeReferenceDirectives) { - resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference); }; + resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); }; } else { var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; @@ -74424,7 +75321,8 @@ var ts; var projectReferenceRedirects; var mapFromFileToProjectReferenceRedirects; var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); - var structuralIsReused = tryReuseStructureFromOldProgram(); + var structuralIsReused; + structuralIsReused = tryReuseStructureFromOldProgram(); if (structuralIsReused !== 2) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -74499,12 +75397,13 @@ var ts; }); } oldProgram = undefined; - program = { + var program = { getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFileByPath: getSourceFileByPath, getSourceFiles: function () { return files; }, getMissingFilePaths: function () { return missingFilePaths; }, + getRefFileMap: function () { return refFileMap; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, getOptionsDiagnostics: getOptionsDiagnostics, @@ -74846,6 +75745,7 @@ var ts; return oldProgram.structureIsReused = 1; } missingFilePaths = oldProgram.getMissingFilePaths(); + refFileMap = oldProgram.getRefFileMap(); for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) { var newSourceFile = newSourceFiles_1[_f]; var filePath = newSourceFile.path; @@ -74866,7 +75766,7 @@ var ts; return oldProgram.structureIsReused = 2; } function getEmitHost(writeFileCallback) { - return __assign({ getPrependNodes: getPrependNodes, + return __assign(__assign({ getPrependNodes: getPrependNodes, getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { var path = toPath(f); @@ -74875,7 +75775,7 @@ var ts; if (ts.contains(missingFilePaths, path)) return false; return host.fileExists(f); - } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); } }); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); }, redirectTargetsMap: redirectTargetsMap }); } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!options.out && !options.outFile); @@ -74925,20 +75825,20 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.has(toPath(emitFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) { var declarationDiagnostics = []; - if (!emitOnlyDtsFiles) { + if (!forceDtsEmit) { if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; } if (options.noEmitOnError) { - var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (diagnostics.length === 0 && ts.getEmitDeclarations(program.getCompilerOptions())) { declarationDiagnostics = program.getDeclarationDiagnostics(undefined, cancellationToken); } @@ -74954,7 +75854,7 @@ var ts; } var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, false, forceDtsEmit); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -75076,62 +75976,62 @@ var ts; return diagnostics; function walk(node) { switch (parent.kind) { - case 152: - case 155: + case 153: + case 156: + case 158: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } case 157: - case 156: - case 158: case 159: case 160: - case 197: - case 240: + case 161: case 198: - case 238: + case 241: + case 199: + case 239: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 249: + case 250: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 255: + case 256: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 274: + case 275: var heritageClause = node; if (heritageClause.token === 110) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 242: + case 243: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 245: + case 246: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 243: + case 244: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 244: + case 245: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 214: + case 215: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 213: + case 214: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 195: + case 196: ts.Debug.fail(); } var prevParent = parent; @@ -75144,25 +76044,25 @@ 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 241: - case 157: - case 156: + case 242: + case 211: case 158: case 159: case 160: - case 197: - case 240: + case 161: case 198: + case 241: + case 199: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 220: + case 221: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 220); + return checkModifiers(parent.modifiers, parent.kind === 221); } break; - case 155: + case 156: if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; @@ -75173,17 +76073,18 @@ var ts; return; } break; - case 152: + case 153: if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 192: case 193: - case 212: - case 262: + case 194: + case 213: case 263: + case 264: + case 195: if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); return; @@ -75426,23 +76327,17 @@ var ts; return sourceFileWithAddedExtension; } } - function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId); }, function (diagnostic) { + function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined - ? ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(args)) : ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(args))); - }, refFile); + return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args))); + }, refFile && refFile.file); } - function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile) { + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { var redirect = Object.create(redirectTarget); @@ -75464,7 +76359,7 @@ var ts; }); return redirect; } - function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId) { + function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) { var originalFileName = fileName; if (filesByName.has(path)) { var file_1 = filesByName.get(path); @@ -75478,7 +76373,7 @@ var ts; var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory); var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory); if (checkedAbsolutePath !== inputAbsolutePath) { - reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile); } } if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth === 0) { @@ -75499,6 +76394,7 @@ var ts; processImportedModules(file_1); } } + addFileToRefFileMap(file_1 || undefined, refFile); return file_1 || undefined; } var redirectedPath; @@ -75513,14 +76409,7 @@ var ts; redirectedPath = toPath(redirect); } } - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }, shouldCreateNewSourceFile); + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { return fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); }, shouldCreateNewSourceFile); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); @@ -75547,7 +76436,7 @@ var ts; var pathLowerCase = path.toLowerCase(); var existingFile = filesByNameIgnoreCase.get(pathLowerCase); if (existingFile) { - reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile); } else { filesByNameIgnoreCase.set(pathLowerCase, file); @@ -75569,8 +76458,18 @@ var ts; processingOtherFiles.push(file); } } + addFileToRefFileMap(file, refFile); return file; } + function addFileToRefFileMap(file, refFile) { + if (refFile && file) { + (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, { + kind: refFile.kind, + index: refFile.index, + file: refFile.file.path + }); + } + } function addFileToFilesByName(file, path, redirectedPath) { if (redirectedPath) { filesByName.set(redirectedPath, file); @@ -75650,9 +76549,15 @@ var ts; return projectReferenceRedirects.get(projectReferencePath) || undefined; } function processReferencedFiles(file, isDefaultLib) { - ts.forEach(file.referencedFiles, function (ref) { + ts.forEach(file.referencedFiles, function (ref, index) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); - processSourceFile(referencedFileName, isDefaultLib, false, undefined, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, false, undefined, { + kind: ts.RefFileKind.ReferenceFile, + index: index, + file: file, + pos: ref.pos, + end: ref.end + }); }); } function processTypeReferenceDirectives(file) { @@ -75666,10 +76571,16 @@ var ts; var resolvedTypeReferenceDirective = resolutions[i]; var fileName = ref.fileName.toLocaleLowerCase(); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); - processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); + processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { + kind: ts.RefFileKind.TypeReferenceDirective, + index: i, + file: file, + pos: ref.pos, + end: ref.end + }); } } - function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { + function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) { var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { return; @@ -75679,27 +76590,27 @@ var ts; if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile); } else { if (previousResolution) { if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); } } saveResolution = false; } else { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile); } } if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--; } else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); @@ -75716,20 +76627,20 @@ var ts; var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts"); var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; - fileProcessingDiagnostics.add(createDiagnostic(file, libReference.pos, libReference.end, message, libName, suggestion)); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion)); } }); } - function createDiagnostic(refFile, refPos, refEnd, message) { + function createRefFileDiagnostic(refFile, message) { var args = []; - for (var _i = 4; _i < arguments.length; _i++) { - args[_i - 4] = arguments[_i]; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; } - if (refFile === undefined || refPos === undefined || refEnd === undefined) { - return ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)); + if (!refFile) { + return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)); } else { - return ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, message].concat(args)); + return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args)); } } function getCanonicalFileName(fileName) { @@ -75768,7 +76679,13 @@ var ts; else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, false, false, file, pos, file.imports[i].end, resolution.packageId); + findSourceFile(resolvedFileName, path, false, false, { + kind: ts.RefFileKind.Import, + index: i, + file: file, + pos: pos, + end: file.imports[i].end + }, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -75786,12 +76703,15 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + var rootPaths; for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { var sourceFile = sourceFiles_2[_i]; if (!sourceFile.isDeclarationFile) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory)); + if (!rootPaths) + rootPaths = ts.arrayToSet(rootNames, toPath); + addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory); allFilesBelongToPath = false; } } @@ -75883,15 +76803,18 @@ var ts; else if (options.incremental && !options.outFile && !options.out && !options.configFilePath) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified)); } + if (options.noEmit && ts.isIncrementalCompilation(options)) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", options.incremental ? "incremental" : "composite"); + } verifyProjectReferences(); if (options.composite) { - var rootPaths = rootNames.map(toPath); + var rootPaths = ts.arrayToSet(rootNames, toPath); for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { var file = files_3[_i]; if (!ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) continue; - if (rootPaths.indexOf(file.path) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || "")); + if (!rootPaths.has(file.path)) { + addProgramDiagnosticAtRefPath(file, rootPaths, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || ""); } } } @@ -76059,6 +76982,39 @@ var ts; } } } + function addProgramDiagnosticAtRefPath(file, rootPaths, message) { + var _a, _b; + var args = []; + for (var _i = 3; _i < arguments.length; _i++) { + args[_i - 3] = arguments[_i]; + } + var refPaths = refFileMap && refFileMap.get(file.path); + var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) || + ts.elementAt(refPaths, 0); + if (refPathToReportErrorOn) { + var refFile = ts.Debug.assertDefined(getSourceFileByPath(refPathToReportErrorOn.file)); + var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index; + var pos = void 0, end = void 0; + switch (kind) { + case ts.RefFileKind.Import: + pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos); + end = refFile.imports[index].end; + break; + case ts.RefFileKind.ReferenceFile: + (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end); + break; + case ts.RefFileKind.TypeReferenceDirective: + (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end); + break; + default: + return ts.Debug.assertNever(kind); + } + programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args))); + } + else { + programDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); + } + } function verifyProjectReferences() { var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { @@ -76300,9 +77256,9 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers) { + function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit); return { outputFiles: outputFiles, emitSkipped: emitResult.emitSkipped, exportedModulesFromDeclarationEmit: emitResult.exportedModulesFromDeclarationEmit }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); @@ -76494,11 +77450,16 @@ var ts; } } else { - var emitOutput = ts.getFileEmitOutput(programOfThisState, sourceFile, true, cancellationToken); - if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { - latestSignature = computeHash(emitOutput.outputFiles[0].text); + var emitOutput_1 = ts.getFileEmitOutput(programOfThisState, sourceFile, true, cancellationToken, undefined, 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; + if (firstDts_1) { + ts.Debug.assert(ts.fileExtensionIs(firstDts_1.name, ".d.ts"), "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(firstDts_1.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { - updateExportedModules(sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache); + updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); } } else { @@ -76681,7 +77642,8 @@ var ts; ts.copyEntries(changedFilesSet, state.changedFilesSet); } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; + state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice(); + state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind); state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; } } @@ -76718,7 +77680,7 @@ var ts; } }); if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { - addToAffectedFilesPendingEmit(state, newProgram.getSourceFiles().map(function (f) { return f.path; })); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.path, 1); }); ts.Debug.assert(state.seenAffectedFiles === undefined); state.seenAffectedFiles = ts.createMap(); } @@ -76746,7 +77708,7 @@ var ts; } function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); } function releaseCache(state) { ts.BuilderState.releaseCache(state); @@ -76766,7 +77728,8 @@ var ts; newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState); newState.program = state.program; newState.compilerOptions = state.compilerOptions; - newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit; + newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); + newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind); newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles); newState.programEmitComplete = state.programEmitComplete; @@ -76788,7 +77751,6 @@ var ts; handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash); return affectedFile; } - seenAffectedFiles.set(affectedFile.path, true); affectedFilesIndex++; } state.changedFilesSet.delete(state.currentChangedFilePath); @@ -76824,12 +77786,17 @@ var ts; var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap()); for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) { var affectedFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]); - if (affectedFile && !seenEmittedFiles.has(affectedFile.path)) { - state.affectedFilesPendingEmitIndex = i; - return affectedFile; + if (affectedFile) { + var seenKind = seenEmittedFiles.get(affectedFile.path); + var emitKind = ts.Debug.assertDefined(ts.Debug.assertDefined(state.affectedFilesPendingEmitKind).get(affectedFile.path)); + if (seenKind === undefined || seenKind < emitKind) { + state.affectedFilesPendingEmitIndex = i; + return { affectedFile: affectedFile, emitKind: emitKind }; + } } } state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; state.affectedFilesPendingEmitIndex = undefined; } return undefined; @@ -76859,7 +77826,7 @@ var ts; if (sourceFile) { ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.assertDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, [path]); + addToAffectedFilesPendingEmit(state, path, 0); } } } @@ -76925,7 +77892,7 @@ var ts; fn(state, referencingFilePath); }); } - function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit) { + function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) { if (isBuildInfoEmit) { state.emittedBuildInfo = true; } @@ -76935,6 +77902,9 @@ var ts; } else { state.seenAffectedFiles.set(affected.path, true); + if (emitKind !== undefined) { + (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, emitKind); + } if (isPendingEmit) { state.affectedFilesPendingEmitIndex++; } @@ -76943,8 +77913,12 @@ var ts; } } } - function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); + function toAffectedFileResult(state, result, affected) { + doneWithAffectedFile(state, affected); + return { result: result, affected: affected }; + } + function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken) { @@ -77057,7 +78031,7 @@ var ts; } function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? relativeToBuildInfo(file.path) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.path) : undefined }); } var BuilderProgramKind; (function (BuilderProgramKind) { @@ -77142,17 +78116,19 @@ var ts; return result; function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var emitKind = 1; var isPendingEmitFile = false; if (!affected) { if (!state.compilerOptions.out && !state.compilerOptions.outFile) { - affected = getNextAffectedFilePendingEmit(state); - if (!affected) { + var pendingAffectedFile = getNextAffectedFilePendingEmit(state); + if (!pendingAffectedFile) { if (state.emittedBuildInfo) { return undefined; } var affected_1 = ts.Debug.assertDefined(state.program); - return toAffectedFileResult(state, affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, false, true); + return toAffectedFileEmitResult(state, affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1, false, true); } + (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind); isPendingEmitFile = true; } else { @@ -77164,7 +78140,7 @@ var ts; affected = program; } } - return toAffectedFileResult(state, ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers), affected, isPendingEmitFile); + return toAffectedFileEmitResult(state, ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0, customTransformers), affected, emitKind, isPendingEmitFile); } function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { @@ -77201,7 +78177,7 @@ var ts; return toAffectedFileResult(state, state.program.getSemanticDiagnostics(undefined, cancellationToken), affected); } if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - addToAffectedFilesPendingEmit(state, [affected.path]); + addToAffectedFilesPendingEmit(state, affected.path, 1); } if (ignoreSourceFile && ignoreSourceFile(affected)) { doneWithAffectedFile(state, affected); @@ -77231,8 +78207,14 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; - function addToAffectedFilesPendingEmit(state, affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit); + function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) { + if (!state.affectedFilesPendingEmit) + state.affectedFilesPendingEmit = []; + if (!state.affectedFilesPendingEmitKind) + state.affectedFilesPendingEmitKind = ts.createMap(); + var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit); + state.affectedFilesPendingEmit.push(affectedFilePendingEmit); + state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind); if (state.affectedFilesPendingEmitIndex === undefined) { state.affectedFilesPendingEmitIndex = 0; } @@ -77262,7 +78244,7 @@ var ts; compilerOptions: convertFromReusableCompilerOptions(program.options, toAbsolutePath), referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), - semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return ts.isString(value) ? value : value[0]; }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), + 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]; }), hasReusableDiagnostic: true }; return { @@ -77379,8 +78361,19 @@ var ts; if (nextDirectorySeparator === -1) { return false; } - if (dirPath.charCodeAt(0) !== 47 && - dirPath.substr(rootLength, nextDirectorySeparator).search(/users/i) === -1) { + var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47; + if (isNonDirectorySeparatorRoot && + dirPath.search(/[a-zA-Z]:/) !== 0 && + pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { + nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1); + if (nextDirectorySeparator === -1) { + return false; + } + pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1); + } + if (isNonDirectorySeparatorRoot && + pathPartForUserCheck.search(/users\//i) !== 0) { return true; } for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) { @@ -77528,8 +78521,8 @@ var ts; !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path : !!redirectedReference; var seenNamesInFile = ts.createMap(); - for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name = names_2[_i]; + for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { + var name = names_3[_i]; var resolution = resolutionsInFile.get(name); if (!seenNamesInFile.has(name) && allFilesHaveInvalidatedResolution || unmatchedRedirects || !resolution || resolution.isInvalidated || @@ -77932,8 +78925,9 @@ var ts; function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 : 1, - ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? 2 - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 : 0, + ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? + 2 : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 : 0, }; } function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, oldImportSpecifier) { @@ -77960,7 +78954,7 @@ var ts; return [ambient]; var info = getInfo(importingSourceFile.path, host); var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); - var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.fileName, info.getCanonicalFileName, host, redirectTargetsMap); + var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.originalFileName, info.getCanonicalFileName, host, redirectTargetsMap); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); var global = ts.mapDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }); return global.length ? global : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifier(moduleFileName, info, compilerOptions, preferences); }); @@ -77975,7 +78969,7 @@ var ts; var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; var ending = _b.ending, relativePreference = _b.relativePreference; var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; - var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); if (!baseUrl || relativePreference === 0) { return relativePath; @@ -78043,7 +79037,7 @@ var ts; } function getAllModulePaths(files, importingFileName, importedFileName, getCanonicalFileName, host, redirectTargetsMap) { var redirects = redirectTargetsMap.get(importedFileName); - var importedFileNames = redirects ? redirects.concat([importedFileName]) : [importedFileName]; + var importedFileNames = redirects ? __spreadArrays(redirects, [importedFileName]) : [importedFileName]; var cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); var links = discoverProbableSymlinks(files, getCanonicalFileName, cwd); @@ -78094,14 +79088,16 @@ var ts; } } } - function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) { + function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) { var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName); if (normalizedTargetPath === undefined) { return undefined; } var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName); var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath; - return ts.removeFileExtension(relativePath); + return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs + ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) + : ts.removeFileExtension(relativePath); } function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; @@ -78482,7 +79478,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); if (result) { result.version = computeHash.call(host, result.text); } @@ -78524,7 +79520,7 @@ var ts; result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); }); }; return result; } @@ -78655,7 +79651,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - return getVersionedSourceFileByPath.apply(void 0, [fileName, toPath(fileName)].concat(args)); + return getVersionedSourceFileByPath.apply(void 0, __spreadArrays([fileName, toPath(fileName)], args)); }; compilerHost.getSourceFileByPath = getVersionedSourceFileByPath; compilerHost.getNewLine = function () { return newLine; }; @@ -78679,10 +79675,22 @@ var ts; ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFileName, currentDirectory)) : currentDirectory, false); compilerHost.resolveModuleNames = host.resolveModuleNames ? - (function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveModuleNames.apply(host, args); + }) : (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }); compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ? - (function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveTypeReferenceDirectives.apply(host, args); + }) : (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; builderProgram = readBuilderProgram(compilerOptions, compilerHost); @@ -78884,13 +79892,19 @@ var ts; reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); switch (reloadLevel) { case ts.ConfigFileProgramReloadLevel.Partial: - return reloadFileNamesFromConfigFile(); + ts.perfLogger.logStartUpdateProgram("PartialConfigReload"); + reloadFileNamesFromConfigFile(); + break; case ts.ConfigFileProgramReloadLevel.Full: - return reloadConfigFile(); + ts.perfLogger.logStartUpdateProgram("FullConfigReload"); + reloadConfigFile(); + break; default: + ts.perfLogger.logStartUpdateProgram("SynchronizeProgram"); synchronizeProgram(); - return; + break; } + ts.perfLogger.logStopUpdateProgram("Done"); } function reloadFileNamesFromConfigFile() { writeLog("Reloading new file names and options"); @@ -79042,6 +80056,14 @@ var ts; function isDeclarationFile(fileName) { return ts.fileExtensionIs(fileName, ".d.ts"); } + function isCircularBuildOrder(buildOrder) { + return !!buildOrder && !!buildOrder.buildOrder; + } + ts.isCircularBuildOrder = isCircularBuildOrder; + function getBuildOrderFromAnyBuildOrder(anyBuildOrder) { + return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder; + } + ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder; function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { var output = pretty ? "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] " : new Date().toLocaleTimeString() + " - "; @@ -79196,18 +80218,21 @@ var ts; var permanentMarks = ts.createMap(); var circularityReportStack = []; var buildOrder; + var circularDiagnostics; for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { var root = roots_1[_i]; visit(root); } - return buildOrder || ts.emptyArray; + return circularDiagnostics ? + { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } : + buildOrder || ts.emptyArray; function visit(configFileName, inCircularContext) { var projPath = toResolvedConfigFilePath(state, configFileName); if (permanentMarks.has(projPath)) return; if (temporaryMarks.has(projPath)) { if (!inCircularContext) { - reportStatus(state, ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")); + (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n"))); } return; } @@ -79227,12 +80252,32 @@ var ts; } } function getBuildOrder(state) { - return state.buildOrder || - (state.buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }))); + return state.buildOrder || createStateBuildOrder(state); + } + function createStateBuildOrder(state) { + var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); })); + state.resolvedConfigFilePaths.clear(); + var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); }); + var noopOnDelete = { onDeleteValue: ts.noop }; + ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete); + if (state.watch) { + ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher }); + ts.mutateMapSkippingNewValues(state.allWatchedWildcardDirectories, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcherOf); } }); + ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } }); + } + return state.buildOrder = buildOrder; } function getBuildOrderFor(state, project, onlyReferences) { var resolvedProject = project && resolveProjectName(state, project); var buildOrderFromState = getBuildOrder(state); + if (isCircularBuildOrder(buildOrderFromState)) + return buildOrderFromState; if (resolvedProject) { var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject); var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; }); @@ -79240,6 +80285,7 @@ var ts; return undefined; } var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState; + ts.Debug.assert(!isCircularBuildOrder(buildOrder)); ts.Debug.assert(!onlyReferences || resolvedProject !== undefined); ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject); return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder; @@ -79256,7 +80302,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); }), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, getSourceFileWithCache = _a.getSourceFileWithCache, readFileWithCache = _a.readFileWithCache; state.readFileWithCache = readFileWithCache; compilerHost.getSourceFile = getSourceFileWithCache; @@ -79310,7 +80356,7 @@ var ts; reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode); } enableCache(state); - var buildOrder = getBuildOrder(state); + var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state)); buildOrder.forEach(function (configFileName) { return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None); }); @@ -79479,7 +80525,7 @@ var ts; } function getSyntaxDiagnostics(cancellationToken) { ts.Debug.assertDefined(program); - handleDiagnostics(program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); + handleDiagnostics(__spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); } function getSemanticDiagnostics(cancellationToken) { handleDiagnostics(ts.Debug.assertDefined(program).getSemanticDiagnostics(undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic"); @@ -79634,6 +80680,8 @@ var ts; function getNextInvalidatedProject(state, buildOrder, reportQueue) { if (!state.projectPendingBuild.size) return undefined; + if (isCircularBuildOrder(buildOrder)) + return undefined; if (state.currentInvalidatedProject) { return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ? state.currentInvalidatedProject : @@ -79686,8 +80734,11 @@ var ts; if (status.type === ts.UpToDateStatusType.UpstreamBlocked) { reportAndStoreErrors(state, projectPath, config.errors); projectPendingBuild.delete(projectPath); - if (options.verbose) - reportStatus(state, ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + if (options.verbose) { + reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built : + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + } continue; } if (status.type === ts.UpToDateStatusType.ContainerOnly) { @@ -79838,10 +80889,12 @@ var ts; refStatus.type === ts.UpToDateStatusType.ContainerOnly) { continue; } - if (refStatus.type === ts.UpToDateStatusType.Unbuildable) { + if (refStatus.type === ts.UpToDateStatusType.Unbuildable || + refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) { return { type: ts.UpToDateStatusType.UpstreamBlocked, - upstreamProjectName: ref.path + upstreamProjectName: ref.path, + upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked }; } if (refStatus.type !== ts.UpToDateStatusType.UpToDate) { @@ -80048,16 +81101,22 @@ var ts; disableCache(state); reportErrorSummary(state, buildOrder); startWatching(state, buildOrder); - return errorProjects ? - successfulProjects ? - ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : - ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : - ts.ExitStatus.Success; + return isCircularBuildOrder(buildOrder) ? + ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped : + errorProjects ? + successfulProjects ? + ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : + ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : + ts.ExitStatus.Success; } function clean(state, project, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; + if (isCircularBuildOrder(buildOrder)) { + reportErrors(state, buildOrder.circularDiagnostics); + return ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped; + } var options = state.options, host = state.host; var filesToDelete = options.dry ? [] : undefined; for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) { @@ -80193,8 +81252,8 @@ var ts; if (!state.watchAllProjectsPending) return; state.watchAllProjectsPending = false; - for (var _i = 0, buildOrder_2 = buildOrder; _i < buildOrder_2.length; _i++) { - var resolved = buildOrder_2[_i]; + for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) { + var resolved = _a[_i]; var resolvedPath = toResolvedConfigFilePath(state, resolved); watchConfigFile(state, resolved, resolvedPath); var cfg = parseConfigFile(state, resolved, resolvedPath); @@ -80223,6 +81282,7 @@ var ts; }, invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); }, buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); }, + getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); }, }; } function relName(state, path) { @@ -80233,7 +81293,7 @@ var ts; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } - state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args))); + state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); } function reportWatchStatus(state, message) { var args = []; @@ -80241,7 +81301,7 @@ var ts; args[_i - 2] = arguments[_i]; } if (state.hostWithWatch.onWatchStatusChange) { - state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)), state.host.getNewLine(), state.baseCompilerOptions); + state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)), state.host.getNewLine(), state.baseCompilerOptions); } } function reportErrors(_a, errors) { @@ -80259,22 +81319,32 @@ var ts; reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]); } function reportErrorSummary(state, buildOrder) { - if (!state.needsSummary || (!state.watch && !state.host.reportErrorSummary)) + if (!state.needsSummary) return; state.needsSummary = false; + var canReportSummary = state.watch || !!state.host.reportErrorSummary; var diagnostics = state.diagnostics; - buildOrder.forEach(function (project) { - var projectPath = toResolvedConfigFilePath(state, project); - if (!state.projectErrorsReported.has(projectPath)) { - reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); - } - }); var totalErrors = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + if (isCircularBuildOrder(buildOrder)) { + reportBuildQueue(state, buildOrder.buildOrder); + reportErrors(state, buildOrder.circularDiagnostics); + if (canReportSummary) + totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics); + } + else { + buildOrder.forEach(function (project) { + var projectPath = toResolvedConfigFilePath(state, project); + if (!state.projectErrorsReported.has(projectPath)) { + reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); + } + }); + if (canReportSummary) + diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + } if (state.watch) { reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors); } - else { + else if (state.host.reportErrorSummary) { state.host.reportErrorSummary(totalErrors); } } @@ -80303,7 +81373,9 @@ var ts; case ts.UpToDateStatusType.UpstreamOutOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.UpstreamBlocked: - return reportStatus(state, ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); + return reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built : + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.Unbuildable: return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason); case ts.UpToDateStatusType.TsVersionOutputOfDate: @@ -80438,7 +81510,7 @@ var ts; configParseResult.errors.forEach(reportDiagnostic); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } - // tslint:disable-next-line:no-null-keyword + // eslint-disable-next-line no-null/no-null ts.sys.write(JSON.stringify(ts.convertToTSConfig(configParseResult, configFileName, ts.sys), null, 4) + ts.sys.newLine); return ts.sys.exit(ts.ExitStatus.Success); } @@ -80456,7 +81528,7 @@ var ts; } else { if (commandLineOptions.showConfig) { - // tslint:disable-next-line:no-null-keyword + // eslint-disable-next-line no-null/no-null ts.sys.write(JSON.stringify(ts.convertToTSConfig(commandLine, ts.combinePaths(ts.sys.getCurrentDirectory(), "tsconfig.json"), ts.sys), null, 4) + ts.sys.newLine); return ts.sys.exit(ts.ExitStatus.Success); } diff --git a/lib/tsserver.js b/lib/tsserver.js index a7782a87174e4..ef8126e62f4ea 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -15,6 +15,13 @@ and limitations under the License. "use strict"; +var __spreadArrays = (this && this.__spreadArrays) || function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +}; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { @@ -75,15 +82,17 @@ var __rest = (this && this.__rest) || function (s, e) { for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) - t[p[i]] = s[p[i]]; + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } return t; }; var ts; (function (ts) { // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configureNightly` too. - ts.versionMajorMinor = "3.6"; + ts.versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ ts.version = ts.versionMajorMinor + ".0-dev"; })(ts || (ts = {})); @@ -101,7 +110,7 @@ var ts; ts.emptyArray = []; /** Create a MapLike with good performance. */ function createDictionaryObject() { - var map = Object.create(/*prototype*/ null); // tslint:disable-line:no-null-keyword + var map = Object.create(/*prototype*/ null); // eslint-disable-line no-null/no-null // Using 'delete' on an object causes V8 to put the object in dictionary mode. // This disables creation of hidden classes, which are expensive when an object is // constantly changing shape. @@ -136,7 +145,7 @@ var ts; } ts.createMapFromTemplate = createMapFromTemplate; // Internet Explorer's Map doesn't support iteration, so don't use it. - // tslint:disable-next-line no-in-operator variable-name + // eslint-disable-next-line no-in-operator ts.MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); // Keep the class inside a function so it doesn't get compiled if it's not used. function shimMap() { @@ -200,7 +209,7 @@ var ts; return this; }; class_1.prototype.has = function (key) { - // tslint:disable-next-line:no-in-operator + // eslint-disable-next-line no-in-operator return key in this.data; }; class_1.prototype.delete = function (key) { @@ -793,7 +802,7 @@ var ts; return array1; if (!some(array1)) return array2; - return array1.concat(array2); + return __spreadArrays(array1, array2); } ts.concatenate = concatenate; function deduplicateRelational(array, equalityComparer, comparer) { @@ -850,6 +859,7 @@ var ts; // equality comparison case true: // relational comparison + // falls through case 0 /* EqualTo */: continue; case -1 /* LessThan */: @@ -1240,6 +1250,18 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; + function getAllKeys(obj) { + var result = []; + do { + var names = Object.getOwnPropertyNames(obj); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name = names_1[_i]; + pushIfUnique(result, name); + } + } while (obj = Object.getPrototypeOf(obj)); + return result; + } + ts.getAllKeys = getAllKeys; function getOwnValues(sparseArray) { var values = []; for (var key in sparseArray) { @@ -1437,7 +1459,7 @@ var ts; } ts.cast = cast; /** Does nothing. */ - function noop(_) { } // tslint:disable-line no-empty + function noop(_) { } ts.noop = noop; /** Do nothing and return false */ function returnFalse() { return false; } @@ -1949,7 +1971,7 @@ var ts; return function (arg) { return f(arg) || g(arg); }; } ts.or = or; - function assertType(_) { } // tslint:disable-line no-empty + function assertType(_) { } ts.assertType = assertType; function singleElementArray(t) { return t === undefined ? undefined : [t]; @@ -2026,8 +2048,10 @@ var ts; (function (ts) { var Debug; (function (Debug) { + /* eslint-disable prefer-const */ Debug.currentAssertionLevel = 0 /* None */; Debug.isDebugging = false; + /* eslint-enable prefer-const */ function shouldAssert(level) { return Debug.currentAssertionLevel >= level; } @@ -2076,6 +2100,7 @@ var ts; } Debug.fail = fail; function assertDefined(value, message) { + // eslint-disable-next-line no-null/no-null if (value === undefined || value === null) return fail(message); return value; @@ -2091,7 +2116,7 @@ var ts; Debug.assertEachDefined = assertEachDefined; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } - var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); + var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); return fail(message + " " + detail, stackCrawlMark || assertNever); } Debug.assertNever = assertNever; @@ -2379,6 +2404,47 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var nullLogger = { + logEvent: ts.noop, + logErrEvent: ts.noop, + logPerfEvent: ts.noop, + logInfoEvent: ts.noop, + logStartCommand: ts.noop, + logStopCommand: ts.noop, + logStartUpdateProgram: ts.noop, + logStopUpdateProgram: ts.noop, + logStartUpdateGraph: ts.noop, + logStopUpdateGraph: ts.noop, + logStartResolveModule: ts.noop, + logStopResolveModule: ts.noop, + logStartParseSourceFile: ts.noop, + logStopParseSourceFile: ts.noop, + logStartReadFile: ts.noop, + logStopReadFile: ts.noop, + logStartBindFile: ts.noop, + logStopBindFile: ts.noop, + logStartScheduledOperation: ts.noop, + logStopScheduledOperation: ts.noop, + }; + // Load optional module to enable Event Tracing for Windows + // See https://github.com/microsoft/typescript-etw for more information + var etwModule; + try { + // require() will throw an exception if the module is not installed + // It may also return undefined if not installed properly + etwModule = require("@microsoft/typescript-etw"); + } + catch (e) { + etwModule = undefined; + } + /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ + ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; + var args = typeof process === "undefined" ? [] : process.argv; + ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify(args)); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { // https://semver.org/#spec-item-2 // > A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative @@ -2903,200 +2969,203 @@ var ts; SyntaxKind[SyntaxKind["FromKeyword"] = 145] = "FromKeyword"; SyntaxKind[SyntaxKind["GlobalKeyword"] = 146] = "GlobalKeyword"; SyntaxKind[SyntaxKind["BigIntKeyword"] = 147] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 148] = "OfKeyword"; + SyntaxKind[SyntaxKind["TagKeyword"] = 148] = "TagKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 149] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 149] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 150] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 150] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 151] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 151] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 152] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 153] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 152] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 153] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 154] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 154] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 155] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 156] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 157] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 158] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 159] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 160] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 161] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 162] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 163] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 155] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 156] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 157] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 158] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 159] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 160] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 161] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 162] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 163] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 164] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 164] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 165] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 166] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 167] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 168] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 169] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 170] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 171] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 172] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 173] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 174] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 175] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 176] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 177] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 178] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 179] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 180] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 181] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 182] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 183] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 184] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 165] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 166] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 167] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 168] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 169] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 170] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 171] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 172] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 173] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 174] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 175] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 176] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 177] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 178] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 179] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 180] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 181] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 182] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 183] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 184] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 185] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 185] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 186] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 187] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 186] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 187] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 188] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 188] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 189] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 190] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 191] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 192] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 193] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 194] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 195] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 196] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 197] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 198] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 199] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 200] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 201] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 202] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 203] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 204] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 205] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 206] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 207] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 208] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 209] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 210] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 211] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 212] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 213] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 214] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 215] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 216] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 189] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 190] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 191] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 192] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 193] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 194] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 195] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 196] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 197] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 198] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 199] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 200] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 201] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 202] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 203] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 204] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 205] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 206] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 207] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 208] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 209] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 210] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 211] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 212] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 213] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 214] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 215] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 216] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 217] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 217] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 218] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 218] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 219] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 219] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 220] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 221] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 222] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 223] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 224] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 225] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 226] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 227] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 228] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 229] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 230] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 231] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 232] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 233] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 234] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 235] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 236] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 237] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 238] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 239] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 240] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 241] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 242] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 243] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 244] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 245] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 246] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 247] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 248] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 249] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 250] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 251] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 252] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 253] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 254] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 255] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 256] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 257] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 258] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 259] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 220] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 221] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 222] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 223] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 224] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 225] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 226] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 227] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 228] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 229] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 230] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 231] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 232] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 233] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 234] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 235] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 236] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 237] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 238] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 239] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 240] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 241] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 242] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 243] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 244] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 245] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 246] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 247] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 248] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 249] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 250] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 251] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 252] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 253] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 254] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 255] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 256] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 257] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 258] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 259] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 260] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 260] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 261] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 261] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 262] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 263] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 264] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 265] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 266] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 267] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 268] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 269] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 270] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 271] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 262] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 263] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 264] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 265] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 266] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 267] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 268] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 269] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 270] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 271] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 272] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 272] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 273] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 274] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 275] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 273] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 274] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 275] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 276] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 276] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 277] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 278] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 277] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 278] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 279] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 279] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 280] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 280] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 281] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 282] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 283] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 284] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 281] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 282] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 283] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 284] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 285] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 285] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 286] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 287] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 288] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 286] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 287] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 288] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 289] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 289] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 290] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 290] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 291] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 291] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 292] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 293] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 294] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 295] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 296] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 297] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 298] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 299] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 300] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 301] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 302] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 303] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 304] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 305] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 306] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 307] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 308] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 309] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 310] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 311] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 312] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 292] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 293] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 294] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 295] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 296] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 297] = "JSDocVariadicType"; + // https://jsdoc.app/about-namepaths.html + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 298] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 299] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 300] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 301] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 302] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 303] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 304] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 305] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 306] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 307] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 308] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 309] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 310] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 311] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 312] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 313] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 314] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 313] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 315] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 314] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 315] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 316] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 317] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 318] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 316] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 317] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 318] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 319] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 320] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 319] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 321] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 60] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 72] = "LastAssignment"; @@ -3105,15 +3174,15 @@ var ts; SyntaxKind[SyntaxKind["FirstReservedWord"] = 74] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 109] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 74] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 148] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 149] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 110] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 118] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 164] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 184] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 165] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 185] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 72] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 148] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 149] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -3122,13 +3191,13 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 72] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 149] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 289] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 312] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 300] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 312] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 150] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 290] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 314] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 302] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 314] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 119] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 148] = "LastContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 149] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -3252,6 +3321,8 @@ var ts; /* @internal */ TokenFlags[TokenFlags["ContainsSeparator"] = 512] = "ContainsSeparator"; /* @internal */ + TokenFlags[TokenFlags["UnicodeEscape"] = 1024] = "UnicodeEscape"; + /* @internal */ TokenFlags[TokenFlags["BinaryOrOctalSpecifier"] = 384] = "BinaryOrOctalSpecifier"; /* @internal */ TokenFlags[TokenFlags["NumericLiteralFlags"] = 1008] = "NumericLiteralFlags"; @@ -3282,6 +3353,13 @@ var ts; return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + /*@internal*/ + var RefFileKind; + (function (RefFileKind) { + RefFileKind[RefFileKind["Import"] = 0] = "Import"; + RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile"; + RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective"; + })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {})); /* @internal */ var StructureIsReused; (function (StructureIsReused) { @@ -3302,6 +3380,8 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; // When build skipped because passed in project is invalid ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped"; + // When build is skipped because project references form cycle + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); /* @internal */ var UnionReduction; @@ -3367,7 +3447,6 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 4096] = "UseTypeOfFunction"; TypeFormatFlags[TypeFormatFlags["OmitParameterModifiers"] = 8192] = "OmitParameterModifiers"; TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; - // even though `T` can't be accessed in the current scope. // Error Handling TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; // TypeFormatFlags exclusive @@ -3422,22 +3501,33 @@ var ts; /* @internal */ var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { + // The TypeReferenceNode could not be resolved. + // The type name should be emitted using a safe fallback. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; - // should be emitted using a safe fallback. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a type with a constructor // function that can be reached at runtime (e.g. a `class` // declaration or a `var` declaration for the static side // of a type, such as the global `Promise` type in lib.d.ts). + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a Void-like, Nullable, or Never type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType"; + // The TypeReferenceNode resolves to a Number-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + // The TypeReferenceNode resolves to a BigInt-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType"; + // The TypeReferenceNode resolves to a String-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType"; + // The TypeReferenceNode resolves to a Boolean-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType"; + // The TypeReferenceNode resolves to an Array-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType"; + // The TypeReferenceNode resolves to the ESSymbol type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType"; + // The TypeReferenceNode resolved to the global Promise constructor symbol. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise"; + // The TypeReferenceNode resolves to a Function type or a type with call signatures. TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature"; - // with call signatures. + // The TypeReferenceNode resolves to any other type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var SymbolFlags; @@ -3475,32 +3565,32 @@ var ts; SymbolFlags[SymbolFlags["All"] = 67108863] = "All"; SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; - SymbolFlags[SymbolFlags["Value"] = 67220415] = "Value"; - SymbolFlags[SymbolFlags["Type"] = 67897832] = "Type"; + SymbolFlags[SymbolFlags["Value"] = 111551] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 788968] = "Type"; SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; // Variables can be redeclared, but can not redeclare a block-scoped declaration with the // same name, or any other value that is not a variable, e.g. ValueModule or Class - SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 67220414] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 111550] = "FunctionScopedVariableExcludes"; // Block-scoped declarations are not allowed to be re-declared // they can not merge with anything in the value space - SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 67220415] = "BlockScopedVariableExcludes"; - SymbolFlags[SymbolFlags["ParameterExcludes"] = 67220415] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 111551] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 111551] = "ParameterExcludes"; SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; - SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 68008959] = "EnumMemberExcludes"; - SymbolFlags[SymbolFlags["FunctionExcludes"] = 67219887] = "FunctionExcludes"; - SymbolFlags[SymbolFlags["ClassExcludes"] = 68008383] = "ClassExcludes"; - SymbolFlags[SymbolFlags["InterfaceExcludes"] = 67897736] = "InterfaceExcludes"; - SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 68008191] = "RegularEnumExcludes"; - SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 68008831] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 110991] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899503] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 788872] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 110735] = "ValueModuleExcludes"; SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; - SymbolFlags[SymbolFlags["MethodExcludes"] = 67212223] = "MethodExcludes"; - SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 67154879] = "GetAccessorExcludes"; - SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 67187647] = "SetAccessorExcludes"; - SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 67635688] = "TypeParameterExcludes"; - SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 67897832] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 103359] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 46015] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 78783] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 526824] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 788968] = "TypeAliasExcludes"; SymbolFlags[SymbolFlags["AliasExcludes"] = 2097152] = "AliasExcludes"; SymbolFlags[SymbolFlags["ModuleMember"] = 2623475] = "ModuleMember"; SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; @@ -3619,6 +3709,7 @@ var ts; TypeFlags[TypeFlags["Conditional"] = 16777216] = "Conditional"; TypeFlags[TypeFlags["Substitution"] = 33554432] = "Substitution"; TypeFlags[TypeFlags["NonPrimitive"] = 67108864] = "NonPrimitive"; + TypeFlags[TypeFlags["StructuralTag"] = 134217728] = "StructuralTag"; /* @internal */ TypeFlags[TypeFlags["AnyOrUnknown"] = 3] = "AnyOrUnknown"; /* @internal */ @@ -3645,22 +3736,22 @@ var ts; /* @internal */ TypeFlags[TypeFlags["DisjointDomains"] = 67238908] = "DisjointDomains"; TypeFlags[TypeFlags["UnionOrIntersection"] = 3145728] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 3670016] = "StructuredType"; + TypeFlags[TypeFlags["StructuredType"] = 137887744] = "StructuredType"; TypeFlags[TypeFlags["TypeVariable"] = 8650752] = "TypeVariable"; TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 58982400] = "InstantiableNonPrimitive"; TypeFlags[TypeFlags["InstantiablePrimitive"] = 4194304] = "InstantiablePrimitive"; TypeFlags[TypeFlags["Instantiable"] = 63176704] = "Instantiable"; - TypeFlags[TypeFlags["StructuredOrInstantiable"] = 66846720] = "StructuredOrInstantiable"; + TypeFlags[TypeFlags["StructuredOrInstantiable"] = 201064448] = "StructuredOrInstantiable"; /* @internal */ TypeFlags[TypeFlags["ObjectFlagsType"] = 3899392] = "ObjectFlagsType"; /* @internal */ TypeFlags[TypeFlags["Simplifiable"] = 25165824] = "Simplifiable"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - TypeFlags[TypeFlags["Narrowable"] = 133970943] = "Narrowable"; + TypeFlags[TypeFlags["Narrowable"] = 268188671] = "Narrowable"; TypeFlags[TypeFlags["NotUnionOrUnit"] = 67637251] = "NotUnionOrUnit"; /* @internal */ - TypeFlags[TypeFlags["NotPrimitiveUnion"] = 66994211] = "NotPrimitiveUnion"; + TypeFlags[TypeFlags["NotPrimitiveUnion"] = 201211939] = "NotPrimitiveUnion"; // The following flags are aggregated during union and intersection type construction /* @internal */ TypeFlags[TypeFlags["IncludesMask"] = 68943871] = "IncludesMask"; @@ -3750,7 +3841,9 @@ var ts; InferencePriority[InferencePriority["LiteralKeyof"] = 32] = "LiteralKeyof"; InferencePriority[InferencePriority["NoConstraints"] = 64] = "NoConstraints"; InferencePriority[InferencePriority["AlwaysStrict"] = 128] = "AlwaysStrict"; + InferencePriority[InferencePriority["MaxValue"] = 256] = "MaxValue"; InferencePriority[InferencePriority["PriorityImpliesCombination"] = 56] = "PriorityImpliesCombination"; + InferencePriority[InferencePriority["Circularity"] = -1] = "Circularity"; })(InferencePriority = ts.InferencePriority || (ts.InferencePriority = {})); /* @internal */ var InferenceFlags; @@ -3828,6 +3921,9 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; + // NOTE: ES module kinds should be contiguous to more easily check whether a module kind is *any* ES module kind. + // Non-ES module kinds should not come between ES2015 (the earliest ES module kind) and ESNext (the last ES + // module kind). ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); @@ -4412,7 +4508,7 @@ var ts; function getCustomPollingBasedLevels(baseVariable, defaultLevels) { var customLevels = getCustomLevels(baseVariable); return (pollingIntervalChanged || customLevels) && - createPollingIntervalBasedLevels(customLevels ? __assign({}, defaultLevels, customLevels) : defaultLevels); + createPollingIntervalBasedLevels(customLevels ? __assign(__assign({}, defaultLevels), customLevels) : defaultLevels); } } ts.setCustomPollingValues = setCustomPollingValues; @@ -4566,6 +4662,38 @@ var ts; } } ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile; + /* @internal */ + function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) { + var cache = ts.createMap(); + var callbacksCache = ts.createMultiMap(); + var toCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); + return function (fileName, callback, pollingInterval) { + var path = toCanonicalFileName(fileName); + var existing = cache.get(path); + if (existing) { + existing.refCount++; + } + else { + cache.set(path, { + watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval), + refCount: 1 + }); + } + callbacksCache.add(path, callback); + return { + close: function () { + var watcher = ts.Debug.assertDefined(cache.get(path)); + callbacksCache.remove(path, callback); + watcher.refCount--; + if (watcher.refCount) + return; + cache.delete(path); + ts.closeFileWatcherOf(watcher); + } + }; + }; + } + ts.createSingleFileWatcherPerName = createSingleFileWatcherPerName; /** * Returns true if file status changed */ @@ -4592,6 +4720,8 @@ var ts; ts.getFileWatcherEventKind = getFileWatcherEventKind; /*@internal*/ ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"]; + /*@internal*/ + ts.sysLog = ts.noop; // eslint-disable-line prefer-const /** * Watch the directory recursively using host provided method to watch child directories * that means if this is recursive watcher, watch the children directories as well @@ -4712,6 +4842,7 @@ var ts; } ts.getNodeMajorVersion = getNodeMajorVersion; // TODO: GH#18217 this is used as if it's certainly defined in many places. + // eslint-disable-next-line prefer-const ts.sys = (function () { // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual // byte order mark from the specified encoding. Using any other byte order mark does @@ -4732,6 +4863,7 @@ var ts; 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 FileSystemEntryKind; @@ -4742,6 +4874,7 @@ var ts; var useNonPollingWatchers = process.env.TSC_NONPOLLING_WATCHER; var tscWatchFile = process.env.TSC_WATCHFILE; var tscWatchDirectory = process.env.TSC_WATCHDIRECTORY; + var fsWatchFile = createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames); var dynamicPollingWatchFile; var nodeSystem = { args: process.argv.slice(2), @@ -4878,7 +5011,7 @@ var ts; return useNonPollingWatchers ? createNonPollingWatchFile() : // Default to do not use polling interval as it is before this experiment branch - function (fileName, callback) { return fsWatchFile(fileName, callback); }; + function (fileName, callback) { return fsWatchFile(fileName, callback, /*pollingInterval*/ undefined); }; } function getWatchDirectory() { // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows @@ -4952,7 +5085,7 @@ var ts; return watcher; } } - function fsWatchFile(fileName, callback, pollingInterval) { + function fsWatchFileWorker(fileName, callback, pollingInterval) { _fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged); var eventKind; return { @@ -5010,6 +5143,12 @@ var ts; } function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingWatchFile, pollingInterval) { var options; + var lastDirectoryPartWithDirectorySeparator; + var lastDirectoryPart; + if (isLinuxOrMacOs) { + lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator)); + lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length); + } /** Watcher for the file system entry depending on whether it is missing or present */ var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry() : @@ -5026,6 +5165,7 @@ var ts; * @param createWatcher */ function invokeCallbackAndUpdateWatcher(createWatcher) { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); // Call the callback for current directory callback("rename", ""); // If watcher is not closed, update it @@ -5050,7 +5190,9 @@ var ts; } } try { - var presentWatcher = _fs.watch(fileOrDirectory, options, callback); + var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ? + callbackChangingToMissingFileSystemEntry : + callback); // Watch the missing file or directory or error presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); }); return presentWatcher; @@ -5062,11 +5204,23 @@ var ts; return watchPresentFileSystemEntryWithFsWatchFile(); } } + function callbackChangingToMissingFileSystemEntry(event, relativeName) { + // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations + // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path + return event === "rename" && + (!relativeName || + relativeName === lastDirectoryPart || + relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) && + !fileSystemEntryExists(fileOrDirectory, entryKind) ? + invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) : + callback(event, relativeName); + } /** * Watch the file or directory using fs.watchFile since fs.watch threw exception * Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point */ function watchPresentFileSystemEntryWithFsWatchFile() { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile"); return fallbackPollingWatchFile(fileOrDirectory, createFileWatcherCallback(callback), pollingInterval); } /** @@ -5099,7 +5253,7 @@ var ts; function createWatchDirectoryUsing(fsWatchFile) { return function (directoryName, callback) { return fsWatchFile(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium); }; } - function readFile(fileName, _encoding) { + function readFileWorker(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -5127,7 +5281,14 @@ var ts; // Default is UTF-8 with no byte order mark return buffer.toString("utf8"); } + function readFile(fileName, _encoding) { + ts.perfLogger.logStartReadFile(fileName); + var file = readFileWorker(fileName, _encoding); + ts.perfLogger.logStopReadFile(); + return file; + } function writeFile(fileName, data, writeByteOrderMark) { + ts.perfLogger.logEvent("WriteFile: " + fileName); // If a BOM is required, emit one if (writeByteOrderMark) { data = byteOrderMarkIndicator + data; @@ -5144,6 +5305,7 @@ var ts; } } function getAccessibleFileSystemEntries(path) { + ts.perfLogger.logEvent("ReadDir: " + (path || ".")); try { var entries = _fs.readdirSync(path || ".").sort(); var files = []; @@ -5199,6 +5361,7 @@ var ts; return fileSystemEntryExists(path, 1 /* Directory */); } function getDirectories(path) { + ts.perfLogger.logEvent("ReadDir: " + path); return ts.filter(_fs.readdirSync(path), function (dir) { return fileSystemEntryExists(ts.combinePaths(path, dir), 1 /* Directory */); }); } function realpath(path) { @@ -5326,7 +5489,6 @@ var ts; function diag(code, category, key, message, reportsUnnecessary) { return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary }; } - // tslint:disable-next-line variable-name ts.Diagnostics = { Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), @@ -5389,7 +5551,6 @@ var ts; A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), - An_accessor_cannot_be_declared_in_an_ambient_context: diag(1086, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_declared_in_an_ambient_context_1086", "An accessor cannot be declared in an ambient context."), _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), @@ -5444,7 +5605,6 @@ var ts; Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: diag(1150, ts.DiagnosticCategory.Error, "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", "'new T[]' cannot be used to create an array. Use 'new Array()' instead."), const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), @@ -5542,6 +5702,7 @@ var ts; 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."), Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), 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."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -5574,7 +5735,7 @@ var ts; Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), - The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), @@ -5588,6 +5749,7 @@ var ts; readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), + An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), @@ -6368,6 +6530,8 @@ var ts; Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2: diag(6381, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381", "Project '{0}' is out of date because output for it was generated with version '{1}' that differs with current version '{2}'"), + Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), + Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), 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."), @@ -6483,6 +6647,7 @@ var ts; require_call_may_be_converted_to_an_import: diag(80005, ts.DiagnosticCategory.Suggestion, "require_call_may_be_converted_to_an_import_80005", "'require' call may be converted to an import."), This_may_be_converted_to_an_async_function: diag(80006, ts.DiagnosticCategory.Suggestion, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."), await_has_no_effect_on_the_type_of_this_expression: diag(80007, ts.DiagnosticCategory.Suggestion, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."), + Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, ts.DiagnosticCategory.Suggestion, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."), Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"), Make_super_call_the_first_statement_in_the_constructor: diag(90002, ts.DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"), Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"), @@ -6600,6 +6765,12 @@ var ts; Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"), Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"), Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"), + Enable_the_jsx_flag_in_your_configuration_file: diag(95088, ts.DiagnosticCategory.Message, "Enable_the_jsx_flag_in_your_configuration_file_95088", "Enable the '--jsx' flag in your configuration file"), + Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"), + Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"), + Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"), + Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"), + Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"), 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?"), @@ -6694,10 +6865,11 @@ var ts; _a.yield = 118 /* YieldKeyword */, _a.async = 122 /* AsyncKeyword */, _a.await = 123 /* AwaitKeyword */, - _a.of = 148 /* OfKeyword */, + _a.of = 149 /* OfKeyword */, + _a.tag = 148 /* TagKeyword */, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 28 /* LessThanToken */, ">": 30 /* GreaterThanToken */, "<=": 31 /* LessThanEqualsToken */, ">=": 32 /* GreaterThanEqualsToken */, "==": 33 /* EqualsEqualsToken */, "!=": 34 /* ExclamationEqualsToken */, "===": 35 /* EqualsEqualsEqualsToken */, "!==": 36 /* ExclamationEqualsEqualsToken */, "=>": 37 /* EqualsGreaterThanToken */, "+": 38 /* PlusToken */, "-": 39 /* MinusToken */, "**": 41 /* AsteriskAsteriskToken */, "*": 40 /* AsteriskToken */, "/": 42 /* SlashToken */, "%": 43 /* PercentToken */, "++": 44 /* PlusPlusToken */, "--": 45 /* MinusMinusToken */, "<<": 46 /* LessThanLessThanToken */, ">": 47 /* GreaterThanGreaterThanToken */, ">>>": 48 /* GreaterThanGreaterThanGreaterThanToken */, "&": 49 /* AmpersandToken */, "|": 50 /* BarToken */, "^": 51 /* CaretToken */, "!": 52 /* ExclamationToken */, "~": 53 /* TildeToken */, "&&": 54 /* AmpersandAmpersandToken */, "||": 55 /* BarBarToken */, "?": 56 /* QuestionToken */, ":": 57 /* ColonToken */, "=": 60 /* EqualsToken */, "+=": 61 /* PlusEqualsToken */, "-=": 62 /* MinusEqualsToken */, "*=": 63 /* AsteriskEqualsToken */, "**=": 64 /* AsteriskAsteriskEqualsToken */, "/=": 65 /* SlashEqualsToken */, "%=": 66 /* PercentEqualsToken */, "<<=": 67 /* LessThanLessThanEqualsToken */, ">>=": 68 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 70 /* AmpersandEqualsToken */, "|=": 71 /* BarEqualsToken */, "^=": 72 /* CaretEqualsToken */, "@": 58 /* AtToken */, "`": 59 /* BacktickToken */ })); + var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 28 /* LessThanToken */, ">": 30 /* GreaterThanToken */, "<=": 31 /* LessThanEqualsToken */, ">=": 32 /* GreaterThanEqualsToken */, "==": 33 /* EqualsEqualsToken */, "!=": 34 /* ExclamationEqualsToken */, "===": 35 /* EqualsEqualsEqualsToken */, "!==": 36 /* ExclamationEqualsEqualsToken */, "=>": 37 /* EqualsGreaterThanToken */, "+": 38 /* PlusToken */, "-": 39 /* MinusToken */, "**": 41 /* AsteriskAsteriskToken */, "*": 40 /* AsteriskToken */, "/": 42 /* SlashToken */, "%": 43 /* PercentToken */, "++": 44 /* PlusPlusToken */, "--": 45 /* MinusMinusToken */, "<<": 46 /* LessThanLessThanToken */, ">": 47 /* GreaterThanGreaterThanToken */, ">>>": 48 /* GreaterThanGreaterThanGreaterThanToken */, "&": 49 /* AmpersandToken */, "|": 50 /* BarToken */, "^": 51 /* CaretToken */, "!": 52 /* ExclamationToken */, "~": 53 /* TildeToken */, "&&": 54 /* AmpersandAmpersandToken */, "||": 55 /* BarBarToken */, "?": 56 /* QuestionToken */, ":": 57 /* ColonToken */, "=": 60 /* EqualsToken */, "+=": 61 /* PlusEqualsToken */, "-=": 62 /* MinusEqualsToken */, "*=": 63 /* AsteriskEqualsToken */, "**=": 64 /* AsteriskAsteriskEqualsToken */, "/=": 65 /* SlashEqualsToken */, "%=": 66 /* PercentEqualsToken */, "<<=": 67 /* LessThanLessThanEqualsToken */, ">>=": 68 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 70 /* AmpersandEqualsToken */, "|=": 71 /* BarEqualsToken */, "^=": 72 /* CaretEqualsToken */, "@": 58 /* AtToken */, "`": 59 /* BacktickToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -6744,6 +6916,14 @@ var ts; */ var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + /** + * Generated by scripts/regenerate-unicode-identifier-parts.js on node v12.4.0 with unicode 12.1 + * based on http://www.unicode.org/reports/tr31/ and https://www.ecma-international.org/ecma-262/6.0/#sec-names-and-keywords + * unicodeESNextIdentifierStart corresponds to the ID_Start and Other_ID_Start property, and + * unicodeESNextIdentifierPart corresponds to ID_Continue, Other_ID_Continue, plus ID_Start and Other_ID_Start + */ + var unicodeESNextIdentifierStart = [65, 90, 97, 122, 170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2809, 2809, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101]; + var unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2208, 2228, 2230, 2237, 2259, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3328, 3331, 3333, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7673, 7675, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43047, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69376, 69404, 69415, 69415, 69424, 69456, 69600, 69622, 69632, 69702, 69734, 69743, 69759, 69818, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69958, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70096, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70206, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70751, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71680, 71738, 71840, 71913, 71935, 71935, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123584, 123641, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101, 917760, 917999]; function lookupInUnicodeMap(code, map) { // Bail out quickly if it couldn't possibly be in the map. if (code < map[0]) { @@ -6770,15 +6950,17 @@ var ts; return false; } /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierStart) : - lookupInUnicodeMap(code, unicodeES3IdentifierStart); + return languageVersion >= 2 /* ES2015 */ ? + lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : + languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierPart) : - lookupInUnicodeMap(code, unicodeES3IdentifierPart); + return languageVersion >= 2 /* ES2015 */ ? + lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : + languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { var result = []; @@ -6951,6 +7133,7 @@ var ts; case 32 /* space */: case 47 /* slash */: // starts of normal trivia + // falls through case 60 /* lessThan */: case 124 /* bar */: case 61 /* equals */: @@ -7274,11 +7457,12 @@ var ts; ts.isIdentifierPart = isIdentifierPart; /* @internal */ function isIdentifierText(name, languageVersion) { - if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { + var ch = codePointAt(name, 0); + if (!isIdentifierStart(ch, languageVersion)) { return false; } - for (var i = 1; i < name.length; i++) { - if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { + for (var i = charSize(ch); i < name.length; i += charSize(ch)) { + if (!isIdentifierPart(ch = codePointAt(name, i), languageVersion)) { return false; } } @@ -7302,13 +7486,14 @@ var ts; var tokenFlags; var inJSDocType = 0; setText(text, start, length); - return { + var scanner = { getStartPos: function () { return startPos; }, getTextPos: function () { return pos; }, getToken: function () { return token; }, getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, isIdentifier: function () { return token === 73 /* Identifier */ || token > 109 /* LastReservedWord */; }, @@ -7336,6 +7521,15 @@ var ts; lookAhead: lookAhead, scanRange: scanRange, }; + if (ts.Debug.isDebugging) { + Object.defineProperty(scanner, "__debugShowCurrentPositionInText", { + get: function () { + var text = scanner.getText(); + return text.slice(0, scanner.getStartPos()) + "║" + text.slice(scanner.getStartPos()); + }, + }); + } + return scanner; function error(message, errPos, length) { if (errPos === void 0) { errPos = pos; } if (onError) { @@ -7435,7 +7629,7 @@ var ts; } } function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) { - if (!isIdentifierStart(text.charCodeAt(pos), languageVersion)) { + if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) { return; } var identifierStart = pos; @@ -7643,6 +7837,7 @@ var ts; pos++; return scanExtendedUnicodeEscape(); } + tokenFlags |= 1024 /* UnicodeEscape */; // '\uDDDD' return scanHexadecimalEscape(/*numDigits*/ 4); case 120 /* x */: @@ -7725,21 +7920,41 @@ var ts; } return -1; } + function peekExtendedUnicodeEscape() { + if (languageVersion >= 2 /* ES2015 */ && codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) { + var start_2 = pos; + pos += 3; + var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); + var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; + pos = start_2; + return escapedValue; + } + return -1; + } function scanIdentifierParts() { var result = ""; var start = pos; while (pos < end) { - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); if (isIdentifierPart(ch, languageVersion)) { - pos++; + pos += charSize(ch); } else if (ch === 92 /* backslash */) { + ch = peekExtendedUnicodeEscape(); + if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + result += scanExtendedUnicodeEscape(); + start = pos; + continue; + } ch = peekUnicodeEscape(); if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } + tokenFlags |= 1024 /* UnicodeEscape */; result += text.substring(start, pos); - result += String.fromCharCode(ch); + result += utf16EncodeAsString(ch); // Valid Unicode escape is always six characters pos += 6; start = pos; @@ -7827,14 +8042,14 @@ var ts; function scan() { var _a; startPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; var asteriskSeen = false; while (true) { tokenPos = pos; if (pos >= end) { return token = 1 /* EndOfFileToken */; } - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); // Special handling for shebang if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); @@ -8199,9 +8414,17 @@ var ts; pos++; return token = 58 /* AtToken */; case 92 /* backslash */: + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; + tokenFlags |= 1024 /* UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } @@ -8210,9 +8433,9 @@ var ts; return token = 0 /* Unknown */; default: if (isIdentifierStart(ch, languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; + pos += charSize(ch); + while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) + pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); if (ch === 92 /* backslash */) { tokenValue += scanIdentifierParts(); @@ -8220,16 +8443,16 @@ var ts; return token = getIdentifierToken(); } else if (isWhiteSpaceSingleLine(ch)) { - pos++; + pos += charSize(ch); continue; } else if (isLineBreak(ch)) { tokenFlags |= 1 /* PrecedingLineBreak */; - pos++; + pos += charSize(ch); continue; } error(ts.Diagnostics.Invalid_character); - pos++; + pos += charSize(ch); return token = 0 /* Unknown */; } } @@ -8346,7 +8569,7 @@ var ts; // First non-whitespace character on this line. var firstNonWhitespace = 0; // These initial values are special because the first line is: - // firstNonWhitespace = 0 to indicate that we want leading whitspace, + // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { char = text.charCodeAt(pos); if (char === 123 /* openBrace */) { @@ -8380,17 +8603,22 @@ var ts; // they allow dashes function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { - var firstCharPosition = pos; + // An identifier or keyword has already been parsed - check for a `-` and then append it and everything after it to the token + // Do note that this means that `scanJsxIdentifier` effectively _mutates_ the visible token without advancing to a new token + // Any caller should be expecting this behavior and should only read the pos or token value after calling it. while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { + if (ch === 45 /* minus */) { + tokenValue += "-"; pos++; + continue; } - else { + var oldPos = pos; + tokenValue += scanIdentifierParts(); // reuse `scanIdentifierParts` so unicode escapes are handled + if (pos === oldPos) { break; } } - tokenValue += text.substring(firstCharPosition, pos); } return token; } @@ -8408,12 +8636,12 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; if (pos >= end) { return token = 1 /* EndOfFileToken */; } - var ch = text.charCodeAt(pos); - pos++; + var ch = codePointAt(text, pos); + pos += charSize(ch); switch (ch) { case 9 /* tab */: case 11 /* verticalTab */: @@ -8451,12 +8679,33 @@ var ts; return token = 24 /* DotToken */; case 96 /* backtick */: return token = 59 /* BacktickToken */; - } - if (isIdentifierStart(ch, 99 /* Latest */)) { - while (isIdentifierPart(text.charCodeAt(pos), 99 /* Latest */) && pos < end) { + case 92 /* backslash */: + pos--; + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } + var cookedChar = peekUnicodeEscape(); + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + pos += 6; + tokenFlags |= 1024 /* UnicodeEscape */; + tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); + return token = getIdentifierToken(); + } pos++; - } + return token = 0 /* Unknown */; + } + if (isIdentifierStart(ch, languageVersion)) { + var char = ch; + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) + pos += charSize(char); tokenValue = text.substring(tokenPos, pos); + if (char === 92 /* backslash */) { + tokenValue += scanIdentifierParts(); + } return token = getIdentifierToken(); } else { @@ -8532,13 +8781,40 @@ var ts; tokenPos = textPos; token = 0 /* Unknown */; tokenValue = undefined; - tokenFlags = 0; + tokenFlags = 0 /* None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; } } ts.createScanner = createScanner; + /* @internal */ + var codePointAt = String.prototype.codePointAt ? function (s, i) { return s.codePointAt(i); } : function codePointAt(str, i) { + // from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt + var size = str.length; + // Account for out-of-bounds indices: + if (i < 0 || i >= size) { + return undefined; // String.codePointAt returns `undefined` for OOB indexes + } + // Get the first code unit + var first = str.charCodeAt(i); + // check if it’s the start of a surrogate pair + if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) { // high surrogate and there is a next code unit + var second = str.charCodeAt(i + 1); + if (second >= 0xDC00 && second <= 0xDFFF) { // low surrogate + // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + } + } + return first; + }; + /* @internal */ + function charSize(ch) { + if (ch >= 0x10000) { + return 2; + } + return 1; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -8705,7 +8981,7 @@ var ts; } ts.copyEntries = copyEntries; function arrayToSet(array, makeKey) { - return ts.arrayToMap(array, makeKey || (function (s) { return s; }), function () { return true; }); + return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue); } ts.arrayToSet = arrayToSet; function cloneMap(map) { @@ -8814,7 +9090,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 285 /* SourceFile */) { + while (node && node.kind !== 286 /* SourceFile */) { node = node.parent; } return node; @@ -8822,11 +9098,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 220 /* Block */: + case 248 /* CaseBlock */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: return true; } return false; @@ -8911,7 +9187,7 @@ var ts; break; } } - to.splice.apply(to, [statementIndex, 0].concat(from)); + to.splice.apply(to, __spreadArrays([statementIndex, 0], from)); return to; } function insertStatementAfterPrologue(to, statement, isPrologueDirective) { @@ -8994,7 +9270,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 313 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 315 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -9013,7 +9289,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 289 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 290 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -9059,6 +9335,8 @@ var ts; ts.isBigIntLiteral(node))) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } + // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text + // had to include a backslash: `not \${a} substitution`. var escapeText = neverAsciiEscape || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; // If we can't reach the original source text, use the canonical form if it's a number, // or a (possibly escaped) quoted form of the original text if it's string-like. @@ -9071,15 +9349,21 @@ var ts; return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; } case 14 /* NoSubstitutionTemplateLiteral */: - return "`" + escapeText(node.text, 96 /* backtick */) + "`"; case 15 /* TemplateHead */: - // tslint:disable-next-line no-invalid-template-strings - return "`" + escapeText(node.text, 96 /* backtick */) + "${"; case 16 /* TemplateMiddle */: - // tslint:disable-next-line no-invalid-template-strings - return "}" + escapeText(node.text, 96 /* backtick */) + "${"; case 17 /* TemplateTail */: - return "}" + escapeText(node.text, 96 /* backtick */) + "`"; + var rawText = node.rawText || escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); + switch (node.kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + return "`" + rawText + "`"; + case 15 /* TemplateHead */: + return "`" + rawText + "${"; + case 16 /* TemplateMiddle */: + return "}" + rawText + "${"; + case 17 /* TemplateTail */: + return "}" + rawText + "`"; + } + break; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 13 /* RegularExpressionLiteral */: @@ -9105,7 +9389,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 238 /* VariableDeclaration */ && node.parent.kind === 275 /* CatchClause */; + return node.kind === 239 /* VariableDeclaration */ && node.parent.kind === 276 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -9137,11 +9421,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 === 245 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 246 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 285 /* SourceFile */ || - node.kind === 245 /* ModuleDeclaration */ || + return node.kind === 286 /* SourceFile */ || + node.kind === 246 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -9158,9 +9442,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: return ts.isExternalModule(node.parent); - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -9174,24 +9458,61 @@ var ts; return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS) && !!node.commonJsModuleIndicator); } ts.isEffectiveExternalModule = isEffectiveExternalModule; + /** + * Returns whether the source file will be treated as if it were in strict mode at runtime. + */ + function isEffectiveStrictModeSourceFile(node, compilerOptions) { + // We can only verify strict mode for JS/TS files + switch (node.scriptKind) { + case 1 /* JS */: + case 3 /* TS */: + case 2 /* JSX */: + case 4 /* TSX */: + break; + default: + return false; + } + // Strict mode does not matter for declaration files. + if (node.isDeclarationFile) { + return false; + } + // If `alwaysStrict` is set, then treat the file as strict. + if (ts.getStrictOptionValue(compilerOptions, "alwaysStrict")) { + return true; + } + // Starting with a "use strict" directive indicates the file is strict. + if (ts.startsWithUseStrict(node.statements)) { + return true; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + // ECMAScript Modules are always strict. + if (ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { + return true; + } + // Other modules are strict unless otherwise specified. + return !compilerOptions.noImplicitUseStrict; + } + return false; + } + ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 275 /* CatchClause */: - case 245 /* ModuleDeclaration */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 286 /* SourceFile */: + case 248 /* CaseBlock */: + case 276 /* CatchClause */: + case 246 /* ModuleDeclaration */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return true; - case 219 /* Block */: + case 220 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -9201,9 +9522,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: - case 299 /* JSDocSignature */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 301 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -9213,25 +9534,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 157 /* MethodSignature */: + case 164 /* IndexSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 296 /* JSDocFunctionType */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 312 /* JSDocTemplateTag */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -9241,8 +9562,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: return true; default: return false; @@ -9251,15 +9572,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 220 /* VariableStatement */: - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 221 /* VariableStatement */: + case 242 /* ClassDeclaration */: + case 241 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: return true; default: return false; @@ -9295,7 +9616,7 @@ var ts; case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 151 /* 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"); @@ -9308,9 +9629,9 @@ var ts; switch (name.kind) { case 73 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -9355,7 +9676,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 219 /* Block */) { + if (node.body && node.body.kind === 220 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -9369,7 +9690,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 285 /* SourceFile */: + case 286 /* 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 @@ -9378,25 +9699,25 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 239 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 244 /* TypeAliasDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: errorNode = node.name; break; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -9404,6 +9725,7 @@ var ts; // construct. return getSpanOfTokenAtPosition(sourceFile, node.pos); } + ts.Debug.assert(!ts.isJSDoc(errorNode)); var isMissing = nodeIsMissing(errorNode); var pos = isMissing || ts.isJsxText(node) ? errorNode.pos @@ -9433,7 +9755,7 @@ var ts; } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { @@ -9445,19 +9767,25 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 99 /* SuperKeyword */; + return n.kind === 193 /* CallExpression */ && n.expression.kind === 99 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 93 /* ImportKeyword */; + return n.kind === 193 /* CallExpression */ && n.expression.kind === 93 /* ImportKeyword */; } ts.isImportCall = isImportCall; + function isImportMeta(n) { + return ts.isMetaProperty(n) + && n.keywordToken === 93 /* ImportKeyword */ + && n.name.escapedText === "meta"; + } + ts.isImportMeta = isImportMeta; function isLiteralImportTypeNode(n) { return ts.isImportTypeNode(n) && ts.isLiteralTypeNode(n.argument) && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 222 /* ExpressionStatement */ + return node.kind === 223 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -9466,11 +9794,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 152 /* Parameter */ || - node.kind === 151 /* TypeParameter */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 198 /* ArrowFunction */ || - node.kind === 196 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 153 /* Parameter */ || + node.kind === 152 /* TypeParameter */ || + node.kind === 198 /* FunctionExpression */ || + node.kind === 199 /* ArrowFunction */ || + node.kind === 197 /* ParenthesizedExpression */) ? 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 '/**/' @@ -9486,7 +9814,7 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (164 /* FirstTypeNode */ <= node.kind && node.kind <= 184 /* LastTypeNode */) { + if (165 /* FirstTypeNode */ <= node.kind && node.kind <= 185 /* LastTypeNode */) { return true; } switch (node.kind) { @@ -9502,32 +9830,32 @@ var ts; case 133 /* NeverKeyword */: return true; case 107 /* VoidKeyword */: - return node.parent.kind !== 201 /* VoidExpression */; - case 212 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 202 /* VoidExpression */; + case 213 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 151 /* TypeParameter */: - return node.parent.kind === 182 /* MappedType */ || node.parent.kind === 177 /* InferType */; + case 152 /* TypeParameter */: + return node.parent.kind === 183 /* MappedType */ || node.parent.kind === 178 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 73 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 150 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 191 /* 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 === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */ || node.kind === 190 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 73 /* Identifier */ || node.kind === 150 /* QualifiedName */ || node.kind === 191 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 149 /* QualifiedName */: - case 190 /* PropertyAccessExpression */: + case 150 /* QualifiedName */: + case 191 /* PropertyAccessExpression */: case 101 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 168 /* TypeQuery */) { + if (parent.kind === 169 /* TypeQuery */) { return false; } - if (parent.kind === 184 /* ImportType */) { + if (parent.kind === 185 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -9536,40 +9864,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 (164 /* FirstTypeNode */ <= parent.kind && parent.kind <= 184 /* LastTypeNode */) { + if (165 /* FirstTypeNode */ <= parent.kind && parent.kind <= 185 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return node === parent.constraint; - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return node === parent.constraint; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 153 /* Parameter */: + case 239 /* VariableDeclaration */: return node === parent.type; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return node === parent.type; - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: return node === parent.type; - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: return node === parent.type; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -9594,23 +9922,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitor(node); - case 247 /* CaseBlock */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 248 /* CaseBlock */: + case 220 /* Block */: + case 224 /* IfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 233 /* WithStatement */: + case 234 /* SwitchStatement */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: + case 235 /* LabeledStatement */: + case 237 /* TryStatement */: + case 276 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -9620,26 +9948,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 245 /* EnumDeclaration */: + case 243 /* InterfaceDeclaration */: + case 246 /* ModuleDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 151 /* 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); @@ -9662,10 +9990,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 170 /* ArrayType */) { + if (node && node.kind === 171 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 165 /* TypeReference */) { + else if (node && node.kind === 166 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9675,12 +10003,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 169 /* TypeLiteral */: + case 243 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 170 /* TypeLiteral */: return node.members; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return node.properties; } } @@ -9688,14 +10016,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 187 /* BindingElement */: - case 279 /* EnumMember */: - case 152 /* Parameter */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 277 /* ShorthandPropertyAssignment */: - case 238 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 280 /* EnumMember */: + case 153 /* Parameter */: + case 277 /* PropertyAssignment */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 278 /* ShorthandPropertyAssignment */: + case 239 /* VariableDeclaration */: return true; } } @@ -9707,8 +10035,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 239 /* VariableDeclarationList */ - && node.parent.parent.kind === 220 /* VariableStatement */; + return node.parent.kind === 240 /* VariableDeclarationList */ + && node.parent.parent.kind === 221 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -9719,13 +10047,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: return true; } return false; @@ -9736,7 +10064,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 234 /* LabeledStatement */) { + if (node.statement.kind !== 235 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -9744,17 +10072,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 219 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 220 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 157 /* MethodDeclaration */ && node.parent.kind === 189 /* ObjectLiteralExpression */; + return node && node.kind === 158 /* MethodDeclaration */ && node.parent.kind === 190 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 157 /* MethodDeclaration */ && - (node.parent.kind === 189 /* ObjectLiteralExpression */ || - node.parent.kind === 210 /* ClassExpression */); + return node.kind === 158 /* MethodDeclaration */ && + (node.parent.kind === 190 /* ObjectLiteralExpression */ || + node.parent.kind === 211 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -9767,7 +10095,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 276 /* PropertyAssignment */) { + if (property.kind === 277 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -9808,14 +10136,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 285 /* SourceFile */); + ts.Debug.assert(node.kind !== 286 /* 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 150 /* ComputedPropertyName */: + case 151 /* 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 @@ -9830,9 +10158,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 153 /* Decorator */: + case 154 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 153 /* 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; @@ -9843,26 +10171,26 @@ var ts; node = node.parent; } break; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 245 /* ModuleDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 244 /* EnumDeclaration */: - case 285 /* SourceFile */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 246 /* ModuleDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 245 /* EnumDeclaration */: + case 286 /* SourceFile */: return node; } } @@ -9872,9 +10200,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 159 /* Constructor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: return container; } } @@ -9896,27 +10224,27 @@ var ts; return node; } switch (node.kind) { - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: node = node.parent; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return node; - case 153 /* Decorator */: + case 154 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 153 /* 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; @@ -9932,14 +10260,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 197 /* FunctionExpression */ || func.kind === 198 /* ArrowFunction */) { + if (func.kind === 198 /* FunctionExpression */ || func.kind === 199 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 196 /* ParenthesizedExpression */) { + while (parent.kind === 197 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 192 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 193 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -9955,7 +10283,7 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) + return (kind === 191 /* PropertyAccessExpression */ || kind === 192 /* ElementAccessExpression */) && node.expression.kind === 99 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; @@ -9964,20 +10292,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) + return (kind === 191 /* PropertyAccessExpression */ || kind === 192 /* ElementAccessExpression */) && node.expression.kind === 101 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return node; } return undefined; @@ -9985,10 +10313,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return node.tag; - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -9997,25 +10325,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: // classes are valid targets return true; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 241 /* ClassDeclaration */; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + return parent.kind === 242 /* ClassDeclaration */; + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 158 /* 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 === 241 /* ClassDeclaration */; - case 152 /* Parameter */: + && parent.kind === 242 /* ClassDeclaration */; + case 153 /* 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 === 158 /* Constructor */ - || parent.kind === 157 /* MethodDeclaration */ - || parent.kind === 160 /* SetAccessor */) - && grandparent.kind === 241 /* ClassDeclaration */; + && (parent.kind === 159 /* Constructor */ + || parent.kind === 158 /* MethodDeclaration */ + || parent.kind === 161 /* SetAccessor */) + && grandparent.kind === 242 /* ClassDeclaration */; } return false; } @@ -10031,10 +10359,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 161 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -10043,9 +10371,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 263 /* JsxOpeningElement */ || - parent.kind === 262 /* JsxSelfClosingElement */ || - parent.kind === 264 /* JsxClosingElement */) { + if (parent.kind === 264 /* JsxOpeningElement */ || + parent.kind === 263 /* JsxSelfClosingElement */ || + parent.kind === 265 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -10058,45 +10386,45 @@ var ts; case 103 /* TrueKeyword */: case 88 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 213 /* AsExpression */: - case 195 /* TypeAssertionExpression */: - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 209 /* SpreadElement */: - case 207 /* TemplateExpression */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 195 /* TaggedTemplateExpression */: + case 214 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 215 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: + case 198 /* FunctionExpression */: + case 211 /* ClassExpression */: + case 199 /* ArrowFunction */: + case 202 /* VoidExpression */: + case 200 /* DeleteExpression */: + case 201 /* TypeOfExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: + case 206 /* BinaryExpression */: + case 207 /* ConditionalExpression */: + case 210 /* SpreadElement */: + case 208 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: - case 211 /* OmittedExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 208 /* YieldExpression */: - case 202 /* AwaitExpression */: - case 215 /* MetaProperty */: + case 212 /* OmittedExpression */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 266 /* JsxFragment */: + case 209 /* YieldExpression */: + case 203 /* AwaitExpression */: + case 216 /* MetaProperty */: return true; - case 149 /* QualifiedName */: - while (node.parent.kind === 149 /* QualifiedName */) { + case 150 /* QualifiedName */: + while (node.parent.kind === 150 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node); + return node.parent.kind === 169 /* TypeQuery */ || isJSXTagName(node); case 73 /* Identifier */: - if (node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node)) { + if (node.parent.kind === 169 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through @@ -10113,49 +10441,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 187 /* BindingElement */: + case 239 /* VariableDeclaration */: + case 153 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 280 /* EnumMember */: + case 277 /* PropertyAssignment */: + case 188 /* BindingElement */: return parent.initializer === node; - case 222 /* ExpressionStatement */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 231 /* ReturnStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 235 /* ThrowStatement */: + case 223 /* ExpressionStatement */: + case 224 /* IfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 232 /* ReturnStatement */: + case 233 /* WithStatement */: + case 234 /* SwitchStatement */: + case 273 /* CaseClause */: + case 236 /* ThrowStatement */: return parent.expression === node; - case 226 /* ForStatement */: + case 227 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 240 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 240 /* VariableDeclarationList */) || forInStatement.expression === node; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: return node === parent.expression; - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return node === parent.expression; - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return node === parent.expression; - case 153 /* Decorator */: - case 271 /* JsxExpression */: - case 270 /* JsxSpreadAttribute */: - case 278 /* SpreadAssignment */: + case 154 /* Decorator */: + case 272 /* JsxExpression */: + case 271 /* JsxSpreadAttribute */: + case 279 /* SpreadAssignment */: return true; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -10163,7 +10491,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */; + return node.kind === 250 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 261 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -10172,7 +10500,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 260 /* ExternalModuleReference */; + return node.kind === 250 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 261 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -10204,7 +10532,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 192 /* CallExpression */) { + if (callExpression.kind !== 193 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -10316,11 +10644,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 197 /* FunctionExpression */ || e.kind === 198 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 198 /* FunctionExpression */ || e.kind === 199 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 197 /* FunctionExpression */ || - initializer.kind === 210 /* ClassExpression */ || - initializer.kind === 198 /* ArrowFunction */) { + if (initializer.kind === 198 /* FunctionExpression */ || + initializer.kind === 211 /* ClassExpression */ || + initializer.kind === 199 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -10488,7 +10816,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 222 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 223 /* ExpressionStatement */ && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -10497,7 +10825,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 240 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 241 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -10506,14 +10834,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: return node.parent; - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: return node.parent.parent; - case 192 /* CallExpression */: + case 193 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 183 /* LiteralType */: + case 184 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -10523,12 +10851,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: return node.moduleSpecifier; - case 249 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 260 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 184 /* ImportType */: + case 250 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 261 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 185 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -10537,11 +10865,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return node; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -10549,19 +10877,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 250 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 251 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 152 /* Parameter */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 277 /* ShorthandPropertyAssignment */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 153 /* Parameter */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 278 /* ShorthandPropertyAssignment */: + case 277 /* PropertyAssignment */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -10575,7 +10903,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 311 /* JSDocTypedefTag */ || node.kind === 304 /* JSDocCallbackTag */; + return node.kind === 313 /* JSDocTypedefTag */ || node.kind === 306 /* JSDocCallbackTag */ || node.kind === 307 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10600,12 +10928,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return node.initializer; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return node.initializer; } } @@ -10616,7 +10944,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 245 /* ModuleDeclaration */ + node.body.kind === 246 /* ModuleDeclaration */ ? node.body : undefined; } @@ -10631,11 +10959,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 152 /* Parameter */) { + if (node.kind === 153 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 151 /* TypeParameter */) { + if (node.kind === 152 /* TypeParameter */) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -10646,10 +10974,10 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 276 /* PropertyAssignment */ || - parent.kind === 255 /* ExportAssignment */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 222 /* ExpressionStatement */ && node.kind === 190 /* PropertyAccessExpression */ || + if (parent.kind === 277 /* PropertyAssignment */ || + parent.kind === 256 /* ExportAssignment */ || + parent.kind === 156 /* PropertyDeclaration */ || + parent.kind === 223 /* ExpressionStatement */ && node.kind === 191 /* PropertyAccessExpression */ || getNestedModuleDeclaration(parent) || ts.isBinaryExpression(node) && node.operatorToken.kind === 60 /* EqualsToken */) { return parent; @@ -10710,7 +11038,7 @@ var ts; function getTypeParameterFromJsDoc(node) { var name = node.name.escapedText; var typeParameters = node.parent.parent.parent.typeParameters; - return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); + return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { @@ -10720,7 +11048,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 === 296 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 297 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10733,31 +11061,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 60 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 44 /* PlusPlusToken */ || unaryOperator === 45 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 196 /* ParenthesizedExpression */: - case 188 /* ArrayLiteralExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: + case 189 /* ArrayLiteralExpression */: + case 210 /* SpreadElement */: + case 215 /* NonNullExpression */: node = parent; break; - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -10784,22 +11112,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 219 /* Block */: - case 220 /* VariableStatement */: - case 232 /* WithStatement */: - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 220 /* Block */: + case 221 /* VariableStatement */: + case 233 /* WithStatement */: + case 224 /* IfStatement */: + case 234 /* SwitchStatement */: + case 248 /* CaseBlock */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: + case 235 /* LabeledStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 237 /* TryStatement */: + case 276 /* CatchClause */: return true; } return false; @@ -10816,33 +11144,33 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 178 /* ParenthesizedType */); + return walkUp(node, 179 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 196 /* ParenthesizedExpression */); + return walkUp(node, 197 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 197 /* ParenthesizedExpression */) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 197 /* 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 !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 191 /* PropertyAccessExpression */ && node.kind !== 192 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 199 /* DeleteExpression */; + return node && node.kind === 200 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -10892,7 +11220,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 10 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 150 /* ComputedPropertyName */ && + node.parent.kind === 151 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -10900,32 +11228,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 190 /* PropertyAccessExpression */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 280 /* EnumMember */: + case 277 /* PropertyAssignment */: + case 191 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 149 /* QualifiedName */) { + while (parent.kind === 150 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 168 /* TypeQuery */ || parent.kind === 165 /* TypeReference */; + return parent.kind === 169 /* TypeQuery */ || parent.kind === 166 /* TypeReference */; } return false; - case 187 /* BindingElement */: - case 254 /* ImportSpecifier */: + case 188 /* BindingElement */: + case 255 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 258 /* ExportSpecifier */: - case 268 /* JsxAttribute */: + case 259 /* ExportSpecifier */: + case 269 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -10942,13 +11270,13 @@ var ts; // export default // module.exports = function isAliasSymbolDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 248 /* NamespaceExportDeclaration */ || - node.kind === 251 /* ImportClause */ && !!node.name || - node.kind === 252 /* NamespaceImport */ || - node.kind === 254 /* ImportSpecifier */ || - node.kind === 258 /* ExportSpecifier */ || - node.kind === 255 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + return node.kind === 250 /* ImportEqualsDeclaration */ || + node.kind === 249 /* NamespaceExportDeclaration */ || + node.kind === 252 /* ImportClause */ && !!node.name || + node.kind === 253 /* NamespaceImport */ || + node.kind === 255 /* ImportSpecifier */ || + node.kind === 259 /* ExportSpecifier */ || + node.kind === 256 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -10981,9 +11309,9 @@ var ts; ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { - return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray - : ts.emptyArray; + return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray : + ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : + ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { @@ -11014,17 +11342,21 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 74 /* FirstKeyword */ <= token && token <= 148 /* LastKeyword */; + return 74 /* FirstKeyword */ <= token && token <= 149 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 119 /* FirstContextualKeyword */ <= token && token <= 148 /* LastContextualKeyword */; + return 119 /* FirstContextualKeyword */ <= token && token <= 149 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { return isKeyword(token) && !isContextualKeyword(token); } ts.isNonContextualKeyword = isNonContextualKeyword; + function isFutureReservedKeyword(token) { + return 110 /* FirstFutureReservedWord */ <= token && token <= 118 /* LastFutureReservedWord */; + } + ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { var token = ts.stringToToken(name); return token !== undefined && isNonContextualKeyword(token); @@ -11053,14 +11385,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -11074,10 +11406,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -11110,7 +11442,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 150 /* ComputedPropertyName */ && + return name.kind === 151 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression) && !isSignedNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); @@ -11132,7 +11464,7 @@ var ts; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -11187,11 +11519,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 152 /* Parameter */; + return root.kind === 153 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 187 /* BindingElement */) { + while (node.kind === 188 /* BindingElement */) { node = node.parent.parent; } return node; @@ -11199,15 +11531,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 197 /* FunctionExpression */ - || kind === 240 /* FunctionDeclaration */ - || kind === 198 /* ArrowFunction */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 245 /* ModuleDeclaration */ - || kind === 285 /* SourceFile */; + return kind === 159 /* Constructor */ + || kind === 198 /* FunctionExpression */ + || kind === 241 /* FunctionDeclaration */ + || kind === 199 /* ArrowFunction */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */ + || kind === 246 /* ModuleDeclaration */ + || kind === 286 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -11226,23 +11558,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 194 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 193 /* NewExpression */: + case 194 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: + case 204 /* PrefixUnaryExpression */: + case 201 /* TypeOfExpression */: + case 202 /* VoidExpression */: + case 200 /* DeleteExpression */: + case 203 /* AwaitExpression */: + case 207 /* ConditionalExpression */: + case 209 /* YieldExpression */: return 1 /* Right */; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (operator) { case 41 /* AsteriskAsteriskToken */: case 60 /* EqualsToken */: @@ -11266,15 +11598,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 194 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 205 /* BinaryExpression */) { + if (expression.kind === 206 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 203 /* PrefixUnaryExpression */ || expression.kind === 204 /* PostfixUnaryExpression */) { + else if (expression.kind === 204 /* PrefixUnaryExpression */ || expression.kind === 205 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -11284,15 +11616,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: return 0; - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return 1; - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return 2; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return 4; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0; @@ -11313,21 +11645,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: + case 204 /* PrefixUnaryExpression */: + case 201 /* TypeOfExpression */: + case 202 /* VoidExpression */: + case 200 /* DeleteExpression */: + case 203 /* AwaitExpression */: return 16; - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return 17; - case 192 /* CallExpression */: + case 193 /* CallExpression */: return 18; - case 193 /* NewExpression */: + case 194 /* NewExpression */: return hasArguments ? 19 : 18; - case 194 /* TaggedTemplateExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 195 /* TaggedTemplateExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return 19; case 101 /* ThisKeyword */: case 99 /* SuperKeyword */: @@ -11338,19 +11670,19 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 211 /* ClassExpression */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 266 /* JsxFragment */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 196 /* ParenthesizedExpression */: - case 211 /* OmittedExpression */: + case 208 /* TemplateExpression */: + case 197 /* ParenthesizedExpression */: + case 212 /* OmittedExpression */: return 20; default: return -1; @@ -11470,6 +11802,10 @@ var ts; } } ts.createDiagnosticCollection = createDiagnosticCollection; + var templateSubstitutionRegExp = /\$\{/g; + function escapeTemplateSubstitution(str) { + return str.replace(templateSubstitutionRegExp, "\\${"); + } // This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, // paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in // the language service. These characters should be escaped when printing, and if any characters are added, @@ -11477,7 +11813,8 @@ var ts; // There is no reason for this other than that JSON.stringify does not handle it either. var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var backtickQuoteEscapedCharsRegExp = /[\\\`\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + // Template strings should be preserved as much as possible + var backtickQuoteEscapedCharsRegExp = /[\\\`]/g; var escapedCharsMap = ts.createMapFromTemplate({ "\t": "\\t", "\v": "\\v", @@ -11655,7 +11992,7 @@ var ts; }; } ts.createTextWriter = createTextWriter; - function getTrailingSemicolonOmittingWriter(writer) { + function getTrailingSemicolonDeferringWriter(writer) { var pendingTrailingSemicolon = false; function commitPendingTrailingSemicolon() { if (pendingTrailingSemicolon) { @@ -11663,7 +12000,7 @@ var ts; pendingTrailingSemicolon = false; } } - return __assign({}, writer, { writeTrailingSemicolon: function () { + return __assign(__assign({}, writer), { writeTrailingSemicolon: function () { pendingTrailingSemicolon = true; }, writeLiteral: function (s) { @@ -11717,6 +12054,17 @@ var ts; decreaseIndent: function () { commitPendingTrailingSemicolon(); writer.decreaseIndent(); + }, + resetPendingTrailingSemicolon: function () { + pendingTrailingSemicolon = false; + } }); + } + ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter; + function getTrailingSemicolonOmittingWriter(writer) { + var deferringWriter = getTrailingSemicolonDeferringWriter(writer); + return __assign(__assign({}, deferringWriter), { writeLine: function () { + deferringWriter.resetPendingTrailingSemicolon(); + writer.writeLine(); } }); } ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; @@ -11838,6 +12186,7 @@ var ts; return accessor.parameters[hasThis ? 1 : 0]; } } + ts.getSetAccessorValueParameter = getSetAccessorValueParameter; /** Get the type annotation for the value parameter. */ function getSetAccessorTypeAnnotationNode(accessor) { var parameter = getSetAccessorValueParameter(accessor); @@ -11874,10 +12223,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 160 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 160 /* SetAccessor */) { + else if (accessor.kind === 161 /* SetAccessor */) { setAccessor = accessor; } else { @@ -11897,10 +12246,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 159 /* GetAccessor */ && !getAccessor) { + if (member.kind === 160 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 160 /* SetAccessor */ && !setAccessor) { + if (member.kind === 161 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -11946,7 +12295,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 === 297 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 299 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -12244,8 +12593,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 189 /* ObjectLiteralExpression */ - || kind === 188 /* ArrayLiteralExpression */; + return kind === 190 /* ObjectLiteralExpression */ + || kind === 189 /* ArrayLiteralExpression */; } return false; } @@ -12277,17 +12626,17 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 150 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 191 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 189 /* ObjectLiteralExpression */ && + return expression.kind === 190 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 188 /* ArrayLiteralExpression */ && + return expression.kind === 189 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -12585,8 +12934,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 246 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -12663,35 +13012,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return accessKind(parent); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 44 /* PlusPlusToken */ || operator === 45 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? operatorToken.kind === 60 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 276 /* PropertyAssignment */: { + case 277 /* 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 277 /* ShorthandPropertyAssignment */: + case 278 /* 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 188 /* ArrayLiteralExpression */: + case 189 /* 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 === 222 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 223 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -12737,8 +13086,8 @@ var ts; /** * Mutates the map with newMap such that keys in map will be same as newMap. */ - function mutateMap(map, newMap, options) { - var createNewValue = options.createNewValue, onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; + function mutateMapSkippingNewValues(map, newMap, options) { + var onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; // Needs update map.forEach(function (existingValue, key) { var valueInNewMap = newMap.get(key); @@ -12752,6 +13101,15 @@ var ts; onExistingValue(existingValue, valueInNewMap, key); } }); + } + ts.mutateMapSkippingNewValues = mutateMapSkippingNewValues; + /** + * Mutates the map with newMap such that keys in map will be same as newMap. + */ + function mutateMap(map, newMap, options) { + // Needs update + mutateMapSkippingNewValues(map, newMap, options); + var createNewValue = options.createNewValue; // Add new values that are not already present newMap.forEach(function (valueInNewMap, key) { if (!map.has(key)) { @@ -12846,7 +13204,7 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) + return (kind >= 165 /* FirstTypeNode */ && kind <= 185 /* LastTypeNode */) || kind === 121 /* AnyKeyword */ || kind === 144 /* UnknownKeyword */ || kind === 136 /* NumberKeyword */ @@ -12860,18 +13218,18 @@ var ts; || kind === 142 /* UndefinedKeyword */ || kind === 97 /* NullKeyword */ || kind === 133 /* NeverKeyword */ - || kind === 212 /* ExpressionWithTypeArguments */ - || kind === 290 /* JSDocAllType */ - || kind === 291 /* JSDocUnknownType */ - || kind === 292 /* JSDocNullableType */ - || kind === 293 /* JSDocNonNullableType */ - || kind === 294 /* JSDocOptionalType */ - || kind === 295 /* JSDocFunctionType */ - || kind === 296 /* JSDocVariadicType */; + || kind === 213 /* ExpressionWithTypeArguments */ + || kind === 291 /* JSDocAllType */ + || kind === 292 /* JSDocUnknownType */ + || kind === 293 /* JSDocNullableType */ + || kind === 294 /* JSDocNonNullableType */ + || kind === 295 /* JSDocOptionalType */ + || kind === 296 /* JSDocFunctionType */ + || kind === 297 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */ || node.kind === 191 /* ElementAccessExpression */; + return node.kind === 191 /* PropertyAccessExpression */ || node.kind === 192 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function isBundleFileTextLike(section) { @@ -12991,7 +13349,7 @@ var ts; return { span: span, newLength: newLength }; } ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); // eslint-disable-line prefer-const /** * Called to merge all the changes that occurred across several versions of a script snapshot * into a single change. i.e. if a user keeps making successive edits to a script we will @@ -13108,17 +13466,17 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 151 /* TypeParameter */) { + if (d && d.kind === 152 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 243 /* InterfaceDeclaration */) { return current; } } } } ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 158 /* Constructor */; + function isParameterPropertyDeclaration(node, parent) { + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 159 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -13148,14 +13506,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 238 /* VariableDeclaration */) { + if (node.kind === 239 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 239 /* VariableDeclarationList */) { + if (node && node.kind === 240 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 220 /* VariableStatement */) { + if (node && node.kind === 221 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -13219,7 +13577,8 @@ var ts; return false; } try { - // tslint:disable-next-line no-unnecessary-qualifier (making clear this is a global mutation!) + // making clear this is a global mutation! + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier ts.localizedDiagnosticMessages = JSON.parse(fileContents); } catch (_a) { @@ -13301,27 +13660,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: var expr = hostNode.expression; + if (expr.kind === 206 /* BinaryExpression */ && expr.operatorToken.kind === 60 /* EqualsToken */) { + expr = expr.left; + } switch (expr.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return expr.name; - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 196 /* ParenthesizedExpression */: { + case 197 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 234 /* LabeledStatement */: { + case 235 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -13347,16 +13709,16 @@ var ts; switch (declaration.kind) { case 73 /* Identifier */: return declaration; - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: { + case 314 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 149 /* QualifiedName */) { + if (name.kind === 150 /* QualifiedName */) { return name.right; } break; } - case 192 /* CallExpression */: - case 205 /* BinaryExpression */: { + case 193 /* CallExpression */: + case 206 /* BinaryExpression */: { var expr = declaration; switch (ts.getAssignmentDeclarationKind(expr)) { case 1 /* ExportsProperty */: @@ -13372,9 +13734,11 @@ var ts; return undefined; } } - case 311 /* JSDocTypedefTag */: + case 313 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 255 /* ExportAssignment */: { + case 307 /* JSDocEnumTag */: + return nameForNamelessJSDocTypedef(declaration); + case 256 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } @@ -13579,7 +13943,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 297 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 299 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13599,10 +13963,9 @@ var ts; } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getEffectiveConstraintOfTypeParameter(node) { - return node.constraint ? node.constraint - : ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] - ? node.parent.constraint - : undefined; + return node.constraint ? node.constraint : + ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint : + undefined; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; })(ts || (ts = {})); @@ -13652,193 +14015,193 @@ var ts; ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 149 /* QualifiedName */; + return node.kind === 150 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 150 /* ComputedPropertyName */; + return node.kind === 151 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 151 /* TypeParameter */; + return node.kind === 152 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 152 /* Parameter */; + return node.kind === 153 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 153 /* Decorator */; + return node.kind === 154 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 154 /* PropertySignature */; + return node.kind === 155 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 155 /* PropertyDeclaration */; + return node.kind === 156 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 156 /* MethodSignature */; + return node.kind === 157 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 158 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 158 /* Constructor */; + return node.kind === 159 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 160 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 161 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 161 /* CallSignature */; + return node.kind === 162 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 162 /* ConstructSignature */; + return node.kind === 163 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 163 /* IndexSignature */; + return node.kind === 164 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */ || node.kind === 159 /* GetAccessor */; + return node.kind === 161 /* SetAccessor */ || node.kind === 160 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 164 /* TypePredicate */; + return node.kind === 165 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 165 /* TypeReference */; + return node.kind === 166 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 166 /* FunctionType */; + return node.kind === 167 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 167 /* ConstructorType */; + return node.kind === 168 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 168 /* TypeQuery */; + return node.kind === 169 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 169 /* TypeLiteral */; + return node.kind === 170 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 170 /* ArrayType */; + return node.kind === 171 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 171 /* TupleType */; + return node.kind === 172 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 174 /* UnionType */; + return node.kind === 175 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 175 /* IntersectionType */; + return node.kind === 176 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 176 /* ConditionalType */; + return node.kind === 177 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 177 /* InferType */; + return node.kind === 178 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 178 /* ParenthesizedType */; + return node.kind === 179 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 179 /* ThisType */; + return node.kind === 180 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 180 /* TypeOperator */; + return node.kind === 181 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 181 /* IndexedAccessType */; + return node.kind === 182 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 182 /* MappedType */; + return node.kind === 183 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 183 /* LiteralType */; + return node.kind === 184 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 184 /* ImportType */; + return node.kind === 185 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 185 /* ObjectBindingPattern */; + return node.kind === 186 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 186 /* ArrayBindingPattern */; + return node.kind === 187 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 187 /* BindingElement */; + return node.kind === 188 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 188 /* ArrayLiteralExpression */; + return node.kind === 189 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 189 /* ObjectLiteralExpression */; + return node.kind === 190 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */; + return node.kind === 191 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 191 /* ElementAccessExpression */; + return node.kind === 192 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 192 /* CallExpression */; + return node.kind === 193 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 193 /* NewExpression */; + return node.kind === 194 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 194 /* TaggedTemplateExpression */; + return node.kind === 195 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 195 /* TypeAssertionExpression */; + return node.kind === 196 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isConstTypeReference(node) { @@ -13847,376 +14210,376 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function isParenthesizedExpression(node) { - return node.kind === 196 /* ParenthesizedExpression */; + return node.kind === 197 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 315 /* PartiallyEmittedExpression */) { + while (node.kind === 317 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 197 /* FunctionExpression */; + return node.kind === 198 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 198 /* ArrowFunction */; + return node.kind === 199 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 199 /* DeleteExpression */; + return node.kind === 200 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 200 /* TypeOfExpression */; + return node.kind === 201 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 201 /* VoidExpression */; + return node.kind === 202 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 202 /* AwaitExpression */; + return node.kind === 203 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 203 /* PrefixUnaryExpression */; + return node.kind === 204 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 204 /* PostfixUnaryExpression */; + return node.kind === 205 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 205 /* BinaryExpression */; + return node.kind === 206 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 206 /* ConditionalExpression */; + return node.kind === 207 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 207 /* TemplateExpression */; + return node.kind === 208 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 208 /* YieldExpression */; + return node.kind === 209 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 209 /* SpreadElement */; + return node.kind === 210 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 210 /* ClassExpression */; + return node.kind === 211 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 211 /* OmittedExpression */; + return node.kind === 212 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 213 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 213 /* AsExpression */; + return node.kind === 214 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 214 /* NonNullExpression */; + return node.kind === 215 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 215 /* MetaProperty */; + return node.kind === 216 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 217 /* TemplateSpan */; + return node.kind === 218 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 218 /* SemicolonClassElement */; + return node.kind === 219 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 219 /* Block */; + return node.kind === 220 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 220 /* VariableStatement */; + return node.kind === 221 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 221 /* EmptyStatement */; + return node.kind === 222 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 222 /* ExpressionStatement */; + return node.kind === 223 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 223 /* IfStatement */; + return node.kind === 224 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 224 /* DoStatement */; + return node.kind === 225 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 225 /* WhileStatement */; + return node.kind === 226 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 226 /* ForStatement */; + return node.kind === 227 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 227 /* ForInStatement */; + return node.kind === 228 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 228 /* ForOfStatement */; + return node.kind === 229 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 229 /* ContinueStatement */; + return node.kind === 230 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 230 /* BreakStatement */; + return node.kind === 231 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 230 /* BreakStatement */ || node.kind === 229 /* ContinueStatement */; + return node.kind === 231 /* BreakStatement */ || node.kind === 230 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 231 /* ReturnStatement */; + return node.kind === 232 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 232 /* WithStatement */; + return node.kind === 233 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 233 /* SwitchStatement */; + return node.kind === 234 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 234 /* LabeledStatement */; + return node.kind === 235 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 235 /* ThrowStatement */; + return node.kind === 236 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 236 /* TryStatement */; + return node.kind === 237 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 237 /* DebuggerStatement */; + return node.kind === 238 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 238 /* VariableDeclaration */; + return node.kind === 239 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 239 /* VariableDeclarationList */; + return node.kind === 240 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 240 /* FunctionDeclaration */; + return node.kind === 241 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 241 /* ClassDeclaration */; + return node.kind === 242 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 242 /* InterfaceDeclaration */; + return node.kind === 243 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 243 /* TypeAliasDeclaration */; + return node.kind === 244 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 244 /* EnumDeclaration */; + return node.kind === 245 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */; + return node.kind === 246 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 246 /* ModuleBlock */; + return node.kind === 247 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 247 /* CaseBlock */; + return node.kind === 248 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 248 /* NamespaceExportDeclaration */; + return node.kind === 249 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */; + return node.kind === 250 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 250 /* ImportDeclaration */; + return node.kind === 251 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 251 /* ImportClause */; + return node.kind === 252 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 252 /* NamespaceImport */; + return node.kind === 253 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 253 /* NamedImports */; + return node.kind === 254 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 254 /* ImportSpecifier */; + return node.kind === 255 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 255 /* ExportAssignment */; + return node.kind === 256 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 256 /* ExportDeclaration */; + return node.kind === 257 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 257 /* NamedExports */; + return node.kind === 258 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 258 /* ExportSpecifier */; + return node.kind === 259 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 259 /* MissingDeclaration */; + return node.kind === 260 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 260 /* ExternalModuleReference */; + return node.kind === 261 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 261 /* JsxElement */; + return node.kind === 262 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 262 /* JsxSelfClosingElement */; + return node.kind === 263 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 263 /* JsxOpeningElement */; + return node.kind === 264 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 264 /* JsxClosingElement */; + return node.kind === 265 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 265 /* JsxFragment */; + return node.kind === 266 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 266 /* JsxOpeningFragment */; + return node.kind === 267 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 267 /* JsxClosingFragment */; + return node.kind === 268 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 268 /* JsxAttribute */; + return node.kind === 269 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 269 /* JsxAttributes */; + return node.kind === 270 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 270 /* JsxSpreadAttribute */; + return node.kind === 271 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 271 /* JsxExpression */; + return node.kind === 272 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 272 /* CaseClause */; + return node.kind === 273 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 273 /* DefaultClause */; + return node.kind === 274 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 274 /* HeritageClause */; + return node.kind === 275 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 275 /* CatchClause */; + return node.kind === 276 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 276 /* PropertyAssignment */; + return node.kind === 277 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 277 /* ShorthandPropertyAssignment */; + return node.kind === 278 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 278 /* SpreadAssignment */; + return node.kind === 279 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 280 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 285 /* SourceFile */; + return node.kind === 286 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 286 /* Bundle */; + return node.kind === 287 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 287 /* UnparsedSource */; + return node.kind === 288 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; function isUnparsedPrepend(node) { - return node.kind === 281 /* UnparsedPrepend */; + return node.kind === 282 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; function isUnparsedTextLike(node) { switch (node.kind) { - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 283 /* UnparsedText */: + case 284 /* UnparsedInternalText */: return true; default: return false; @@ -14225,105 +14588,105 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 280 /* UnparsedPrologue */ || - node.kind === 284 /* UnparsedSyntheticReference */; + node.kind === 281 /* UnparsedPrologue */ || + node.kind === 285 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 289 /* JSDocTypeExpression */; + return node.kind === 290 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 290 /* JSDocAllType */; + return node.kind === 291 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 291 /* JSDocUnknownType */; + return node.kind === 292 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 292 /* JSDocNullableType */; + return node.kind === 293 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 293 /* JSDocNonNullableType */; + return node.kind === 294 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 294 /* JSDocOptionalType */; + return node.kind === 295 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 295 /* JSDocFunctionType */; + return node.kind === 296 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 296 /* JSDocVariadicType */; + return node.kind === 297 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 297 /* JSDocComment */; + return node.kind === 299 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAuthorTag(node) { - return node.kind === 302 /* JSDocAuthorTag */; + return node.kind === 304 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocAugmentsTag(node) { - return node.kind === 301 /* JSDocAugmentsTag */; + return node.kind === 303 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 303 /* JSDocClassTag */; + return node.kind === 305 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 305 /* JSDocEnumTag */; + return node.kind === 307 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 308 /* JSDocThisTag */; + return node.kind === 310 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 306 /* JSDocParameterTag */; + return node.kind === 308 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 307 /* JSDocReturnTag */; + return node.kind === 309 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 309 /* JSDocTypeTag */; + return node.kind === 311 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 310 /* JSDocTemplateTag */; + return node.kind === 312 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 311 /* JSDocTypedefTag */; + return node.kind === 313 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 312 /* JSDocPropertyTag */; + return node.kind === 314 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 312 /* JSDocPropertyTag */ || node.kind === 306 /* JSDocParameterTag */; + return node.kind === 314 /* JSDocPropertyTag */ || node.kind === 308 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 298 /* JSDocTypeLiteral */; + return node.kind === 300 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 304 /* JSDocCallbackTag */; + return node.kind === 306 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 299 /* JSDocSignature */; + return node.kind === 301 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -14334,7 +14697,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 313 /* SyntaxList */; + return n.kind === 315 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -14344,7 +14707,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 149 /* FirstNode */; + return kind >= 150 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -14353,7 +14716,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 148 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 149 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -14438,7 +14801,7 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 149 /* QualifiedName */ + return kind === 150 /* QualifiedName */ || kind === 73 /* Identifier */; } ts.isEntityName = isEntityName; @@ -14447,14 +14810,14 @@ var ts; return kind === 73 /* Identifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 150 /* ComputedPropertyName */; + || kind === 151 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; return kind === 73 /* Identifier */ - || kind === 185 /* ObjectBindingPattern */ - || kind === 186 /* ArrayBindingPattern */; + || kind === 186 /* ObjectBindingPattern */ + || kind === 187 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -14469,13 +14832,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return true; default: return false; @@ -14484,14 +14847,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 167 /* ConstructorType */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 301 /* JSDocSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 167 /* FunctionType */: + case 296 /* JSDocFunctionType */: + case 168 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -14506,29 +14869,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 155 /* PropertyDeclaration */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 163 /* IndexSignature */ - || kind === 218 /* SemicolonClassElement */; + return kind === 159 /* Constructor */ + || kind === 156 /* PropertyDeclaration */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */ + || kind === 164 /* IndexSignature */ + || kind === 219 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */); + return node && (node.kind === 242 /* ClassDeclaration */ || node.kind === 211 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */); + return node && (node.kind === 160 /* GetAccessor */ || node.kind === 161 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return true; default: return false; @@ -14538,11 +14901,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 162 /* ConstructSignature */ - || kind === 161 /* CallSignature */ - || kind === 154 /* PropertySignature */ - || kind === 156 /* MethodSignature */ - || kind === 163 /* IndexSignature */; + return kind === 163 /* ConstructSignature */ + || kind === 162 /* CallSignature */ + || kind === 155 /* PropertySignature */ + || kind === 157 /* MethodSignature */ + || kind === 164 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -14551,12 +14914,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 276 /* PropertyAssignment */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 278 /* SpreadAssignment */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 277 /* PropertyAssignment */ + || kind === 278 /* ShorthandPropertyAssignment */ + || kind === 279 /* SpreadAssignment */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -14571,8 +14934,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: return true; } return false; @@ -14583,8 +14946,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 186 /* ArrayBindingPattern */ - || kind === 185 /* ObjectBindingPattern */; + return kind === 187 /* ArrayBindingPattern */ + || kind === 186 /* ObjectBindingPattern */; } return false; } @@ -14592,15 +14955,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 188 /* ArrayLiteralExpression */ - || kind === 189 /* ObjectLiteralExpression */; + return kind === 189 /* ArrayLiteralExpression */ + || kind === 190 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 187 /* BindingElement */ - || kind === 211 /* OmittedExpression */; + return kind === 188 /* BindingElement */ + || kind === 212 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -14609,9 +14972,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 239 /* VariableDeclaration */: + case 153 /* Parameter */: + case 188 /* BindingElement */: return true; } return false; @@ -14632,8 +14995,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 186 /* ObjectBindingPattern */: + case 190 /* ObjectLiteralExpression */: return true; } return false; @@ -14645,8 +15008,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 187 /* ArrayBindingPattern */: + case 189 /* ArrayLiteralExpression */: return true; } return false; @@ -14655,26 +15018,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */ - || kind === 184 /* ImportType */; + return kind === 191 /* PropertyAccessExpression */ + || kind === 150 /* QualifiedName */ + || kind === 185 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */; + return kind === 191 /* PropertyAccessExpression */ + || kind === 150 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 153 /* Decorator */: + case 264 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 195 /* TaggedTemplateExpression */: + case 154 /* Decorator */: return true; default: return false; @@ -14682,12 +15045,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 192 /* CallExpression */ || node.kind === 193 /* NewExpression */; + return node.kind === 193 /* CallExpression */ || node.kind === 194 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 207 /* TemplateExpression */ + return kind === 208 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -14698,33 +15061,33 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 193 /* NewExpression */: - case 192 /* CallExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 194 /* TaggedTemplateExpression */: - case 188 /* ArrayLiteralExpression */: - case 196 /* ParenthesizedExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: + case 194 /* NewExpression */: + case 193 /* CallExpression */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 266 /* JsxFragment */: + case 195 /* TaggedTemplateExpression */: + case 189 /* ArrayLiteralExpression */: + case 197 /* ParenthesizedExpression */: + case 190 /* ObjectLiteralExpression */: + case 211 /* ClassExpression */: + case 198 /* FunctionExpression */: case 73 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: case 88 /* FalseKeyword */: case 97 /* NullKeyword */: case 101 /* ThisKeyword */: case 103 /* TrueKeyword */: case 99 /* SuperKeyword */: - case 214 /* NonNullExpression */: - case 215 /* MetaProperty */: + case 215 /* NonNullExpression */: + case 216 /* MetaProperty */: case 93 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: @@ -14738,13 +15101,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 195 /* TypeAssertionExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: + case 200 /* DeleteExpression */: + case 201 /* TypeOfExpression */: + case 202 /* VoidExpression */: + case 203 /* AwaitExpression */: + case 196 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -14753,9 +15116,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return true; - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; default: @@ -14774,15 +15137,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: - case 198 /* ArrowFunction */: - case 205 /* BinaryExpression */: - case 209 /* SpreadElement */: - case 213 /* AsExpression */: - case 211 /* OmittedExpression */: - case 316 /* CommaListExpression */: - case 315 /* PartiallyEmittedExpression */: + case 207 /* ConditionalExpression */: + case 209 /* YieldExpression */: + case 199 /* ArrowFunction */: + case 206 /* BinaryExpression */: + case 210 /* SpreadElement */: + case 214 /* AsExpression */: + case 212 /* OmittedExpression */: + case 318 /* CommaListExpression */: + case 317 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -14790,18 +15153,18 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 195 /* TypeAssertionExpression */ - || kind === 213 /* AsExpression */; + return kind === 196 /* TypeAssertionExpression */ + || kind === 214 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 315 /* PartiallyEmittedExpression */; + return node.kind === 317 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 314 /* NotEmittedStatement */; + return node.kind === 316 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -14812,13 +15175,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: return true; - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -14826,7 +15189,7 @@ var ts; ts.isIterationStatement = isIterationStatement; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 227 /* ForInStatement */ || node.kind === 228 /* ForOfStatement */; + return node.kind === 228 /* ForInStatement */ || node.kind === 229 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -14850,113 +15213,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */ + return kind === 247 /* ModuleBlock */ + || kind === 246 /* ModuleDeclaration */ || kind === 73 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */; + return kind === 247 /* ModuleBlock */ + || kind === 246 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 73 /* Identifier */ - || kind === 245 /* ModuleDeclaration */; + || kind === 246 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 253 /* NamedImports */ - || kind === 252 /* NamespaceImport */; + return kind === 254 /* NamedImports */ + || kind === 253 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ || node.kind === 244 /* EnumDeclaration */; + return node.kind === 246 /* ModuleDeclaration */ || node.kind === 245 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 198 /* ArrowFunction */ - || kind === 187 /* BindingElement */ - || kind === 241 /* ClassDeclaration */ - || kind === 210 /* ClassExpression */ - || kind === 158 /* Constructor */ - || kind === 244 /* EnumDeclaration */ - || kind === 279 /* EnumMember */ - || kind === 258 /* ExportSpecifier */ - || kind === 240 /* FunctionDeclaration */ - || kind === 197 /* FunctionExpression */ - || kind === 159 /* GetAccessor */ - || kind === 251 /* ImportClause */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 254 /* ImportSpecifier */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 268 /* JsxAttribute */ - || kind === 157 /* MethodDeclaration */ - || kind === 156 /* MethodSignature */ - || kind === 245 /* ModuleDeclaration */ - || kind === 248 /* NamespaceExportDeclaration */ - || kind === 252 /* NamespaceImport */ - || kind === 152 /* Parameter */ - || kind === 276 /* PropertyAssignment */ - || kind === 155 /* PropertyDeclaration */ - || kind === 154 /* PropertySignature */ - || kind === 160 /* SetAccessor */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 151 /* TypeParameter */ - || kind === 238 /* VariableDeclaration */ - || kind === 311 /* JSDocTypedefTag */ - || kind === 304 /* JSDocCallbackTag */ - || kind === 312 /* JSDocPropertyTag */; + return kind === 199 /* ArrowFunction */ + || kind === 188 /* BindingElement */ + || kind === 242 /* ClassDeclaration */ + || kind === 211 /* ClassExpression */ + || kind === 159 /* Constructor */ + || kind === 245 /* EnumDeclaration */ + || kind === 280 /* EnumMember */ + || kind === 259 /* ExportSpecifier */ + || kind === 241 /* FunctionDeclaration */ + || kind === 198 /* FunctionExpression */ + || kind === 160 /* GetAccessor */ + || kind === 252 /* ImportClause */ + || kind === 250 /* ImportEqualsDeclaration */ + || kind === 255 /* ImportSpecifier */ + || kind === 243 /* InterfaceDeclaration */ + || kind === 269 /* JsxAttribute */ + || kind === 158 /* MethodDeclaration */ + || kind === 157 /* MethodSignature */ + || kind === 246 /* ModuleDeclaration */ + || kind === 249 /* NamespaceExportDeclaration */ + || kind === 253 /* NamespaceImport */ + || kind === 153 /* Parameter */ + || kind === 277 /* PropertyAssignment */ + || kind === 156 /* PropertyDeclaration */ + || kind === 155 /* PropertySignature */ + || kind === 161 /* SetAccessor */ + || kind === 278 /* ShorthandPropertyAssignment */ + || kind === 244 /* TypeAliasDeclaration */ + || kind === 152 /* TypeParameter */ + || kind === 239 /* VariableDeclaration */ + || kind === 313 /* JSDocTypedefTag */ + || kind === 306 /* JSDocCallbackTag */ + || kind === 314 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 240 /* FunctionDeclaration */ - || kind === 259 /* MissingDeclaration */ - || kind === 241 /* ClassDeclaration */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 244 /* EnumDeclaration */ - || kind === 245 /* ModuleDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */ - || kind === 255 /* ExportAssignment */ - || kind === 248 /* NamespaceExportDeclaration */; + return kind === 241 /* FunctionDeclaration */ + || kind === 260 /* MissingDeclaration */ + || kind === 242 /* ClassDeclaration */ + || kind === 243 /* InterfaceDeclaration */ + || kind === 244 /* TypeAliasDeclaration */ + || kind === 245 /* EnumDeclaration */ + || kind === 246 /* ModuleDeclaration */ + || kind === 251 /* ImportDeclaration */ + || kind === 250 /* ImportEqualsDeclaration */ + || kind === 257 /* ExportDeclaration */ + || kind === 256 /* ExportAssignment */ + || kind === 249 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 230 /* BreakStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 224 /* DoStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 221 /* EmptyStatement */ - || kind === 227 /* ForInStatement */ - || kind === 228 /* ForOfStatement */ - || kind === 226 /* ForStatement */ - || kind === 223 /* IfStatement */ - || kind === 234 /* LabeledStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 233 /* SwitchStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 236 /* TryStatement */ - || kind === 220 /* VariableStatement */ - || kind === 225 /* WhileStatement */ - || kind === 232 /* WithStatement */ - || kind === 314 /* NotEmittedStatement */ - || kind === 318 /* EndOfDeclarationMarker */ - || kind === 317 /* MergeDeclarationMarker */; + return kind === 231 /* BreakStatement */ + || kind === 230 /* ContinueStatement */ + || kind === 238 /* DebuggerStatement */ + || kind === 225 /* DoStatement */ + || kind === 223 /* ExpressionStatement */ + || kind === 222 /* EmptyStatement */ + || kind === 228 /* ForInStatement */ + || kind === 229 /* ForOfStatement */ + || kind === 227 /* ForStatement */ + || kind === 224 /* IfStatement */ + || kind === 235 /* LabeledStatement */ + || kind === 232 /* ReturnStatement */ + || kind === 234 /* SwitchStatement */ + || kind === 236 /* ThrowStatement */ + || kind === 237 /* TryStatement */ + || kind === 221 /* VariableStatement */ + || kind === 226 /* WhileStatement */ + || kind === 233 /* WithStatement */ + || kind === 316 /* NotEmittedStatement */ + || kind === 320 /* EndOfDeclarationMarker */ + || kind === 319 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 151 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 310 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 152 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 312 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14983,10 +15346,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 219 /* Block */) + if (node.kind !== 220 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 236 /* TryStatement */ || node.parent.kind === 275 /* CatchClause */) { + if (node.parent.kind === 237 /* TryStatement */ || node.parent.kind === 276 /* CatchClause */) { return false; } } @@ -14996,8 +15359,8 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 260 /* ExternalModuleReference */ - || kind === 149 /* QualifiedName */ + return kind === 261 /* ExternalModuleReference */ + || kind === 150 /* QualifiedName */ || kind === 73 /* Identifier */; } ts.isModuleReference = isModuleReference; @@ -15007,70 +15370,70 @@ var ts; var kind = node.kind; return kind === 101 /* ThisKeyword */ || kind === 73 /* Identifier */ - || kind === 190 /* PropertyAccessExpression */; + || kind === 191 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 261 /* JsxElement */ - || kind === 271 /* JsxExpression */ - || kind === 262 /* JsxSelfClosingElement */ + return kind === 262 /* JsxElement */ + || kind === 272 /* JsxExpression */ + || kind === 263 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 265 /* JsxFragment */; + || kind === 266 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 268 /* JsxAttribute */ - || kind === 270 /* JsxSpreadAttribute */; + return kind === 269 /* JsxAttribute */ + || kind === 271 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 271 /* JsxExpression */; + || kind === 272 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 263 /* JsxOpeningElement */ - || kind === 262 /* JsxSelfClosingElement */; + return kind === 264 /* JsxOpeningElement */ + || kind === 263 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 272 /* CaseClause */ - || kind === 273 /* DefaultClause */; + return kind === 273 /* CaseClause */ + || kind === 274 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 289 /* FirstJSDocNode */ && node.kind <= 312 /* LastJSDocNode */; + return node.kind >= 290 /* FirstJSDocNode */ && node.kind <= 314 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 297 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 299 /* JSDocComment */ || 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 >= 300 /* FirstJSDocTagNode */ && node.kind <= 312 /* LastJSDocTagNode */; + return node.kind >= 302 /* FirstJSDocTagNode */ && node.kind <= 314 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 161 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 160 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -15100,12 +15463,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 268 /* JsxAttribute */ || node.kind === 270 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 269 /* JsxAttribute */ || node.kind === 271 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 165 /* TypeReference */ || node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 166 /* TypeReference */ || node.kind === 213 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -15141,7 +15504,7 @@ var ts; /* @internal */ (function (ts) { function isNamedImportsOrExports(node) { - return node.kind === 253 /* NamedImports */ || node.kind === 257 /* NamedExports */; + return node.kind === 254 /* NamedImports */ || node.kind === 258 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -15159,7 +15522,7 @@ var ts; this.checker = checker; } } - function Signature() { } // tslint:disable-line no-empty + function Signature() { } function Node(kind, pos, end) { this.pos = pos; this.end = end; @@ -15176,6 +15539,7 @@ var ts; this.text = text; this.skipTrivia = skipTrivia || (function (pos) { return pos; }); } + // eslint-disable-next-line prefer-const ts.objectAllocator = { getNodeConstructor: function () { return Node; }, getTokenConstructor: function () { return Node; }, @@ -15622,7 +15986,7 @@ var ts; var rest = path.substring(rootLength).split(ts.directorySeparator); if (rest.length && !ts.lastOrUndefined(rest)) rest.pop(); - return [root].concat(rest); + return __spreadArrays([root], rest); } /** * Parse a path into an array containing a root component (at index 0) and zero or more path @@ -15722,7 +16086,7 @@ var ts; for (; start < fromComponents.length; start++) { relative.push(".."); } - return [""].concat(relative, components); + return __spreadArrays([""], relative, components); } ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; function getRelativePathFromFile(from, to, getCanonicalFileName) { @@ -15803,7 +16167,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { paths[_i - 1] = arguments[_i]; } - var combined = ts.some(paths) ? combinePaths.apply(void 0, [path].concat(paths)) : ts.normalizeSlashes(path); + var combined = ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : ts.normalizeSlashes(path); var normalized = ts.getPathFromPathComponents(ts.reducePathComponents(ts.getPathComponents(combined))); return normalized && hasTrailingDirectorySeparator(combined) ? ensureTrailingDirectorySeparator(normalized) : normalized; } @@ -16242,14 +16606,14 @@ var ts; ts.supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */]; ts.supportedJSExtensions = [".js" /* Js */, ".jsx" /* Jsx */]; ts.supportedJSAndJsonExtensions = [".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */]; - var allSupportedExtensions = ts.supportedTSExtensions.concat(ts.supportedJSExtensions); - var allSupportedExtensionsWithJson = ts.supportedTSExtensions.concat(ts.supportedJSExtensions, [".json" /* Json */]); + var allSupportedExtensions = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions); + var allSupportedExtensionsWithJson = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions, [".json" /* Json */]); function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && options.allowJs; if (!extraFileExtensions || extraFileExtensions.length === 0) { return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; } - var extensions = (needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions).concat(ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); + var extensions = __spreadArrays(needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions, ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); return ts.deduplicate(extensions, ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } ts.getSupportedExtensions = getSupportedExtensions; @@ -16263,7 +16627,7 @@ var ts; if (supportedExtensions === ts.supportedTSExtensions) { return ts.supportedTSExtensionsWithJson; } - return supportedExtensions.concat([".json" /* Json */]); + return __spreadArrays(supportedExtensions, [".json" /* Json */]); } ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { @@ -16583,6 +16947,7 @@ var ts; } ts.skipTypeChecking = skipTypeChecking; function isJsonEqual(a, b) { + // eslint-disable-next-line no-null/no-null return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && ts.equalOwnProperties(a, b, isJsonEqual); } ts.isJsonEqual = isJsonEqual; @@ -16686,14 +17051,12 @@ var ts; SignatureFlags[SignatureFlags["IgnoreMissingOpenBrace"] = 16] = "IgnoreMissingOpenBrace"; SignatureFlags[SignatureFlags["JSDoc"] = 32] = "JSDoc"; })(SignatureFlags || (SignatureFlags = {})); - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 285 /* SourceFile */) { + if (kind === 286 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 73 /* Identifier */) { @@ -16745,19 +17108,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 <= 148 /* LastToken */) { + if (!node || node.kind <= 149 /* LastToken */) { return; } switch (node.kind) { - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -16765,9 +17128,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 152 /* Parameter */: + case 153 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -16775,7 +17138,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -16783,51 +17146,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 154 /* PropertySignature */: + case 155 /* 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 276 /* PropertyAssignment */: + case 277 /* 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 238 /* VariableDeclaration */: + case 239 /* 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 187 /* BindingElement */: + case 188 /* 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 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -16839,345 +17202,345 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 171 /* TupleType */: + case 172 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 177 /* InferType */: + case 178 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 184 /* ImportType */: + case 185 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 178 /* ParenthesizedType */: - case 180 /* TypeOperator */: + case 179 /* ParenthesizedType */: + case 181 /* TypeOperator */: return visitNode(cbNode, node.type); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 182 /* MappedType */: + case 183 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 183 /* LiteralType */: + case 184 /* LiteralType */: return visitNode(cbNode, node.literal); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 213 /* AsExpression */: + case 214 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return visitNode(cbNode, node.name); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 220 /* Block */: + case 247 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 285 /* SourceFile */: + case 286 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 230 /* ContinueStatement */: + case 231 /* BreakStatement */: return visitNode(cbNode, node.label); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 272 /* CaseClause */: + case 273 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 153 /* Decorator */: + case 154 /* Decorator */: return visitNode(cbNode, node.expression); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* 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 242 /* InterfaceDeclaration */: + case 243 /* 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 243 /* TypeAliasDeclaration */: + case 244 /* 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 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 279 /* EnumMember */: + case 280 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 254 /* NamedImports */: + case 258 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 259 /* MissingDeclaration */: + case 260 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 261 /* JsxElement */: + case 262 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 172 /* OptionalType */: - case 173 /* RestType */: - case 289 /* JSDocTypeExpression */: - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 294 /* JSDocOptionalType */: - case 296 /* JSDocVariadicType */: + case 173 /* OptionalType */: + case 174 /* RestType */: + case 290 /* JSDocTypeExpression */: + case 294 /* JSDocNonNullableType */: + case 293 /* JSDocNullableType */: + case 295 /* JSDocOptionalType */: + case 297 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 297 /* JSDocComment */: + case 299 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: + case 314 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 302 /* JSDocAuthorTag */: + case 304 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName); - case 301 /* JSDocAugmentsTag */: + case 303 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 311 /* JSDocTypedefTag */: + case 313 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 289 /* JSDocTypeExpression */ + node.typeExpression.kind === 290 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 304 /* JSDocCallbackTag */: + case 306 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 308 /* JSDocThisTag */: - case 305 /* JSDocEnumTag */: + case 309 /* JSDocReturnTag */: + case 311 /* JSDocTypeTag */: + case 310 /* JSDocThisTag */: + case 307 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 299 /* JSDocSignature */: + case 301 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 298 /* JSDocTypeLiteral */: + case 300 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 300 /* JSDocTag */: - case 303 /* JSDocClassTag */: + case 302 /* JSDocTag */: + case 305 /* JSDocClassTag */: return visitNode(cbNode, node.tagName); - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -17186,12 +17549,14 @@ var ts; if (setParentNodes === void 0) { setParentNodes = false; } ts.performance.mark("beforeParse"); var result; + ts.perfLogger.logStartParseSourceFile(fileName); if (languageVersion === 100 /* JSON */) { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */); } else { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind); } + ts.perfLogger.logStopParseSourceFile(); ts.performance.mark("afterParse"); ts.performance.measure("Parse", "beforeParse", "afterParse"); return result; @@ -17260,12 +17625,10 @@ var ts; var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); var disallowInAndDecoratorContext = 2048 /* DisallowInContext */ | 8192 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name var sourceFile; var parseDiagnostics; var syntaxCursor; @@ -17275,6 +17638,7 @@ var ts; var identifiers; var identifierCount; var parsingContext; + var notParenthesizedArrow; // Flags that dictate what parsing context we're in. For example: // Whether or not we are in strict parsing mode. All that changes in strict parsing mode is // that some tokens that would be considered identifiers may be considered keywords. @@ -17395,7 +17759,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(222 /* ExpressionStatement */); + var statement = createNode(223 /* ExpressionStatement */); switch (token()) { case 22 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); @@ -17431,6 +17795,9 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; sourceFile.parseDiagnostics = parseDiagnostics; var result = sourceFile; clearState(); @@ -17482,6 +17849,7 @@ var ts; identifiers = undefined; syntaxCursor = undefined; sourceText = undefined; + notParenthesizedArrow = undefined; } function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { var isDeclarationFile = isDeclarationFileName(fileName); @@ -17551,7 +17919,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(285 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(286 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -17691,9 +18059,17 @@ var ts; function token() { return currentToken; } - function nextToken() { + function nextTokenWithoutCheck() { return currentToken = scanner.scan(); } + function nextToken() { + // if the keyword had an escape + if (ts.isKeyword(currentToken) && (scanner.hasUnicodeEscape() || scanner.hasExtendedUnicodeEscape())) { + // issue a parse error for the escape + parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), ts.Diagnostics.Keywords_cannot_contain_escape_characters); + } + return nextTokenWithoutCheck(); + } function nextTokenJSDoc() { return currentToken = scanner.scanJsDocToken(); } @@ -17932,7 +18308,7 @@ var ts; node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); - nextToken(); + nextTokenWithoutCheck(); return finishNode(node); } // Only for end of file because the error gets reported incorrectly on embedded script tags. @@ -17968,7 +18344,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(150 /* ComputedPropertyName */); + var node = createNode(151 /* ComputedPropertyName */); parseExpected(22 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -18402,14 +18778,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 158 /* Constructor */: - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 218 /* SemicolonClassElement */: + case 159 /* Constructor */: + case 164 /* IndexSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 219 /* SemicolonClassElement */: return true; - case 157 /* MethodDeclaration */: + case 158 /* 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. @@ -18424,8 +18800,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: return true; } } @@ -18434,58 +18810,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 220 /* VariableStatement */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 222 /* ExpressionStatement */: - case 235 /* ThrowStatement */: - case 231 /* ReturnStatement */: - case 233 /* SwitchStatement */: - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 221 /* EmptyStatement */: - case 236 /* TryStatement */: - case 234 /* LabeledStatement */: - case 224 /* DoStatement */: - case 237 /* DebuggerStatement */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 241 /* FunctionDeclaration */: + case 221 /* VariableStatement */: + case 220 /* Block */: + case 224 /* IfStatement */: + case 223 /* ExpressionStatement */: + case 236 /* ThrowStatement */: + case 232 /* ReturnStatement */: + case 234 /* SwitchStatement */: + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 227 /* ForStatement */: + case 226 /* WhileStatement */: + case 233 /* WithStatement */: + case 222 /* EmptyStatement */: + case 237 /* TryStatement */: + case 235 /* LabeledStatement */: + case 225 /* DoStatement */: + case 238 /* DebuggerStatement */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 257 /* ExportDeclaration */: + case 256 /* ExportAssignment */: + case 246 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 280 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 154 /* PropertySignature */: - case 161 /* CallSignature */: + case 163 /* ConstructSignature */: + case 157 /* MethodSignature */: + case 164 /* IndexSignature */: + case 155 /* PropertySignature */: + case 162 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 238 /* VariableDeclaration */) { + if (node.kind !== 239 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -18506,7 +18882,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 152 /* Parameter */) { + if (node.kind !== 153 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -18573,7 +18949,7 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */); + parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use @@ -18611,6 +18987,9 @@ var ts; } return result; } + function getExpectedCommaDiagnostic(kind) { + return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + } function createMissingList() { var list = createNodeArray([], getNodePos()); list.isMissingList = true; @@ -18642,7 +19021,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(149 /* QualifiedName */, entity.pos); + var node = createNode(150 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -18679,7 +19058,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(207 /* TemplateExpression */); + var template = createNode(208 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -18691,7 +19070,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(217 /* TemplateSpan */); + var span = createNode(218 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 19 /* CloseBraceToken */) { @@ -18720,6 +19099,16 @@ var ts; function parseLiteralLikeNode(kind) { var node = createNode(kind); node.text = scanner.getTokenValue(); + switch (kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + var isLast = kind === 14 /* NoSubstitutionTemplateLiteral */ || kind === 17 /* TemplateTail */; + var tokenText = scanner.getTokenText(); + node.rawText = tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); + break; + } if (scanner.hasExtendedUnicodeEscape()) { node.hasExtendedUnicodeEscape = true; } @@ -18741,7 +19130,7 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(165 /* TypeReference */); + var node = createNode(166 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); @@ -18751,14 +19140,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: { + case 167 /* FunctionType */: + case 168 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -18766,20 +19155,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(164 /* TypePredicate */, lhs.pos); + var node = createNode(165 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(179 /* ThisType */); + var node = createNode(180 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(290 /* JSDocAllType */); + var result = createNode(291 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(294 /* JSDocOptionalType */, result); + return createPostfixType(295 /* JSDocOptionalType */, result); } else { nextToken(); @@ -18787,7 +19176,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(293 /* JSDocNonNullableType */); + var result = createNode(294 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -18811,28 +19200,28 @@ var ts; token() === 30 /* GreaterThanToken */ || token() === 60 /* EqualsToken */ || token() === 50 /* BarToken */) { - var result = createNode(291 /* JSDocUnknownType */, pos); + var result = createNode(292 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(292 /* JSDocNullableType */, pos); + var result = createNode(293 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(295 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(296 /* JSDocFunctionType */); nextToken(); fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(165 /* TypeReference */); + var node = createNode(166 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(152 /* Parameter */); + var parameter = createNode(153 /* Parameter */); if (token() === 101 /* ThisKeyword */ || token() === 96 /* NewKeyword */) { parameter.name = parseIdentifierName(); parseExpected(57 /* ColonToken */); @@ -18842,27 +19231,44 @@ var ts; } function parseJSDocType() { scanner.setInJSDocType(true); + var moduleSpecifier = parseOptionalToken(131 /* ModuleKeyword */); + if (moduleSpecifier) { + var moduleTag = createNode(298 /* JSDocNamepathType */, moduleSpecifier.pos); + terminate: while (true) { + switch (token()) { + case 19 /* CloseBraceToken */: + case 1 /* EndOfFileToken */: + case 27 /* CommaToken */: + case 5 /* WhitespaceTrivia */: + break terminate; + default: + nextTokenJSDoc(); + } + } + scanner.setInJSDocType(false); + return finishNode(moduleTag); + } var dotdotdot = parseOptionalToken(25 /* DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(296 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(297 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 60 /* EqualsToken */) { - return createPostfixType(294 /* JSDocOptionalType */, type); + return createPostfixType(295 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(168 /* TypeQuery */); + var node = createNode(169 /* TypeQuery */); parseExpected(105 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(152 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(87 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -18907,7 +19313,7 @@ var ts; isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(152 /* Parameter */); + var node = createNodeWithJSDoc(153 /* Parameter */); if (token() === 101 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); @@ -19008,7 +19414,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 162 /* ConstructSignature */) { + if (kind === 163 /* ConstructSignature */) { parseExpected(96 /* NewKeyword */); } fillSignature(57 /* ColonToken */, 4 /* Type */, node); @@ -19069,7 +19475,7 @@ var ts; return token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 163 /* IndexSignature */; + node.kind = 164 /* IndexSignature */; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -19079,13 +19485,13 @@ var ts; node.name = parsePropertyName(); node.questionToken = parseOptionalToken(56 /* QuestionToken */); if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - node.kind = 156 /* MethodSignature */; + node.kind = 157 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] fillSignature(57 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 154 /* PropertySignature */; + node.kind = 155 /* PropertySignature */; node.type = parseTypeAnnotation(); if (token() === 60 /* EqualsToken */) { // Although type literal properties cannot not have initializers, we attempt @@ -19131,10 +19537,10 @@ var ts; } function parseTypeMember() { if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - return parseSignatureMember(161 /* CallSignature */); + return parseSignatureMember(162 /* CallSignature */); } if (token() === 96 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(162 /* ConstructSignature */); + return parseSignatureMember(163 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -19160,7 +19566,7 @@ var ts; return false; } function parseTypeLiteral() { - var node = createNode(169 /* TypeLiteral */); + var node = createNode(170 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -19186,14 +19592,14 @@ var ts; return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 94 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(152 /* TypeParameter */); node.name = parseIdentifier(); parseExpected(94 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(182 /* MappedType */); + var node = createNode(183 /* MappedType */); parseExpected(18 /* OpenBraceToken */); if (token() === 134 /* ReadonlyKeyword */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { node.readonlyToken = parseTokenNode(); @@ -19218,23 +19624,23 @@ var ts; function parseTupleElementType() { var pos = getNodePos(); if (parseOptional(25 /* DotDotDotToken */)) { - var node = createNode(173 /* RestType */, pos); + var node = createNode(174 /* RestType */, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 292 /* JSDocNullableType */ && type.pos === type.type.pos) { - type.kind = 172 /* OptionalType */; + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 293 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 173 /* OptionalType */; } return type; } function parseTupleType() { - var node = createNode(171 /* TupleType */); + var node = createNode(172 /* TupleType */); node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(178 /* ParenthesizedType */); + var node = createNode(179 /* ParenthesizedType */); parseExpected(20 /* OpenParenToken */); node.type = parseType(); parseExpected(21 /* CloseParenToken */); @@ -19242,7 +19648,7 @@ var ts; } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(96 /* NewKeyword */) ? 167 /* ConstructorType */ : 166 /* FunctionType */; + var kind = parseOptional(96 /* NewKeyword */) ? 168 /* ConstructorType */ : 167 /* FunctionType */; var node = createNodeWithJSDoc(kind, pos); fillSignature(37 /* EqualsGreaterThanToken */, 4 /* Type */, node); return finishNode(node); @@ -19252,10 +19658,10 @@ var ts; return token() === 24 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(183 /* LiteralType */); + var node = createNode(184 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(203 /* PrefixUnaryExpression */); + unaryMinusExpression = createNode(204 /* PrefixUnaryExpression */); unaryMinusExpression.operator = 39 /* MinusToken */; nextToken(); } @@ -19276,7 +19682,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(184 /* ImportType */); + var node = createNode(185 /* ImportType */); if (parseOptional(105 /* TypeOfKeyword */)) { node.isTypeOf = true; } @@ -19366,6 +19772,7 @@ var ts; case 134 /* ReadonlyKeyword */: case 140 /* SymbolKeyword */: case 143 /* UniqueKeyword */: + case 148 /* TagKeyword */: case 107 /* VoidKeyword */: case 142 /* UndefinedKeyword */: case 97 /* NullKeyword */: @@ -19412,26 +19819,26 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 52 /* ExclamationToken */: - type = createPostfixType(293 /* JSDocNonNullableType */, type); + type = createPostfixType(294 /* JSDocNonNullableType */, type); break; case 56 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(292 /* JSDocNullableType */, type); + type = createPostfixType(293 /* JSDocNullableType */, type); break; case 22 /* OpenBracketToken */: parseExpected(22 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(181 /* IndexedAccessType */, type.pos); + var node = createNode(182 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(170 /* ArrayType */, type.pos); + var node = createNode(171 /* ArrayType */, type.pos); node.elementType = type; parseExpected(23 /* CloseBracketToken */); type = finishNode(node); @@ -19450,16 +19857,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(180 /* TypeOperator */); + var node = createNode(181 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(177 /* InferType */); + var node = createNode(178 /* InferType */); parseExpected(128 /* InferKeyword */); - var typeParameter = createNode(151 /* TypeParameter */); + var typeParameter = createNode(152 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -19470,6 +19877,7 @@ var ts; case 130 /* KeyOfKeyword */: case 143 /* UniqueKeyword */: case 134 /* ReadonlyKeyword */: + case 148 /* TagKeyword */: return parseTypeOperator(operator); case 128 /* InferKeyword */: return parseInferType(); @@ -19492,10 +19900,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(175 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); + return parseUnionOrIntersectionType(176 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(174 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); + return parseUnionOrIntersectionType(175 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); } function isStartOfFunctionType() { if (token() === 28 /* LessThanToken */) { @@ -19552,7 +19960,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(164 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(165 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -19579,7 +19987,7 @@ var ts; } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(87 /* ExtendsKeyword */)) { - var node = createNode(176 /* ConditionalType */, type.pos); + var node = createNode(177 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); @@ -19773,7 +20181,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(208 /* YieldExpression */); + var node = createNode(209 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -19795,13 +20203,13 @@ var ts; ts.Debug.assert(token() === 37 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(198 /* ArrowFunction */, asyncModifier.pos); + node = createNode(199 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(198 /* ArrowFunction */, identifier.pos); + node = createNode(199 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(152 /* Parameter */, identifier.pos); + var parameter = createNode(153 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); @@ -19965,7 +20373,15 @@ var ts; } } function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + var tokenPos = scanner.getTokenPos(); + if (notParenthesizedArrow && notParenthesizedArrow.has(tokenPos.toString())) { + return undefined; + } + var result = parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + if (!result) { + (notParenthesizedArrow || (notParenthesizedArrow = ts.createMap())).set(tokenPos.toString(), true); + } + return result; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" @@ -19998,7 +20414,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(198 /* ArrowFunction */); + var node = createNodeWithJSDoc(199 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -20064,7 +20480,7 @@ var ts; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(206 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(207 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -20079,7 +20495,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 94 /* InKeyword */ || t === 148 /* OfKeyword */; + return t === 94 /* InKeyword */ || t === 149 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -20144,39 +20560,39 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(205 /* BinaryExpression */, left.pos); + var node = createNode(206 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(213 /* AsExpression */, left.pos); + var node = createNode(214 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(203 /* PrefixUnaryExpression */); + var node = createNode(204 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(199 /* DeleteExpression */); + var node = createNode(200 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(200 /* TypeOfExpression */); + var node = createNode(201 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(201 /* VoidExpression */); + var node = createNode(202 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -20192,7 +20608,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(202 /* AwaitExpression */); + var node = createNode(203 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -20236,7 +20652,7 @@ var ts; if (token() === 41 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 195 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 196 /* 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 { @@ -20333,7 +20749,7 @@ var ts; */ function parseUpdateExpression() { if (token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) { - var node = createNode(203 /* PrefixUnaryExpression */); + var node = createNode(204 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -20346,7 +20762,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(204 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(205 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -20402,7 +20818,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(215 /* MetaProperty */, fullStart); + var node = createNode(216 /* MetaProperty */, fullStart); node.keywordToken = 93 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); @@ -20484,7 +20900,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(190 /* PropertyAccessExpression */, expression.pos); + var node = createNode(191 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -20493,8 +20909,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 263 /* JsxOpeningElement */) { - var node = createNode(261 /* JsxElement */, opening.pos); + if (opening.kind === 264 /* JsxOpeningElement */) { + var node = createNode(262 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -20503,15 +20919,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 266 /* JsxOpeningFragment */) { - var node = createNode(265 /* JsxFragment */, opening.pos); + else if (opening.kind === 267 /* JsxOpeningFragment */) { + var node = createNode(266 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 262 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 263 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -20526,7 +20942,7 @@ var ts; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(205 /* BinaryExpression */, result.pos); + var badNode = createNode(206 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -20585,7 +21001,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(269 /* JsxAttributes */); + var jsxAttributes = createNode(270 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -20594,7 +21010,7 @@ var ts; parseExpected(28 /* LessThanToken */); if (token() === 30 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(266 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(267 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -20606,7 +21022,7 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(263 /* JsxOpeningElement */, fullStart); + node = createNode(264 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -20618,7 +21034,7 @@ var ts; parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(262 /* JsxSelfClosingElement */, fullStart); + node = createNode(263 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -20635,7 +21051,7 @@ var ts; var expression = token() === 101 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(191 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -20643,7 +21059,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(271 /* JsxExpression */); + var node = createNode(272 /* JsxExpression */); if (!parseExpected(18 /* OpenBraceToken */)) { return undefined; } @@ -20669,7 +21085,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(268 /* JsxAttribute */); + var node = createNode(269 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 60 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -20684,7 +21100,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(270 /* JsxSpreadAttribute */); + var node = createNode(271 /* JsxSpreadAttribute */); parseExpected(18 /* OpenBraceToken */); parseExpected(25 /* DotDotDotToken */); node.expression = parseExpression(); @@ -20692,7 +21108,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(264 /* JsxClosingElement */); + var node = createNode(265 /* JsxClosingElement */); parseExpected(29 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -20705,7 +21121,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(267 /* JsxClosingFragment */); + var node = createNode(268 /* JsxClosingFragment */); parseExpected(29 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -20720,7 +21136,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(195 /* TypeAssertionExpression */); + var node = createNode(196 /* TypeAssertionExpression */); parseExpected(28 /* LessThanToken */); node.type = parseType(); parseExpected(30 /* GreaterThanToken */); @@ -20731,7 +21147,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(24 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(191 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -20739,14 +21155,14 @@ var ts; } if (token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(214 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(215 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(22 /* OpenBracketToken */)) { - var indexedAccess = createNode(191 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(192 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; if (token() === 23 /* CloseBracketToken */) { indexedAccess.argumentExpression = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); @@ -20773,7 +21189,7 @@ var ts; return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(194 /* TaggedTemplateExpression */, tag.pos); + var tagExpression = createNode(195 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 14 /* NoSubstitutionTemplateLiteral */ @@ -20798,7 +21214,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(192 /* CallExpression */, expression.pos); + var callExpr = createNode(193 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -20806,7 +21222,7 @@ var ts; continue; } else if (token() === 20 /* OpenParenToken */) { - var callExpr = createNode(192 /* CallExpression */, expression.pos); + var callExpr = createNode(193 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -20844,6 +21260,7 @@ var ts; case 15 /* TemplateHead */: // foo `...${100}...` // these are the only tokens can legally follow a type argument // list. So we definitely want to treat them as type arg lists. + // falls through case 24 /* DotToken */: // foo. case 21 /* CloseParenToken */: // foo) case 23 /* CloseBracketToken */: // foo] @@ -20870,6 +21287,7 @@ var ts; // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. + // falls through default: // Anything else treat as an expression. return false; @@ -20920,28 +21338,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(196 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(197 /* ParenthesizedExpression */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(209 /* SpreadElement */); + var node = createNode(210 /* SpreadElement */); parseExpected(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? createNode(211 /* OmittedExpression */) : + token() === 27 /* CommaToken */ ? createNode(212 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(188 /* ArrayLiteralExpression */); + var node = createNode(189 /* ArrayLiteralExpression */); parseExpected(22 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -20953,17 +21371,17 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(25 /* DotDotDotToken */)) { - node.kind = 278 /* SpreadAssignment */; + node.kind = 279 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + return parseAccessorDeclaration(node, 160 /* GetAccessor */); } if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + return parseAccessorDeclaration(node, 161 /* SetAccessor */); } var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); @@ -20981,7 +21399,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 57 /* ColonToken */); if (isShorthandPropertyAssignment) { - node.kind = 277 /* ShorthandPropertyAssignment */; + node.kind = 278 /* ShorthandPropertyAssignment */; var equalsToken = parseOptionalToken(60 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; @@ -20989,14 +21407,14 @@ var ts; } } else { - node.kind = 276 /* PropertyAssignment */; + node.kind = 277 /* PropertyAssignment */; parseExpected(57 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(189 /* ObjectLiteralExpression */); + var node = createNode(190 /* ObjectLiteralExpression */); parseExpected(18 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21015,7 +21433,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(197 /* FunctionExpression */); + var node = createNodeWithJSDoc(198 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(91 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); @@ -21040,7 +21458,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(96 /* NewKeyword */); if (parseOptional(24 /* DotToken */)) { - var node_2 = createNode(215 /* MetaProperty */, fullStart); + var node_2 = createNode(216 /* MetaProperty */, fullStart); node_2.keywordToken = 96 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -21057,7 +21475,7 @@ var ts; } break; } - var node = createNode(193 /* NewExpression */, fullStart); + var node = createNode(194 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 20 /* OpenParenToken */) { @@ -21067,7 +21485,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(219 /* Block */); + var node = createNode(220 /* Block */); if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21100,12 +21518,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(221 /* EmptyStatement */); + var node = createNode(222 /* EmptyStatement */); parseExpected(26 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(223 /* IfStatement */); + var node = createNode(224 /* IfStatement */); parseExpected(92 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -21115,7 +21533,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(224 /* DoStatement */); + var node = createNode(225 /* DoStatement */); parseExpected(83 /* DoKeyword */); node.statement = parseStatement(); parseExpected(108 /* WhileKeyword */); @@ -21130,7 +21548,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(225 /* WhileStatement */); + var node = createNode(226 /* WhileStatement */); parseExpected(108 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -21153,8 +21571,8 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(148 /* OfKeyword */) : parseOptional(148 /* OfKeyword */)) { - var forOfStatement = createNode(228 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(149 /* OfKeyword */) : parseOptional(149 /* OfKeyword */)) { + var forOfStatement = createNode(229 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -21162,14 +21580,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(94 /* InKeyword */)) { - var forInStatement = createNode(227 /* ForInStatement */, pos); + var forInStatement = createNode(228 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(226 /* ForStatement */, pos); + var forStatement = createNode(227 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(26 /* SemicolonToken */); if (token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */) { @@ -21187,7 +21605,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 230 /* BreakStatement */ ? 74 /* BreakKeyword */ : 79 /* ContinueKeyword */); + parseExpected(kind === 231 /* BreakStatement */ ? 74 /* BreakKeyword */ : 79 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -21195,7 +21613,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(231 /* ReturnStatement */); + var node = createNode(232 /* ReturnStatement */); parseExpected(98 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -21204,7 +21622,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(232 /* WithStatement */); + var node = createNode(233 /* WithStatement */); parseExpected(109 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -21213,7 +21631,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(272 /* CaseClause */); + var node = createNode(273 /* CaseClause */); parseExpected(75 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(57 /* ColonToken */); @@ -21221,7 +21639,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(273 /* DefaultClause */); + var node = createNode(274 /* DefaultClause */); parseExpected(81 /* DefaultKeyword */); parseExpected(57 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -21231,12 +21649,12 @@ var ts; return token() === 75 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(233 /* SwitchStatement */); + var node = createNode(234 /* SwitchStatement */); parseExpected(100 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - var caseBlock = createNode(247 /* CaseBlock */); + var caseBlock = createNode(248 /* CaseBlock */); parseExpected(18 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(19 /* CloseBraceToken */); @@ -21251,7 +21669,7 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(235 /* ThrowStatement */); + var node = createNode(236 /* ThrowStatement */); parseExpected(102 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -21259,7 +21677,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(236 /* TryStatement */); + var node = createNode(237 /* TryStatement */); parseExpected(104 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 76 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -21272,7 +21690,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(275 /* CatchClause */); + var result = createNode(276 /* CatchClause */); parseExpected(76 /* CatchKeyword */); if (parseOptional(20 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -21286,7 +21704,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(237 /* DebuggerStatement */); + var node = createNode(238 /* DebuggerStatement */); parseExpected(80 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -21298,12 +21716,12 @@ var ts; var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); if (expression.kind === 73 /* Identifier */ && parseOptional(57 /* ColonToken */)) { - node.kind = 234 /* LabeledStatement */; + node.kind = 235 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 222 /* ExpressionStatement */; + node.kind = 223 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -21425,6 +21843,7 @@ var ts; case 80 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. + // falls through case 76 /* CatchKeyword */: case 89 /* FinallyKeyword */: return true; @@ -21470,16 +21889,16 @@ var ts; case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); case 106 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(239 /* VariableDeclaration */)); case 112 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(239 /* VariableDeclaration */)); } break; case 91 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(240 /* FunctionDeclaration */)); + return parseFunctionDeclaration(createNodeWithJSDoc(241 /* FunctionDeclaration */)); case 77 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(241 /* ClassDeclaration */)); + return parseClassDeclaration(createNodeWithJSDoc(242 /* ClassDeclaration */)); case 92 /* IfKeyword */: return parseIfStatement(); case 83 /* DoKeyword */: @@ -21489,9 +21908,9 @@ var ts; case 90 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 79 /* ContinueKeyword */: - return parseBreakOrContinueStatement(229 /* ContinueStatement */); + return parseBreakOrContinueStatement(230 /* ContinueStatement */); case 74 /* BreakKeyword */: - return parseBreakOrContinueStatement(230 /* BreakStatement */); + return parseBreakOrContinueStatement(231 /* BreakStatement */); case 98 /* ReturnKeyword */: return parseReturnStatement(); case 109 /* WithKeyword */: @@ -21502,6 +21921,7 @@ var ts; return parseThrowStatement(); case 104 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. + // falls through case 76 /* CatchKeyword */: case 89 /* FinallyKeyword */: return parseTryStatement(); @@ -21537,10 +21957,21 @@ var ts; return modifier.kind === 126 /* DeclareKeyword */; } function parseDeclaration() { + var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); }); + // `parseListElement` attempted to get the reused node at this position, + // but the ambient context flag was not yet set, so the node appeared + // not reusable in that context. + var isAmbient = ts.some(modifiers, isDeclareModifier); + if (isAmbient) { + var node_3 = tryReuseAmbientDeclaration(); + if (node_3) { + return node_3; + } + } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (ts.some(node.modifiers, isDeclareModifier)) { + if (isAmbient) { for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var m = _a[_i]; m.flags |= 4194304 /* Ambient */; @@ -21551,6 +21982,14 @@ var ts; return parseDeclarationWorker(node); } } + function tryReuseAmbientDeclaration() { + return doInsideOfContext(4194304 /* Ambient */, function () { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + }); + } function parseDeclarationWorker(node) { switch (token()) { case 106 /* VarKeyword */: @@ -21588,7 +22027,7 @@ var ts; if (node.decorators || node.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(259 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(260 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -21611,16 +22050,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 27 /* CommaToken */) { - return createNode(211 /* OmittedExpression */); + return createNode(212 /* OmittedExpression */); } - var node = createNode(187 /* BindingElement */); + var node = createNode(188 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(187 /* BindingElement */); + var node = createNode(188 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -21636,14 +22075,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(185 /* ObjectBindingPattern */); + var node = createNode(186 /* ObjectBindingPattern */); parseExpected(18 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(186 /* ArrayBindingPattern */); + var node = createNode(187 /* ArrayBindingPattern */); parseExpected(22 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(23 /* CloseBracketToken */); @@ -21665,7 +22104,7 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(238 /* VariableDeclaration */); + var node = createNode(239 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 73 /* Identifier */ && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { @@ -21678,7 +22117,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(239 /* VariableDeclarationList */); + var node = createNode(240 /* VariableDeclarationList */); switch (token()) { case 106 /* VarKeyword */: break; @@ -21701,7 +22140,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 148 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 149 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -21716,13 +22155,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 220 /* VariableStatement */; + node.kind = 221 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 240 /* FunctionDeclaration */; + node.kind = 241 /* FunctionDeclaration */; parseExpected(91 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); @@ -21746,7 +22185,7 @@ var ts; function tryParseConstructorDeclaration(node) { return tryParse(function () { if (parseConstructorName()) { - node.kind = 158 /* Constructor */; + node.kind = 159 /* Constructor */; fillSignature(57 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); @@ -21754,7 +22193,7 @@ var ts; }); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 157 /* MethodDeclaration */; + node.kind = 158 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; @@ -21763,7 +22202,7 @@ var ts; return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 155 /* PropertyDeclaration */; + node.kind = 156 /* PropertyDeclaration */; if (!node.questionToken && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } @@ -21868,7 +22307,7 @@ var ts; if (!parseOptional(58 /* AtToken */)) { break; } - var decorator = createNode(153 /* Decorator */, decoratorStart); + var decorator = createNode(154 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -21918,7 +22357,7 @@ var ts; } function parseClassElement() { if (token() === 26 /* SemicolonToken */) { - var result = createNode(218 /* SemicolonClassElement */); + var result = createNode(219 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -21926,10 +22365,10 @@ var ts; node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + return parseAccessorDeclaration(node, 160 /* GetAccessor */); } if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + return parseAccessorDeclaration(node, 161 /* SetAccessor */); } if (token() === 125 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(node); @@ -21958,10 +22397,10 @@ var ts; return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 210 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 211 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 241 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 242 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -22004,22 +22443,21 @@ var ts; function parseHeritageClause() { var tok = token(); ts.Debug.assert(tok === 87 /* ExtendsKeyword */ || tok === 110 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(274 /* HeritageClause */); + var node = createNode(275 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(213 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 28 /* LessThanToken */ - ? parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) - : undefined; + return token() === 28 /* LessThanToken */ ? + parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) : undefined; } function isHeritageClause() { return token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; @@ -22028,7 +22466,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 242 /* InterfaceDeclaration */; + node.kind = 243 /* InterfaceDeclaration */; parseExpected(111 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -22037,7 +22475,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 243 /* TypeAliasDeclaration */; + node.kind = 244 /* TypeAliasDeclaration */; parseExpected(141 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -22051,13 +22489,13 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNodeWithJSDoc(279 /* EnumMember */); + var node = createNodeWithJSDoc(280 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 244 /* EnumDeclaration */; + node.kind = 245 /* EnumDeclaration */; parseExpected(85 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(18 /* OpenBraceToken */)) { @@ -22070,7 +22508,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(246 /* ModuleBlock */); + var node = createNode(247 /* ModuleBlock */); if (parseExpected(18 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(19 /* CloseBraceToken */); @@ -22081,7 +22519,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 245 /* ModuleDeclaration */; + node.kind = 246 /* ModuleDeclaration */; // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -22093,7 +22531,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 245 /* ModuleDeclaration */; + node.kind = 246 /* ModuleDeclaration */; if (token() === 146 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); @@ -22139,7 +22577,7 @@ var ts; return nextToken() === 42 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 248 /* NamespaceExportDeclaration */; + node.kind = 249 /* NamespaceExportDeclaration */; parseExpected(120 /* AsKeyword */); parseExpected(132 /* NamespaceKeyword */); node.name = parseIdentifier(); @@ -22157,7 +22595,7 @@ var ts; } } // Import statement - node.kind = 250 /* ImportDeclaration */; + node.kind = 251 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; @@ -22172,7 +22610,7 @@ var ts; return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 249 /* ImportEqualsDeclaration */; + node.kind = 250 /* ImportEqualsDeclaration */; node.name = identifier; parseExpected(60 /* EqualsToken */); node.moduleReference = parseModuleReference(); @@ -22186,7 +22624,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(251 /* ImportClause */, fullStart); + var importClause = createNode(252 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -22196,7 +22634,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(27 /* CommaToken */)) { - importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(253 /* NamedImports */); + importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(254 /* NamedImports */); } return finishNode(importClause); } @@ -22206,7 +22644,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(260 /* ExternalModuleReference */); + var node = createNode(261 /* ExternalModuleReference */); parseExpected(135 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -22229,7 +22667,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(252 /* NamespaceImport */); + var namespaceImport = createNode(253 /* NamespaceImport */); parseExpected(40 /* AsteriskToken */); parseExpected(120 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -22244,14 +22682,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 253 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); + node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 254 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(258 /* ExportSpecifier */); + return parseImportOrExportSpecifier(259 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(254 /* ImportSpecifier */); + return parseImportOrExportSpecifier(255 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -22276,19 +22714,19 @@ var ts; else { node.name = identifierName; } - if (kind === 254 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 255 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 256 /* ExportDeclaration */; + node.kind = 257 /* ExportDeclaration */; if (parseOptional(40 /* AsteriskToken */)) { parseExpected(145 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(257 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(258 /* 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. @@ -22301,7 +22739,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 255 /* ExportAssignment */; + node.kind = 256 /* ExportAssignment */; if (parseOptional(60 /* EqualsToken */)) { node.isExportEquals = true; } @@ -22321,12 +22759,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */ - || node.kind === 250 /* ImportDeclaration */ - || node.kind === 255 /* ExportAssignment */ - || node.kind === 256 /* ExportDeclaration */ - ? node - : undefined; + || node.kind === 250 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 261 /* ExternalModuleReference */ + || node.kind === 251 /* ImportDeclaration */ + || node.kind === 256 /* ExportAssignment */ + || node.kind === 257 /* ExportDeclaration */ ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { return sourceFile.flags & 1048576 /* PossiblyContainsImportMeta */ ? @@ -22388,7 +22824,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(289 /* JSDocTypeExpression */); + var result = createNode(290 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -22400,8 +22836,8 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseIsolatedJSDocComment(content, start, length) { initializeState(content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = { languageVariant: 0 /* Standard */, text: content }; // tslint:disable-line no-object-literal-type-assertion - var jsDoc = parseJSDocCommentWorker(start, length); + sourceFile = { languageVariant: 0 /* Standard */, text: content }; + var jsDoc = doInsideOfContext(2097152 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); var diagnostics = parseDiagnostics; clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -22412,7 +22848,7 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = parseJSDocCommentWorker(start, length); + var comment = doInsideOfContext(2097152 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); if (comment) { comment.parent = parent; } @@ -22551,7 +22987,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(297 /* JSDocComment */, start); + var result = createNode(299 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -22751,7 +23187,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(300 /* JSDocTag */, start); + var result = createNode(302 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -22798,7 +23234,7 @@ var ts; switch (node.kind) { case 137 /* ObjectKeyword */: return true; - case 170 /* ArrayType */: + case 171 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -22814,8 +23250,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(312 /* JSDocPropertyTag */, start) : - createNode(306 /* JSDocParameterTag */, start); + createNode(314 /* JSDocPropertyTag */, start) : + createNode(308 /* JSDocParameterTag */, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -22832,20 +23268,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(289 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(290 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; - var start_2 = scanner.getStartPos(); + var start_3 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 306 /* JSDocParameterTag */ || child.kind === 312 /* JSDocPropertyTag */) { + if (child.kind === 308 /* JSDocParameterTag */ || child.kind === 314 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(298 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(300 /* JSDocTypeLiteral */, start_3); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression.type.kind === 171 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -22857,7 +23293,7 @@ var ts; if (ts.some(tags, ts.isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(307 /* JSDocReturnTag */, start); + var result = createNode(309 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); @@ -22866,13 +23302,13 @@ var ts; if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(309 /* JSDocTypeTag */, start); + var result = createNode(311 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAuthorTag(start, tagName, indent) { - var result = createNode(302 /* JSDocAuthorTag */, start); + var result = createNode(304 /* JSDocAuthorTag */, start); result.tagName = tagName; var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); }); if (!authorInfoWithEmail) { @@ -22926,14 +23362,14 @@ var ts; } } function parseAugmentsTag(start, tagName) { - var result = createNode(301 /* JSDocAugmentsTag */, start); + var result = createNode(303 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18 /* OpenBraceToken */); - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(213 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -22945,7 +23381,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var prop = createNode(190 /* PropertyAccessExpression */, node.pos); + var prop = createNode(191 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -22953,19 +23389,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(303 /* JSDocClassTag */, start); + var tag = createNode(305 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(308 /* JSDocThisTag */, start); + var tag = createNode(310 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(305 /* JSDocEnumTag */, start); + var tag = createNode(307 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); @@ -22974,7 +23410,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(311 /* JSDocTypedefTag */, start); + var typedefTag = createNode(313 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -22988,9 +23424,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(298 /* JSDocTypeLiteral */, start); + jsdocTypeLiteral = createNode(300 /* JSDocTypeLiteral */, start); } - if (child.kind === 309 /* JSDocTypeTag */) { + if (child.kind === 311 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -23003,7 +23439,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 171 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -23022,7 +23458,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(24 /* DotToken */)) { - var jsDocNamespaceNode = createNode(245 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(246 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -23036,14 +23472,14 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(304 /* JSDocCallbackTag */, start); + var callbackTag = createNode(306 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(299 /* JSDocSignature */, start); + var jsdocSignature = createNode(301 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -23051,7 +23487,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(58 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 307 /* JSDocReturnTag */) { + if (tag && tag.kind === 309 /* JSDocReturnTag */) { return tag; } } @@ -23096,7 +23532,7 @@ var ts; case 58 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 306 /* JSDocParameterTag */ || child.kind === 312 /* JSDocPropertyTag */) && + if (child && (child.kind === 308 /* JSDocParameterTag */ || child.kind === 314 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -23160,13 +23596,13 @@ var ts; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(151 /* TypeParameter */); + var typeParameter = createNode(152 /* TypeParameter */); typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); finishNode(typeParameter); skipWhitespace(); typeParameters.push(typeParameter); } while (parseOptionalJsdoc(27 /* CommaToken */)); - var result = createNode(310 /* JSDocTemplateTag */, start); + var result = createNode(312 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -23201,16 +23637,19 @@ var ts; if (!ts.tokenIsIdentifierOrKeyword(token())) { return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } + identifierCount++; var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); var result = createNode(73 /* Identifier */, pos); - result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); + if (token() !== 73 /* Identifier */) { + result.originalKeywordKind = token(); + } + result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); finishNode(result, end); nextTokenJSDoc(); return result; } } - JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {})); })(Parser || (Parser = {})); var IncrementalParser; @@ -24056,6 +24495,7 @@ var ts; type: "boolean", category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_incremental_compilation, + transpileOptionValue: undefined }, { name: "locale", @@ -24065,7 +24505,7 @@ var ts; }, ]; /* @internal */ - ts.optionDeclarations = ts.commonOptionsWithBuild.concat([ + ts.optionDeclarations = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "all", type: "boolean", @@ -24167,7 +24607,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation + description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation, + transpileOptionValue: undefined }, { name: "allowJs", @@ -24204,6 +24645,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "declarationMap", @@ -24212,6 +24654,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "emitDeclarationOnly", @@ -24219,6 +24662,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Only_emit_d_ts_declaration_files, + transpileOptionValue: undefined }, { name: "sourceMap", @@ -24237,6 +24681,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "outDir", @@ -24264,6 +24709,7 @@ var ts; isTSConfigOnly: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_project_compilation, + transpileOptionValue: undefined }, { name: "tsBuildInfoFile", @@ -24273,6 +24719,7 @@ var ts; paramType: ts.Diagnostics.FILE, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, + transpileOptionValue: undefined }, { name: "removeComments", @@ -24289,6 +24736,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Do_not_emit_outputs, + transpileOptionValue: undefined }, { name: "importHelpers", @@ -24308,7 +24756,8 @@ var ts; name: "isolatedModules", type: "boolean", category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule + description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule, + transpileOptionValue: true }, // Strict Type Checks { @@ -24442,7 +24891,8 @@ var ts; affectsModuleResolution: true, isTSConfigOnly: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl + description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl, + transpileOptionValue: undefined }, { // this option can only be specified in tsconfig.json @@ -24457,7 +24907,8 @@ var ts; }, affectsModuleResolution: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime + description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime, + transpileOptionValue: undefined }, { name: "typeRoots", @@ -24481,7 +24932,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation, + transpileOptionValue: undefined }, { name: "allowSyntheticDefaultImports", @@ -24578,6 +25030,7 @@ var ts; category: ts.Diagnostics.Advanced_Options, paramType: ts.Diagnostics.FILE, description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "reactNamespace", @@ -24627,14 +25080,20 @@ var ts; type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts + description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts, + // We are not returning a sourceFile for lib file when asked by the program, + // so pass --noLib to avoid reporting a file not found error. + transpileOptionValue: true }, { name: "noResolve", type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files + description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files, + // We are not doing a full typecheck, we are not resolving the whole context, + // so pass --noResolve to avoid reporting missing file errors. + transpileOptionValue: true }, { name: "stripInternal", @@ -24670,6 +25129,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + transpileOptionValue: undefined }, { name: "preserveConstEnums", @@ -24685,7 +25145,8 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Output_directory_for_generated_declaration_files + description: ts.Diagnostics.Output_directory_for_generated_declaration_files, + transpileOptionValue: undefined }, { name: "skipLibCheck", @@ -24772,7 +25233,11 @@ var ts; return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics; }); /* @internal */ - ts.buildOpts = ts.commonOptionsWithBuild.concat([ + ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) { + return ts.hasProperty(option, "transpileOptionValue"); + }); + /* @internal */ + ts.buildOpts = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "verbose", shortName: "v", @@ -25336,7 +25801,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 276 /* PropertyAssignment */) { + if (element.kind !== 277 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -25400,7 +25865,7 @@ var ts; return false; case 97 /* NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for - return null; // tslint:disable-line:no-null-keyword + return null; // eslint-disable-line no-null/no-null case 10 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); @@ -25418,13 +25883,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: if (valueExpression.operator !== 39 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -25441,7 +25906,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25492,13 +25957,13 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName); }); var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames }); - var config = __assign({ compilerOptions: __assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { + var config = __assign(__assign({ compilerOptions: __assign(__assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { var _a; - return (__assign({}, prev, (_a = {}, _a[cur[0]] = cur[1], _a))); - }, {}), { showConfig: undefined, configFile: undefined, configFilePath: undefined, help: undefined, init: undefined, listFiles: undefined, listEmittedFiles: undefined, project: undefined, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign({}, r, { path: r.originalPath, originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { + return (__assign(__assign({}, prev), (_a = {}, _a[cur[0]] = cur[1], _a))); + }, {})), { showConfig: undefined, configFile: undefined, configFilePath: undefined, help: undefined, init: undefined, listFiles: undefined, listEmittedFiles: undefined, project: undefined, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign(__assign({}, r), { path: r.originalPath ? r.originalPath : "", originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs), exclude: configParseResult.configFileSpecs.validatedExcludeSpecs - } : {}), { compilerOnSave: !!configParseResult.compileOnSave ? true : undefined }); + } : {})), { compileOnSave: !!configParseResult.compileOnSave ? true : undefined }); return config; } ts.convertToTSConfig = convertToTSConfig; @@ -25723,8 +26188,7 @@ var ts; } ts.setConfigFileInOptions = setConfigFileInOptions; function isNullOrUndefined(x) { - // tslint:disable-next-line:no-null-keyword - return x === undefined || x === null; + return x === undefined || x === null; // eslint-disable-line no-null/no-null } function directoryOfCombinedPath(fileName, basePath) { // Use the `getNormalizedAbsolutePath` function to avoid canonicalizing the path, as it must remain noncanonical @@ -25890,7 +26354,7 @@ var ts; basePath = ts.normalizeSlashes(basePath); var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath); if (resolutionStack.indexOf(resolvedPath) >= 0) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))); + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, __spreadArrays(resolutionStack, [resolvedPath]).join(" -> "))); return { raw: json || convertToObject(sourceFile, errors) }; } var ownConfig = json ? @@ -26579,8 +27043,9 @@ var ts; return; } var value = jsonContent[fieldName]; - if (typeof value !== typeOfTag || value === null) { + if (typeof value !== typeOfTag || value === null) { // eslint-disable-line no-null/no-null if (state.traceEnabled) { + // eslint-disable-next-line no-null/no-null trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, fieldName, typeOfTag, value === null ? "null" : typeof value); } return; @@ -26839,7 +27304,7 @@ var ts; var packageJsonPath = ts.combinePaths(root, normalized, "package.json"); // `types-publisher` sometimes creates packages with `"typings": null` for packages that don't provide their own types. // See `createNotNeededPackageJSON` in the types-publisher` repo. - // tslint:disable-next-line:no-null-keyword + // eslint-disable-next-line no-null/no-null var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); @@ -27023,6 +27488,7 @@ var ts; trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); } } + ts.perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/); switch (moduleResolution) { case ts.ModuleResolutionKind.NodeJs: result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); @@ -27033,6 +27499,9 @@ var ts; default: return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); } + if (result && result.resolvedModule) + ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, result); if (!ts.isExternalModuleNameRelative(moduleName)) { @@ -27242,7 +27711,7 @@ var ts; ts.tryResolveJSModule = tryResolveJSModule; var jsOnlyExtensions = [Extensions.JavaScript]; var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript]; - var tsPlusJsonExtensions = tsExtensions.concat([Extensions.Json]); + var tsPlusJsonExtensions = __spreadArrays(tsExtensions, [Extensions.Json]); var tsconfigExtensions = [Extensions.TSConfig]; function tryResolveJSModuleWorker(moduleName, initialDir, host) { return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); @@ -27278,7 +27747,7 @@ var ts; if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) { var path = realPath(resolvedValue.path, host, traceEnabled); var originalPath = path === resolvedValue.path ? undefined : resolvedValue.path; - resolvedValue = __assign({}, resolvedValue, { path: path, originalPath: originalPath }); + resolvedValue = __assign(__assign({}, resolvedValue), { path: path, originalPath: originalPath }); } // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } }; @@ -27299,7 +27768,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); // tslint:disable-line + ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -27787,24 +28256,24 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. other uninstantiated module declarations. - case 246 /* ModuleBlock */: { + case 247 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -27826,7 +28295,7 @@ var ts; }); return state_1; } - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return getModuleInstanceState(node); case 73 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should @@ -27865,7 +28334,9 @@ var ts; var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); + ts.perfLogger.logStartBindFile("" + file.fileName); binder(file, options); + ts.perfLogger.logStopBindFile(); ts.performance.mark("afterBind"); ts.performance.measure("Bind", "beforeBind", "afterBind"); } @@ -27899,7 +28370,7 @@ var ts; // or if compiler options contain alwaysStrict. var inStrictMode; var symbolCount = 0; - var Symbol; // tslint:disable-line variable-name + var Symbol; var classifiableNames; var unreachableFlow = { flags: 1 /* Unreachable */ }; var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; @@ -27967,7 +28438,7 @@ var ts; function addDeclarationToSymbol(symbol, node, symbolFlags) { symbol.flags |= symbolFlags; node.symbol = symbol; - symbol.declarations = ts.append(symbol.declarations, node); + symbol.declarations = ts.appendIfUnique(symbol.declarations, node); if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -27978,7 +28449,7 @@ var ts; if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 67220415 /* Value */) { + if (symbolFlags & 111551 /* Value */) { setValueDeclaration(symbol, node); } } @@ -27994,7 +28465,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 === 255 /* ExportAssignment */) { + if (node.kind === 256 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -28003,7 +28474,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 151 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -28018,36 +28489,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: return "__constructor" /* Constructor */; - case 166 /* FunctionType */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: + case 167 /* FunctionType */: + case 162 /* CallSignature */: + case 301 /* JSDocSignature */: return "__call" /* Call */; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 168 /* ConstructorType */: + case 163 /* ConstructSignature */: return "__new" /* New */; - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: return "__index" /* Index */; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 285 /* SourceFile */: + case 286 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 152 /* Parameter */: + case 153 /* 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 === 295 /* 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 === 296 /* 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; @@ -28147,7 +28618,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 === 255 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 256 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -28165,7 +28636,7 @@ var ts; } }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); - file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInformation_1)) : diag); + file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInformation_1)) : diag); symbol = createSymbol(0 /* None */, name); } } @@ -28182,7 +28653,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 258 /* ExportSpecifier */ || (node.kind === 249 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 259 /* ExportSpecifier */ || (node.kind === 250 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -28207,10 +28678,10 @@ var ts; if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { - if (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node)) { + if (!container.locals || (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } - var exportKind = symbolFlags & 67220415 /* Value */ ? 1048576 /* ExportValue */ : 0; + var exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -28249,7 +28720,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 !== 198 /* ArrowFunction */) { + if (node.kind !== 199 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -28282,7 +28753,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 === 158 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 159 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -28296,13 +28767,13 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 158 /* Constructor */) { + if (node.kind === 159 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -28346,8 +28817,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 241 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 241 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -28380,78 +28851,82 @@ var ts; return; } switch (node.kind) { - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: bindWhileStatement(node); break; - case 224 /* DoStatement */: + case 225 /* DoStatement */: bindDoStatement(node); break; - case 226 /* ForStatement */: + case 227 /* ForStatement */: bindForStatement(node); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 223 /* IfStatement */: + case 224 /* IfStatement */: bindIfStatement(node); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 232 /* ReturnStatement */: + case 236 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 236 /* TryStatement */: + case 237 /* TryStatement */: bindTryStatement(node); break; - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: bindSwitchStatement(node); break; - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: bindCaseBlock(node); break; - case 272 /* CaseClause */: + case 273 /* CaseClause */: bindCaseClause(node); break; - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: bindLabeledStatement(node); break; - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 192 /* CallExpression */: + case 193 /* CallExpression */: bindCallExpressionFlow(node); break; - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; + case 305 /* JSDocClassTag */: + bindJSDocClassTag(node); + break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 285 /* SourceFile */: { + case 286 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 220 /* Block */: + case 247 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -28464,18 +28939,18 @@ var ts; switch (expr.kind) { case 73 /* Identifier */: case 101 /* ThisKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return isNarrowableReference(expr); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return hasNarrowableArgument(expr); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return expr.operator === 52 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; @@ -28483,7 +28958,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 73 /* Identifier */ || expr.kind === 101 /* ThisKeyword */ || expr.kind === 99 /* SuperKeyword */ || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isElementAccessExpression(expr) && expr.argumentExpression && + ts.isElementAccessExpression(expr) && (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && isNarrowableReference(expr.expression); } @@ -28496,7 +28971,7 @@ var ts; } } } - if (expr.expression.kind === 190 /* PropertyAccessExpression */ && + if (expr.expression.kind === 191 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -28529,9 +29004,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 60 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -28609,33 +29084,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 224 /* IfStatement */: + case 226 /* WhileStatement */: + case 225 /* DoStatement */: return parent.expression === node; - case 226 /* ForStatement */: - case 206 /* ConditionalExpression */: + case 227 /* ForStatement */: + case 207 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 196 /* ParenthesizedExpression */) { + if (node.kind === 197 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 203 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { + else if (node.kind === 204 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 205 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || + return node.kind === 206 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 55 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */ || - node.parent.kind === 203 /* PrefixUnaryExpression */ && + while (node.parent.kind === 197 /* ParenthesizedExpression */ || + node.parent.kind === 204 /* PrefixUnaryExpression */ && node.parent.operator === 52 /* ExclamationToken */) { node = node.parent; } @@ -28677,7 +29152,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 234 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 235 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -28711,13 +29186,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 228 /* ForOfStatement */) { + if (node.kind === 229 /* ForOfStatement */) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 239 /* VariableDeclarationList */) { + if (node.initializer.kind !== 240 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -28739,7 +29214,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 231 /* ReturnStatement */) { + if (node.kind === 232 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -28759,7 +29234,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 230 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 231 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -28887,7 +29362,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 273 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 274 /* 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). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -28954,14 +29429,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 224 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 225 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */) { + if (node.kind === 206 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -28972,10 +29447,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 188 /* ArrayLiteralExpression */) { + else if (node.kind === 189 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 209 /* SpreadElement */) { + if (e.kind === 210 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -28983,16 +29458,16 @@ var ts; } } } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 190 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 276 /* PropertyAssignment */) { + if (p.kind === 277 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 277 /* ShorthandPropertyAssignment */) { + else if (p.kind === 278 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 278 /* SpreadAssignment */) { + else if (p.kind === 279 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -29048,7 +29523,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 60 /* EqualsToken */ && node.left.kind === 191 /* ElementAccessExpression */) { + if (operator === 60 /* EqualsToken */ && node.left.kind === 192 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29059,7 +29534,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + if (node.expression.kind === 191 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -29098,19 +29573,26 @@ var ts; } function bindJSDocTypeAlias(node) { node.tagName.parent = node; - if (node.fullName) { + if (node.kind !== 307 /* JSDocEnumTag */ && node.fullName) { setParentPointers(node, node.fullName); } } + function bindJSDocClassTag(node) { + bindEachChild(node); + var host = ts.getHostSignatureFromJSDoc(node); + if (host && host.kind !== 158 /* MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* Class */); + } + } function bindCallExpressionFlow(node) { // If the target of the call expression is a function expression or arrow function we have // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = node.expression; - while (expr.kind === 196 /* ParenthesizedExpression */) { + while (expr.kind === 197 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 197 /* FunctionExpression */ || expr.kind === 198 /* ArrowFunction */) { + if (expr.kind === 198 /* FunctionExpression */ || expr.kind === 199 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -29118,7 +29600,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + if (node.expression.kind === 191 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29127,54 +29609,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 269 /* JsxAttributes */: + case 211 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 190 /* ObjectLiteralExpression */: + case 170 /* TypeLiteral */: + case 300 /* JSDocTypeLiteral */: + case 270 /* JsxAttributes */: return 1 /* IsContainer */; - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 246 /* ModuleDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 183 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 285 /* SourceFile */: + case 286 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: - case 295 /* JSDocFunctionType */: - case 166 /* FunctionType */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 167 /* ConstructorType */: + case 159 /* Constructor */: + case 241 /* FunctionDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 162 /* CallSignature */: + case 301 /* JSDocSignature */: + case 296 /* JSDocFunctionType */: + case 167 /* FunctionType */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 168 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 275 /* CatchClause */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 247 /* CaseBlock */: + case 276 /* CatchClause */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 248 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 219 /* Block */: + case 220 /* 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 @@ -29207,45 +29689,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 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 285 /* SourceFile */: + case 286 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 242 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 189 /* ObjectLiteralExpression */: - case 242 /* InterfaceDeclaration */: - case 269 /* JsxAttributes */: + case 170 /* TypeLiteral */: + case 300 /* JSDocTypeLiteral */: + case 190 /* ObjectLiteralExpression */: + case 243 /* InterfaceDeclaration */: + case 270 /* 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 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 299 /* JSDocSignature */: - case 163 /* IndexSignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 295 /* JSDocFunctionType */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 301 /* JSDocSignature */: + case 164 /* IndexSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 296 /* JSDocFunctionType */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 244 /* TypeAliasDeclaration */: + case 183 /* 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 @@ -29346,7 +29828,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */ || prop.name.kind !== 73 /* Identifier */) { + if (prop.kind === 279 /* SpreadAssignment */ || prop.name.kind !== 73 /* Identifier */) { continue; } var identifier = prop.name; @@ -29358,7 +29840,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 === 276 /* PropertyAssignment */ || prop.kind === 277 /* ShorthandPropertyAssignment */ || prop.kind === 157 /* MethodDeclaration */ + var currentKind = prop.kind === 277 /* PropertyAssignment */ || prop.kind === 278 /* ShorthandPropertyAssignment */ || prop.kind === 158 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -29390,10 +29872,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -29424,9 +29906,37 @@ var ts; currentFlow = { flags: 2 /* Start */ }; parent = typeAlias; bind(typeAlias.typeExpression); - if (!typeAlias.fullName || typeAlias.fullName.kind === 73 /* Identifier */) { + var declName = ts.getNameOfDeclaration(typeAlias); + if ((ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName) && declName && ts.isPropertyAccessEntityNameExpression(declName.parent)) { + // typedef anchored to an A.B.C assignment - we need to bind into B's namespace under name C + var isTopLevel = isTopLevelNamespaceAssignment(declName.parent); + if (isTopLevel) { + bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); + var oldContainer = container; + switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { + case 1 /* ExportsProperty */: + case 2 /* ModuleExports */: + container = file; + break; + case 4 /* ThisProperty */: + container = declName.parent.expression; + break; + case 3 /* PrototypeProperty */: + container = declName.parent.expression.name; + break; + case 5 /* Property */: + container = ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; + break; + case 0 /* None */: + return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); + } + declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + container = oldContainer; + } + } + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 73 /* Identifier */) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); } else { bind(typeAlias.fullName); @@ -29445,7 +29955,8 @@ var ts; node.originalKeywordKind >= 110 /* FirstFutureReservedWord */ && node.originalKeywordKind <= 118 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && - !(node.flags & 4194304 /* Ambient */)) { + !(node.flags & 4194304 /* Ambient */) && + !(node.flags & 2097152 /* JSDoc */)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -29531,8 +30042,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 285 /* SourceFile */ && - blockScopeContainer.kind !== 245 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 286 /* SourceFile */ && + blockScopeContainer.kind !== 246 /* 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. @@ -29593,7 +30104,7 @@ var ts; file.bindDiagnostics.push(diag); } else { - file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } } function bind(node) { @@ -29627,7 +30138,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 > 148 /* LastToken */) { + if (node.kind > 149 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -29698,17 +30209,17 @@ var ts; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); break; } // falls through case 101 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 277 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 278 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -29719,10 +30230,10 @@ var ts; file.commonJsModuleIndicator && ts.isModuleExportsPropertyAccessExpression(node) && !lookupSymbolForNameWorker(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 67220414 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -29750,76 +30261,76 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return checkStrictModeCatchClause(node); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return checkStrictModeWithStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 179 /* ThisType */: + case 180 /* ThisType */: seenThisKeyword = true; return; - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: break; // Binding the children will handle everything - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return bindTypeParameter(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return bindParameter(node); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 187 /* BindingElement */: + case 188 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return bindPropertyWorker(node); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 279 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 280 /* EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* 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 */ : 67212223 /* MethodExcludes */); - case 240 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); + case 241 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 158 /* Constructor */: + case 159 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 159 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 67154879 /* GetAccessorExcludes */); - case 160 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67187647 /* SetAccessorExcludes */); - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 299 /* JSDocSignature */: - case 167 /* ConstructorType */: + case 160 /* GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); + case 161 /* SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); + case 167 /* FunctionType */: + case 296 /* JSDocFunctionType */: + case 301 /* JSDocSignature */: + case 168 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 182 /* MappedType */: + case 170 /* TypeLiteral */: + case 300 /* JSDocTypeLiteral */: + case 183 /* MappedType */: return bindAnonymousTypeWorker(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return bindFunctionExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -29838,64 +30349,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 242 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 242 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 67897736 /* InterfaceExcludes */); - case 243 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); - case 244 /* EnumDeclaration */: + case 243 /* InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); + case 244 /* TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + case 245 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return bindJsxAttributes(node); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 250 /* ImportEqualsDeclaration */: + case 253 /* NamespaceImport */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return bindImportClause(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return bindExportDeclaration(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return bindExportAssignment(node); - case 285 /* SourceFile */: + case 286 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 219 /* Block */: + case 220 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 306 /* JSDocParameterTag */: - if (node.parent.kind === 299 /* JSDocSignature */) { + case 308 /* JSDocParameterTag */: + if (node.parent.kind === 301 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 298 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 300 /* JSDocTypeLiteral */) { break; } // falls through - case 312 /* JSDocPropertyTag */: + case 314 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 294 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 295 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -30039,8 +30551,8 @@ var ts; ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 198 /* 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 === 60 /* EqualsToken */) { @@ -30054,26 +30566,27 @@ var ts; constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable(); // It's acceptable for multiple 'this' assignments of the same identifier to occur declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 159 /* Constructor */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 285 /* SourceFile */: + case 286 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220414 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); } break; default: @@ -30084,7 +30597,7 @@ var ts; if (node.expression.kind === 101 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 285 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 286 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -30098,7 +30611,7 @@ var ts; node.left.parent = node; node.right.parent = node; var lhs = node.left; - bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false); + bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false, /*containerIsClass*/ true); } function bindObjectDefinePrototypeProperty(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); @@ -30117,12 +30630,12 @@ var ts; lhs.parent = parent; constructorFunction.parent = classPrototype; classPrototype.parent = lhs; - bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true); + bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true, /*containerIsClass*/ true); } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); + var isToplevel = node.parent.parent.kind === 286 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } function bindSpecialPropertyAssignment(node) { @@ -30151,10 +30664,10 @@ var ts; */ function bindStaticPropertyAssignment(node) { node.expression.parent = node; - bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } - function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { - if (isToplevel && !isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */))) { + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { + if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* Assignment */; var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; @@ -30170,6 +30683,9 @@ var ts; } }); } + if (containerIsClass && namespaceSymbol) { + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + } return namespaceSymbol; } function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { @@ -30182,15 +30698,18 @@ var ts; (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); var includes = isMethod ? 8192 /* Method */ : 4 /* Property */; - var excludes = isMethod ? 67212223 /* MethodExcludes */ : 0 /* PropertyExcludes */; + var excludes = isMethod ? 103359 /* MethodExcludes */ : 0 /* PropertyExcludes */; declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + function isTopLevelNamespaceAssignment(propertyAccess) { + return ts.isBinaryExpression(propertyAccess.parent) + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 286 /* SourceFile */ + : propertyAccess.parent.parent.kind === 286 /* SourceFile */; + } + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); - var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 285 /* SourceFile */ - : propertyAccess.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } /** @@ -30259,8 +30778,8 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 241 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); + if (node.kind === 242 /* ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { var bindingName = node.name ? node.name.escapedText : "__class" /* Class */; @@ -30293,19 +30812,16 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 68008831 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 68008191 /* RegularEnumExcludes */); + ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - var isEnum = ts.isInJSFile(node) && !!ts.getJSDocEnumTag(node); - var enumFlags = (isEnum ? 256 /* RegularEnum */ : 0 /* None */); - var enumExcludes = (isEnum ? 68008191 /* RegularEnumExcludes */ : 0 /* None */); if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */ | enumFlags, 67220415 /* BlockScopedVariableExcludes */ | enumExcludes); + bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); } else if (ts.isParameterDeclaration(node)) { // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration @@ -30317,15 +30833,15 @@ var ts; // function foo([a,a]) {} // Duplicate Identifier error // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter // // which correctly set excluded symbols - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220415 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */ | enumFlags, 67220414 /* FunctionScopedVariableExcludes */ | enumExcludes); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); } } } function bindParameter(node) { - if (node.kind === 306 /* JSDocParameterTag */ && container.kind !== 299 /* JSDocSignature */) { + if (node.kind === 308 /* JSDocParameterTag */ && container.kind !== 301 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -30337,11 +30853,11 @@ var ts; bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220415 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); } // If this is a property-parameter, then also declare the property symbol into the // containing class. - if (ts.isParameterPropertyDeclaration(node)) { + if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); } @@ -30355,10 +30871,10 @@ var ts; checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16 /* Function */, 67219887 /* FunctionExcludes */); + bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 67219887 /* FunctionExcludes */); + declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */); } } function bindFunctionExpression(node) { @@ -30396,26 +30912,26 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 177 /* InferType */) { + else if (node.parent.kind === 178 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } else { bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } // reachability checks @@ -30430,11 +30946,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 221 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 222 /* EmptyStatement */) || // report error on class declarations - node.kind === 241 /* ClassDeclaration */ || + node.kind === 242 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 245 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 246 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -30478,12 +30994,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: return true; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; @@ -30532,58 +31048,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 192 /* CallExpression */: + case 193 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 152 /* Parameter */: + case 153 /* Parameter */: return computeParameter(node, subtreeFlags); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 158 /* Constructor */: + case 159 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -30628,12 +31144,12 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 189 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 190 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ES2018 if they contain rest transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 188 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 189 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } @@ -30681,8 +31197,8 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 213 /* AsExpression */ - || expressionKind === 195 /* TypeAssertionExpression */) { + if (expressionKind === 214 /* AsExpression */ + || expressionKind === 196 /* TypeAssertionExpression */) { transformFlags |= 1 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -31020,13 +31536,13 @@ var ts; var excludeFlags = 536870912 /* NodeExcludes */; switch (kind) { case 122 /* AsyncKeyword */: - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ES2018 syntax (for async generators) transformFlags |= 16 /* AssertES2018 */ | 32 /* AssertES2017 */; break; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 315 /* PartiallyEmittedExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: + case 317 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; excludeFlags = 536870912 /* OuterExpressionExcludes */; @@ -31037,25 +31553,25 @@ var ts; case 119 /* AbstractKeyword */: case 126 /* DeclareKeyword */: case 78 /* ConstKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 214 /* NonNullExpression */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 215 /* NonNullExpression */: case 134 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: case 11 /* JsxText */: - case 264 /* JsxClosingElement */: - case 265 /* JsxFragment */: - case 266 /* JsxOpeningFragment */: - case 267 /* JsxClosingFragment */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 271 /* JsxExpression */: + case 265 /* JsxClosingElement */: + case 266 /* JsxFragment */: + case 267 /* JsxOpeningFragment */: + case 268 /* JsxClosingFragment */: + case 269 /* JsxAttribute */: + case 270 /* JsxAttributes */: + case 271 /* JsxSpreadAttribute */: + case 272 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 2 /* AssertJsx */; break; @@ -31063,11 +31579,11 @@ var ts; case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: - case 277 /* ShorthandPropertyAssignment */: + case 208 /* TemplateExpression */: + case 195 /* TaggedTemplateExpression */: + case 278 /* ShorthandPropertyAssignment */: case 117 /* StaticKeyword */: - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; @@ -31084,14 +31600,14 @@ var ts; case 9 /* BigIntLiteral */: transformFlags |= 4 /* AssertESNext */; break; - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 16 /* AssertES2018 */; } transformFlags |= 128 /* AssertES2015 */; break; - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 131072 /* ContainsYield */; @@ -31105,49 +31621,49 @@ var ts; case 124 /* BooleanKeyword */: case 140 /* SymbolKeyword */: case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 164 /* TypePredicate */: - case 165 /* TypeReference */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 168 /* TypeQuery */: - case 169 /* TypeLiteral */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 177 /* InferType */: - case 178 /* ParenthesizedType */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: - case 248 /* NamespaceExportDeclaration */: + case 152 /* TypeParameter */: + case 155 /* PropertySignature */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 165 /* TypePredicate */: + case 166 /* TypeReference */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 169 /* TypeQuery */: + case 170 /* TypeLiteral */: + case 171 /* ArrayType */: + case 172 /* TupleType */: + case 173 /* OptionalType */: + case 174 /* RestType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: + case 177 /* ConditionalType */: + case 178 /* InferType */: + case 179 /* ParenthesizedType */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 180 /* ThisType */: + case 181 /* TypeOperator */: + case 182 /* IndexedAccessType */: + case 183 /* MappedType */: + case 184 /* LiteralType */: + case 249 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 1 /* AssertTypeScript */; excludeFlags = -2 /* TypeExcludes */; break; - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. transformFlags |= 16384 /* ContainsComputedPropertyName */; break; - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: transformFlags |= 128 /* AssertES2015 */ | 4096 /* ContainsRestOrSpread */; break; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; break; case 99 /* SuperKeyword */: @@ -31159,28 +31675,28 @@ var ts; // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 2048 /* ContainsLexicalThis */; break; - case 185 /* ObjectBindingPattern */: + case 186 /* ObjectBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; if (subtreeFlags & 4096 /* ContainsRestOrSpread */) { transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; } excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 187 /* BindingElement */: + case 188 /* BindingElement */: transformFlags |= 128 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 4096 /* ContainsRestOrSpread */; } break; - case 153 /* Decorator */: + case 154 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */ | 1024 /* ContainsTypeScriptClassSyntax */; break; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: excludeFlags = 536896512 /* ObjectLiteralExcludes */; if (subtreeFlags & 16384 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -31193,26 +31709,26 @@ var ts; transformFlags |= 16 /* AssertES2018 */; } break; - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: excludeFlags = 536875008 /* ArrayLiteralOrCallOrNewExcludes */; break; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 32768 /* ContainsBlockScopedBinding */) { transformFlags |= 128 /* AssertES2015 */; } break; - case 285 /* SourceFile */: + case 286 /* SourceFile */: break; - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: // Return statements may require an `await` in ES2018. transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */ | 16 /* AssertES2018 */; break; - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 230 /* ContinueStatement */: + case 231 /* BreakStatement */: transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -31230,33 +31746,33 @@ var ts; * than calling this function. */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) { + if (kind >= 165 /* FirstTypeNode */ && kind <= 185 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 188 /* ArrayLiteralExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 189 /* ArrayLiteralExpression */: return 536875008 /* ArrayLiteralOrCallOrNewExcludes */; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return 537168896 /* ModuleExcludes */; - case 152 /* Parameter */: + case 153 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return 537371648 /* ArrowFunctionExcludes */; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: return 537373696 /* FunctionExcludes */; - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return 536944640 /* VariableDeclarationListExcludes */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return 536888320 /* ClassExcludes */; - case 158 /* Constructor */: + case 159 /* Constructor */: return 537372672 /* ConstructorExcludes */; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return 537372672 /* MethodOrAccessorExcludes */; case 121 /* AnyKeyword */: case 136 /* NumberKeyword */: @@ -31267,30 +31783,30 @@ var ts; case 124 /* BooleanKeyword */: case 140 /* SymbolKeyword */: case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 152 /* TypeParameter */: + case 155 /* PropertySignature */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return 536896512 /* ObjectLiteralExcludes */; - case 275 /* CatchClause */: + case 276 /* CatchClause */: return 536879104 /* CatchClauseExcludes */; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: return 536875008 /* BindingPatternExcludes */; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 315 /* PartiallyEmittedExpression */: - case 196 /* ParenthesizedExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: + case 317 /* PartiallyEmittedExpression */: + case 197 /* ParenthesizedExpression */: case 99 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -31465,7 +31981,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 === 168 /* TypeQuery */) { + if (d.type && d.type.kind === 169 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -31516,6 +32032,179 @@ var ts; WideningKind[WideningKind["Normal"] = 0] = "Normal"; WideningKind[WideningKind["GeneratorYield"] = 1] = "GeneratorYield"; })(WideningKind || (WideningKind = {})); + var TypeFacts; + (function (TypeFacts) { + TypeFacts[TypeFacts["None"] = 0] = "None"; + TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; + TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; + TypeFacts[TypeFacts["TypeofEQBigInt"] = 4] = "TypeofEQBigInt"; + TypeFacts[TypeFacts["TypeofEQBoolean"] = 8] = "TypeofEQBoolean"; + TypeFacts[TypeFacts["TypeofEQSymbol"] = 16] = "TypeofEQSymbol"; + TypeFacts[TypeFacts["TypeofEQObject"] = 32] = "TypeofEQObject"; + TypeFacts[TypeFacts["TypeofEQFunction"] = 64] = "TypeofEQFunction"; + TypeFacts[TypeFacts["TypeofEQHostObject"] = 128] = "TypeofEQHostObject"; + TypeFacts[TypeFacts["TypeofNEString"] = 256] = "TypeofNEString"; + TypeFacts[TypeFacts["TypeofNENumber"] = 512] = "TypeofNENumber"; + TypeFacts[TypeFacts["TypeofNEBigInt"] = 1024] = "TypeofNEBigInt"; + TypeFacts[TypeFacts["TypeofNEBoolean"] = 2048] = "TypeofNEBoolean"; + TypeFacts[TypeFacts["TypeofNESymbol"] = 4096] = "TypeofNESymbol"; + TypeFacts[TypeFacts["TypeofNEObject"] = 8192] = "TypeofNEObject"; + TypeFacts[TypeFacts["TypeofNEFunction"] = 16384] = "TypeofNEFunction"; + TypeFacts[TypeFacts["TypeofNEHostObject"] = 32768] = "TypeofNEHostObject"; + TypeFacts[TypeFacts["EQUndefined"] = 65536] = "EQUndefined"; + TypeFacts[TypeFacts["EQNull"] = 131072] = "EQNull"; + TypeFacts[TypeFacts["EQUndefinedOrNull"] = 262144] = "EQUndefinedOrNull"; + TypeFacts[TypeFacts["NEUndefined"] = 524288] = "NEUndefined"; + TypeFacts[TypeFacts["NENull"] = 1048576] = "NENull"; + TypeFacts[TypeFacts["NEUndefinedOrNull"] = 2097152] = "NEUndefinedOrNull"; + TypeFacts[TypeFacts["Truthy"] = 4194304] = "Truthy"; + TypeFacts[TypeFacts["Falsy"] = 8388608] = "Falsy"; + TypeFacts[TypeFacts["All"] = 16777215] = "All"; + // The following members encode facts about particular kinds of types for use in the getTypeFacts function. + // The presence of a particular fact means that the given test is true for some (and possibly all) values + // of that kind of type. + TypeFacts[TypeFacts["BaseStringStrictFacts"] = 3735041] = "BaseStringStrictFacts"; + TypeFacts[TypeFacts["BaseStringFacts"] = 12582401] = "BaseStringFacts"; + TypeFacts[TypeFacts["StringStrictFacts"] = 16317953] = "StringStrictFacts"; + TypeFacts[TypeFacts["StringFacts"] = 16776705] = "StringFacts"; + TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 12123649] = "EmptyStringStrictFacts"; + TypeFacts[TypeFacts["EmptyStringFacts"] = 12582401] = "EmptyStringFacts"; + TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 7929345] = "NonEmptyStringStrictFacts"; + TypeFacts[TypeFacts["NonEmptyStringFacts"] = 16776705] = "NonEmptyStringFacts"; + TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 3734786] = "BaseNumberStrictFacts"; + TypeFacts[TypeFacts["BaseNumberFacts"] = 12582146] = "BaseNumberFacts"; + TypeFacts[TypeFacts["NumberStrictFacts"] = 16317698] = "NumberStrictFacts"; + TypeFacts[TypeFacts["NumberFacts"] = 16776450] = "NumberFacts"; + TypeFacts[TypeFacts["ZeroNumberStrictFacts"] = 12123394] = "ZeroNumberStrictFacts"; + TypeFacts[TypeFacts["ZeroNumberFacts"] = 12582146] = "ZeroNumberFacts"; + TypeFacts[TypeFacts["NonZeroNumberStrictFacts"] = 7929090] = "NonZeroNumberStrictFacts"; + TypeFacts[TypeFacts["NonZeroNumberFacts"] = 16776450] = "NonZeroNumberFacts"; + TypeFacts[TypeFacts["BaseBigIntStrictFacts"] = 3734276] = "BaseBigIntStrictFacts"; + TypeFacts[TypeFacts["BaseBigIntFacts"] = 12581636] = "BaseBigIntFacts"; + TypeFacts[TypeFacts["BigIntStrictFacts"] = 16317188] = "BigIntStrictFacts"; + TypeFacts[TypeFacts["BigIntFacts"] = 16775940] = "BigIntFacts"; + TypeFacts[TypeFacts["ZeroBigIntStrictFacts"] = 12122884] = "ZeroBigIntStrictFacts"; + TypeFacts[TypeFacts["ZeroBigIntFacts"] = 12581636] = "ZeroBigIntFacts"; + TypeFacts[TypeFacts["NonZeroBigIntStrictFacts"] = 7928580] = "NonZeroBigIntStrictFacts"; + TypeFacts[TypeFacts["NonZeroBigIntFacts"] = 16775940] = "NonZeroBigIntFacts"; + TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 3733256] = "BaseBooleanStrictFacts"; + TypeFacts[TypeFacts["BaseBooleanFacts"] = 12580616] = "BaseBooleanFacts"; + TypeFacts[TypeFacts["BooleanStrictFacts"] = 16316168] = "BooleanStrictFacts"; + TypeFacts[TypeFacts["BooleanFacts"] = 16774920] = "BooleanFacts"; + TypeFacts[TypeFacts["FalseStrictFacts"] = 12121864] = "FalseStrictFacts"; + TypeFacts[TypeFacts["FalseFacts"] = 12580616] = "FalseFacts"; + TypeFacts[TypeFacts["TrueStrictFacts"] = 7927560] = "TrueStrictFacts"; + TypeFacts[TypeFacts["TrueFacts"] = 16774920] = "TrueFacts"; + TypeFacts[TypeFacts["SymbolStrictFacts"] = 7925520] = "SymbolStrictFacts"; + TypeFacts[TypeFacts["SymbolFacts"] = 16772880] = "SymbolFacts"; + TypeFacts[TypeFacts["ObjectStrictFacts"] = 7888800] = "ObjectStrictFacts"; + TypeFacts[TypeFacts["ObjectFacts"] = 16736160] = "ObjectFacts"; + TypeFacts[TypeFacts["FunctionStrictFacts"] = 7880640] = "FunctionStrictFacts"; + TypeFacts[TypeFacts["FunctionFacts"] = 16728000] = "FunctionFacts"; + TypeFacts[TypeFacts["UndefinedFacts"] = 9830144] = "UndefinedFacts"; + TypeFacts[TypeFacts["NullFacts"] = 9363232] = "NullFacts"; + TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts"; + TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts"; + })(TypeFacts || (TypeFacts = {})); + var typeofEQFacts = ts.createMapFromTemplate({ + string: 1 /* TypeofEQString */, + number: 2 /* TypeofEQNumber */, + bigint: 4 /* TypeofEQBigInt */, + boolean: 8 /* TypeofEQBoolean */, + symbol: 16 /* TypeofEQSymbol */, + undefined: 65536 /* EQUndefined */, + object: 32 /* TypeofEQObject */, + function: 64 /* TypeofEQFunction */ + }); + var typeofNEFacts = ts.createMapFromTemplate({ + string: 256 /* TypeofNEString */, + number: 512 /* TypeofNENumber */, + bigint: 1024 /* TypeofNEBigInt */, + boolean: 2048 /* TypeofNEBoolean */, + symbol: 4096 /* TypeofNESymbol */, + undefined: 524288 /* NEUndefined */, + object: 8192 /* TypeofNEObject */, + function: 16384 /* TypeofNEFunction */ + }); + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; + TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; + TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); + var CheckMode; + (function (CheckMode) { + CheckMode[CheckMode["Normal"] = 0] = "Normal"; + CheckMode[CheckMode["Contextual"] = 1] = "Contextual"; + CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; + CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive"; + CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; + CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; + })(CheckMode || (CheckMode = {})); + var ContextFlags; + (function (ContextFlags) { + ContextFlags[ContextFlags["None"] = 0] = "None"; + ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; + })(ContextFlags || (ContextFlags = {})); + var AccessFlags; + (function (AccessFlags) { + AccessFlags[AccessFlags["None"] = 0] = "None"; + AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; + AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; + AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; + AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; + })(AccessFlags || (AccessFlags = {})); + var CallbackCheck; + (function (CallbackCheck) { + CallbackCheck[CallbackCheck["None"] = 0] = "None"; + CallbackCheck[CallbackCheck["Bivariant"] = 1] = "Bivariant"; + CallbackCheck[CallbackCheck["Strict"] = 2] = "Strict"; + })(CallbackCheck || (CallbackCheck = {})); + var MappedTypeModifiers; + (function (MappedTypeModifiers) { + MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly"; + MappedTypeModifiers[MappedTypeModifiers["ExcludeReadonly"] = 2] = "ExcludeReadonly"; + MappedTypeModifiers[MappedTypeModifiers["IncludeOptional"] = 4] = "IncludeOptional"; + MappedTypeModifiers[MappedTypeModifiers["ExcludeOptional"] = 8] = "ExcludeOptional"; + })(MappedTypeModifiers || (MappedTypeModifiers = {})); + var ExpandingFlags; + (function (ExpandingFlags) { + ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; + ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; + ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; + ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; + })(ExpandingFlags || (ExpandingFlags = {})); + var MembersOrExportsResolutionKind; + (function (MembersOrExportsResolutionKind) { + MembersOrExportsResolutionKind["resolvedExports"] = "resolvedExports"; + MembersOrExportsResolutionKind["resolvedMembers"] = "resolvedMembers"; + })(MembersOrExportsResolutionKind || (MembersOrExportsResolutionKind = {})); + var UnusedKind; + (function (UnusedKind) { + UnusedKind[UnusedKind["Local"] = 0] = "Local"; + UnusedKind[UnusedKind["Parameter"] = 1] = "Parameter"; + })(UnusedKind || (UnusedKind = {})); + var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); + var DeclarationMeaning; + (function (DeclarationMeaning) { + DeclarationMeaning[DeclarationMeaning["GetAccessor"] = 1] = "GetAccessor"; + DeclarationMeaning[DeclarationMeaning["SetAccessor"] = 2] = "SetAccessor"; + DeclarationMeaning[DeclarationMeaning["PropertyAssignment"] = 4] = "PropertyAssignment"; + DeclarationMeaning[DeclarationMeaning["Method"] = 8] = "Method"; + DeclarationMeaning[DeclarationMeaning["GetOrSetAccessor"] = 3] = "GetOrSetAccessor"; + DeclarationMeaning[DeclarationMeaning["PropertyAssignmentOrMethod"] = 12] = "PropertyAssignmentOrMethod"; + })(DeclarationMeaning || (DeclarationMeaning = {})); + var DeclarationSpaces; + (function (DeclarationSpaces) { + DeclarationSpaces[DeclarationSpaces["None"] = 0] = "None"; + DeclarationSpaces[DeclarationSpaces["ExportValue"] = 1] = "ExportValue"; + DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; + DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; + })(DeclarationSpaces || (DeclarationSpaces = {})); function getNodeId(node) { if (!node.id) { node.id = nextNodeId; @@ -31563,11 +32252,9 @@ var ts; var cancellationToken; var requestedExternalEmitHelpers; var externalHelpersModule; - // tslint:disable variable-name var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); - // tslint:enable variable-name var typeCount = 0; var symbolCount = 0; var enumCount = 0; @@ -31841,7 +32528,7 @@ var ts; // Ensure file is type checked checkSourceFile(file); ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); - diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.get(file.fileName)); + diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); if (!file.isDeclarationFile && (!unusedIsError(0 /* Local */) || !unusedIsError(1 /* Parameter */))) { addUnusedDiagnostics(); } @@ -31853,7 +32540,7 @@ var ts; function addUnusedDiagnostics() { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { if (!ts.containsParseError(containingNode) && !unusedIsError(kind)) { - (diagnostics || (diagnostics = [])).push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); } @@ -31882,6 +32569,7 @@ var ts; var literalTypes = ts.createMap(); var indexedAccessTypes = ts.createMap(); var substitutionTypes = ts.createMap(); + var structuralTags = ts.createMap(); var evolvingArrayTypes = []; var undefinedProperties = ts.createMap(); var unknownSymbol = createSymbol(4 /* Property */, "unknown"); @@ -32065,102 +32753,7 @@ var ts; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); - // Suggestion diagnostics must have a file. Keyed by source file name. - var suggestionDiagnostics = ts.createMultiMap(); - var TypeFacts; - (function (TypeFacts) { - TypeFacts[TypeFacts["None"] = 0] = "None"; - TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; - TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; - TypeFacts[TypeFacts["TypeofEQBigInt"] = 4] = "TypeofEQBigInt"; - TypeFacts[TypeFacts["TypeofEQBoolean"] = 8] = "TypeofEQBoolean"; - TypeFacts[TypeFacts["TypeofEQSymbol"] = 16] = "TypeofEQSymbol"; - TypeFacts[TypeFacts["TypeofEQObject"] = 32] = "TypeofEQObject"; - TypeFacts[TypeFacts["TypeofEQFunction"] = 64] = "TypeofEQFunction"; - TypeFacts[TypeFacts["TypeofEQHostObject"] = 128] = "TypeofEQHostObject"; - TypeFacts[TypeFacts["TypeofNEString"] = 256] = "TypeofNEString"; - TypeFacts[TypeFacts["TypeofNENumber"] = 512] = "TypeofNENumber"; - TypeFacts[TypeFacts["TypeofNEBigInt"] = 1024] = "TypeofNEBigInt"; - TypeFacts[TypeFacts["TypeofNEBoolean"] = 2048] = "TypeofNEBoolean"; - TypeFacts[TypeFacts["TypeofNESymbol"] = 4096] = "TypeofNESymbol"; - TypeFacts[TypeFacts["TypeofNEObject"] = 8192] = "TypeofNEObject"; - TypeFacts[TypeFacts["TypeofNEFunction"] = 16384] = "TypeofNEFunction"; - TypeFacts[TypeFacts["TypeofNEHostObject"] = 32768] = "TypeofNEHostObject"; - TypeFacts[TypeFacts["EQUndefined"] = 65536] = "EQUndefined"; - TypeFacts[TypeFacts["EQNull"] = 131072] = "EQNull"; - TypeFacts[TypeFacts["EQUndefinedOrNull"] = 262144] = "EQUndefinedOrNull"; - TypeFacts[TypeFacts["NEUndefined"] = 524288] = "NEUndefined"; - TypeFacts[TypeFacts["NENull"] = 1048576] = "NENull"; - TypeFacts[TypeFacts["NEUndefinedOrNull"] = 2097152] = "NEUndefinedOrNull"; - TypeFacts[TypeFacts["Truthy"] = 4194304] = "Truthy"; - TypeFacts[TypeFacts["Falsy"] = 8388608] = "Falsy"; - TypeFacts[TypeFacts["All"] = 16777215] = "All"; - // The following members encode facts about particular kinds of types for use in the getTypeFacts function. - // The presence of a particular fact means that the given test is true for some (and possibly all) values - // of that kind of type. - TypeFacts[TypeFacts["BaseStringStrictFacts"] = 3735041] = "BaseStringStrictFacts"; - TypeFacts[TypeFacts["BaseStringFacts"] = 12582401] = "BaseStringFacts"; - TypeFacts[TypeFacts["StringStrictFacts"] = 16317953] = "StringStrictFacts"; - TypeFacts[TypeFacts["StringFacts"] = 16776705] = "StringFacts"; - TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 12123649] = "EmptyStringStrictFacts"; - TypeFacts[TypeFacts["EmptyStringFacts"] = 12582401] = "EmptyStringFacts"; - TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 7929345] = "NonEmptyStringStrictFacts"; - TypeFacts[TypeFacts["NonEmptyStringFacts"] = 16776705] = "NonEmptyStringFacts"; - TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 3734786] = "BaseNumberStrictFacts"; - TypeFacts[TypeFacts["BaseNumberFacts"] = 12582146] = "BaseNumberFacts"; - TypeFacts[TypeFacts["NumberStrictFacts"] = 16317698] = "NumberStrictFacts"; - TypeFacts[TypeFacts["NumberFacts"] = 16776450] = "NumberFacts"; - TypeFacts[TypeFacts["ZeroNumberStrictFacts"] = 12123394] = "ZeroNumberStrictFacts"; - TypeFacts[TypeFacts["ZeroNumberFacts"] = 12582146] = "ZeroNumberFacts"; - TypeFacts[TypeFacts["NonZeroNumberStrictFacts"] = 7929090] = "NonZeroNumberStrictFacts"; - TypeFacts[TypeFacts["NonZeroNumberFacts"] = 16776450] = "NonZeroNumberFacts"; - TypeFacts[TypeFacts["BaseBigIntStrictFacts"] = 3734276] = "BaseBigIntStrictFacts"; - TypeFacts[TypeFacts["BaseBigIntFacts"] = 12581636] = "BaseBigIntFacts"; - TypeFacts[TypeFacts["BigIntStrictFacts"] = 16317188] = "BigIntStrictFacts"; - TypeFacts[TypeFacts["BigIntFacts"] = 16775940] = "BigIntFacts"; - TypeFacts[TypeFacts["ZeroBigIntStrictFacts"] = 12122884] = "ZeroBigIntStrictFacts"; - TypeFacts[TypeFacts["ZeroBigIntFacts"] = 12581636] = "ZeroBigIntFacts"; - TypeFacts[TypeFacts["NonZeroBigIntStrictFacts"] = 7928580] = "NonZeroBigIntStrictFacts"; - TypeFacts[TypeFacts["NonZeroBigIntFacts"] = 16775940] = "NonZeroBigIntFacts"; - TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 3733256] = "BaseBooleanStrictFacts"; - TypeFacts[TypeFacts["BaseBooleanFacts"] = 12580616] = "BaseBooleanFacts"; - TypeFacts[TypeFacts["BooleanStrictFacts"] = 16316168] = "BooleanStrictFacts"; - TypeFacts[TypeFacts["BooleanFacts"] = 16774920] = "BooleanFacts"; - TypeFacts[TypeFacts["FalseStrictFacts"] = 12121864] = "FalseStrictFacts"; - TypeFacts[TypeFacts["FalseFacts"] = 12580616] = "FalseFacts"; - TypeFacts[TypeFacts["TrueStrictFacts"] = 7927560] = "TrueStrictFacts"; - TypeFacts[TypeFacts["TrueFacts"] = 16774920] = "TrueFacts"; - TypeFacts[TypeFacts["SymbolStrictFacts"] = 7925520] = "SymbolStrictFacts"; - TypeFacts[TypeFacts["SymbolFacts"] = 16772880] = "SymbolFacts"; - TypeFacts[TypeFacts["ObjectStrictFacts"] = 7888800] = "ObjectStrictFacts"; - TypeFacts[TypeFacts["ObjectFacts"] = 16736160] = "ObjectFacts"; - TypeFacts[TypeFacts["FunctionStrictFacts"] = 7880640] = "FunctionStrictFacts"; - TypeFacts[TypeFacts["FunctionFacts"] = 16728000] = "FunctionFacts"; - TypeFacts[TypeFacts["UndefinedFacts"] = 9830144] = "UndefinedFacts"; - TypeFacts[TypeFacts["NullFacts"] = 9363232] = "NullFacts"; - TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts"; - TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts"; - })(TypeFacts || (TypeFacts = {})); - var typeofEQFacts = ts.createMapFromTemplate({ - string: 1 /* TypeofEQString */, - number: 2 /* TypeofEQNumber */, - bigint: 4 /* TypeofEQBigInt */, - boolean: 8 /* TypeofEQBoolean */, - symbol: 16 /* TypeofEQSymbol */, - undefined: 65536 /* EQUndefined */, - object: 32 /* TypeofEQObject */, - function: 64 /* TypeofEQFunction */ - }); - var typeofNEFacts = ts.createMapFromTemplate({ - string: 256 /* TypeofNEString */, - number: 512 /* TypeofNENumber */, - bigint: 1024 /* TypeofNEBigInt */, - boolean: 2048 /* TypeofNEBoolean */, - symbol: 4096 /* TypeofNESymbol */, - undefined: 524288 /* NEUndefined */, - object: 8192 /* TypeofNEObject */, - function: 16384 /* TypeofNEFunction */ - }); + var suggestionDiagnostics = ts.createDiagnosticCollection(); var typeofTypesByName = ts.createMapFromTemplate({ string: stringType, number: numberType, @@ -32178,71 +32771,8 @@ var ts; var comparableRelation = ts.createMap(); var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); - var TypeSystemPropertyName; - (function (TypeSystemPropertyName) { - TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; - TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; - TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; - TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; - TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; - })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); - var CheckMode; - (function (CheckMode) { - CheckMode[CheckMode["Normal"] = 0] = "Normal"; - CheckMode[CheckMode["Contextual"] = 1] = "Contextual"; - CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; - CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive"; - CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; - CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; - })(CheckMode || (CheckMode = {})); - var ContextFlags; - (function (ContextFlags) { - ContextFlags[ContextFlags["None"] = 0] = "None"; - ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; - })(ContextFlags || (ContextFlags = {})); - var AccessFlags; - (function (AccessFlags) { - AccessFlags[AccessFlags["None"] = 0] = "None"; - AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; - AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; - AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; - AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; - })(AccessFlags || (AccessFlags = {})); - var CallbackCheck; - (function (CallbackCheck) { - CallbackCheck[CallbackCheck["None"] = 0] = "None"; - CallbackCheck[CallbackCheck["Bivariant"] = 1] = "Bivariant"; - CallbackCheck[CallbackCheck["Strict"] = 2] = "Strict"; - })(CallbackCheck || (CallbackCheck = {})); - var MappedTypeModifiers; - (function (MappedTypeModifiers) { - MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly"; - MappedTypeModifiers[MappedTypeModifiers["ExcludeReadonly"] = 2] = "ExcludeReadonly"; - MappedTypeModifiers[MappedTypeModifiers["IncludeOptional"] = 4] = "IncludeOptional"; - MappedTypeModifiers[MappedTypeModifiers["ExcludeOptional"] = 8] = "ExcludeOptional"; - })(MappedTypeModifiers || (MappedTypeModifiers = {})); - var ExpandingFlags; - (function (ExpandingFlags) { - ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; - ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; - ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; - ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; - })(ExpandingFlags || (ExpandingFlags = {})); - var MembersOrExportsResolutionKind; - (function (MembersOrExportsResolutionKind) { - MembersOrExportsResolutionKind["resolvedExports"] = "resolvedExports"; - MembersOrExportsResolutionKind["resolvedMembers"] = "resolvedMembers"; - })(MembersOrExportsResolutionKind || (MembersOrExportsResolutionKind = {})); - var UnusedKind; - (function (UnusedKind) { - UnusedKind[UnusedKind["Local"] = 0] = "Local"; - UnusedKind[UnusedKind["Parameter"] = 1] = "Parameter"; - })(UnusedKind || (UnusedKind = {})); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); - var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; function getJsxNamespace(location) { @@ -32254,7 +32784,7 @@ var ts; } var jsxPragma = file.pragmas.get("jsx"); if (jsxPragma) { - var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; // TODO: GH#18217 + var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; file.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion); if (file.localJsxFactory) { return file.localJsxNamespace = getFirstIdentifier(file.localJsxFactory).escapedText; @@ -32307,11 +32837,11 @@ var ts; diagnostics.add(diagnostic); } else { - suggestionDiagnostics.add(diagnostic.file.fileName, __assign({}, diagnostic, { category: ts.DiagnosticCategory.Suggestion })); + suggestionDiagnostics.add(__assign(__assign({}, diagnostic), { category: ts.DiagnosticCategory.Suggestion })); } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { - addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); + addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { var diagnostic = error(location, message, arg0, arg1, arg2, arg3); @@ -32333,35 +32863,35 @@ var ts; function getExcludedSymbolFlags(flags) { var result = 0; if (flags & 2 /* BlockScopedVariable */) - result |= 67220415 /* BlockScopedVariableExcludes */; + result |= 111551 /* BlockScopedVariableExcludes */; if (flags & 1 /* FunctionScopedVariable */) - result |= 67220414 /* FunctionScopedVariableExcludes */; + result |= 111550 /* FunctionScopedVariableExcludes */; if (flags & 4 /* Property */) result |= 0 /* PropertyExcludes */; if (flags & 8 /* EnumMember */) - result |= 68008959 /* EnumMemberExcludes */; + result |= 900095 /* EnumMemberExcludes */; if (flags & 16 /* Function */) - result |= 67219887 /* FunctionExcludes */; + result |= 110991 /* FunctionExcludes */; if (flags & 32 /* Class */) - result |= 68008383 /* ClassExcludes */; + result |= 899503 /* ClassExcludes */; if (flags & 64 /* Interface */) - result |= 67897736 /* InterfaceExcludes */; + result |= 788872 /* InterfaceExcludes */; if (flags & 256 /* RegularEnum */) - result |= 68008191 /* RegularEnumExcludes */; + result |= 899327 /* RegularEnumExcludes */; if (flags & 128 /* ConstEnum */) - result |= 68008831 /* ConstEnumExcludes */; + result |= 899967 /* ConstEnumExcludes */; if (flags & 512 /* ValueModule */) result |= 110735 /* ValueModuleExcludes */; if (flags & 8192 /* Method */) - result |= 67212223 /* MethodExcludes */; + result |= 103359 /* MethodExcludes */; if (flags & 32768 /* GetAccessor */) - result |= 67154879 /* GetAccessorExcludes */; + result |= 46015 /* GetAccessorExcludes */; if (flags & 65536 /* SetAccessor */) - result |= 67187647 /* SetAccessorExcludes */; + result |= 78783 /* SetAccessorExcludes */; if (flags & 262144 /* TypeParameter */) - result |= 67635688 /* TypeParameterExcludes */; + result |= 526824 /* TypeParameterExcludes */; if (flags & 524288 /* TypeAlias */) - result |= 67897832 /* TypeAliasExcludes */; + result |= 788968 /* TypeAliasExcludes */; if (flags & 2097152 /* Alias */) result |= 2097152 /* AliasExcludes */; return result; @@ -32584,7 +33114,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 286 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -32614,8 +33144,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 67220415 /* Value */); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 67220415 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* Value */); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -32642,17 +33172,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 187 /* BindingElement */) { + if (declaration.kind === 188 /* 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, 187 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 188 /* 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, 238 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 239 /* VariableDeclaration */), usage); } - else if (declaration.kind === 238 /* VariableDeclaration */) { + else if (declaration.kind === 239 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -32675,12 +33205,12 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 258 /* ExportSpecifier */ || (usage.parent.kind === 255 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 259 /* ExportSpecifier */ || (usage.parent.kind === 256 /* 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 === 255 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 256 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -32688,9 +33218,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 220 /* VariableStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 221 /* VariableStatement */: + case 227 /* ForStatement */: + case 229 /* 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, container)) { @@ -32711,16 +33241,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 155 /* PropertyDeclaration */ && + current.parent.kind === 156 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 157 /* MethodDeclaration */) { + if (declaration.kind === 158 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 156 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -32741,14 +33271,14 @@ var ts; return "quit"; } switch (node.kind) { - case 198 /* ArrowFunction */: - case 155 /* PropertyDeclaration */: + case 199 /* ArrowFunction */: + case 156 /* PropertyDeclaration */: return true; - case 219 /* Block */: + case 220 /* Block */: switch (node.parent.kind) { - case 159 /* GetAccessor */: - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 158 /* MethodDeclaration */: + case 161 /* SetAccessor */: return true; default: return false; @@ -32794,12 +33324,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 & 67897832 /* Type */ && lastLocation.kind !== 297 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 299 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 152 /* Parameter */ || - lastLocation.kind === 151 /* TypeParameter */ + lastLocation.kind === 153 /* Parameter */ || + lastLocation.kind === 152 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -32816,13 +33346,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 === 152 /* Parameter */ || + lastLocation.kind === 153 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 176 /* ConditionalType */) { + else if (location.kind === 177 /* 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; @@ -32837,14 +33367,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 286 /* SourceFile */ || ts.isAmbientModule(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 */)) { @@ -32868,7 +33398,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 258 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 259 /* ExportSpecifier */)) { break; } } @@ -32882,12 +33412,12 @@ var ts; } } break; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 155 /* PropertyDeclaration */: + case 156 /* 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 @@ -32897,20 +33427,20 @@ var ts; if (!ts.hasModifier(location, 32 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 67220415 /* Value */)) { + if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) { // Remember the property node, it will be used later to report appropriate error propertyWithInvalidInitializer = location; } } } break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* 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! - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 67897832 /* Type */)) { + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -32925,7 +33455,7 @@ var ts; } break loop; } - if (location.kind === 210 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 211 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -32933,11 +33463,11 @@ var ts; } } break; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. if (lastLocation === location.expression && location.parent.token === 87 /* ExtendsKeyword */) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 67897832 /* Type */))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -32953,34 +33483,34 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 242 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 243 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67897832 /* Type */)) { + 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); return undefined; } } break; - case 198 /* ArrowFunction */: + case 199 /* 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 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -32993,7 +33523,7 @@ var ts; } } break; - case 153 /* Decorator */: + case 154 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -33002,7 +33532,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 === 152 /* Parameter */) { + if (location.parent && location.parent.kind === 153 /* Parameter */) { location = location.parent; } // @@ -33017,24 +33547,25 @@ 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 === 241 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 242 /* ClassDeclaration */)) { location = location.parent; } break; - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; - case 152 /* Parameter */: + case 153 /* Parameter */: if (lastLocation && lastLocation === location.initializer) { associatedDeclarationForContainingInitializer = location; } break; - case 187 /* BindingElement */: + case 188 /* BindingElement */: if (lastLocation && lastLocation === location.initializer) { var root = ts.getRootDeclaration(location); - if (root.kind === 152 /* Parameter */) { + if (root.kind === 153 /* Parameter */) { associatedDeclarationForContainingInitializer = location; } } @@ -33054,7 +33585,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 285 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 286 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -33120,21 +33651,21 @@ var ts; // we want to check for block-scoped if (errorLocation && (meaning & 2 /* BlockScopedVariable */ || - ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 67220415 /* Value */) === 67220415 /* Value */))) { + ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 67220415 /* Value */) === 67220415 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } // If we're in a parameter initializer, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 67220415 /* Value */) === 67220415 /* Value */) { + if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializer); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself @@ -33150,10 +33681,10 @@ var ts; return result; } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 198 /* ArrowFunction */ && location.kind !== 197 /* FunctionExpression */) { + if (location.kind !== 199 /* ArrowFunction */ && location.kind !== 198 /* 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 === 155 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 156 /* PropertyDeclaration */ && !ts.hasModifier(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; @@ -33166,12 +33697,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: // For `namespace N { N; }` + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 246 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -33183,7 +33714,7 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 151 /* TypeParameter */) { + if (decl.kind === 152 /* 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 @@ -33239,9 +33770,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -33251,9 +33782,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 67220415 /* Value */ : 0); + var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* Value */ : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -33272,8 +33803,8 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (67897832 /* Type */ & ~1920 /* Namespace */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~67897832 /* Type */ & 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1920 /* Namespace */)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here, ts.unescapeLeadingUnderscores(name)); return true; @@ -33282,12 +33813,12 @@ var ts; return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 /* Value */ & ~1024 /* NamespaceModule */)) { + if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) { if (name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never") { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 /* Type */ & ~67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { var message = isES2015OrLaterConstructorName(name) ? ts.Diagnostics._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 @@ -33311,15 +33842,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 /* Value */ & ~1024 /* NamespaceModule */ & ~67897832 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */ & ~788968 /* Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (67897832 /* Type */ & ~1024 /* NamespaceModule */ & ~67220415 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~67897832 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + else if (meaning & (788968 /* Type */ & ~1024 /* NamespaceModule */ & ~111551 /* Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~788968 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -33329,10 +33860,14 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { 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 === 244 /* EnumDeclaration */) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 245 /* EnumDeclaration */); }); if (declaration === undefined) - return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); + return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); @@ -33365,13 +33900,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return node; - case 251 /* ImportClause */: + case 252 /* ImportClause */: return node.parent; - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return node.parent.parent; - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -33381,7 +33916,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 261 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -33482,7 +34017,7 @@ var ts; if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (67897832 /* Type */ | 1920 /* Namespace */)) { + if (valueSymbol.flags & (788968 /* Type */ | 1920 /* Namespace */)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -33572,7 +34107,7 @@ var ts; if (ts.isClassExpression(expression)) { return checkExpression(expression).symbol; } - var aliasLike = resolveEntityName(expression, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); + var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } @@ -33582,20 +34117,20 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 258 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 255 /* ExportAssignment */: - case 205 /* BinaryExpression */: + case 259 /* ExportSpecifier */: + return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); + case 256 /* ExportAssignment */: + case 206 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -33606,7 +34141,7 @@ var ts; * OR Is a JSContainer which may merge an alias with a local declaration */ function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */; } + if (excludes === void 0) { excludes = 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */; } if (!symbol) return false; return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* Assignment */); @@ -33640,7 +34175,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 67220415 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); + ((target.flags & 111551 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -33656,17 +34191,15 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 255 /* ExportAssignment */) { - // export default - checkExpressionCached(node.expression); - } - else if (node.kind === 258 /* ExportSpecifier */) { - // export { } or export { as foo } - checkExpressionCached(node.propertyName || node.name); - } - else if (ts.isInternalModuleImportEqualsDeclaration(node)) { - // import foo = - checkExpressionCached(node.moduleReference); + // We defer checking of the reference of an `import =` until the import itself is referenced, + // This way a chain of imports can be elided if ultimately the final input is only used in a type + // position. + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + var target = resolveSymbol(symbol); + if (target === unknownSymbol || target.flags & 111551 /* Value */) { + // import foo = + checkExpressionCached(node.moduleReference); + } } } } @@ -33682,14 +34215,14 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 73 /* Identifier */ || entityName.parent.kind === 149 /* QualifiedName */) { + if (entityName.kind === 73 /* Identifier */ || entityName.parent.kind === 150 /* 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 === 249 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 250 /* ImportEqualsDeclaration */); + return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { @@ -33702,7 +34235,7 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 67220415 /* Value */ : 0); + var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; if (name.kind === 73 /* Identifier */) { var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name)); @@ -33712,9 +34245,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 149 /* QualifiedName */ || name.kind === 190 /* PropertyAccessExpression */) { - var left = name.kind === 149 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 149 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 150 /* QualifiedName */ || name.kind === 191 /* PropertyAccessExpression */) { + var left = name.kind === 150 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 150 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -33805,6 +34338,20 @@ var ts; undefined; return initializer || decl; } + /** + * Get the real symbol of a declaration with an expando initializer. + * + * Normally, declarations have an associated symbol, but when a declaration has an expando + * initializer, the expando's symbol is the one that has all the members merged into it. + */ + function getExpandoSymbol(symbol) { + var decl = symbol.valueDeclaration; + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */) { + return undefined; + } + var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); + return init && getSymbolOfNode(init) || undefined; + } function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0); } @@ -33816,9 +34363,6 @@ var ts; } function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReference === undefined) { - return; - } if (ts.startsWith(moduleReference, "@types/")) { var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1; var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/"); @@ -33947,7 +34491,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 285 /* SourceFile */)) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 286 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -34203,13 +34747,13 @@ var ts; return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? symbol.exportSymbol : symbol); } function symbolIsValue(symbol) { - return !!(symbol.flags & 67220415 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 67220415 /* Value */); + return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 158 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 159 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -34295,12 +34839,12 @@ var ts; } } switch (location.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -34311,7 +34855,7 @@ var ts; } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 67220415 /* Value */ ? 67220415 /* Value */ : 1920 /* Namespace */; + return rightMeaning === 111551 /* Value */ ? 111551 /* Value */ : 1920 /* Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = ts.createMap(); } @@ -34364,7 +34908,7 @@ var ts; && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) // 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, 258 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 259 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -34400,7 +34944,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, 258 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 259 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -34415,10 +34959,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: continue; default: return false; @@ -34429,11 +34973,11 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67897832 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 788968 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); return access.accessibility === 0 /* Accessible */; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67220415 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 111551 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false); return access.accessibility === 0 /* Accessible */; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible) { @@ -34476,7 +35020,7 @@ var ts; // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. var firstDecl = ts.first(symbol.declarations); - if (!ts.length(containers) && meaning & 67220415 /* Value */ && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { + if (!ts.length(containers) && meaning & 111551 /* Value */ && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { if (firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent) && firstDecl === firstDecl.parent.initializer) { containers = [getSymbolOfNode(firstDecl.parent)]; } @@ -34535,10 +35079,10 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 286 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 286 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -34585,21 +35129,21 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 168 /* TypeQuery */ || + if (entityName.parent.kind === 169 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 150 /* ComputedPropertyName */) { + entityName.parent.kind === 151 /* ComputedPropertyName */) { // Typeof value - meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; + meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 149 /* QualifiedName */ || entityName.kind === 190 /* PropertyAccessExpression */ || - entityName.parent.kind === 249 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 150 /* QualifiedName */ || entityName.kind === 191 /* PropertyAccessExpression */ || + entityName.parent.kind === 250 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; } else { // Type Reference or TypeAlias entity = Identifier - meaning = 67897832 /* Type */; + meaning = 788968 /* Type */; } var firstIdentifier = getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); @@ -34641,15 +35185,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 167 /* ConstructorType */ : 166 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 168 /* ConstructorType */ : 167 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 162 /* ConstructSignature */ : 161 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 163 /* ConstructSignature */ : 162 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } @@ -34672,14 +35216,17 @@ var ts; return result; } function getTypeNamesForErrorDisplay(left, right) { - var leftStr = typeToString(left); - var rightStr = typeToString(right); + var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left); + var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right); if (leftStr === rightStr) { leftStr = typeToString(left, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); rightStr = typeToString(right, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); } return [leftStr, rightStr]; } + function symbolValueDeclarationIsContextSensitive(symbol) { + return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0 /* None */; } return flags & 9469291 /* NodeBuilderFlagsMask */; @@ -34771,14 +35318,14 @@ var ts; } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 67897832 /* Type */); + var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */); var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), /*typeArguments*/ undefined)); return enumLiteralName; } if (type.flags & 1056 /* EnumLike */) { - return symbolToTypeNode(type.symbol, context, 67897832 /* Type */); + return symbolToTypeNode(type.symbol, context, 788968 /* Type */); } if (type.flags & 128 /* StringLiteral */) { context.approximateLength += (type.value.length + 2); @@ -34801,7 +35348,7 @@ var ts; if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 67220415 /* Value */); + return symbolToTypeNode(type.symbol, context, 111551 /* Value */); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); @@ -34864,14 +35411,14 @@ var ts; } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. return type.symbol - ? symbolToTypeNode(type.symbol, context, 67897832 /* Type */) + ? symbolToTypeNode(type.symbol, context, 788968 /* Type */) : ts.createTypeReferenceNode(ts.createIdentifier("?"), /*typeArguments*/ undefined); } if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 67897832 /* Type */, typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); } if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; @@ -34880,7 +35427,7 @@ var ts; } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 174 /* UnionType */ : 175 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 175 /* UnionType */ : 176 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -34921,6 +35468,36 @@ var ts; if (type.flags & 33554432 /* Substitution */) { return typeToTypeNodeHelper(type.typeVariable, context); } + if (type.flags & 134217728 /* StructuralTag */) { + var innerType = type.type; + if (innerType.flags & 2097152 /* Intersection */) { + // If some inner type of the intersection has an alias when hoisted out, (attempt to) hoist out all of the aliasable things + if (ts.some(innerType.types, function (t) { return !!getStructuralTagForType(t).aliasSymbol; })) { + var aliasingTypes = []; + var nonAliasingTypes = []; + for (var _i = 0, _a = innerType.types; _i < _a.length; _i++) { + var t = _a[_i]; + var taggedVersion = getStructuralTagForType(t); + if (taggedVersion.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(taggedVersion.aliasSymbol, context.enclosingDeclaration))) { + aliasingTypes.push(taggedVersion); + } + else { + nonAliasingTypes.push(t); + } + } + if (ts.length(aliasingTypes)) { + if (ts.length(nonAliasingTypes)) { + aliasingTypes.push(getStructuralTagForType(getIntersectionType(nonAliasingTypes))); + } + // Do note: this can make an intersection become nested within another intersection - this _is_ handled correctly + // during emit, so is fine (and honestly is more clear, since it groups all the tags together) + return ts.createUnionOrIntersectionTypeNode(176 /* IntersectionType */, ts.map(aliasingTypes, function (t) { return typeToTypeNodeHelper(t, context); })); + } + } + } + context.approximateLength += 4; + return ts.createTypeOperatorNode(148 /* TagKeyword */, typeToTypeNodeHelper(innerType, context)); + } return ts.Debug.fail("Should be unreachable."); function createMappedTypeNodeFromType(type) { ts.Debug.assert(!!(type.flags & 524288 /* Object */)); @@ -34950,21 +35527,21 @@ var ts; id = (isConstructorObject ? "+" : "") + getSymbolId(symbol); if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. - var isInstanceType = type === getInferredClassType(symbol) ? 67897832 /* Type */ : 67220415 /* Value */; + var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 /* Type */ : 111551 /* Value */; 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 === 210 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 211 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { - return symbolToTypeNode(symbol, context, 67220415 /* Value */); + return symbolToTypeNode(symbol, context, 111551 /* Value */); } else if (context.visitedTypes && context.visitedTypes.has(typeId)) { // If type is an anonymous type literal in a type alias declaration, use type alias name var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags - return symbolToTypeNode(typeAlias, context, 67897832 /* Type */); + return symbolToTypeNode(typeAlias, context, 788968 /* Type */); } else { return createElidedInformationPlaceholder(context); @@ -35001,12 +35578,12 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 285 /* SourceFile */ || declaration.parent.kind === 246 /* ModuleBlock */; + return declaration.parent.kind === 286 /* SourceFile */ || declaration.parent.kind === 247 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedTypes && context.visitedTypes.has(typeId))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // TODO: GH#18217 // And the build is going to succeed without visibility error or there is no structural fallback allowed + (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } @@ -35022,12 +35599,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 166 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 167 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 167 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 168 /* ConstructorType */, context); return signatureNode; } } @@ -35097,7 +35674,7 @@ var ts; var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_2 = context.flags; context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var ref = symbolToTypeNode(parent, context, 67897832 /* Type */, typeArgumentSlice); + var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice); context.flags = flags_2; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -35110,7 +35687,7 @@ var ts; } var flags = context.flags; context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var finalRef = symbolToTypeNode(type.symbol, context, 67897832 /* Type */, typeArgumentNodes); + var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* Type */, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -35162,11 +35739,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 161 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 162 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 162 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 163 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; @@ -35227,7 +35804,7 @@ var ts; trackComputedName(decl.name, saveEnclosingDeclaration, context); } } - var propertyName = symbolToName(propertySymbol, context, 67220415 /* Value */, /*expectsIdentifier*/ true); + var propertyName = symbolToName(propertySymbol, context, 111551 /* Value */, /*expectsIdentifier*/ true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(56 /* QuestionToken */) : undefined; @@ -35235,7 +35812,7 @@ var ts; var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 156 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 157 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; if (propertySymbol.valueDeclaration) { @@ -35331,7 +35908,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 158 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 159 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -35375,9 +35952,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 152 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 153 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 306 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 308 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -35387,13 +35964,12 @@ var ts; var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(25 /* DotDotDotToken */) : undefined; - var name = parameterDeclaration - ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 73 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 149 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : - cloneBindingName(parameterDeclaration.name) : - ts.symbolName(parameterSymbol) - : ts.symbolName(parameterSymbol); + var name = parameterDeclaration ? parameterDeclaration.name ? + parameterDeclaration.name.kind === 73 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 150 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + cloneBindingName(parameterDeclaration.name) : + ts.symbolName(parameterSymbol) : + ts.symbolName(parameterSymbol); var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */; var questionToken = isOptional ? ts.createToken(56 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( @@ -35409,7 +35985,7 @@ var ts; } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 187 /* BindingElement */) { + if (clone.kind === 188 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); @@ -35421,9 +35997,9 @@ var ts; return; // get symbol of the first identifier of the entityName var firstIdentifier = getFirstIdentifier(node.expression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 67220415 /* Value */); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { @@ -35540,7 +36116,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 285 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 286 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -35576,7 +36152,7 @@ var ts; // using the `baseUrl` compiler option (which we would otherwise never use in declaration emit) and a non-relative // specifier preference var moduleResolverHost = context.tracker.moduleResolverHost; - var specifierCompilerOptions = isBundle_1 ? __assign({}, compilerOptions, { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; + var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, host.getSourceFiles(), { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative" }, host.redirectTargetsMap)); links.specifierCache = links.specifierCache || ts.createMap(); links.specifierCache.set(contextFile.path, specifier); @@ -35585,7 +36161,7 @@ var ts; } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - var isTypeOf = meaning === 67220415 /* Value */; + var isTypeOf = meaning === 111551 /* Value */; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; @@ -35664,7 +36240,7 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context) { - return !!resolveName(context.enclosingDeclaration, escapedName, 67897832 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + return !!resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); } function typeParameterToName(type, context) { if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { @@ -35673,7 +36249,7 @@ var ts; return cached; } } - var result = symbolToName(type.symbol, context, 67897832 /* Type */, /*expectsIdentifier*/ true); + var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = 0; @@ -35719,9 +36295,6 @@ var ts; function createExpressionFromSymbolChain(chain, index) { var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; - if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { - return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); - } if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; } @@ -35730,6 +36303,9 @@ var ts; context.flags ^= 16777216 /* InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); + if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); + } var canUsePropertyAccess = ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); @@ -35807,8 +36383,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 178 /* ParenthesizedType */; }); - if (node.kind === 243 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 179 /* ParenthesizedType */; }); + if (node.kind === 244 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -35816,11 +36392,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 246 /* ModuleBlock */ && + node.parent.kind === 247 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 286 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -35858,9 +36434,9 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - var name_2 = ts.getNameOfDeclaration(declaration); - if (name_2) { + var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; }); // Try using a declaration with a name, first + var name_2 = declaration && ts.getNameOfDeclaration(declaration); + if (declaration && name_2) { if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } @@ -35873,17 +36449,20 @@ var ts; } return ts.declarationNameToString(name_2); } - if (declaration.parent && declaration.parent.kind === 238 /* VariableDeclaration */) { + if (!declaration) { + declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway + } + if (declaration.parent && declaration.parent.kind === 239 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 211 /* ClassExpression */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 210 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 211 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -35900,27 +36479,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 307 /* 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 187 /* BindingElement */: + case 188 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 238 /* VariableDeclaration */: + case 239 /* 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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 240 /* FunctionDeclaration */: - case 244 /* EnumDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 246 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 241 /* FunctionDeclaration */: + case 245 /* EnumDeclaration */: + case 250 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -35928,53 +36508,54 @@ 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 !== 249 /* ImportEqualsDeclaration */ && parent.kind !== 285 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 250 /* ImportEqualsDeclaration */ && parent.kind !== 286 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.hasModifier(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 158 /* Constructor */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 152 /* Parameter */: - case 246 /* ModuleBlock */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 165 /* TypeReference */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 178 /* ParenthesizedType */: + case 159 /* Constructor */: + case 163 /* ConstructSignature */: + case 162 /* CallSignature */: + case 164 /* IndexSignature */: + case 153 /* Parameter */: + case 247 /* ModuleBlock */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 170 /* TypeLiteral */: + case 166 /* TypeReference */: + case 171 /* ArrayType */: + case 172 /* TupleType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: + case 179 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: + case 252 /* ImportClause */: + case 253 /* NamespaceImport */: + case 255 /* ImportSpecifier */: return false; // Type parameters are always visible - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: // Source file and namespace export are always visible - case 285 /* SourceFile */: - case 248 /* NamespaceExportDeclaration */: + // falls through + case 286 /* SourceFile */: + case 249 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return false; default: return false; @@ -35983,11 +36564,11 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 255 /* ExportAssignment */) { - exportSymbol = resolveName(node, node.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); + if (node.parent && node.parent.kind === 256 /* ExportAssignment */) { + exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 258 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + else if (node.parent.kind === 259 /* ExportSpecifier */) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; if (exportSymbol) { @@ -36008,7 +36589,7 @@ var ts; // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); if (importSymbol) { buildVisibleNodeList(importSymbol.declarations); } @@ -36072,8 +36653,10 @@ var ts; } return ts.Debug.assertNever(propertyName); } - // Pop an entry from the type resolution stack and return its associated result value. The result value will - // be true if no circularities were detected, or false if a circularity was found. + /** + * Pop an entry from the type resolution stack and return its associated result value. The result value will + * be true if no circularities were detected, or false if a circularity was found. + */ function popTypeResolution() { resolutionTargets.pop(); resolutionPropertyNames.pop(); @@ -36082,12 +36665,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 238 /* VariableDeclaration */: - case 239 /* VariableDeclarationList */: - case 254 /* ImportSpecifier */: - case 253 /* NamedImports */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + case 239 /* VariableDeclaration */: + case 240 /* VariableDeclarationList */: + case 255 /* ImportSpecifier */: + case 254 /* NamedImports */: + case 253 /* NamespaceImport */: + case 252 /* ImportClause */: return false; default: return true; @@ -36120,7 +36703,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 150 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 151 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); @@ -36172,7 +36755,7 @@ var ts; if (parentAccess && parentAccess.flowNode) { var propName = getDestructuringPropertyName(node); if (propName) { - var result = ts.createNode(191 /* ElementAccessExpression */, node.pos, node.end); + var result = ts.createNode(192 /* ElementAccessExpression */, node.pos, node.end); result.parent = node; result.expression = parentAccess; var literal = ts.createNode(10 /* StringLiteral */, node.pos, node.end); @@ -36187,23 +36770,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 187 /* BindingElement */: - case 276 /* PropertyAssignment */: + case 188 /* BindingElement */: + case 277 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ancestor.initializer; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 187 /* BindingElement */ && parent.kind === 185 /* ObjectBindingPattern */) { + if (node.kind === 188 /* BindingElement */ && parent.kind === 186 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 276 /* PropertyAssignment */ || node.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.kind === 277 /* PropertyAssignment */ || node.kind === 278 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -36225,7 +36808,7 @@ var ts; parentType = getNonNullableType(parentType); } var type; - if (pattern.kind === 185 /* ObjectBindingPattern */) { + if (pattern.kind === 186 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -36297,26 +36880,26 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 188 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 189 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function isParameterOfContextuallyTypedFunction(node) { - return node.kind === 152 /* Parameter */ && - (node.parent.kind === 197 /* FunctionExpression */ || node.parent.kind === 198 /* ArrowFunction */) && + return node.kind === 153 /* Parameter */ && + (node.parent.kind === 198 /* FunctionExpression */ || node.parent.kind === 199 /* ArrowFunction */) && !!getContextualType(node.parent); } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 227 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 228 /* 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 === 228 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 229 /* 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, @@ -36335,7 +36918,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 238 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 239 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no @@ -36349,11 +36932,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 152 /* Parameter */) { + if (declaration.kind === 153 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 160 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 159 /* GetAccessor */); + if (func.kind === 161 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 160 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -36563,9 +37146,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 === 158 /* Constructor */ || - thisContainer.kind === 240 /* FunctionDeclaration */ || - (thisContainer.kind === 197 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 159 /* Constructor */ || + thisContainer.kind === 241 /* FunctionDeclaration */ || + (thisContainer.kind === 198 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -36640,7 +37223,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 187 /* BindingElement */ && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 188 /* BindingElement */ && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -36663,7 +37246,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 185 /* ObjectBindingPattern */ + return pattern.kind === 186 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -36702,7 +37285,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 152 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 153 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -36764,7 +37347,7 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 255 /* ExportAssignment */) { + if (declaration.kind === 256 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } else if (ts.isInJSFile(declaration) && @@ -36828,7 +37411,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 160 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -36855,8 +37438,8 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 160 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 160 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 161 /* SetAccessor */); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -36886,7 +37469,9 @@ var ts; // Otherwise, fall back to 'any'. else { if (setter) { - errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); + 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 existed getter as we are current checking either setter or getter in this function"); @@ -36899,7 +37484,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 160 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -36915,19 +37500,10 @@ var ts; if (!links.type) { var jsDeclaration = ts.getDeclarationOfExpando(symbol.valueDeclaration); if (jsDeclaration) { - var jsSymbol = getSymbolOfNode(jsDeclaration); - if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { - symbol = cloneSymbol(symbol); + var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration)); + if (merged) { // note:we overwrite links because we just cloned the symbol - links = symbol; - if (ts.hasEntries(jsSymbol.exports)) { - symbol.exports = symbol.exports || ts.createSymbolTable(); - mergeSymbolTable(symbol.exports, jsSymbol.exports); - } - if (ts.hasEntries(jsSymbol.members)) { - symbol.members = symbol.members || ts.createSymbolTable(); - mergeSymbolTable(symbol.members, jsSymbol.members); - } + symbol = links = merged; } } originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol); @@ -36939,8 +37515,8 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 205 /* BinaryExpression */ || - declaration.kind === 190 /* PropertyAccessExpression */ && declaration.parent.kind === 205 /* BinaryExpression */) { + else if (declaration.kind === 206 /* BinaryExpression */ || + declaration.kind === 191 /* PropertyAccessExpression */ && declaration.parent.kind === 206 /* BinaryExpression */) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -36979,7 +37555,7 @@ var ts; // 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 & 67220415 /* Value */ + links.type = targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) : errorType; } @@ -37007,7 +37583,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 152 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 153 /* 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 @@ -37088,39 +37664,50 @@ var ts; function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; // TODO: GH#18217 Use SourceFile kind check instead + if (node && ts.isBinaryExpression(node)) { + // prototype assignments get the outer type parameters of their constructor function + var assignmentKind = ts.getAssignmentDeclarationKind(node); + if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + var symbol = getSymbolOfNode(node.left); + if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { + node = symbol.parent.valueDeclaration; + } + } + } if (!node) { return undefined; } switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 182 /* MappedType */: - case 176 /* ConditionalType */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 157 /* MethodSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 296 /* JSDocFunctionType */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 244 /* TypeAliasDeclaration */: + case 312 /* JSDocTemplateTag */: + case 313 /* JSDocTypedefTag */: + case 307 /* JSDocEnumTag */: + case 306 /* JSDocCallbackTag */: + case 183 /* MappedType */: + case 177 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 182 /* MappedType */) { + if (node.kind === 183 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 176 /* ConditionalType */) { + else if (node.kind === 177 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */ || node.kind === 242 /* InterfaceDeclaration */) && + (node.kind === 242 /* ClassDeclaration */ || node.kind === 211 /* ClassExpression */ || node.kind === 243 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -37128,7 +37715,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 243 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -37137,9 +37724,10 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 241 /* ClassDeclaration */ || - node.kind === 210 /* ClassExpression */ || + if (node.kind === 243 /* InterfaceDeclaration */ || + node.kind === 242 /* ClassDeclaration */ || + node.kind === 211 /* ClassExpression */ || + isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -37170,7 +37758,7 @@ var ts; var constraint = getBaseConstraintOfType(type); return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } - return isJSConstructorType(type); + return false; } function getBaseTypeNodeOfClass(type) { return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); @@ -37265,9 +37853,7 @@ var ts; var baseTypeNode = getBaseTypeNodeOfClass(type); var typeArgs = typeArgumentsFromTypeReferenceNode(baseTypeNode); var baseType; - var originalBaseType = isJSConstructorType(baseConstructorType) ? baseConstructorType : - baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : - undefined; + var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the @@ -37278,9 +37864,6 @@ var ts; else if (baseConstructorType.flags & 1 /* Any */) { baseType = baseConstructorType; } - else if (isJSConstructorType(baseConstructorType)) { - baseType = !baseTypeNode.typeArguments && getJSClassType(baseConstructorType.symbol) || anyType; - } else { // The class derives from a "class-like" constructor function, check that we have at least one construct signature // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere @@ -37333,7 +37916,7 @@ var ts; 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 === 242 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 243 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -37369,7 +37952,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242 /* InterfaceDeclaration */) { + if (declaration.kind === 243 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -37378,7 +37961,7 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 67897832 /* Type */, /*ignoreErrors*/ true); + var baseSymbol = resolveEntityName(node.expression, 788968 /* Type */, /*ignoreErrors*/ true); if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } @@ -37391,9 +37974,15 @@ var ts; } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); + var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; - var type = links.declaredType = createObjectType(kind, symbol); + var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + if (merged) { + // note:we overwrite links because we just cloned the symbol + symbol = links = merged; + } + var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type @@ -37425,9 +38014,10 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return errorType; } - var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 243 /* TypeAliasDeclaration */; - }); + var declaration = ts.find(symbol.declarations, ts.isTypeAlias); + if (!declaration) { + return ts.Debug.fail("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; @@ -37443,7 +38033,7 @@ var ts; } else { type = errorType; - error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + error(ts.isJSDocEnumTag(declaration) ? declaration : declaration.name || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } links.declaredType = type; } @@ -37453,7 +38043,7 @@ var ts; if (expr.kind === 10 /* StringLiteral */) { return true; } - else if (expr.kind === 205 /* BinaryExpression */) { + else if (expr.kind === 206 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -37467,12 +38057,12 @@ var ts; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return true; - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return expr.operator === 39 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; case 73 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -37486,7 +38076,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 245 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && member.initializer.kind === 10 /* StringLiteral */) { @@ -37513,7 +38103,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 245 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -37597,11 +38187,11 @@ var ts; case 142 /* UndefinedKeyword */: case 97 /* NullKeyword */: case 133 /* NeverKeyword */: - case 183 /* LiteralType */: + case 184 /* LiteralType */: return true; - case 170 /* ArrayType */: + case 171 /* ArrayType */: return isThislessType(node.elementType); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -37627,7 +38217,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 158 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 159 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -37643,14 +38233,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -37760,7 +38350,7 @@ var ts; else { symbol.declarations.push(member); } - if (symbolFlags & 67220415 /* Value */) { + if (symbolFlags & 111551 /* Value */) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -38022,7 +38612,7 @@ var ts; var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; // TODO: GH#18217 + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -38066,8 +38656,9 @@ var ts; } var result; for (var i = 0; i < signatureLists.length; i++) { - // Allow matching non-generic signatures to have excess parameters and different return types - var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true); + // Allow matching non-generic signatures to have excess parameters and different return types. + // Prefer matching this types if possible. + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true); if (!match) { return undefined; } @@ -38091,7 +38682,7 @@ var ts; for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { var signature = _a[_i]; // Only process signatures with parameter lists that aren't already in the result list - if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true)) { + if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true)) { var unionSignatures = findMatchingSignatures(signatureLists, signature, i); if (unionSignatures) { var s = signature; @@ -38100,7 +38691,7 @@ var ts; var thisParameter = signature.thisParameter; var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; }); if (firstThisParameterOfUnionSignatures) { - var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType; }), 2 /* Subtype */); + var thisType = getIntersectionType(ts.mapDefined(unionSignatures, function (sig) { return sig.thisParameter && getTypeOfSymbol(sig.thisParameter); })); thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType); } s = createUnionSignature(signature, unionSignatures); @@ -38144,8 +38735,8 @@ var ts; } // 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 - // permissive when calling, for now, we'll union the `this` types just like the overlapping-union-signature check does - var thisType = getUnionType([getTypeOfSymbol(left), getTypeOfSymbol(right)], 2 /* Subtype */); + // permissive when calling, for now, we'll intersect the `this` types just like we do for param types in union signatures. + var thisType = getIntersectionType([getTypeOfSymbol(left), getTypeOfSymbol(right)]); return createSymbolWithType(left, thisType); } function combineUnionParameters(left, right) { @@ -38299,7 +38890,7 @@ var ts; * Converts an AnonymousType to a ResolvedType. */ function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; + var symbol = getMergedSymbol(type.symbol); if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); @@ -38355,14 +38946,18 @@ var ts; // will never be observed because a qualified name can't reference signatures. if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); - type.constructSignatures = ts.filter(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration); }); } // And likewise for construct signatures for classes if (symbol.flags & 32 /* Class */) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)); + var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* Function */) { + constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes) : + undefined; })); + } if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); + constructSignatures = getDefaultConstructSignatures(classType_1); } type.constructSignatures = constructSignatures; } @@ -38505,7 +39100,7 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 180 /* TypeOperator */ && + return constraintDeclaration.kind === 181 /* TypeOperator */ && constraintDeclaration.operator === 130 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { @@ -38519,7 +39114,7 @@ var ts; else { // Otherwise, get the declared constraint type, and if the constraint type is a type parameter, // get the constraint of that type parameter. If the resulting type is an indexed type 'keyof T', - // the modifiers type is T. Otherwise, the modifiers type is {}. + // the modifiers type is T. Otherwise, the modifiers type is unknown. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; @@ -38573,9 +39168,16 @@ var ts; else if (type.flags & 2097152 /* Intersection */) { resolveIntersectionTypeMembers(type); } + else if (type.flags & 134217728 /* StructuralTag */) { + resolveStructuralTagTypeMembers(type); + } } return type; } + function resolveStructuralTagTypeMembers(type) { + // Explicitly do nothing - structured tags, despite "containing structure" (in their argument), do not have any visible structure. + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { if (type.flags & 524288 /* Object */) { @@ -38890,6 +39492,9 @@ var ts; if (t.flags & 33554432 /* Substitution */) { return getBaseConstraint(t.substitute); } + if (t.flags & 134217728 /* StructuralTag */) { + return unknownType; + } return t; } } @@ -39136,7 +39741,7 @@ var ts; return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 137887744 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; } @@ -39150,7 +39755,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 137887744 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* String */ ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -39209,10 +39814,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 === 294 /* JSDocOptionalType */ + node.type && node.type.kind === 295 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 295 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -39246,7 +39851,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 295 /* JSDocOptionalType */; } function createIdentifierTypePredicate(parameterName, parameterIndex, type) { return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -39318,7 +39923,7 @@ var ts; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; // Include parameter symbol instead of property symbol in the signature if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 67220415 /* Value */, undefined, undefined, /*isUse*/ false); + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } if (i === 0 && paramSymbol.escapedName === "this" /* This */) { @@ -39328,7 +39933,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 183 /* LiteralType */) { + if (type && type.kind === 184 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -39342,16 +39947,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 === 159 /* GetAccessor */ || declaration.kind === 160 /* SetAccessor */) && + if ((declaration.kind === 160 /* GetAccessor */ || declaration.kind === 161 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = declaration.kind === 160 /* GetAccessor */ ? 161 /* SetAccessor */ : 160 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 158 /* Constructor */ ? + var classType = declaration.kind === 159 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -39411,11 +40016,11 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return node.name.kind === 150 /* ComputedPropertyName */ + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + return node.name.kind === 151 /* ComputedPropertyName */ && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -39505,7 +40110,6 @@ var ts; var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) : getReturnTypeFromAnnotation(signature.declaration) || - isJSConstructor(signature.declaration) && getJSClassType(getSymbolOfNode(signature.declaration)) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); if (!popTypeResolution()) { if (signature.declaration) { @@ -39531,7 +40135,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 158 /* Constructor */) { + if (declaration.kind === 159 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -39541,12 +40145,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 159 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 160 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 160 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 161 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -39636,7 +40240,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 === 158 /* Constructor */ || kind === 162 /* ConstructSignature */ || kind === 167 /* ConstructorType */; + var isConstructor = kind === 159 /* Constructor */ || kind === 163 /* ConstructSignature */ || kind === 168 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -39677,7 +40281,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 151 /* TypeParameter */); + var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 152 /* TypeParameter */); return decl && ts.getEffectiveConstraintOfTypeParameter(decl); } function getInferredTypeParameterConstraint(typeParameter) { @@ -39685,13 +40289,13 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 177 /* InferType */) { + if (declaration.parent.kind === 178 /* 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 grandParent = declaration.parent.parent; - if (grandParent.kind === 165 /* TypeReference */) { + if (grandParent.kind === 166 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -39716,7 +40320,7 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter // declaration, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 152 /* Parameter */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 153 /* Parameter */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -39740,7 +40344,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 151 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 152 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -39817,13 +40421,13 @@ var ts; var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent); - var diag = minTypeArgumentCount === typeParameters.length - ? missingAugmentsTag - ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : missingAugmentsTag - ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; + var diag = minTypeArgumentCount === typeParameters.length ? + missingAugmentsTag ? + ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + missingAugmentsTag ? + ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { @@ -39862,9 +40466,9 @@ var ts; var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { - error(node, minTypeArgumentCount === typeParameters.length - ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); + error(node, minTypeArgumentCount === typeParameters.length ? + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } return getTypeAliasInstantiation(symbol, typeArguments); @@ -39873,9 +40477,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -39886,34 +40490,23 @@ var ts; } return undefined; } - function resolveTypeReferenceName(typeReferenceName, meaning) { + function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) { if (!typeReferenceName) { return unknownSymbol; } - return resolveEntityName(typeReferenceName, meaning) || unknownSymbol; + return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. if (symbol === unknownSymbol) { return errorType; } - var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); - if (type) { - return type; + symbol = getExpandoSymbol(symbol) || symbol; + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); } - // JS enums are 'string' or 'number', not an enum type. - var enumTag = ts.isInJSFile(node) && symbol.valueDeclaration && ts.getJSDocEnumTag(symbol.valueDeclaration); - if (enumTag) { - var links = getNodeLinks(enumTag); - if (!pushTypeResolution(enumTag, 5 /* EnumTagType */)) { - return errorType; - } - var type_4 = enumTag.typeExpression ? getTypeFromTypeNode(enumTag.typeExpression) : errorType; - if (!popTypeResolution()) { - type_4 = errorType; - error(node, ts.Diagnostics.Enum_type_0_circularly_references_itself, symbolToString(symbol)); - } - return (links.resolvedEnumType = type_4); + if (symbol.flags & 524288 /* TypeAlias */) { + return getTypeFromTypeAliasReference(node, symbol, typeArguments); } // Get type from reference to named type that cannot be generic (enum or type parameter) var res = tryGetDeclaredTypeOfSymbol(symbol); @@ -39922,55 +40515,31 @@ var ts; res.flags & 262144 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } - if (!(symbol.flags & 67220415 /* Value */ && isJSDocTypeReference(node))) { - return errorType; - } - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; + if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + var jsdocType = getTypeFromJSAlias(node, symbol); + if (jsdocType) { + return jsdocType; + } + else { + // Resolve the type reference as a Type for the purpose of reporting errors. + resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */); + return getTypeOfSymbol(symbol); + } } - // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(getTypeReferenceName(node), 67897832 /* Type */); - return getTypeOfSymbol(symbol); + return errorType; } /** - * A jsdoc TypeReference may have resolved to a value (as opposed to a type). If - * the symbol is a constructor function, return the inferred class type; otherwise, - * the type of this reference is just the type of the value we resolved to. + * A JSdoc TypeReference may be to a value imported from commonjs. + * These should really be aliases, but this special-case code fakes alias resolution + * by producing a type from a value. */ - function getJSDocTypeReference(node, symbol, typeArguments) { - // In the case of an assignment of a function expression (binary expressions, variable declarations, etc.), we will get the - // correct instance type for the symbol on the LHS by finding the type for RHS. For example if we want to get the type of the symbol `foo`: - // var foo = function() {} - // We will find the static type of the assigned anonymous function. - var staticType = getTypeOfSymbol(symbol); - var instanceType = staticType.symbol && - staticType.symbol !== symbol && // Make sure this is an assignment like expression by checking that symbol -> type -> symbol doesn't roundtrips. - getTypeReferenceTypeWorker(node, staticType.symbol, typeArguments); // Get the instance type of the RHS symbol. - if (instanceType) { - return getSymbolLinks(symbol).resolvedJSDocType = instanceType; - } - } - function getTypeReferenceTypeWorker(node, symbol, typeArguments) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (symbol.valueDeclaration && symbol.valueDeclaration.parent && ts.isBinaryExpression(symbol.valueDeclaration.parent)) { - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; - } - } - return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); - } - if (symbol.flags & 524288 /* TypeAlias */) { - return getTypeFromTypeAliasReference(node, symbol, typeArguments); - } - if (symbol.flags & 16 /* Function */ && - isJSDocTypeReference(node) && - isJSConstructor(symbol.valueDeclaration)) { - var resolved = resolveStructuredTypeMembers(getTypeOfSymbol(symbol)); - if (resolved.callSignatures.length === 1) { - return getReturnTypeOfSignature(resolved.callSignatures[0]); - } + function getTypeFromJSAlias(node, symbol) { + var valueType = getTypeOfSymbol(symbol); + var typeType = valueType.symbol && + valueType.symbol !== symbol && // Make sure this is a commonjs export by checking that symbol -> type -> symbol doesn't roundtrip. + getTypeReferenceType(node, valueType.symbol); + if (typeType) { + return getSymbolLinks(symbol).resolvedJSDocType = typeType; } } function getSubstitutionType(typeVariable, substitute) { @@ -39989,7 +40558,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 171 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 172 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -39998,9 +40567,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 297 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 299 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 176 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 177 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -40011,7 +40580,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 165 /* TypeReference */ || node.kind === 184 /* ImportType */); + return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 166 /* TypeReference */ || node.kind === 185 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -40048,10 +40617,10 @@ var ts; return globalFunctionType; case "Array": case "array": - return !typeArgs || !typeArgs.length ? anyArrayType : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined; case "Promise": case "promise": - return !typeArgs || !typeArgs.length ? createPromiseType(anyType) : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined; case "Object": if (typeArgs && typeArgs.length === 2) { if (ts.isJSDocIndexSignature(node)) { @@ -40063,7 +40632,7 @@ var ts; return anyType; } checkNoTypeArguments(node); - return anyType; + return !noImplicitAny ? anyType : undefined; } } } @@ -40076,10 +40645,19 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - var meaning = 67897832 /* Type */; + var meaning = 788968 /* Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); - meaning |= 67220415 /* Value */; + if (!type) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, /*ignoreErrors*/ true); + if (symbol === unknownSymbol) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551 /* Value */); + } + else { + resolveTypeReferenceName(getTypeReferenceName(node), meaning); // Resolve again to mark errors, if any + } + type = getTypeReferenceType(node, symbol); + } } if (!type) { symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning); @@ -40112,9 +40690,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: return declaration; } } @@ -40134,10 +40712,10 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67220415 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67897832 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { // Don't track references for global symbols anyway, so value if `isReference` is arbitrary @@ -40206,7 +40784,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 67897832 /* Type */, /*diagnostic*/ undefined); + var symbol = getGlobalSymbol(name, 788968 /* Type */, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -40316,8 +40894,8 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 173 /* RestType */ ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 172 /* OptionalType */ && n !== restElement_1; }) + 1; + var restElement_1 = lastElement && lastElement.kind === 174 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 173 /* OptionalType */ && n !== restElement_1; }) + 1; var elementTypes = ts.map(node.elementTypes, function (n) { var type = getTypeFromTypeNode(n); return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; @@ -40360,7 +40938,7 @@ var ts; // We ignore 'never' types in unions if (!(flags & 131072 /* Never */)) { includes |= flags & 68943871 /* IncludesMask */; - if (flags & 66846720 /* StructuredOrInstantiable */) + if (flags & 201064448 /* StructuredOrInstantiable */) includes |= 262144 /* IncludesStructuredOrInstantiable */; if (type === wildcardType) includes |= 4194304 /* IncludesWildcard */; @@ -40492,7 +41070,7 @@ var ts; neverType; } } - return getUnionTypeFromSortedList(typeSet, includes & 66994211 /* NotPrimitiveUnion */ ? 0 : 131072 /* PrimitiveUnion */, aliasSymbol, aliasTypeArguments); + return getUnionTypeFromSortedList(typeSet, includes & 201211939 /* NotPrimitiveUnion */ ? 0 : 131072 /* PrimitiveUnion */, aliasSymbol, aliasTypeArguments); } function getUnionTypePredicate(signatures) { var first; @@ -40562,10 +41140,10 @@ var ts; } return links.resolvedType; } - function addTypeToIntersection(typeSet, includes, type) { + function addTypeToIntersection(typeSet, includes, type, tagSet) { var flags = type.flags; if (flags & 2097152 /* Intersection */) { - return addTypesToIntersection(typeSet, includes, type.types); + return addTypesToIntersection(typeSet, includes, type.types, tagSet); } if (isEmptyAnonymousObjectType(type)) { if (!(includes & 8388608 /* IncludesEmptyObject */)) { @@ -40578,6 +41156,9 @@ var ts; if (type === wildcardType) includes |= 4194304 /* IncludesWildcard */; } + else if (flags & 134217728 /* StructuralTag */) { + tagSet.set(type.id.toString(), type); + } else if ((strictNullChecks || !(flags & 98304 /* Nullable */)) && !typeSet.has(type.id.toString())) { if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) { // We have seen two distinct unit types which means we should reduce to an @@ -40592,10 +41173,27 @@ var ts; } // Add the given types to the given type set. Order is preserved, freshness is removed from literal // types, duplicates are removed, and nested types of the given kind are flattened into the set. - function addTypesToIntersection(typeSet, includes, types) { + function addTypesToIntersection(typeSet, includes, types, tagSet) { + var isTopLevel = !tagSet; + tagSet = tagSet || ts.createMap(); for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { var type = types_8[_i]; - includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); + includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type), tagSet); + } + if (isTopLevel && tagSet.size) { + var tag = void 0; + if (tagSet.size === 1) { + tag = tagSet.values().next().value; + } + else { + var tagTypes_1 = []; + tagSet.forEach(function (t) { return tagTypes_1.push(t.type); }); + tag = getStructuralTagForType(getIntersectionType(tagTypes_1)); + if (tag.flags & 1048576 /* Union */) { + includes |= 1048576 /* Union */; + } + } + typeSet.set(tag.id.toString(), tag); } return includes; } @@ -40632,6 +41230,15 @@ var ts; } return true; } + function extractIrreducible(types, flag) { + if (ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); })) { + for (var i = 0; i < types.length; i++) { + types[i] = filterType(types[i], function (t) { return !(t.flags & flag); }); + } + return true; + } + return false; + } // If the given list of types contains more than one union of primitive types, replace the // first with a union containing an intersection of those primitive types, then remove the // other unions and return true. Otherwise, do nothing and return false. @@ -40750,6 +41357,12 @@ var ts; // reduced we'll never reduce again, so this occurs at most once. result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } + else if (extractIrreducible(typeSet, 32768 /* Undefined */)) { + result = getUnionType([getIntersectionType(typeSet), undefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + } + else if (extractIrreducible(typeSet, 65536 /* Null */)) { + result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + } else { // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain. @@ -40865,9 +41478,16 @@ var ts; case 134 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; + case 148 /* TagKeyword */: + var aliasSymbol = getAliasSymbolForTypeNode(node); + var aliasParams = getTypeArgumentsForAliasSymbol(aliasSymbol); + links.resolvedType = getStructuralTagForType(getTypeFromTypeNode(node.type), aliasSymbol, aliasParams); + break; + default: + throw ts.Debug.assertNever(node.operator); } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function createIndexedAccessType(objectType, indexType) { var type = createType(8388608 /* IndexedAccess */); @@ -40875,6 +41495,26 @@ var ts; type.indexType = indexType; return type; } + function getStructuralTagForType(type, aliasSymbol, aliasTypeArguments) { + if (typeof aliasSymbol === "number") { + aliasSymbol = undefined; + } + var tid = "" + getTypeId(type); + if (structuralTags.has(tid)) { + return structuralTags.get(tid); + } + if (type.flags & 1048576 /* Union */) { + var union = getUnionType(ts.map(type.types, getStructuralTagForType), 2 /* Subtype */, aliasSymbol, aliasTypeArguments); + structuralTags.set(tid, union); + return union; + } + var tag = createType(134217728 /* StructuralTag */); + tag.type = type; + tag.aliasSymbol = aliasSymbol; + tag.aliasTypeArguments = aliasTypeArguments; + structuralTags.set(tid, tag); + return tag; + } /** * Returns if a type is or consists of a JSLiteral object type * In addition to objects which are directly literals, @@ -40903,7 +41543,7 @@ var ts; return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 192 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -40914,7 +41554,7 @@ var ts; undefined; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 192 /* ElementAccessExpression */ ? accessNode : undefined; var propName = getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); @@ -41051,13 +41691,10 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 191 /* ElementAccessExpression */ - ? accessNode.argumentExpression - : accessNode.kind === 181 /* IndexedAccessType */ - ? accessNode.indexType - : accessNode.kind === 150 /* ComputedPropertyName */ - ? accessNode.expression - : accessNode; + return accessNode.kind === 192 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 182 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 151 /* ComputedPropertyName */ ? accessNode.expression : + accessNode; } function isGenericObjectType(type) { return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 131072 /* GenericMappedType */); @@ -41182,7 +41819,7 @@ var ts; // object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in // an expression. This is to preserve backwards compatibility. For example, an element access 'this["foo"]' // has always been resolved eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 181 /* IndexedAccessType */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 182 /* IndexedAccessType */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -41394,7 +42031,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 67220415 /* Value */ : node.flags & 2097152 /* JSDoc */ ? 67220415 /* Value */ | 67897832 /* Type */ : 67897832 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 2097152 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { @@ -41417,14 +42054,14 @@ var ts; getNodeLinks(current.parent).resolvedSymbol = next; currentNamespace = next; } - resolveImportSymbolType(node, links, currentNamespace, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning); } else { if (moduleSymbol.flags & targetMeaning) { - resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 67220415 /* Value */ + var errorMessage = targetMeaning === 111551 /* Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -41433,16 +42070,16 @@ var ts; } } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 67220415 /* Value */) { - return links.resolvedType = getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias + if (meaning === 111551 /* Value */) { + return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { - return links.resolvedType = getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol + return getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol } } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { @@ -41466,7 +42103,11 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined; + var host = node.parent; + while (ts.isParenthesizedTypeNode(host)) { + host = host.parent; + } + return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; } function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; @@ -41655,12 +42296,26 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 242 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 243 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 158 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } + // inside x.prototype = { ... } + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; + } + // /** @return {this} */ + // x.prototype.m = function() { ... } + var host = node.flags & 2097152 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; + } + // inside constructor function C() { ... } + if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType; + } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); return errorType; } @@ -41674,8 +42329,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 121 /* AnyKeyword */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 291 /* JSDocAllType */: + case 292 /* JSDocUnknownType */: return anyType; case 144 /* UnknownKeyword */: return unknownType; @@ -41699,63 +42354,63 @@ var ts; return neverType; case 137 /* ObjectKeyword */: return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 179 /* ThisType */: + case 180 /* ThisType */: case 101 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 183 /* LiteralType */: + case 184 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return getTypeFromTypeReference(node); - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return booleanType; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 171 /* TupleType */: + case 172 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 172 /* OptionalType */: + case 173 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 174 /* UnionType */: + case 175 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 175 /* IntersectionType */: + case 176 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 292 /* JSDocNullableType */: + case 293 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 294 /* JSDocOptionalType */: + case 295 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 178 /* ParenthesizedType */: - case 173 /* RestType */: - case 293 /* JSDocNonNullableType */: - case 289 /* JSDocTypeExpression */: + case 179 /* ParenthesizedType */: + case 174 /* RestType */: + case 294 /* JSDocNonNullableType */: + case 290 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 296 /* JSDocVariadicType */: + case 297 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 295 /* JSDocFunctionType */: - case 299 /* JSDocSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 170 /* TypeLiteral */: + case 300 /* JSDocTypeLiteral */: + case 296 /* JSDocFunctionType */: + case 301 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 182 /* MappedType */: + case 183 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 177 /* InferType */: + case 178 /* InferType */: return getTypeFromInferTypeNode(node); - case 184 /* ImportType */: + case 185 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -41884,7 +42539,7 @@ var ts; } function instantiateSymbol(symbol, mapper) { var links = getSymbolLinks(symbol); - if (links.type && !maybeTypeOfKind(links.type, 524288 /* Object */ | 63176704 /* Instantiable */)) { + if (links.type && !maybeTypeOfKind(links.type, 524288 /* Object */ | 63176704 /* Instantiable */ | 134217728 /* StructuralTag */)) { // If the type of the symbol is already resolved, and if that type could not possibly // be affected by instantiation, simply return the symbol itself. return symbol; @@ -41964,8 +42619,9 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 149 /* QualifiedName */ || - node.parent.kind === 165 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 150 /* QualifiedName */ || + node.parent.kind === 166 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 185 /* 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 @@ -41974,7 +42630,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 219 /* Block */ || n.kind === 176 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 220 /* Block */ || n.kind === 177 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -41983,12 +42639,12 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 179 /* ThisType */: + case 180 /* ThisType */: return !!tp.isThisType; case 73 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return true; } return !!ts.forEachChild(node, containsReference); @@ -42182,6 +42838,10 @@ var ts; return sub; } } + if (flags & 134217728 /* StructuralTag */) { + var newType = instantiateType(type.type, mapper); + return newType !== type ? getStructuralTagForType(newType, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; + } return type; } function getPermissiveInstantiation(type) { @@ -42210,35 +42870,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 !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return node.operatorToken.kind === 55 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 268 /* JsxAttribute */: { + case 269 /* 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 271 /* JsxExpression */: { + case 272 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -42258,7 +42918,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 198 /* ArrowFunction */) { + if (node.kind !== 199 /* 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); @@ -42270,7 +42930,7 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !!node.body && node.body.kind !== 219 /* Block */ && isContextSensitive(node.body); + return !!node.body && node.body.kind !== 220 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -42373,23 +43033,23 @@ var ts; return true; } switch (node.kind) { - case 271 /* JsxExpression */: - case 196 /* ParenthesizedExpression */: + case 272 /* JsxExpression */: + case 197 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (node.operatorToken.kind) { case 60 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -42561,7 +43221,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -42570,9 +43230,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 266 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -42646,7 +43306,7 @@ var ts; var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName); var childrenTargetType = getIndexedAccessType(target, getLiteralType(childrenPropName)); var diagnostic = ts.Diagnostics._0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2; - invalidTextDiagnostic = __assign({}, diagnostic, { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); + invalidTextDiagnostic = __assign(__assign({}, diagnostic), { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); } return invalidTextDiagnostic; } @@ -42714,11 +43374,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 160 /* SetAccessor */: return [3 /*break*/, 2]; - case 159 /* GetAccessor */: return [3 /*break*/, 2]; - case 157 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 277 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 276 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 161 /* SetAccessor */: return [3 /*break*/, 2]; + case 160 /* GetAccessor */: return [3 /*break*/, 2]; + case 158 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 278 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 277 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -42790,8 +43450,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 157 /* MethodDeclaration */ && - kind !== 156 /* MethodSignature */ && kind !== 158 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 158 /* MethodDeclaration */ && + kind !== 157 /* MethodSignature */ && kind !== 159 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -42839,15 +43499,17 @@ var ts; result &= related; } if (!ignoreReturnTypes) { - // If a signature reolution is already in-flight, skip issuing a circularity error + // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly - var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType : (target.declaration && isJSConstructor(target.declaration)) ? - getJSClassType(target.declaration.symbol) : getReturnTypeOfSignature(target); + var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType + : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(target.declaration.symbol) + : getReturnTypeOfSignature(target); if (targetReturnType === voidType) { return result; } - var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType : (source.declaration && isJSConstructor(source.declaration)) ? - getJSClassType(source.declaration.symbol) : getReturnTypeOfSignature(source); + var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType + : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(source.declaration.symbol) + : getReturnTypeOfSignature(source); // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions var targetTypePredicate = getTypePredicateOfSignature(target); if (targetTypePredicate) { @@ -43033,7 +43695,7 @@ var ts; return related === 1 /* Succeeded */; } } - if (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */) { + if (source.flags & 201064448 /* StructuredOrInstantiable */ || target.flags & 201064448 /* StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; @@ -43094,7 +43756,7 @@ var ts; } var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); if (relatedInfo) { - ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInfo)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInfo)); } if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -43139,8 +43801,8 @@ var ts; reportError(message, sourceType, targetType); } function tryElaborateErrorsForPrimitivesAndObjects(source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); + var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source); + var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target); if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || @@ -43233,7 +43895,7 @@ var ts; isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); - var isPerformingExcessPropertyChecks = (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); + var isPerformingExcessPropertyChecks = !isApparentIntersectionConstituent && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); if (isPerformingExcessPropertyChecks) { var discriminantType = target.flags & 1048576 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { @@ -43243,11 +43905,11 @@ var ts; return 0 /* False */; } } - if (relation !== comparableRelation && !isApparentIntersectionConstituent && + var isPerformingCommonPropertyChecks = relation !== comparableRelation && !isApparentIntersectionConstituent && source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType && target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) && - (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)) && - !hasCommonProperties(source, target, isComparingJsxAttributes)) { + (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); + if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var calls = getSignaturesOfType(source, 0 /* Call */); var constructs = getSignaturesOfType(source, 1 /* Construct */); @@ -43269,16 +43931,16 @@ var ts; // and we need to handle "each" relations before "some" relations for the same kind of type. if (source.flags & 1048576 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)) : + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), isIntersectionConstituent) : eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)); } else { if (target.flags & 1048576 /* Union */) { result = typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { // Validate against excess props using the original `source` var discriminantType = findMatchingDiscriminantType(source, target) || filterPrimitivesIfContainsNonPrimitive(target); - if (!propertiesRelatedTo(source, discriminantType, reportErrors, /*excludedProperties*/ undefined)) { + if (!propertiesRelatedTo(source, discriminantType, reportErrors, /*excludedProperties*/ undefined, isIntersectionConstituent)) { return 0 /* False */; } } @@ -43286,9 +43948,9 @@ var ts; else if (target.flags & 2097152 /* Intersection */) { isIntersectionConstituent = true; // set here to affect the following trio of checks result = typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { // Validate against excess props using the original `source` - if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined)) { + if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, /*isIntersectionConstituent*/ false)) { return 0 /* False */; } } @@ -43307,9 +43969,9 @@ var ts; // // - For a primitive type or type parameter (such as 'number = A & B') there is no point in // breaking the intersection apart. - result = someTypeRelatedToType(source, target, /*reportErrors*/ false); + result = someTypeRelatedToType(source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ true); } - if (!result && (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */)) { + if (!result && (source.flags & 201064448 /* StructuredOrInstantiable */ || target.flags & 201064448 /* StructuredOrInstantiable */)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { errorInfo = saveErrorInfo; } @@ -43576,14 +44238,14 @@ var ts; } return result; } - function someTypeRelatedToType(source, target, reportErrors) { + function someTypeRelatedToType(source, target, reportErrors, isIntersectionConstituent) { var sourceTypes = source.types; if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, isIntersectionConstituent); if (related) { return related; } @@ -43603,7 +44265,7 @@ var ts; } return result; } - function typeArgumentsRelatedTo(sources, targets, variances, reportErrors) { + function typeArgumentsRelatedTo(sources, targets, variances, reportErrors, isIntersectionConstituent) { if (sources === void 0) { sources = ts.emptyArray; } if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } @@ -43630,10 +44292,10 @@ var ts; related = relation === identityRelation ? isRelatedTo(s, t, /*reportErrors*/ false) : compareTypesIdentical(s, t); } else if (variance === 1 /* Covariant */) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } else if (variance === 2 /* Contravariant */) { - related = isRelatedTo(t, s, reportErrors); + related = isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } else if (variance === 3 /* Bivariant */) { // In the bivariant case we first compare contravariantly without reporting @@ -43642,16 +44304,16 @@ var ts; // which is generally easier to reason about. related = isRelatedTo(t, s, /*reportErrors*/ false); if (!related) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } else { // In the invariant case we first compare covariantly, and only when that // succeeds do we proceed to compare contravariantly. Thus, error elaboration // will typically be based on the covariant check. - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); if (related) { - related &= isRelatedTo(t, s, reportErrors); + related &= isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } if (!related) { @@ -43781,6 +44443,9 @@ var ts; if (flags & 33554432 /* Substitution */) { return isRelatedTo(source.substitute, target.substitute, /*reportErrors*/ false); } + if (flags & 134217728 /* StructuralTag */) { + return isRelatedTo(source.type, target.type, /*reportErrors*/ false); + } return 0 /* False */; } var result; @@ -43794,7 +44459,7 @@ var ts; source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) { var variances = getAliasVariances(source.aliasSymbol); - var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances); + var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -43880,6 +44545,12 @@ var ts; } } } + else if (target.flags & 134217728 /* StructuralTag */) { + if (source.flags & 134217728 /* StructuralTag */) { + return isRelatedTo(source.type, target.type, reportErrors); + } + return 0 /* False */; + } 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. @@ -43923,9 +44594,19 @@ var ts; // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. - if (isTypeIdenticalTo(source.extendsType, target.extendsType) && + var sourceParams = source.root.inferTypeParameters; + var sourceExtends = source.extendsType; + var mapper = void 0; + if (sourceParams) { + // If the source has infer type parameters, we instantiate them in the context of the target + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedTo); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 64 /* NoConstraints */ | 128 /* AlwaysStrict */); + sourceExtends = instantiateType(sourceExtends, ctx.mapper); + mapper = ctx.mapper; + } + if (isTypeIdenticalTo(sourceExtends, target.extendsType) && (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { - if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } if (result) { @@ -43978,7 +44659,7 @@ var ts; // type references (which are intended by be compared structurally). Obtain the variance // information for the type parameters and relate the type arguments accordingly. var variances = getVariances(source.target); - var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances); + var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -44006,7 +44687,7 @@ var ts; if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 524288 /* Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; - result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined); + result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, isIntersectionConstituent); if (result) { result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); if (result) { @@ -44041,8 +44722,8 @@ var ts; } } return 0 /* False */; - function relateVariances(sourceTypeArguments, targetTypeArguments, variances) { - if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors)) { + function relateVariances(sourceTypeArguments, targetTypeArguments, variances, isIntersectionConstituent) { + if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, isIntersectionConstituent)) { return result; } if (ts.some(variances, function (v) { return !!(v & 24 /* AllowsStructuralFallback */); })) { @@ -44167,7 +44848,7 @@ var ts; if (sourceProperty === targetProperty) return "continue"; // We compare the source property to the target in the context of a single discriminant type. - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, /*isIntersectionConstituent*/ false); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -44197,7 +44878,7 @@ var ts; var result = -1 /* True */; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties); + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, /*isIntersectionConstituent*/ false); if (result) { result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false); if (result) { @@ -44232,7 +44913,7 @@ var ts; } return result || properties; } - function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); var source = getTypeOfSourceProperty(sourceProp); if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { @@ -44272,10 +44953,10 @@ var ts; return result_7; } else { - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } - function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { @@ -44313,7 +44994,7 @@ var ts; return 0 /* False */; } // If the target comes from a partial union prop, allow `undefined` in the target type - var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors); + var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); @@ -44336,7 +45017,7 @@ var ts; } return related; } - function propertiesRelatedTo(source, target, reportErrors, excludedProperties) { + function propertiesRelatedTo(source, target, reportErrors, excludedProperties, isIntersectionConstituent) { if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } @@ -44352,7 +45033,7 @@ var ts; } if (props.length === 1) { var propName = symbolToString(unmatchedProperty); - reportError.apply(void 0, [ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName].concat(getTypeNamesForErrorDisplay(source, target))); + reportError.apply(void 0, __spreadArrays([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target))); if (ts.length(unmatchedProperty.declarations)) { associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); } @@ -44425,7 +45106,7 @@ var ts; if (!(targetProp.flags & 4194304 /* Prototype */)) { var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp && sourceProp !== targetProp) { - var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors); + var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, isIntersectionConstituent); if (!related) { return 0 /* False */; } @@ -44604,7 +45285,7 @@ var ts; if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U } // if T is related to U. - return (kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); // TODO: GH#18217 + return kind === 0 /* String */ ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) : 0 /* False */; } if (isObjectTypeWithInferableIndex(source)) { var related = -1 /* True */; @@ -44660,23 +45341,27 @@ var ts; } } function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue) { - var match; + // undefined=unknown, true=discriminated, false=not discriminated + // The state of each type progresses from left to right. Discriminated types stop at 'true'. + var discriminable = target.types.map(function (_) { return undefined; }); for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; + var i = 0; for (var _b = 0, _c = target.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, propertyName); if (targetType && related(getDiscriminatingType(), targetType)) { - if (match) { - if (type === match) - continue; // Finding multiple fields which discriminate to the same type is fine - return defaultValue; - } - match = type; + discriminable[i] = discriminable[i] === undefined ? true : discriminable[i]; + } + else { + discriminable[i] = false; } + i++; } } - return match || defaultValue; + var match = discriminable.indexOf(/*searchElement*/ true); + // make sure exactly 1 matches before returning it + return match === -1 || discriminable.indexOf(/*searchElement*/ true, match + 1) !== -1 ? defaultValue : target.types[match]; } /** * A type is 'weak' if it is an object type with at least one optional property @@ -44879,6 +45564,9 @@ var ts; // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least 5 // levels, but unequal at some level beyond that. + // In addition, this will also detect when an indexed access has been chained off of 5 or more times (which is essentially + // the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding false positives + // for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`). function isDeeplyNestedType(type, stack, depth) { // We track all object types that have an associated symbol (representing the origin of the type) if (depth >= 5 && type.flags & 524288 /* Object */) { @@ -44895,8 +45583,30 @@ var ts; } } } + if (depth >= 5 && type.flags & 8388608 /* IndexedAccess */) { + var root = getRootObjectTypeFromIndexedAccessChain(type); + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (getRootObjectTypeFromIndexedAccessChain(t) === root) { + count++; + if (count >= 5) + return true; + } + } + } return false; } + /** + * Gets the leftmost object type in a chain of indexed accesses, eg, in A[P][Q], returns A + */ + function getRootObjectTypeFromIndexedAccessChain(type) { + var t = type; + while (t.flags & 8388608 /* IndexedAccess */) { + t = t.objectType; + } + return t; + } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; } @@ -45258,8 +45968,8 @@ var ts; * with no call or construct signatures. */ function isObjectTypeWithInferableIndex(type) { - return type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && - !typeHasCallOrConstructSignatures(type); + return !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); @@ -45478,17 +46188,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 205 /* BinaryExpression */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 206 /* BinaryExpression */: + case 156 /* PropertyDeclaration */: + case 155 /* 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 152 /* Parameter */: + case 153 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 67897832 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || + (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, ts.declarationNameToString(param.name)); @@ -45498,23 +46208,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 187 /* BindingElement */: + case 188 /* 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 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 1 /* 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); @@ -45528,7 +46238,7 @@ var ts; wideningKind === 1 /* 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 182 /* MappedType */: + case 183 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -45649,10 +46359,11 @@ var ts; function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); return !!(type.flags & 63176704 /* Instantiable */ || + type.flags & 134217728 /* StructuralTag */ && couldContainTypeVariables(type.type) || objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, 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 */ || - type.flags & 3145728 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { @@ -45807,8 +46518,7 @@ var ts; var visited; var bivariant = false; var propagationType; - var inferenceCount = 0; - var inferenceIncomplete = false; + var inferencePriority = 256 /* MaxValue */; var allowComplexConstraintInference = true; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { @@ -45831,50 +46541,57 @@ var ts; inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); return; } - if (source.flags & 1048576 /* Union */ && target.flags & 1048576 /* Union */ && !(source.flags & 1024 /* EnumLiteral */ && target.flags & 1024 /* EnumLiteral */) || - source.flags & 2097152 /* Intersection */ && target.flags & 2097152 /* Intersection */) { - // Source and target are both unions or both intersections. If source and target - // are the same type, just relate each constituent type to itself. - if (source === target) { - for (var _i = 0, _a = source.types; _i < _a.length; _i++) { - var t = _a[_i]; - inferFromTypes(t, t); - } - return; - } - // Find each source constituent type that has an identically matching target constituent - // type, and for each such type infer from the type to itself. When inferring from a - // type to itself we effectively find all type parameter occurrences within that type - // and infer themselves as their type arguments. We have special handling for numeric - // and string literals because the number and string types are not represented as unions - // of all their possible values. - var matchingTypes = void 0; - for (var _b = 0, _c = source.types; _b < _c.length; _b++) { - var t = _c[_b]; - var matched = findMatchedType(t, target); - if (matched) { - (matchingTypes || (matchingTypes = [])).push(matched); - inferFromTypes(matched, matched); - } - } - // Next, to improve the quality of inferences, reduce the source and target types by - // removing the identically matched constituents. For example, when inferring from - // 'string | string[]' to 'string | T' we reduce the types to 'string[]' and 'T'. - if (matchingTypes) { - var s = removeTypesFromUnionOrIntersection(source, matchingTypes); - var t = removeTypesFromUnionOrIntersection(target, matchingTypes); - if (!(s && t)) - return; - source = s; - target = t; + if (source === target && source.flags & 3145728 /* UnionOrIntersection */) { + // When source and target are the same union or intersection type, just relate each constituent + // type to itself. + for (var _i = 0, _a = source.types; _i < _a.length; _i++) { + var t = _a[_i]; + inferFromTypes(t, t); } + return; } - else if (target.flags & 1048576 /* Union */ && !(target.flags & 1024 /* EnumLiteral */) || target.flags & 2097152 /* Intersection */) { - var matched = findMatchedType(source, target); - if (matched) { - inferFromTypes(matched, matched); + if (target.flags & 1048576 /* Union */) { + // First, infer between identically matching source and target constituents and remove the + // matching types. + var _b = inferFromMatchingTypes(source.flags & 1048576 /* Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + // Next, infer between closely matching source and target constituents and remove + // the matching types. Types closely match when they are instantiations of the same + // object type or instantiations of the same type alias. + var _c = inferFromMatchingTypes(tempSources, tempTargets, isTypeCloselyMatchedBy), sources = _c[0], targets = _c[1]; + if (targets.length === 0) { return; } + target = getUnionType(targets); + if (sources.length === 0) { + // All source constituents have been matched and there is nothing further to infer from. + // However, simply making no inferences is undesirable because it could ultimately mean + // inferring a type parameter constraint. Instead, make a lower priority inference from + // the full source to whatever remains in the target. For example, when inferring from + // string to 'string | T', make a lower priority inference of string for T. + var savePriority = priority; + priority |= 1 /* NakedTypeVariable */; + inferFromTypes(source, target); + priority = savePriority; + return; + } + source = getUnionType(sources); + } + else if (target.flags & 2097152 /* Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + // We reduce intersection types only when they contain naked type parameters. For example, when + // inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and + // infer { extra: any } for T. But when inferring to 'string[] & Iterable' we want to keep the + // string[] on the source side and infer string for T. + // Likewise, we consider a homomorphic mapped type constrainted to the target type parameter as similar to a "naked type variable" + // in such scenarios. + if (!(source.flags & 1048576 /* Union */)) { + // Infer between identically matching source and target constituents and remove the matching types. + var _d = inferFromMatchingTypes(source.flags & 2097152 /* Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + if (sources.length === 0 || targets.length === 0) { + return; + } + source = getIntersectionType(sources); + target = getIntersectionType(targets); + } } else if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) { target = getActualTypeVariable(target); @@ -45919,7 +46636,7 @@ var ts; clearCachedInferences(inferences); } } - inferenceCount++; + inferencePriority = Math.min(inferencePriority, priority); return; } else { @@ -45950,6 +46667,9 @@ var ts; inferFromTypes(source.type, target.type); contravariant = !contravariant; } + else if (source.flags & 134217728 /* StructuralTag */ && target.flags & 134217728 /* StructuralTag */) { + inferFromTypes(source.type, target.type); + } else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; @@ -45976,11 +46696,17 @@ var ts; else if (target.flags & 3145728 /* UnionOrIntersection */) { inferToMultipleTypes(source, target.types, target.flags); } + else if (target.flags & 134217728 /* StructuralTag */ && source.flags & 2097152 /* Intersection */) { + var tagsOnly = getIntersectionType(ts.filter(source.types, function (t) { return !!(t.flags & 134217728 /* StructuralTag */); })); + if (tagsOnly !== source) { + inferFromTypes(tagsOnly, target); + } + } else if (source.flags & 1048576 /* Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; - for (var _d = 0, sourceTypes_3 = sourceTypes; _d < sourceTypes_3.length; _d++) { - var sourceType = sourceTypes_3[_d]; + for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { + var sourceType = sourceTypes_3[_e]; inferFromTypes(sourceType, target); } } @@ -46010,15 +46736,36 @@ var ts; } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; - var count = visited && visited.get(key); - if (count !== undefined) { - inferenceCount += count; + var status = visited && visited.get(key); + if (status !== undefined) { + inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = ts.createMap())).set(key, 0); - var startCount = inferenceCount; + (visited || (visited = ts.createMap())).set(key, -1 /* Circularity */); + var saveInferencePriority = inferencePriority; + inferencePriority = 256 /* MaxValue */; action(source, target); - visited.set(key, inferenceCount - startCount); + visited.set(key, inferencePriority); + inferencePriority = Math.min(inferencePriority, saveInferencePriority); + } + function inferFromMatchingTypes(sources, targets, matches) { + var matchedSources; + var matchedTargets; + for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { + var t = targets_1[_i]; + for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) { + var s = sources_1[_a]; + if (matches(s, t)) { + inferFromTypes(s, t); + matchedSources = ts.appendIfUnique(matchedSources, s); + matchedTargets = ts.appendIfUnique(matchedTargets, t); + } + } + } + return [ + matchedSources ? ts.filter(sources, function (t) { return !ts.contains(matchedSources, t); }) : sources, + matchedTargets ? ts.filter(targets, function (t) { return !ts.contains(matchedTargets, t); }) : targets, + ]; } function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; @@ -46058,31 +46805,34 @@ var ts; var nakedTypeVariable = void 0; var sources = source.flags & 1048576 /* Union */ ? source.types : [source]; var matched_1 = new Array(sources.length); - var saveInferenceIncomplete = inferenceIncomplete; - inferenceIncomplete = false; + var inferenceCircularity = false; // First infer to types that are not naked type variables. For each source type we - // track whether inferences were made from that particular type to some target. - for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { - var t = targets_1[_i]; + // track whether inferences were made from that particular type to some target with + // equal priority (i.e. of equal quality) to what we would infer for a naked type + // parameter. + for (var _i = 0, targets_2 = targets; _i < targets_2.length; _i++) { + var t = targets_2[_i]; if (getInferenceInfoForType(t)) { nakedTypeVariable = t; typeVariableCount++; } else { for (var i = 0; i < sources.length; i++) { - var count = inferenceCount; + var saveInferencePriority = inferencePriority; + inferencePriority = 256 /* MaxValue */; inferFromTypes(sources[i], t); - if (count !== inferenceCount) + if (inferencePriority === priority) matched_1[i] = true; + inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* Circularity */; + inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } } - var inferenceComplete = !inferenceIncomplete; - inferenceIncomplete = inferenceIncomplete || saveInferenceIncomplete; - // If the target has a single naked type variable and inference completed (meaning we - // explored the types fully), create a union of the source types from which no inferences - // have been made so far and infer from that union to the naked type variable. - if (typeVariableCount === 1 && inferenceComplete) { + // If the target has a single naked type variable and no inference circularities were + // encountered above (meaning we explored the types fully), create a union of the source + // types from which no inferences have been made so far and infer from that union to the + // naked type variable. + if (typeVariableCount === 1 && !inferenceCircularity) { var unmatched = ts.flatMap(sources, function (s, i) { return matched_1[i] ? undefined : s; }); if (unmatched.length) { inferFromTypes(getUnionType(unmatched), nakedTypeVariable); @@ -46094,8 +46844,8 @@ var ts; // We infer from types that are not naked type variables first so that inferences we // make from nested naked type variables and given slightly higher priority by virtue // of being first in the candidates array. - for (var _a = 0, targets_2 = targets; _a < targets_2.length; _a++) { - var t = targets_2[_a]; + for (var _a = 0, targets_3 = targets; _a < targets_3.length; _a++) { + var t = targets_3[_a]; if (getInferenceInfoForType(t)) { typeVariableCount++; } @@ -46111,8 +46861,8 @@ var ts; if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { var savePriority = priority; priority |= 1 /* NakedTypeVariable */; - for (var _b = 0, targets_3 = targets; _b < targets_3.length; _b++) { - var t = targets_3[_b]; + for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { + var t = targets_4[_b]; if (getInferenceInfoForType(t)) { inferFromTypes(source, t); } @@ -46186,7 +46936,7 @@ var ts; var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { if (ts.contains(symbolStack, symbol)) { - inferenceIncomplete = true; + inferencePriority = -1 /* Circularity */; return; } (symbolStack || (symbolStack = [])).push(symbol); @@ -46270,7 +47020,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 === 157 /* MethodDeclaration */ || kind === 156 /* MethodSignature */ || kind === 158 /* Constructor */; + bivariant = bivariant || kind === 158 /* MethodDeclaration */ || kind === 157 /* MethodSignature */ || kind === 159 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -46296,46 +47046,12 @@ var ts; } } } - function isMatchableType(type) { - // We exclude non-anonymous object types because some frameworks (e.g. Ember) rely on the ability to - // infer between types that don't witness their type variables. Such types would otherwise be eliminated - // because they appear identical. - return !(type.flags & 524288 /* Object */) || !!(ts.getObjectFlags(type) & 16 /* Anonymous */); - } - function typeMatchedBySomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; - if (t === type || isMatchableType(t) && isMatchableType(type) && isTypeIdenticalTo(t, type)) { - return true; - } - } - return false; - } - function findMatchedType(type, target) { - if (typeMatchedBySomeType(type, target.types)) { - return type; - } - if (type.flags & (256 /* NumberLiteral */ | 128 /* StringLiteral */) && target.flags & 1048576 /* Union */) { - var base = getBaseTypeOfLiteralType(type); - if (typeMatchedBySomeType(base, target.types)) { - return base; - } - } - return undefined; + function isTypeOrBaseIdenticalTo(s, t) { + return isTypeIdenticalTo(s, t) || !!(s.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) && isTypeIdenticalTo(getBaseTypeOfLiteralType(s), t); } - /** - * Return a new union or intersection type computed by removing a given set of types - * from a given union or intersection type. - */ - function removeTypesFromUnionOrIntersection(type, typesToRemove) { - var reducedTypes = []; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (!typeMatchedBySomeType(t, typesToRemove)) { - reducedTypes.push(t); - } - } - return reducedTypes.length ? type.flags & 1048576 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes) : undefined; + function isTypeCloselyMatchedBy(s, t) { + return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || + s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); @@ -46474,7 +47190,7 @@ var ts; case "AsyncIterator": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later; default: - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 278 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -46486,7 +47202,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), + resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), /*excludeGlobals*/ false, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; } return links.resolvedSymbol; @@ -46495,7 +47211,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 168 /* TypeQuery */ ? true : n.kind === 73 /* Identifier */ || n.kind === 149 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 169 /* TypeQuery */ ? true : n.kind === 73 /* Identifier */ || n.kind === 150 /* 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 @@ -46510,11 +47226,11 @@ var ts; return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; case 101 /* ThisKeyword */: return "0"; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 215 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -46525,24 +47241,24 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 196 /* ParenthesizedExpression */: - case 214 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: + case 215 /* NonNullExpression */: return isMatchingReference(source, target.expression); } switch (source.kind) { case 73 /* Identifier */: return target.kind === 73 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 238 /* VariableDeclaration */ || target.kind === 187 /* BindingElement */) && + (target.kind === 239 /* VariableDeclaration */ || target.kind === 188 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 101 /* ThisKeyword */: return target.kind === 101 /* ThisKeyword */; case 99 /* SuperKeyword */: return target.kind === 99 /* SuperKeyword */; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 215 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); @@ -46550,7 +47266,7 @@ var ts; return false; } function getAccessedPropertyName(access) { - return access.kind === 190 /* PropertyAccessExpression */ ? access.name.escapedText : + return access.kind === 191 /* PropertyAccessExpression */ ? access.name.escapedText : ts.isStringLiteral(access.argumentExpression) || ts.isNumericLiteral(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } @@ -46634,7 +47350,7 @@ var ts; } } } - if (callExpression.expression.kind === 190 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 191 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -46683,8 +47399,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; result |= getTypeFacts(t); } return result; @@ -46789,15 +47505,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 188 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 189 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 277 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 205 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 228 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 206 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 229 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -46814,21 +47530,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return stringType; - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return undefinedType; - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -46836,7 +47552,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 185 /* ObjectBindingPattern */ ? + var type = pattern.kind === 186 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -46854,35 +47570,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 227 /* ForInStatement */) { + if (node.parent.parent.kind === 228 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.parent.kind === 229 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 238 /* VariableDeclaration */ ? + return node.kind === 239 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */ ? + return getConstraintForLocation(node.kind === 239 /* VariableDeclaration */ || node.kind === 188 /* BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } function isEmptyArrayAssignment(node) { - return node.kind === 238 /* VariableDeclaration */ && node.initializer && + return node.kind === 239 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 187 /* BindingElement */ && node.parent.kind === 205 /* BinaryExpression */ && + node.kind !== 188 /* BindingElement */ && node.parent.kind === 206 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (node.operatorToken.kind) { case 60 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -46894,13 +47610,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 196 /* ParenthesizedExpression */ || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */ && parent.left === node || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 197 /* ParenthesizedExpression */ || + parent.kind === 206 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */ && parent.left === node || + parent.kind === 206 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 273 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -46922,7 +47638,7 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 273 /* CaseClause */) { if (clause.expression.kind === 10 /* StringLiteral */) { witnesses.push(clause.expression.text); continue; @@ -47006,8 +47722,7 @@ var ts; return mapType(typeWithPrimitives, function (t) { return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */) : t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : - t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : - t; + t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -47059,8 +47774,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -47083,11 +47798,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 190 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 192 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 191 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 191 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 193 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 192 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 205 /* BinaryExpression */ && + parent.parent.kind === 206 /* BinaryExpression */ && parent.parent.operatorToken.kind === 60 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -47125,7 +47840,7 @@ var ts; if (flowAnalysisDisabled) { return errorType; } - if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943 /* Narrowable */)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 268188671 /* Narrowable */)) { return declaredType; } var sharedFlowStart = sharedFlowCount; @@ -47136,7 +47851,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 (reference.parent && reference.parent.kind === 214 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (reference.parent && reference.parent.kind === 215 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -47233,8 +47948,8 @@ var ts; // Check if we should continue with the control flow of the containing function. var container = flow.container; if (container && container !== flowContainer && - reference.kind !== 190 /* PropertyAccessExpression */ && - reference.kind !== 191 /* ElementAccessExpression */ && + reference.kind !== 191 /* PropertyAccessExpression */ && + reference.kind !== 192 /* ElementAccessExpression */ && reference.kind !== 101 /* ThisKeyword */) { flow = container.flowNode; continue; @@ -47287,14 +48002,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 === 197 /* FunctionExpression */ || init.kind === 198 /* ArrowFunction */)) { + if (init && (init.kind === 198 /* FunctionExpression */ || init.kind === 199 /* 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 === 227 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 228 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference @@ -47303,7 +48018,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 192 /* CallExpression */ ? + var expr = node.kind === 193 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -47311,7 +48026,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 193 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -47364,7 +48079,7 @@ var ts; else if (isMatchingReferenceDiscriminant(expr, type)) { type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); } - else if (expr.kind === 200 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 201 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else if (containsMatchingReferenceDiscriminant(reference, expr)) { @@ -47539,10 +48254,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 201 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 201 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -47620,7 +48335,7 @@ var ts; return type; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { - // We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands + // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { // For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the @@ -47902,16 +48617,16 @@ var ts; case 73 /* Identifier */: case 101 /* ThisKeyword */: case 99 /* SuperKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: if (expr.operator === 52 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -47947,9 +48662,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 246 /* ModuleBlock */ || - node.kind === 285 /* SourceFile */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 247 /* ModuleBlock */ || + node.kind === 286 /* SourceFile */ || + node.kind === 156 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -47971,7 +48686,7 @@ var ts; if (node.kind === 73 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 152 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 153 /* Parameter */) { symbol.isAssigned = true; } } @@ -47986,7 +48701,7 @@ var ts; /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 152 /* Parameter */ && + declaration.kind === 153 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -47994,10 +48709,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 190 /* PropertyAccessExpression */ || - parent.kind === 192 /* CallExpression */ && parent.expression === node || - parent.kind === 191 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 187 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 191 /* PropertyAccessExpression */ || + parent.kind === 193 /* CallExpression */ && parent.expression === node || + parent.kind === 192 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 188 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); @@ -48012,8 +48727,11 @@ var ts; } return type; } + function isExportOrExportExpression(location) { + return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); + } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 67220415 /* Value */) && !isInTypeQuery(location) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && ((compilerOptions.preserveConstEnums && isExportOrExportExpression(location)) || !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol)))) { markAliasSymbolAsReferenced(symbol); } } @@ -48031,7 +48749,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 198 /* ArrowFunction */) { + if (container.kind === 199 /* 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.hasModifier(container, 256 /* Async */)) { @@ -48052,7 +48770,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 241 /* ClassDeclaration */ + if (declaration.kind === 242 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -48064,14 +48782,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 210 /* ClassExpression */) { + else if (declaration.kind === 211 /* 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 !== 285 /* SourceFile */) { + while (container.kind !== 286 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 155 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 156 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -48120,7 +48838,7 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 152 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 153 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -48129,8 +48847,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 === 197 /* FunctionExpression */ || - flowContainer.kind === 198 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 198 /* FunctionExpression */ || + flowContainer.kind === 199 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -48138,10 +48856,10 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 258 /* ExportSpecifier */) || - node.parent.kind === 214 /* NonNullExpression */ || - declaration.kind === 238 /* VariableDeclaration */ && declaration.exclamationToken || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 259 /* ExportSpecifier */) || + node.parent.kind === 215 /* NonNullExpression */ || + declaration.kind === 239 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 4194304 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -48176,7 +48894,7 @@ var ts; if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 275 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 276 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -48199,7 +48917,7 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container) && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 240 /* VariableDeclarationList */).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -48217,8 +48935,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 226 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container && + if (container.kind === 227 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 240 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -48236,7 +48954,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 196 /* ParenthesizedExpression */) { + while (current.parent.kind === 197 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -48244,7 +48962,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 203 /* PrefixUnaryExpression */ || current.parent.kind === 204 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 204 /* PrefixUnaryExpression */ || current.parent.kind === 205 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; } @@ -48257,7 +48975,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 155 /* PropertyDeclaration */ || container.kind === 158 /* Constructor */) { + if (container.kind === 156 /* PropertyDeclaration */ || container.kind === 159 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -48325,37 +49043,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 158 /* Constructor */) { + if (container.kind === 159 /* 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 === 198 /* ArrowFunction */) { + if (container.kind === 199 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 245 /* ModuleDeclaration */: + case 246 /* 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 244 /* EnumDeclaration */: + case 245 /* 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 158 /* Constructor */: + case 159 /* 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 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: if (ts.hasModifier(container, 32 /* Static */)) { 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 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -48394,10 +49112,8 @@ var ts; if (isInJS && className) { var classSymbol = checkExpression(className).symbol; if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { - var classType = getJSClassType(classSymbol); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(classSymbol).thisType; + return getFlowTypeOfReference(node, classType); } } // Check if it's a constructor definition, can be either a variable decl or function decl @@ -48405,12 +49121,10 @@ var ts; // * /** @constructor */ function [name]() { ... } // * /** @constructor */ var x = function() { ... } else if (isInJS && - (container.kind === 197 /* FunctionExpression */ || container.kind === 240 /* FunctionDeclaration */) && + (container.kind === 198 /* FunctionExpression */ || container.kind === 241 /* FunctionDeclaration */) && ts.getJSDocClassTag(container)) { - var classType = getJSClassType(getMergedSymbol(container.symbol)); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType; + return getFlowTypeOfReference(node, classType); } var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { @@ -48441,7 +49155,7 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 197 /* FunctionExpression */ && + if (container.kind === 198 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -48451,16 +49165,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 157 /* MethodDeclaration */ && - container.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 158 /* MethodDeclaration */ && + container.parent.kind === 190 /* 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 === 197 /* FunctionExpression */ && - container.parent.kind === 276 /* PropertyAssignment */ && - container.parent.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 198 /* FunctionExpression */ && + container.parent.kind === 277 /* PropertyAssignment */ && + container.parent.parent.kind === 190 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -48468,7 +49182,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 === 197 /* FunctionExpression */ && + else if (container.kind === 198 /* 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") && @@ -48493,7 +49207,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 295 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 296 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -48507,15 +49221,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 152 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 153 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 192 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 193 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); 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 === 198 /* ArrowFunction */) { + while (container && container.kind === 199 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -48528,14 +49242,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 150 /* ComputedPropertyName */; }); - if (current && current.kind === 150 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 151 /* ComputedPropertyName */; }); + if (current && current.kind === 151 /* 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 === 189 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 190 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -48543,7 +49257,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 158 /* Constructor */) { + if (!isCallExpression && container.kind === 159 /* 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.hasModifier(container, 32 /* Static */) || isCallExpression) { @@ -48612,7 +49326,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 === 157 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 158 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -48626,7 +49340,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 189 /* ObjectLiteralExpression */) { + if (container.parent.kind === 190 /* 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; @@ -48647,7 +49361,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 158 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 159 /* 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; @@ -48662,7 +49376,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 === 158 /* Constructor */; + return container.kind === 159 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -48670,21 +49384,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 === 189 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 190 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */; + return container.kind === 158 /* MethodDeclaration */ || + container.kind === 157 /* MethodSignature */ || + container.kind === 160 /* GetAccessor */ || + container.kind === 161 /* SetAccessor */; } else { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */ || - container.kind === 155 /* PropertyDeclaration */ || - container.kind === 154 /* PropertySignature */ || - container.kind === 158 /* Constructor */; + return container.kind === 158 /* MethodDeclaration */ || + container.kind === 157 /* MethodSignature */ || + container.kind === 160 /* GetAccessor */ || + container.kind === 161 /* SetAccessor */ || + container.kind === 156 /* PropertyDeclaration */ || + container.kind === 155 /* PropertySignature */ || + container.kind === 159 /* Constructor */; } } } @@ -48692,10 +49406,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 157 /* MethodDeclaration */ || - func.kind === 159 /* GetAccessor */ || - func.kind === 160 /* SetAccessor */) && func.parent.kind === 189 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 197 /* FunctionExpression */ && func.parent.kind === 276 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 158 /* MethodDeclaration */ || + func.kind === 160 /* GetAccessor */ || + func.kind === 161 /* SetAccessor */) && func.parent.kind === 190 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 198 /* FunctionExpression */ && func.parent.kind === 277 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -48707,7 +49421,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 199 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -48734,7 +49448,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 276 /* PropertyAssignment */) { + if (literal.parent.kind !== 277 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -48748,9 +49462,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent.kind === 206 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */) { var target = parent.left; - if (target.kind === 190 /* PropertyAccessExpression */ || target.kind === 191 /* ElementAccessExpression */) { + if (target.kind === 191 /* PropertyAccessExpression */ || target.kind === 192 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -48814,9 +49528,9 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 152 /* Parameter */: + case 153 /* Parameter */: return getContextuallyTypedParameterType(declaration, /*forCache*/ false); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return getContextualTypeForBindingElement(declaration); // By default, do nothing and return undefined - only parameters and binding elements have context implied by a parent } @@ -48906,6 +49620,15 @@ var ts; } return false; } + function getContextualIterationType(kind, functionDecl) { + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */); + var contextualReturnType = getContextualReturnType(functionDecl); + if (contextualReturnType) { + return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) + || undefined; + } + return undefined; + } function getContextualReturnType(functionDecl) { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed @@ -48937,7 +49660,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 194 /* TaggedTemplateExpression */) { + if (template.parent.kind === 195 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -48999,7 +49722,7 @@ var ts; } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 67220415 /* Value */, undefined, id.escapedText, /*isUse*/ true); + var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated) { @@ -49050,7 +49773,7 @@ var ts; return substituteIndexedMappedType(t, propertyNameType); } } - else if (t.flags & 3670016 /* StructuredType */) { + else if (t.flags & 137887744 /* StructuredType */) { var prop = getPropertyOfType(t, name); if (prop) { return getTypeOfSymbol(prop); @@ -49170,26 +49893,29 @@ var ts; case 73 /* Identifier */: case 142 /* UndefinedKeyword */: return true; - case 190 /* PropertyAccessExpression */: - case 196 /* ParenthesizedExpression */: + case 191 /* PropertyAccessExpression */: + case 197 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 271 /* JsxExpression */: + case 272 /* 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 === 276 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 277 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 268 /* 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.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 269 /* 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 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. function getApparentTypeOfContextualType(node, contextFlags) { - var contextualType = instantiateContextualType(getContextualType(node, contextFlags), node, contextFlags); - if (contextualType) { - var apparentType = mapType(contextualType, getApparentType, /*noReductions*/ true); + var contextualType = ts.isObjectLiteralMethod(node) ? + getContextualTypeForObjectLiteralMethod(node, contextFlags) : + getContextualType(node, contextFlags); + var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); + if (instantiatedType) { + var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); if (apparentType.flags & 1048576 /* Union */) { if (ts.isObjectLiteralExpression(node)) { return discriminateContextualTypeByObjectMembers(node, apparentType); @@ -49227,7 +49953,7 @@ var ts; // are classified as instantiable (i.e. it doesn't instantiate object types), and (b) it performs // no reductions on instantiated union types. function instantiateInstantiableTypes(type, mapper) { - if (type.flags & 63176704 /* Instantiable */) { + if (type.flags & (63176704 /* Instantiable */ | 134217728 /* StructuralTag */)) { return instantiateType(type, mapper); } if (type.flags & 1048576 /* Union */) { @@ -49265,58 +49991,58 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 187 /* BindingElement */: + case 239 /* VariableDeclaration */: + case 153 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 188 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 198 /* ArrowFunction */: - case 231 /* ReturnStatement */: + case 199 /* ArrowFunction */: + case 232 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent); - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (parent.expression.kind === 93 /* ImportKeyword */) { return stringType; } /* falls through */ - case 193 /* NewExpression */: + case 194 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 188 /* ArrayLiteralExpression */: { + case 189 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 217 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 207 /* TemplateExpression */); + case 218 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 208 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 196 /* ParenthesizedExpression */: { + case 197 /* 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 271 /* JsxExpression */: + case 272 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: + case 269 /* JsxAttribute */: + case 271 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -49471,7 +50197,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 197 /* FunctionExpression */ || node.kind === 198 /* ArrowFunction */; + return node.kind === 198 /* FunctionExpression */ || node.kind === 199 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -49485,14 +50211,12 @@ 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 !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = ts.isObjectLiteralMethod(node) ? - getContextualTypeForObjectLiteralMethod(node, 1 /* Signature */) : - getApparentTypeOfContextualType(node, 1 /* Signature */); + var type = getApparentTypeOfContextualType(node, 1 /* Signature */); if (!type) { return undefined; } @@ -49501,8 +50225,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var current = types_13[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -49532,8 +50256,8 @@ var ts; return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); } function hasDefaultValue(node) { - return (node.kind === 187 /* BindingElement */ && !!node.initializer) || - (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */); + return (node.kind === 188 /* BindingElement */ && !!node.initializer) || + (node.kind === 206 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -49545,7 +50269,7 @@ var ts; var inConstContext = isConstContext(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 209 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 210 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -49570,12 +50294,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 209 /* SpreadElement */) { + if (index < elementCount - 1 && e.kind === 210 /* SpreadElement */) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 209 /* SpreadElement */; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 210 /* SpreadElement */; var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". @@ -49617,7 +50341,7 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return isNumericComputedName(name); case 73 /* Identifier */: return isNumericLiteralName(name.escapedText); @@ -49707,7 +50431,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 185 /* ObjectBindingPattern */ || contextualType.pattern.kind === 189 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 186 /* ObjectBindingPattern */ || contextualType.pattern.kind === 190 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -49722,13 +50446,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 150 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 151 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 276 /* PropertyAssignment */ || - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 277 /* PropertyAssignment */ || + memberDecl.kind === 278 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 276 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 277 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 278 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -49751,8 +50475,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 === 276 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 277 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 277 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 278 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -49777,7 +50501,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 278 /* SpreadAssignment */) { + else if (memberDecl.kind === 279 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -49803,7 +50527,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 === 159 /* GetAccessor */ || memberDecl.kind === 160 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 160 /* GetAccessor */ || memberDecl.kind === 161 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -49863,7 +50587,13 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (3 /* AnyOrUnknown */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || + if (type.flags & 63176704 /* Instantiable */) { + var constraint = getBaseConstraintOfType(type); + if (constraint !== undefined) { + return isValidSpreadType(constraint); + } + } + return !!(type.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 134217728 /* StructuralTag */ | 58982400 /* InstantiableNonPrimitive */) || getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } @@ -49956,7 +50686,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 270 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 271 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -49979,7 +50709,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 261 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 262 /* 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); @@ -50053,7 +50783,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 67897832 /* Type */); + var typeSymbol = exports && getSymbol(exports, name, 788968 /* Type */); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** @@ -50127,7 +50857,7 @@ var ts; */ function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 67897832 /* Type */); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* Type */); // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute @@ -50151,7 +50881,7 @@ var ts; } function getJsxLibraryManagedAttributes(jsxNamespace) { // JSX.LibraryManagedAttributes [symbol] - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67897832 /* Type */); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* Type */); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -50303,13 +51033,13 @@ var ts; var reactRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var reactNamespace = getJsxNamespace(node); var reactLocation = isNodeOpeningLikeElement ? node.tagName : node; - var reactSym = resolveName(reactLocation, reactNamespace, 67220415 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); + var reactSym = resolveName(reactLocation, reactNamespace, 111551 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); if (reactSym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not react as there wont be error being emitted reactSym.isReferenced = 67108863 /* All */; - // If react symbol is alias, mark it as referenced - if (reactSym.flags & 2097152 /* Alias */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { + // If react symbol is alias, mark it as refereced + if (reactSym.flags & 2097152 /* Alias */) { markAliasSymbolAsReferenced(reactSym); } } @@ -50398,7 +51128,7 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 149 /* QualifiedName */ ? node.right : node.kind === 184 /* ImportType */ ? node : node.name; + var errorNode = node.kind === 150 /* QualifiedName */ ? node.right : node.kind === 185 /* ImportType */ ? node : node.name; if (ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */) { // Synthetic property with private constituent property error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); @@ -50533,7 +51263,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } function isMethodAccessForCall(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */) { + while (node.parent.kind === 197 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -50599,7 +51329,7 @@ var ts; // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (node.kind !== 191 /* ElementAccessExpression */ && node.kind !== 190 /* PropertyAccessExpression */ || + if (node.kind !== 192 /* ElementAccessExpression */ && node.kind !== 191 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; @@ -50613,7 +51343,7 @@ var ts; var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 158 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 159 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -50634,7 +51364,7 @@ var ts; } function checkPropertyNotUsedBeforeDeclaration(prop, node, right) { var valueDeclaration = prop.valueDeclaration; - if (!valueDeclaration) { + if (!valueDeclaration || ts.getSourceFileOfNode(node).isDeclarationFile) { return; } var diagnosticMessage; @@ -50644,8 +51374,8 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 241 /* ClassDeclaration */ && - node.parent.kind !== 165 /* TypeReference */ && + else if (valueDeclaration.kind === 242 /* ClassDeclaration */ && + node.parent.kind !== 166 /* TypeReference */ && !(valueDeclaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -50657,22 +51387,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return true; - case 276 /* PropertyAssignment */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 278 /* SpreadAssignment */: - case 150 /* ComputedPropertyName */: - case 217 /* TemplateSpan */: - case 271 /* JsxExpression */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 263 /* JsxOpeningElement */: - case 212 /* ExpressionWithTypeArguments */: - case 274 /* HeritageClause */: + case 277 /* PropertyAssignment */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 279 /* SpreadAssignment */: + case 151 /* ComputedPropertyName */: + case 218 /* TemplateSpan */: + case 272 /* JsxExpression */: + case 269 /* JsxAttribute */: + case 270 /* JsxAttributes */: + case 271 /* JsxSpreadAttribute */: + case 264 /* JsxOpeningElement */: + case 213 /* ExpressionWithTypeArguments */: + case 275 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -50712,7 +51442,7 @@ var ts; if (containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; - if (!getPropertyOfType(subtype, propNode.escapedText)) { + if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0 /* String */)) { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); break; } @@ -50750,7 +51480,7 @@ var ts; return prop !== undefined && prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 32 /* Static */); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { - return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67220415 /* Value */); + return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551 /* Value */); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -50845,16 +51575,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return isValidPropertyAccessWithType(node, node.expression.kind === 99 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 184 /* ImportType */: + case 185 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 190 /* PropertyAccessExpression */ && node.expression.kind === 99 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 191 /* PropertyAccessExpression */ && node.expression.kind === 99 /* 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) { @@ -50871,7 +51601,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer.kind === 240 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -50900,7 +51630,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 227 /* ForInStatement */ && + if (node.kind === 228 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -50917,20 +51647,6 @@ var ts; var exprType = checkNonNullExpression(node.expression); var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; - if (!indexExpression) { - var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 193 /* NewExpression */ && node.parent.expression === node) { - var start = ts.skipTrivia(sourceFile.text, node.expression.end); - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - return errorType; - } var indexType = checkExpression(indexExpression); if (objectType === errorType || objectType === silentNeverType) { return objectType; @@ -50990,13 +51706,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 195 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 153 /* Decorator */) { + else if (node.kind !== 154 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -51060,7 +51776,7 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 209 /* SpreadElement */ || arg.kind === 216 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 210 /* SpreadElement */ || arg.kind === 217 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -51074,9 +51790,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 === 194 /* TaggedTemplateExpression */) { + if (node.kind === 195 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 207 /* TemplateExpression */) { + if (node.template.kind === 208 /* 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. @@ -51091,7 +51807,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 153 /* Decorator */) { + else if (node.kind === 154 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -51106,7 +51822,7 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 193 /* NewExpression */); + ts.Debug.assert(node.kind === 194 /* NewExpression */); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -51199,7 +51915,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 !== 153 /* Decorator */) { + if (node.kind !== 154 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -51242,7 +51958,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 !== 211 /* OmittedExpression */) { + if (arg.kind !== 212 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -51266,7 +51982,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 arg.kind === 216 /* SyntheticExpression */ ? + return arg.kind === 217 /* SyntheticExpression */ ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0 /* Normal */)); } @@ -51341,12 +52057,12 @@ var ts; if (ts.isJsxOpeningLikeElement(node)) { if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 193 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 194 /* 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. @@ -51356,7 +52072,7 @@ var ts; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; @@ -51364,7 +52080,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 !== 211 /* OmittedExpression */) { + if (arg.kind !== 212 /* 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), @@ -51374,7 +52090,7 @@ var ts; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } } @@ -51384,7 +52100,7 @@ var ts; if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, /*containingMessageChain*/ undefined, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(errorNode, spreadType, restType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } return undefined; @@ -51405,15 +52121,15 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 193 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 190 /* PropertyAccessExpression */ || callee.kind === 191 /* ElementAccessExpression */) { + if (callee.kind === 191 /* PropertyAccessExpression */ || callee.kind === 192 /* ElementAccessExpression */) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(216 /* SyntheticExpression */, parent.pos, parent.end); + var result = ts.createNode(217 /* SyntheticExpression */, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; @@ -51423,17 +52139,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 195 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 207 /* TemplateExpression */) { + if (template.kind === 208 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 153 /* Decorator */) { + if (node.kind === 154 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -51463,30 +52179,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* 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 152 /* Parameter */: + case 153 /* 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 === 158 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 159 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* 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 !== 155 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 156 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -51500,17 +52216,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return 1; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return 2; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* 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 152 /* Parameter */: + case 153 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -51635,8 +52351,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, fallbackError) { - var isTaggedTemplate = node.kind === 194 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 153 /* Decorator */; + var isTaggedTemplate = node.kind === 195 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 154 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; @@ -51698,7 +52414,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 === 192 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 193 /* 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 @@ -52234,8 +52950,8 @@ var ts; if (apparentType.flags & 1048576 /* Union */) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var constituent = types_15[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var constituent = types_14[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -52333,16 +53049,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 152 /* Parameter */: + case 153 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -52386,8 +53102,8 @@ var ts; var exports = namespace && getExportsOfSymbol(namespace); // We fake up a SFC signature for each intrinsic, however a more specific per-element signature drawn from the JSX declaration // file would probably be preferable. - var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 67897832 /* Type */); - var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 67897832 /* Type */, node); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node); var declaration = ts.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.createKeywordTypeNode(121 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; @@ -52435,16 +53151,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 192 /* CallExpression */: + case 193 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 153 /* Decorator */: + case 154 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -52495,43 +53211,45 @@ var ts; return true; // If the symbol of the node has members, treat it like a constructor. var symbol = getSymbolOfNode(func); - return !!symbol && (symbol.members !== undefined || symbol.exports !== undefined && symbol.exports.get("prototype") !== undefined); - } - return false; - } - function isJSConstructorType(type) { - if (type.flags & 524288 /* Object */) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); + return !!symbol && ts.hasEntries(symbol.members); } return false; } - function getJSClassType(symbol) { - var inferred; - if (isJSConstructor(symbol.valueDeclaration)) { - inferred = getInferredClassType(symbol); + function mergeJSSymbols(target, source) { + if (source && (ts.hasEntries(source.exports) || ts.hasEntries(source.members))) { + var links = getSymbolLinks(source); + if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) { + var inferred = isTransientSymbol(target) ? target : cloneSymbol(target); + inferred.exports = inferred.exports || ts.createSymbolTable(); + inferred.members = inferred.members || ts.createSymbolTable(); + inferred.flags |= source.flags & 32 /* Class */; + if (ts.hasEntries(source.exports)) { + mergeSymbolTable(inferred.exports, source.exports); + } + if (ts.hasEntries(source.members)) { + mergeSymbolTable(inferred.members, source.members); + } + (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred); + return inferred; + } + return links.inferredClassSymbol.get("" + getSymbolId(target)); } - var assigned = getAssignedClassType(symbol); - return assigned && inferred ? - getIntersectionType([inferred, assigned]) : - assigned || inferred; } - function getAssignedClassType(symbol) { - var decl = symbol.valueDeclaration; + function getAssignedClassSymbol(decl) { var assignmentSymbol = decl && decl.parent && (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype"); var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration); - return init ? getWidenedType(checkExpressionCached(init)) : undefined; + return init ? getSymbolOfNode(init) : undefined; } function getAssignedJSPrototype(node) { if (!node.parent) { return false; } var parent = node.parent; - while (parent && parent.kind === 190 /* PropertyAccessExpression */) { + while (parent && parent.kind === 191 /* PropertyAccessExpression */) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 60 /* EqualsToken */) { @@ -52539,13 +53257,6 @@ var ts; return ts.isObjectLiteralExpression(right) && right; } } - function getInferredClassType(symbol) { - var links = getSymbolLinks(symbol); - if (!links.inferredClassType) { - links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol) || emptySymbols, ts.emptyArray, ts.emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined); - } - return links.inferredClassType; - } /** * Syntactically and semantically checks a call or new expression. * @param node The call/new expression to be checked. @@ -52563,12 +53274,12 @@ var ts; if (node.expression.kind === 99 /* SuperKeyword */) { return voidType; } - if (node.kind === 193 /* NewExpression */) { + if (node.kind === 194 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 158 /* Constructor */ && - declaration.kind !== 162 /* ConstructSignature */ && - declaration.kind !== 167 /* ConstructorType */ && + declaration.kind !== 159 /* Constructor */ && + declaration.kind !== 163 /* ConstructSignature */ && + declaration.kind !== 168 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -52616,7 +53327,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } function checkImportCallExpression(node) { // Check grammar of dynamic import @@ -52676,7 +53387,7 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } @@ -52685,9 +53396,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 240 /* FunctionDeclaration */ + ? 241 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 238 /* VariableDeclaration */ + ? 239 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -52714,18 +53425,18 @@ var ts; case 9 /* BigIntLiteral */: case 103 /* TrueKeyword */: case 88 /* FalseKeyword */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return true; - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; return op === 39 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || op === 38 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -52775,7 +53486,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 === 158 /* Constructor */) { + else if (container.kind === 159 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -52785,8 +53496,8 @@ var ts; } } function checkImportMetaProperty(node) { - if (languageVersion < 99 /* ESNext */ || moduleKind < ts.ModuleKind.ESNext) { - error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options); + if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) { + error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system); } var file = ts.getSourceFileOfNode(node); ts.Debug.assert(!!(file.flags & 1048576 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); @@ -52976,7 +53687,7 @@ var ts; links.type = contextualType; var decl = parameter.valueDeclaration; if (decl.name.kind !== 73 /* Identifier */) { - // if inference didn't come up with anything but {}, fall back to the binding pattern if present. + // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(decl.name); } @@ -53030,7 +53741,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 219 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 220 /* 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 @@ -53102,7 +53813,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* Next */, func) || unknownType, isAsync); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -53216,14 +53927,14 @@ var ts; if (!node.possiblyExhaustive) { return false; } - if (node.expression.kind === 200 /* TypeOfExpression */) { + if (node.expression.kind === 201 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); // This cast is safe because the switch is possibly exhaustive and does not contain a default case, so there can be no undefined. var witnesses = getSwitchClauseTypeOfWitnesses(node); // notEqualFacts states that the type of the switched value is not equal to every type in the switch. var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true); - var type_5 = getBaseConstraintOfType(operandType) || operandType; - return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); + var type_4 = getBaseConstraintOfType(operandType) || operandType; + return !!(filterType(type_4, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -53239,7 +53950,7 @@ var ts; if (!(func.flags & 128 /* HasImplicitReturn */)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 233 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 234 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -53282,11 +53993,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return true; - case 157 /* MethodDeclaration */: - return func.parent.kind === 189 /* ObjectLiteralExpression */; + case 158 /* MethodDeclaration */: + return func.parent.kind === 190 /* ObjectLiteralExpression */; default: return false; } @@ -53312,7 +54023,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 156 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 219 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 157 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 220 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -53345,7 +54056,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 /* 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)) { @@ -53365,7 +54076,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 197 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 198 /* FunctionExpression */) { checkGrammarForGenerator(node); } var type = getTypeOfSymbol(getMergedSymbol(node.symbol)); @@ -53419,7 +54130,7 @@ var ts; type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -53432,7 +54143,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 219 /* Block */) { + if (node.body.kind === 220 /* Block */) { checkSourceElement(node.body); } else { @@ -53513,11 +54224,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) && + (expr.kind === 191 /* PropertyAccessExpression */ || expr.kind === 192 /* ElementAccessExpression */) && expr.expression.kind === 101 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 158 /* Constructor */)) { + if (!(func && func.kind === 159 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -53530,13 +54241,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) { + if (expr.kind === 191 /* PropertyAccessExpression */ || expr.kind === 192 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); if (node.kind === 73 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 252 /* NamespaceImport */; + return !!declaration && declaration.kind === 253 /* NamespaceImport */; } } } @@ -53545,7 +54256,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 73 /* Identifier */ && node.kind !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 73 /* Identifier */ && node.kind !== 191 /* PropertyAccessExpression */ && node.kind !== 192 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -53554,7 +54265,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 190 /* PropertyAccessExpression */ && expr.kind !== 191 /* ElementAccessExpression */) { + if (expr.kind !== 191 /* PropertyAccessExpression */ && expr.kind !== 192 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -53583,7 +54294,7 @@ var ts; var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); var func = ts.getContainingFunction(node); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 159 /* 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); @@ -53596,7 +54307,11 @@ var ts; } } var operandType = checkExpression(node.expression); - return checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + var awaitedType = checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + if (awaitedType === operandType && awaitedType !== errorType && !(operandType.flags & 3 /* AnyOrUnknown */)) { + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); + } + return awaitedType; } function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); @@ -53630,7 +54345,7 @@ var ts; } if (node.operator === 38 /* PlusToken */) { if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { - error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(operandType)); + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } @@ -53681,8 +54396,8 @@ var ts; } if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -53771,7 +54486,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 276 /* PropertyAssignment */ || property.kind === 277 /* ShorthandPropertyAssignment */) { + if (property.kind === 277 /* PropertyAssignment */ || property.kind === 278 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -53784,9 +54499,9 @@ var ts; } var elementType = getIndexedAccessType(objectLiteralType, exprType, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 277 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 278 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 278 /* SpreadAssignment */) { + else if (property.kind === 279 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -53829,8 +54544,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 211 /* OmittedExpression */) { - if (element.kind !== 209 /* SpreadElement */) { + if (element.kind !== 212 /* OmittedExpression */) { + if (element.kind !== 210 /* SpreadElement */) { var indexType = getLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused @@ -53848,7 +54563,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 205 /* BinaryExpression */ && restExpression.operatorToken.kind === 60 /* EqualsToken */) { + if (restExpression.kind === 206 /* BinaryExpression */ && restExpression.operatorToken.kind === 60 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -53864,7 +54579,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 277 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 278 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -53880,21 +54595,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 205 /* BinaryExpression */ && target.operatorToken.kind === 60 /* EqualsToken */) { + if (target.kind === 206 /* BinaryExpression */ && target.operatorToken.kind === 60 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 189 /* ObjectLiteralExpression */) { + if (target.kind === 190 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 188 /* ArrayLiteralExpression */) { + if (target.kind === 189 /* 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 === 278 /* SpreadAssignment */ ? + var error = target.parent.kind === 279 /* 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; if (checkReferenceExpression(target, error)) { @@ -53916,8 +54631,8 @@ var ts; case 73 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 194 /* TaggedTemplateExpression */: - case 207 /* TemplateExpression */: + case 195 /* TaggedTemplateExpression */: + case 208 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: @@ -53925,27 +54640,27 @@ var ts; case 88 /* FalseKeyword */: case 97 /* NullKeyword */: case 142 /* UndefinedKeyword */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 200 /* TypeOfExpression */: - case 214 /* NonNullExpression */: - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: + case 198 /* FunctionExpression */: + case 211 /* ClassExpression */: + case 199 /* ArrowFunction */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: + case 201 /* TypeOfExpression */: + case 215 /* NonNullExpression */: + case 263 /* JsxSelfClosingElement */: + case 262 /* JsxElement */: return true; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -53957,9 +54672,9 @@ var ts; } return false; // Some forms listed here for clarity - case 201 /* VoidExpression */: // Explicit opt-out - case 195 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 213 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 202 /* VoidExpression */: // Explicit opt-out + case 196 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 214 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -53975,7 +54690,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 60 /* EqualsToken */ && (left.kind === 189 /* ObjectLiteralExpression */ || left.kind === 188 /* ArrayLiteralExpression */)) { + if (operator === 60 /* EqualsToken */ && (left.kind === 190 /* ObjectLiteralExpression */ || left.kind === 189 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 101 /* ThisKeyword */); } var leftType; @@ -54035,7 +54750,7 @@ var ts; resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */)) { + else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { case 48 /* GreaterThanGreaterThanGreaterThanToken */: case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: @@ -54045,7 +54760,7 @@ var ts; } // Exactly one of leftType/rightType is assignable to bigint else { - reportOperatorError(function (awaitedLeft, awaitedRight) { return isTypeAssignableToKind(awaitedLeft, 2112 /* BigIntLike */) && isTypeAssignableToKind(awaitedRight, 2112 /* BigIntLike */); }); + reportOperatorError(bothAreBigIntLike); resultType_1 = errorType; } if (leftOk && rightOk) { @@ -54091,9 +54806,9 @@ var ts; // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 3 /* AnyOrUnknown */; - reportOperatorError(function (awaitedLeft, awaitedRight) { - return isTypeAssignableToKind(awaitedLeft, closeEnoughKind_1) && - isTypeAssignableToKind(awaitedRight, closeEnoughKind_1); + reportOperatorError(function (left, right) { + return isTypeAssignableToKind(left, closeEnoughKind_1) && + isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } @@ -54158,6 +54873,9 @@ var ts; default: return ts.Debug.fail(); } + function bothAreBigIntLike(left, right) { + return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + } function checkAssignmentDeclaration(kind, rightType) { if (kind === 2 /* ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { @@ -54165,7 +54883,7 @@ var ts; var propType = getTypeOfSymbol(prop); if (propType.symbol && propType.symbol.flags & 32 /* Class */) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 67897832 /* Type */, undefined, name, /*isUse*/ false); + var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) { grammarErrorOnNode(symbol.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); return grammarErrorOnNode(prop.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); @@ -54245,17 +54963,23 @@ var ts; } return false; } - function reportOperatorError(awaitedTypesAreCompatible) { + function reportOperatorError(isRelated) { + var _a; var wouldWorkWithAwait = false; var errNode = errorNode || operatorToken; - var _a = getTypeNamesForErrorDisplay(leftType, rightType), leftStr = _a[0], rightStr = _a[1]; - if (awaitedTypesAreCompatible) { + if (isRelated) { var awaitedLeftType = getAwaitedType(leftType); var awaitedRightType = getAwaitedType(rightType); wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType) && !!(awaitedLeftType && awaitedRightType) - && awaitedTypesAreCompatible(awaitedLeftType, awaitedRightType); + && isRelated(awaitedLeftType, awaitedRightType); } + var effectiveLeft = leftType; + var effectiveRight = rightType; + if (!wouldWorkWithAwait && isRelated) { + _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1]; + } + var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1]; if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) { errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); } @@ -54277,6 +55001,17 @@ var ts; return undefined; } } + function getBaseTypesIfUnrelated(leftType, rightType, isRelated) { + var effectiveLeft = leftType; + var effectiveRight = rightType; + var leftBase = getBaseTypeOfLiteralType(leftType); + var rightBase = getBaseTypeOfLiteralType(rightType); + if (!isRelated(leftBase, rightBase)) { + effectiveLeft = leftBase; + effectiveRight = rightBase; + } + return [effectiveLeft, effectiveRight]; + } function isYieldExpressionInClass(node) { var current = node; var parent = node.parent; @@ -54344,12 +55079,7 @@ var ts; return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync) || anyType; } - var contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, contextualReturnType, isAsync) - || anyType; - } - return anyType; + return getContextualIterationType(2 /* Next */, func) || anyType; } function checkConditionalExpression(node, checkMode) { checkTruthinessExpression(node.condition); @@ -54371,7 +55101,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 269 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 270 /* 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; @@ -54410,12 +55140,12 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 195 /* TypeAssertionExpression */ || node.kind === 213 /* AsExpression */; + return node.kind === 196 /* TypeAssertionExpression */ || node.kind === 214 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, /*cache*/ true); - var padded = ts.isParameter(declaration) && declaration.name.kind === 186 /* ArrayBindingPattern */ && + var padded = ts.isParameter(declaration) && declaration.name.kind === 187 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || @@ -54440,7 +55170,7 @@ var ts; var elementTypes = arity ? type.typeArguments.slice() : []; for (var i = arity; i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 187 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 188 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); @@ -54492,7 +55222,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -54503,7 +55233,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -54646,7 +55376,7 @@ var ts; var expr = ts.skipParentheses(node); // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (expr.kind === 192 /* CallExpression */ && expr.expression.kind !== 99 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (expr.kind === 193 /* CallExpression */ && expr.expression.kind !== 99 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var funcType = checkNonNullExpression(expr.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -54696,10 +55426,11 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 191 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 168 /* TypeQuery */ && node.parent.exprName === node)); + var ok = (node.parent.kind === 191 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 192 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 73 /* Identifier */ || node.kind === 150 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 169 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 259 /* ExportSpecifier */ && (compilerOptions.preserveConstEnums || node.flags & 4194304 /* Ambient */)); // 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); } @@ -54719,7 +55450,18 @@ var ts; return checkExpression(node.expression, checkMode); } function checkExpressionWorker(node, checkMode, forceTuple) { - switch (node.kind) { + var kind = node.kind; + if (cancellationToken) { + // 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 211 /* ClassExpression */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + cancellationToken.throwIfCancellationRequested(); + } + } + switch (kind) { case 73 /* Identifier */: return checkIdentifier(node); case 101 /* ThisKeyword */: @@ -54741,78 +55483,78 @@ var ts; return trueType; case 88 /* FalseKeyword */: return falseType; - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return checkQualifiedName(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (node.expression.kind === 93 /* ImportKeyword */) { return checkImportCallExpression(node); } - /* falls through */ - case 193 /* NewExpression */: + // falls through + case 194 /* NewExpression */: return checkCallExpression(node, checkMode); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return checkClassExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: return checkAssertion(node); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: return checkNonNullAssertion(node); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return checkMetaProperty(node); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return checkDeleteExpression(node); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return checkVoidExpression(node); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return checkAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 211 /* OmittedExpression */: + case 212 /* OmittedExpression */: return undefinedWideningType; - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return checkYieldExpression(node); - case 216 /* SyntheticExpression */: + case 217 /* SyntheticExpression */: return node.type; - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 261 /* JsxElement */: + case 262 /* JsxElement */: return checkJsxElement(node, checkMode); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return checkJsxFragment(node); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 263 /* JsxOpeningElement */: + case 264 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -54849,7 +55591,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 158 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 159 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -54860,10 +55602,10 @@ 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 === 158 /* Constructor */ || func.kind === 162 /* ConstructSignature */ || func.kind === 167 /* ConstructorType */) { + if (func.kind === 159 /* Constructor */ || func.kind === 163 /* ConstructSignature */ || func.kind === 168 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 199 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -54919,13 +55661,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 198 /* ArrowFunction */: - case 161 /* CallSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 166 /* FunctionType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 199 /* ArrowFunction */: + case 162 /* CallSignature */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 167 /* FunctionType */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -54943,7 +55685,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 === 186 /* ArrayBindingPattern */ || name.kind === 185 /* ObjectBindingPattern */) { + else if (name.kind === 187 /* ArrayBindingPattern */ || name.kind === 186 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -54952,13 +55694,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 164 /* 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 === 166 /* FunctionType */ || node.kind === 240 /* FunctionDeclaration */ || node.kind === 167 /* ConstructorType */ || - node.kind === 161 /* CallSignature */ || node.kind === 158 /* Constructor */ || - node.kind === 162 /* ConstructSignature */) { + else if (node.kind === 167 /* FunctionType */ || node.kind === 241 /* FunctionDeclaration */ || node.kind === 168 /* ConstructorType */ || + node.kind === 162 /* CallSignature */ || node.kind === 159 /* Constructor */ || + node.kind === 163 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -54988,10 +55730,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 161 /* CallSignature */: + case 162 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -55021,28 +55763,21 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 163 /* IndexSignature */ && node.kind !== 295 /* JSDocFunctionType */) { + if (node.kind !== 164 /* IndexSignature */ && node.kind !== 296 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } } function checkClassForDuplicateDeclarations(node) { - var Declaration; - (function (Declaration) { - Declaration[Declaration["Getter"] = 1] = "Getter"; - Declaration[Declaration["Setter"] = 2] = "Setter"; - Declaration[Declaration["Method"] = 4] = "Method"; - Declaration[Declaration["Property"] = 3] = "Property"; - })(Declaration || (Declaration = {})); var instanceNames = ts.createUnderscoreEscapedMap(); var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 158 /* Constructor */) { + if (member.kind === 159 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; - if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { - addName(instanceNames, param.name, param.name.escapedText, 3 /* Property */); + if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { + addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); } } } @@ -55053,17 +55788,17 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 159 /* GetAccessor */: - addName(names, name, memberName, 1 /* Getter */); + case 160 /* GetAccessor */: + addName(names, name, memberName, 1 /* GetAccessor */); break; - case 160 /* SetAccessor */: - addName(names, name, memberName, 2 /* Setter */); + case 161 /* SetAccessor */: + addName(names, name, memberName, 2 /* SetAccessor */); break; - case 155 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* Property */); + case 156 /* PropertyDeclaration */: + addName(names, name, memberName, 3 /* GetOrSetAccessor */); break; - case 157 /* MethodDeclaration */: - addName(names, name, memberName, 4 /* Method */); + case 158 /* MethodDeclaration */: + addName(names, name, memberName, 8 /* Method */); break; } } @@ -55072,8 +55807,8 @@ var ts; function addName(names, location, name, meaning) { var prev = names.get(name); if (prev) { - if (prev & 4 /* Method */) { - if (meaning !== 4 /* Method */) { + if (prev & 8 /* Method */) { + if (meaning !== 8 /* Method */) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } } @@ -55125,7 +55860,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154 /* PropertySignature */) { + if (member.kind === 155 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -55150,7 +55885,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 243 /* 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 @@ -55205,7 +55940,7 @@ var ts; 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.hasModifier(node, 128 /* Abstract */) && node.kind === 157 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 158 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -55230,7 +55965,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 155 /* PropertyDeclaration */ && + return n.kind === 156 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -55260,7 +55995,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 223 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -55285,7 +56020,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 160 /* GetAccessor */) { if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -55295,13 +56030,13 @@ 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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(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 === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = node.kind === 160 /* GetAccessor */ ? 161 /* SetAccessor */ : 160 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -55319,7 +56054,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 160 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -55367,7 +56102,7 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 165 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 166 /* 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); } var type = getTypeFromTypeReference(node); @@ -55415,7 +56150,7 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 173 /* RestType */) { + if (e.kind === 174 /* RestType */) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; @@ -55424,7 +56159,7 @@ var ts; error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 172 /* OptionalType */) { + else if (e.kind === 173 /* OptionalType */) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -55445,7 +56180,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 191 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 192 /* 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)); } @@ -55496,7 +56231,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 176 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 177 /* 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); @@ -55513,9 +56248,9 @@ var ts; var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 242 /* InterfaceDeclaration */ && - n.parent.kind !== 241 /* ClassDeclaration */ && - n.parent.kind !== 210 /* ClassExpression */ && + if (n.parent.kind !== 243 /* InterfaceDeclaration */ && + n.parent.kind !== 242 /* ClassDeclaration */ && + n.parent.kind !== 211 /* ClassExpression */ && n.flags & 4194304 /* 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 @@ -55606,7 +56341,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */) && + var reportError = (node.kind === 158 /* MethodDeclaration */ || node.kind === 157 /* MethodSignature */) && ts.hasModifier(node, 32 /* Static */) !== ts.hasModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -55641,11 +56376,12 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; + var hasNonAmbientClass = false; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 242 /* InterfaceDeclaration */ || node.parent.kind === 169 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 243 /* InterfaceDeclaration */ || node.parent.kind === 170 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -55656,7 +56392,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 240 /* FunctionDeclaration */ || node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */ || node.kind === 158 /* Constructor */) { + if ((node.kind === 242 /* ClassDeclaration */ || node.kind === 211 /* ClassExpression */) && !inAmbientContext) { + hasNonAmbientClass = true; + } + if (node.kind === 241 /* FunctionDeclaration */ || node.kind === 158 /* MethodDeclaration */ || node.kind === 157 /* MethodSignature */ || node.kind === 159 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -55697,6 +56436,15 @@ var ts; error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Duplicate_function_implementation); }); } + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */) { + // A non-ambient class cannot be an implementation for a non-constructor function/class merge + // TODO: The below just replicates our older error from when classes and functions were + // entirely unable to merge - a more helpful message like "Class declaration cannot implement overload list" + // might be warranted. :shrug: + ts.forEach(declarations, function (declaration) { + addDuplicateDeclarationError(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), ts.filter(declarations, function (d) { return d !== declaration; })); + }); + } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && !ts.hasModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { @@ -55718,13 +56466,6 @@ var ts; } } } - var DeclarationSpaces; - (function (DeclarationSpaces) { - DeclarationSpaces[DeclarationSpaces["None"] = 0] = "None"; - DeclarationSpaces[DeclarationSpaces["ExportValue"] = 1] = "ExportValue"; - DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; - DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; - })(DeclarationSpaces || (DeclarationSpaces = {})); function checkExportsOnMergedDeclarations(node) { if (!produceDiagnostics) { return; @@ -55785,40 +56526,42 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - // A jsdoc typedef and callback are, by definition, type aliases - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + // A jsdoc typedef and callback are, by definition, type aliases. + // falls through + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: return 2 /* ExportType */; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 285 /* SourceFile */: + case 286 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; } d = d.expression; - /* falls through */ - // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + // The below options all declare an Alias, which is allowed to merge with other values within the importing module. + // falls through + case 250 /* ImportEqualsDeclaration */: + case 253 /* NamespaceImport */: + case 252 /* ImportClause */: var result_8 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_8 |= getDeclarationSpaces(d); }); return result_8; - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 240 /* FunctionDeclaration */: - case 254 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 239 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 241 /* FunctionDeclaration */: + case 255 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); @@ -55887,9 +56630,6 @@ var ts; */ function checkAwaitedType(type, errorNode, diagnosticMessage, arg0) { var awaitedType = getAwaitedType(type, errorNode, diagnosticMessage, arg0); - if (awaitedType === type && !(type.flags & 3 /* AnyOrUnknown */)) { - addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(errorNode, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); - } return awaitedType || errorType; } function getAwaitedType(type, errorNode, diagnosticMessage, arg0) { @@ -56048,7 +56788,7 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67220415 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { if (promiseConstructorName.kind === 73 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { @@ -56071,7 +56811,7 @@ var ts; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 67220415 /* Value */); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -56090,24 +56830,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 152 /* Parameter */: + case 153 /* 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 155 /* PropertyDeclaration */: + case 156 /* 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 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -56128,7 +56868,7 @@ var ts; if (!typeName) return; var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 73 /* Identifier */ ? 67897832 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 73 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -56153,23 +56893,23 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 176 /* IntersectionType */: + case 175 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return node.typeName; } } } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var typeNode = types_17[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var typeNode = types_16[_i]; + while (typeNode.kind === 179 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 133 /* NeverKeyword */) { @@ -56221,14 +56961,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 152 /* Parameter */) { + if (node.kind === 153 /* 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 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -56237,23 +56977,23 @@ var ts; } } break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - var otherKind = node.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + var otherKind = node.kind === 160 /* GetAccessor */ ? 161 /* SetAccessor */ : 160 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 157 /* MethodDeclaration */: + case 158 /* 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 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 152 /* Parameter */: + case 153 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -56316,7 +57056,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 === 149 /* 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 === 150 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -56351,7 +57091,7 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return node; - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -56364,7 +57104,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 151 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -56393,7 +57133,7 @@ var ts; } } } - var body = node.kind === 156 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 157 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -56435,42 +57175,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 285 /* SourceFile */: - case 245 /* ModuleDeclaration */: - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 286 /* SourceFile */: + case 246 /* ModuleDeclaration */: + case 220 /* Block */: + case 248 /* CaseBlock */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 159 /* Constructor */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 177 /* InferType */: + case 178 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -56490,11 +57230,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 157 /* MethodDeclaration */: - case 155 /* PropertyDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - if (member.kind === 160 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 158 /* MethodDeclaration */: + case 156 /* PropertyDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + if (member.kind === 161 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -56503,7 +57243,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 158 /* Constructor */: + case 159 /* Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { @@ -56511,8 +57251,8 @@ var ts; } } break; - case 163 /* IndexSignature */: - case 218 /* SemicolonClassElement */: + case 164 /* IndexSignature */: + case 219 /* SemicolonClassElement */: // Can't be private break; default: @@ -56539,7 +57279,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 177 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 178 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) // Whole @template tag @@ -56609,7 +57349,7 @@ var ts; var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -56624,7 +57364,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 252 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 253 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -56642,7 +57382,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 === 238 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 239 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 239 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 240 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -56663,7 +57403,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 === 220 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 221 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -56677,22 +57417,22 @@ var ts; switch (name.kind) { case 73 /* Identifier */: return ts.idText(name); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 251 /* ImportClause */ || node.kind === 254 /* ImportSpecifier */ || node.kind === 252 /* NamespaceImport */; + return node.kind === 252 /* ImportClause */ || node.kind === 255 /* ImportSpecifier */ || node.kind === 253 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 251 /* ImportClause */ ? decl : decl.kind === 252 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 252 /* ImportClause */ ? decl : decl.kind === 253 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 219 /* Block */) { + if (node.kind === 220 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -56722,12 +57462,12 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 155 /* PropertyDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 157 /* MethodDeclaration */ || - node.kind === 156 /* MethodSignature */ || - node.kind === 159 /* GetAccessor */ || - node.kind === 160 /* SetAccessor */) { + if (node.kind === 156 /* PropertyDeclaration */ || + node.kind === 155 /* PropertySignature */ || + node.kind === 158 /* MethodDeclaration */ || + node.kind === 157 /* MethodSignature */ || + node.kind === 160 /* GetAccessor */ || + node.kind === 161 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -56736,7 +57476,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 152 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 153 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -56787,7 +57527,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 === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 286 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -56802,7 +57542,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 === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 286 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(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)); } @@ -56837,7 +57577,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 === 238 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 239 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -56849,17 +57589,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 239 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 220 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 240 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 221 /* 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 === 219 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 246 /* ModuleBlock */ || - container.kind === 245 /* ModuleDeclaration */ || - container.kind === 285 /* SourceFile */); + (container.kind === 220 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 247 /* ModuleBlock */ || + container.kind === 246 /* ModuleDeclaration */ || + container.kind === 286 /* 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 @@ -56889,18 +57629,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 187 /* BindingElement */) { - if (node.parent.kind === 185 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (node.kind === 188 /* BindingElement */) { + if (node.parent.kind === 186 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 150 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -56921,19 +57661,19 @@ var ts; } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 186 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 187 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 152 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 153 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 227 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 228 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -56970,7 +57710,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 227 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 228 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -56996,10 +57736,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */) { + if (node.kind !== 156 /* PropertyDeclaration */ && node.kind !== 155 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 239 /* VariableDeclaration */ || node.kind === 188 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -57008,7 +57748,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 155 /* PropertyDeclaration */ || nextDeclaration.kind === 154 /* PropertySignature */ + var message = nextDeclaration.kind === 156 /* PropertyDeclaration */ || nextDeclaration.kind === 155 /* 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); @@ -57018,8 +57758,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 152 /* Parameter */ && right.kind === 238 /* VariableDeclaration */) || - (left.kind === 238 /* VariableDeclaration */ && right.kind === 152 /* Parameter */)) { + if ((left.kind === 153 /* Parameter */ && right.kind === 239 /* VariableDeclaration */) || + (left.kind === 239 /* VariableDeclaration */ && right.kind === 153 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -57058,7 +57798,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkTruthinessExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 221 /* EmptyStatement */) { + if (node.thenStatement.kind === 222 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -57085,12 +57825,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 240 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 240 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -57124,14 +57864,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 === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 240 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 189 /* ArrayLiteralExpression */ || varExpr.kind === 190 /* 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. @@ -57163,7 +57903,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 === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 240 /* 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); @@ -57177,7 +57917,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 === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 189 /* ArrayLiteralExpression */ || varExpr.kind === 190 /* 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)) { @@ -57841,12 +58581,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 === 160 /* SetAccessor */) { + if (func.kind === 161 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 158 /* Constructor */) { + else if (func.kind === 159 /* 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); } @@ -57864,7 +58604,7 @@ var ts; } } } - else if (func.kind !== 158 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 159 /* 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); } @@ -57893,7 +58633,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 === 273 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 274 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -57905,7 +58645,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 272 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 273 /* 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. @@ -57934,7 +58674,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 234 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 235 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -58041,8 +58781,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 === 205 /* BinaryExpression */ || - name.kind === 150 /* ComputedPropertyName */ || + (propDeclaration.kind === 206 /* BinaryExpression */ || + name.kind === 151 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -58119,7 +58859,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 165 /* TypeReference */) { + if (node.kind === 166 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -58368,7 +59108,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 241 /* ClassDeclaration */ || d.kind === 242 /* InterfaceDeclaration */; + return d.kind === 242 /* ClassDeclaration */ || d.kind === 243 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -58387,7 +59127,7 @@ var ts; // derived class instance member variables and accessors, but not by other kinds of members. // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfType(baseType); - for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { + basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); if (base.flags & 4194304 /* Prototype */) { @@ -58396,53 +59136,64 @@ var ts; var derived = getTargetSymbol(getPropertyOfObjectType(type, base.escapedName)); // TODO: GH#18217 var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base); ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); - if (derived) { - // In order to resolve whether the inherited method was overridden in the base class or not, - // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* - // type declaration, derived and base resolve to the same symbol even in the case of generic classes. - if (derived === base) { - // derived class inherits base without override/redeclaration - var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); - // It is an error to inherit an abstract member without implementing it or being declared abstract. - // If there is no declaration for the derived class (as in the case of class expressions), - // then the class cannot be declared abstract. - if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 210 /* ClassExpression */) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); - } - else { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + // In order to resolve whether the inherited method was overridden in the base class or not, + // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* + // type declaration, derived and base resolve to the same symbol even in the case of generic classes. + if (derived === base) { + // derived class inherits base without override/redeclaration + var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); + // It is an error to inherit an abstract member without implementing it or being declared abstract. + // If there is no declaration for the derived class (as in the case of class expressions), + // then the class cannot be declared abstract. + if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { + // 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]; + if (otherBaseType === baseType) + continue; + var baseSymbol = getPropertyOfObjectType(otherBaseType, base.escapedName); + var derivedElsewhere = baseSymbol && getTargetSymbol(baseSymbol); + if (derivedElsewhere && derivedElsewhere !== base) { + continue basePropertyCheck; } } - } - else { - // derived overrides base. - var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { - // either base or derived property is private - not override, skip it - continue; + if (derivedClassDecl.kind === 211 /* ClassExpression */) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } - if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; - } - var errorMessage = void 0; - if (isPrototypeProperty(base)) { - if (derived.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } - else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); } - else if (base.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + } + else { + // derived overrides base. + var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); + if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + // either base or derived property is private - not override, skip it + continue; + } + if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { + // method is overridden with method or property/accessor is overridden with property/accessor - correct case + continue; + } + var errorMessage = void 0; + if (isPrototypeProperty(base)) { + if (derived.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } - error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } + else if (base.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } @@ -58499,7 +59250,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 155 /* PropertyDeclaration */ && + return node.kind === 156 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -58523,7 +59274,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 243 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -58628,7 +59379,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -58638,7 +59389,7 @@ var ts; } } break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -58666,7 +59417,7 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return evaluate(expr.expression); case 73 /* Identifier */: var identifier = expr; @@ -58674,20 +59425,18 @@ var ts; return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: + case 191 /* 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 === 190 /* PropertyAccessExpression */) { + if (ex.kind === 191 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { - var argument = ex.argumentExpression; - ts.Debug.assert(ts.isLiteralExpression(argument)); - name = ts.escapeLeadingUnderscores(argument.text); + name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text); } return evaluateEnumMember(expr, type.symbol, name); } @@ -58713,8 +59462,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 73 /* Identifier */ || - node.kind === 190 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 191 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.kind === 191 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 192 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && node.argumentExpression.kind === 10 /* StringLiteral */; } function checkEnumDeclaration(node) { @@ -58749,7 +59498,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 !== 244 /* EnumDeclaration */) { + if (declaration.kind !== 245 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -58772,8 +59521,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 241 /* ClassDeclaration */ || - (declaration.kind === 240 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 242 /* ClassDeclaration */ || + (declaration.kind === 241 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304 /* Ambient */)) { return declaration; } @@ -58836,7 +59585,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, 241 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 242 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -58886,23 +59635,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* 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]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 256 /* ExportAssignment */: + case 257 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 239 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -58913,12 +59662,12 @@ var ts; break; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 240 /* FunctionDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 241 /* FunctionDeclaration */: + case 243 /* InterfaceDeclaration */: + case 246 /* ModuleDeclaration */: + case 244 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -58941,12 +59690,12 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return node; - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: do { node = node.left; } while (node.kind !== 73 /* Identifier */); return node; - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 73 /* Identifier */); @@ -58963,9 +59712,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 256 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 247 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 286 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 257 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -58987,26 +59736,27 @@ var ts; function checkAliasSymbol(node) { var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); - if (target !== unknownSymbol) { - // For external modules symbol represent local symbol for an alias. + var shouldSkipWithJSExpandoTargets = symbol.flags & 67108864 /* Assignment */; + if (!shouldSkipWithJSExpandoTargets && target !== unknownSymbol) { + // For external modules symbol represents local symbol for an alias. // This local symbol will merge any other local declarations (excluding other aliases) // and symbol.flags will contains combined representation for all merged declaration. // Based on symbol.flags we can compute a set of excluded meanings (meaning that resolved alias should not have, // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export* // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). - var excludedMeanings = (symbol.flags & (67220415 /* Value */ | 1048576 /* ExportValue */) ? 67220415 /* Value */ : 0) | - (symbol.flags & 67897832 /* Type */ ? 67897832 /* Type */ : 0) | + var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | + (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 258 /* ExportSpecifier */ ? + var message = node.kind === 259 /* 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 === 258 /* ExportSpecifier */ - && !(target.flags & 67220415 /* Value */) + && node.kind === 259 /* ExportSpecifier */ + && !(target.flags & 111551 /* Value */) && !(node.flags & 4194304 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); } @@ -59032,7 +59782,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 253 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -59056,17 +59806,17 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 261 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 67220415 /* Value */) { + if (target.flags & 111551 /* Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name var moduleName = getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 67220415 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { + if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 67897832 /* Type */) { + if (target.flags & 788968 /* Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } @@ -59092,10 +59842,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 246 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 247 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 247 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 286 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -59112,7 +59862,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 285 /* SourceFile */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 245 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 286 /* SourceFile */ || node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 246 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -59126,13 +59876,17 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) - var symbol = resolveName(exportedName, exportedName.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || 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 { markExportAsReferenced(node); + var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) { + checkExpressionCached(node.propertyName || node.name); + } } } } @@ -59141,8 +59895,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 286 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 246 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -59156,7 +59910,17 @@ var ts; grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 73 /* Identifier */) { - markExportAsReferenced(node); + var id = node.expression; + var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); + if (sym) { + markAliasReferenced(sym, id); + // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`) + var target = sym.flags & 2097152 /* Alias */ ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551 /* Value */) { + // However if it is a value, we need to check it's being used correctly + checkExpressionCached(node.expression); + } + } if (ts.getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression, /*setVisibility*/ true); } @@ -59225,14 +59989,6 @@ var ts; links.exportsChecked = true; } } - function isNotAccessor(declaration) { - // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks - return !ts.isAccessor(declaration); - } - function isNotOverload(declaration) { - return (declaration.kind !== 240 /* FunctionDeclaration */ && declaration.kind !== 157 /* MethodDeclaration */) || - !!declaration.body; - } function checkSourceElement(node) { if (node) { var saveCurrentNode = currentNode; @@ -59254,158 +60010,159 @@ 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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 241 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return checkTypeParameter(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return checkParameter(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return checkPropertyDeclaration(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: return checkSignatureDeclaration(node); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: return checkMethodDeclaration(node); - case 158 /* Constructor */: + case 159 /* Constructor */: return checkConstructorDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return checkAccessorDeclaration(node); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return checkTypeReferenceNode(node); - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return checkTypePredicate(node); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return checkTypeQuery(node); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return checkTypeLiteral(node); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return checkArrayType(node); - case 171 /* TupleType */: + case 172 /* TupleType */: return checkTupleType(node); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 178 /* ParenthesizedType */: - case 172 /* OptionalType */: - case 173 /* RestType */: + case 179 /* ParenthesizedType */: + case 173 /* OptionalType */: + case 174 /* RestType */: return checkSourceElement(node.type); - case 179 /* ThisType */: + case 180 /* ThisType */: return checkThisType(node); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: return checkTypeOperator(node); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return checkConditionalType(node); - case 177 /* InferType */: + case 178 /* InferType */: return checkInferType(node); - case 184 /* ImportType */: + case 185 /* ImportType */: return checkImportType(node); - case 301 /* JSDocAugmentsTag */: + case 303 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 309 /* JSDocTypeTag */: + case 311 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 306 /* JSDocParameterTag */: + case 308 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: - case 298 /* JSDocTypeLiteral */: + case 294 /* JSDocNonNullableType */: + case 293 /* JSDocNullableType */: + case 291 /* JSDocAllType */: + case 292 /* JSDocUnknownType */: + case 300 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 296 /* JSDocVariadicType */: + case 297 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 289 /* JSDocTypeExpression */: + case 290 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 182 /* MappedType */: + case 183 /* MappedType */: return checkMappedType(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 220 /* Block */: + case 247 /* ModuleBlock */: return checkBlock(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return checkVariableStatement(node); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return checkExpressionStatement(node); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return checkIfStatement(node); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return checkDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return checkWhileStatement(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return checkForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return checkForInStatement(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return checkForOfStatement(node); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 230 /* ContinueStatement */: + case 231 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return checkReturnStatement(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return checkWithStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return checkSwitchStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return checkLabeledStatement(node); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return checkThrowStatement(node); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return checkTryStatement(node); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return checkBindingElement(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return checkClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return checkImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return checkExportDeclaration(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return checkExportAssignment(node); - case 221 /* EmptyStatement */: - case 237 /* DebuggerStatement */: + case 222 /* EmptyStatement */: + case 238 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 259 /* MissingDeclaration */: + case 260 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -59500,23 +60257,23 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 261 /* JsxElement */: + case 262 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -59646,35 +60403,35 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; // falls through - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - // falls through // this fall-through is necessary because we would like to handle - // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. + // falls through + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!isStatic) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67897832 /* Type */); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -59722,11 +60479,11 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 151 /* TypeParameter */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 152 /* TypeParameter */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 245 /* EnumDeclaration */: return true; default: return false; @@ -59734,16 +60491,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 150 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 165 /* TypeReference */; + return node.parent.kind === 166 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 190 /* PropertyAccessExpression */) { + while (node.parent.kind === 191 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 212 /* ExpressionWithTypeArguments */; + return node.parent.kind === 213 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -59771,13 +60528,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 149 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 150 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 249 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 250 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 255 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 256 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -59803,7 +60560,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 184 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 185 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -59813,7 +60570,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 190 /* PropertyAccessExpression */ && + entityName.parent.kind === 191 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -59821,17 +60578,17 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 255 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 256 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, - /*all meanings*/ 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); + /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); if (success && success !== unknownSymbol) { return success; } } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 249 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 250 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -59849,11 +60606,11 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 212 /* ExpressionWithTypeArguments */) { - meaning = 67897832 /* Type */; + if (entityName.parent.kind === 213 /* ExpressionWithTypeArguments */) { + meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { - meaning |= 67220415 /* Value */; + meaning |= 111551 /* Value */; } } else { @@ -59865,10 +60622,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 306 /* JSDocParameterTag */) { + if (entityName.parent.kind === 308 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 151 /* TypeParameter */ && entityName.parent.parent.kind === 310 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 152 /* TypeParameter */ && entityName.parent.parent.kind === 312 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -59883,14 +60640,14 @@ var ts; var symbol = getIntrinsicTagSymbol(entityName.parent); return symbol === unknownSymbol ? undefined : symbol; } - return resolveEntityName(entityName, 67220415 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); + return resolveEntityName(entityName, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 190 /* PropertyAccessExpression */ || entityName.kind === 149 /* QualifiedName */) { + else if (entityName.kind === 191 /* PropertyAccessExpression */ || entityName.kind === 150 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 190 /* PropertyAccessExpression */) { + if (entityName.kind === 191 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -59900,17 +60657,17 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 165 /* TypeReference */ ? 67897832 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 166 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - if (entityName.parent.kind === 164 /* TypePredicate */) { + if (entityName.parent.kind === 165 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -59933,8 +60690,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 187 /* BindingElement */ && - grandParent.kind === 185 /* ObjectBindingPattern */ && + else if (parent.kind === 188 /* BindingElement */ && + grandParent.kind === 186 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -59945,8 +60702,8 @@ var ts; } switch (node.kind) { case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 191 /* PropertyAccessExpression */: + case 150 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 101 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); @@ -59960,14 +60717,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 179 /* ThisType */: + case 180 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; case 99 /* SuperKeyword */: return checkExpression(node).symbol; case 125 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 158 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 159 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -59978,7 +60735,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 === 250 /* ImportDeclaration */ || node.parent.kind === 256 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 251 /* ImportDeclaration */ || node.parent.kind === 257 /* 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); @@ -60000,7 +60757,7 @@ var ts; case 37 /* EqualsGreaterThanToken */: case 77 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 184 /* ImportType */: + case 185 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; case 86 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; @@ -60009,8 +60766,8 @@ var ts; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 277 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 67220415 /* Value */ | 2097152 /* Alias */); + if (location && location.kind === 278 /* ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; } @@ -60018,7 +60775,7 @@ var ts; function getExportSpecifierLocalTargetSymbol(node) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } function getTypeOfNode(node) { if (node.flags & 8388608 /* InWithStatement */) { @@ -60077,27 +60834,27 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 189 /* ObjectLiteralExpression */ || expr.kind === 188 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 190 /* ObjectLiteralExpression */ || expr.kind === 189 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 228 /* ForOfStatement */) { + if (expr.parent.kind === 229 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 205 /* BinaryExpression */) { + if (expr.parent.kind === 206 /* 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 === 276 /* 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); + if (expr.parent.kind === 277 /* PropertyAssignment */) { + var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); + var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType; + var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex); } // Array literal assignment - array destructuring pattern var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); @@ -60141,7 +60898,7 @@ var ts; case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: @@ -60198,7 +60955,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 191 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -60219,13 +60976,13 @@ var ts; // for export assignments - check if resolved symbol for RHS is itself a value // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 67220415 /* Value */) + ? !!(moduleSymbol.flags & 111551 /* Value */) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 67220415 /* Value */); + return s && !!(s.flags & 111551 /* Value */); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -60254,7 +61011,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 285 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 286 /* 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. @@ -60274,7 +61031,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 67220415 /* Value */)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -60282,7 +61039,7 @@ var ts; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 276 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { @@ -60291,7 +61048,7 @@ var ts; var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { + if (resolveName(container.parent, symbol.escapedName, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } @@ -60313,7 +61070,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 === 219 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 220 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -60354,26 +61111,25 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 250 /* ImportEqualsDeclaration */: + case 252 /* ImportClause */: + case 253 /* NamespaceImport */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 255 /* ExportAssignment */: - return node.expression - && node.expression.kind === 73 /* Identifier */ - ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) - : true; + case 256 /* ExportAssignment */: + return node.expression && node.expression.kind === 73 /* Identifier */ ? + isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : + true; } return false; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 285 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 286 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -60387,7 +61143,7 @@ var ts; } // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true - return !!(target.flags & 67220415 /* Value */) && + return !!(target.flags & 111551 /* Value */) && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -60401,7 +61157,7 @@ var ts; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 if (target && ts.getModifierFlags(node) & 1 /* Export */ && - target.flags & 67220415 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { + target.flags & 111551 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -60455,7 +61211,7 @@ var ts; if (!symbol || !(symbol.flags & 16 /* Function */)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 67220415 /* Value */ && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -60474,15 +61230,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 279 /* EnumMember */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 280 /* EnumMember */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 279 /* EnumMember */) { + if (node.kind === 280 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -60509,9 +61265,9 @@ var ts; return ts.TypeReferenceSerializationKind.Unknown; } // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. - var valueSymbol = resolveEntityName(typeName, 67220415 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 67897832 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (valueSymbol && valueSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { @@ -60616,7 +61372,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + return resolveName(location, reference.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -60637,7 +61393,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 67220415 /* Value */, enclosing, /*flags*/ undefined, tracker) + var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse(); return enumResult || ts.createLiteral(type.value); } @@ -60718,12 +61474,12 @@ var ts; getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 160 /* SetAccessor */ ? 159 /* GetAccessor */ : 160 /* SetAccessor */; + var otherKind = accessor.kind === 161 /* SetAccessor */ ? 160 /* GetAccessor */ : 161 /* 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 === 160 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 159 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 161 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 160 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -60739,7 +61495,7 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 212 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 274 /* HeritageClause */; + return node.parent && node.parent.kind === 213 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 275 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -60750,9 +61506,9 @@ var ts; // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = 67897832 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 73 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 190 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { - meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; + var meaning = 788968 /* Type */ | 1920 /* Namespace */; + if ((node.kind === 73 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 191 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -60802,7 +61558,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 285 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 286 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -60830,12 +61586,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 245 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 246 /* 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, 285 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 286 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -60975,7 +61731,7 @@ var ts; for (var helper = 1 /* FirstEmitHelper */; helper <= 131072 /* LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 67220415 /* Value */); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); if (!symbol) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); } @@ -61024,14 +61780,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 157 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 158 /* 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 === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */) { + else if (node.kind === 160 /* GetAccessor */ || node.kind === 161 /* 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); @@ -61049,16 +61805,16 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 134 /* ReadonlyKeyword */) { - if (node.kind === 154 /* PropertySignature */ || node.kind === 156 /* MethodSignature */) { + if (node.kind === 155 /* PropertySignature */ || node.kind === 157 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 164 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 78 /* ConstKeyword */: - if (node.kind !== 244 /* EnumDeclaration */) { + if (node.kind !== 245 /* EnumDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(78 /* ConstKeyword */)); } break; @@ -61078,7 +61834,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 === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 286 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -61101,10 +61857,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 286 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 153 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -61117,7 +61873,7 @@ var ts; if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */ && node.kind !== 163 /* IndexSignature */ && node.kind !== 152 /* Parameter */) { + else if (node.kind !== 156 /* PropertyDeclaration */ && node.kind !== 155 /* PropertySignature */ && node.kind !== 164 /* IndexSignature */ && node.kind !== 153 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report 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); } @@ -61137,17 +61893,17 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 153 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; case 81 /* DefaultKeyword */: - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 286 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 246 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; @@ -61159,13 +61915,13 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 153 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 246 /* ModuleBlock */) { + else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 247 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -61175,14 +61931,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 241 /* ClassDeclaration */) { - if (node.kind !== 157 /* MethodDeclaration */ && - node.kind !== 155 /* PropertyDeclaration */ && - node.kind !== 159 /* GetAccessor */ && - node.kind !== 160 /* SetAccessor */) { + if (node.kind !== 242 /* ClassDeclaration */) { + if (node.kind !== 158 /* MethodDeclaration */ && + node.kind !== 156 /* PropertyDeclaration */ && + node.kind !== 160 /* GetAccessor */ && + node.kind !== 161 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 241 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 242 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -61201,7 +61957,7 @@ var ts; else if (flags & 2 /* Ambient */ || node.parent.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 153 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -61209,7 +61965,7 @@ var ts; break; } } - if (node.kind === 158 /* Constructor */) { + if (node.kind === 159 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -61224,13 +61980,13 @@ var ts; } return false; } - else if ((node.kind === 250 /* ImportDeclaration */ || node.kind === 249 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 251 /* ImportDeclaration */ || node.kind === 250 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 153 /* Parameter */ && (flags & 92 /* 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 === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 153 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -61251,37 +62007,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 245 /* ModuleDeclaration */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 152 /* Parameter */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 159 /* Constructor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 164 /* IndexSignature */: + case 246 /* ModuleDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 257 /* ExportDeclaration */: + case 256 /* ExportAssignment */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 153 /* Parameter */: return false; default: - if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 286 /* SourceFile */) { return false; } switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 122 /* AsyncKeyword */); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 119 /* AbstractKeyword */); - case 242 /* InterfaceDeclaration */: - case 220 /* VariableStatement */: - case 243 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 221 /* VariableStatement */: + case 244 /* TypeAliasDeclaration */: return true; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 78 /* ConstKeyword */); default: ts.Debug.fail(); @@ -61294,10 +62050,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -61360,7 +62116,7 @@ var ts; ts.addRelatedInfo(error(parameter, ts.Diagnostics.This_parameter_is_not_allowed_with_use_strict_directive), ts.createDiagnosticForNode(useStrictDirective_1, ts.Diagnostics.use_strict_directive_used_here)); }); var diagnostics_1 = nonSimpleParameters.map(function (parameter, index) { return (index === 0 ? ts.createDiagnosticForNode(parameter, ts.Diagnostics.Non_simple_parameter_declared_here) : ts.createDiagnosticForNode(parameter, ts.Diagnostics.and_here)); }); - ts.addRelatedInfo.apply(void 0, [error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)].concat(diagnostics_1)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)], diagnostics_1)); return true; } } @@ -61448,7 +62204,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 === 211 /* OmittedExpression */) { + if (arg.kind === 212 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -61525,20 +62281,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 150 /* ComputedPropertyName */) { + if (node.kind !== 151 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 205 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 206 /* 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 === 240 /* FunctionDeclaration */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 157 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 241 /* FunctionDeclaration */ || + node.kind === 198 /* FunctionExpression */ || + node.kind === 158 /* MethodDeclaration */); if (node.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -61554,17 +62310,10 @@ var ts; return !!exclamationToken && grammarErrorOnNode(exclamationToken, message); } function checkGrammarObjectLiteralExpression(node, inDestructuring) { - var Flags; - (function (Flags) { - Flags[Flags["Property"] = 1] = "Property"; - Flags[Flags["GetAccessor"] = 2] = "GetAccessor"; - Flags[Flags["SetAccessor"] = 4] = "SetAccessor"; - Flags[Flags["GetOrSetAccessor"] = 6] = "GetOrSetAccessor"; - })(Flags || (Flags = {})); var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */) { + if (prop.kind === 279 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -61575,11 +62324,11 @@ var ts; continue; } var name = prop.name; - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 151 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 277 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 278 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -61588,7 +62337,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 157 /* MethodDeclaration */) { + if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 158 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -61603,24 +62352,25 @@ 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 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); - /* tslint:disable:no-switch-case-fall-through */ - case 276 /* PropertyAssignment */: + // falls through + case 277 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name); } - // falls through - case 157 /* MethodDeclaration */: - currentKind = 1 /* Property */; + currentKind = 4 /* PropertyAssignment */; break; - case 159 /* GetAccessor */: - currentKind = 2 /* GetAccessor */; + case 158 /* MethodDeclaration */: + currentKind = 8 /* Method */; break; - case 160 /* SetAccessor */: - currentKind = 4 /* SetAccessor */; + case 160 /* GetAccessor */: + currentKind = 1 /* GetAccessor */; + break; + case 161 /* SetAccessor */: + currentKind = 2 /* SetAccessor */; break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); @@ -61634,11 +62384,11 @@ var ts; seen.set(effectiveName, currentKind); } else { - if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { + if ((currentKind & 12 /* PropertyAssignmentOrMethod */) && (existingKind & 12 /* PropertyAssignmentOrMethod */)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 6 /* GetOrSetAccessor */) && (existingKind & 6 /* GetOrSetAccessor */)) { - if (existingKind !== 6 /* GetOrSetAccessor */ && currentKind !== existingKind) { + else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) { + if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -61656,7 +62406,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 270 /* JsxSpreadAttribute */) { + if (attr.kind === 271 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -61666,7 +62416,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 271 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 272 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -61680,14 +62430,14 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 228 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 229 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { // use of 'for-await-of' in non-async function var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 159 /* 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); @@ -61698,7 +62448,7 @@ var ts; return false; } } - if (forInOrOfStatement.initializer.kind === 239 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 240 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -61713,20 +62463,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 228 /* 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 === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 228 /* 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 === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 228 /* 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); @@ -61736,42 +62486,38 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - var kind = accessor.kind; - if (languageVersion < 1 /* ES5 */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (accessor.flags & 4194304 /* Ambient */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); - } - else if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { - return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + if (!(accessor.flags & 4194304 /* Ambient */)) { + if (languageVersion < 1 /* ES5 */) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { + return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + } } - else if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { + if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - else if (accessor.typeParameters) { + if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 159 /* GetAccessor */ ? + if (!doesAccessorHaveCorrectParameterCount(accessor)) { + return grammarErrorOnNode(accessor.name, accessor.kind === 160 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 160 /* SetAccessor */) { + if (accessor.kind === 161 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } - else { - var parameter = accessor.parameters[0]; - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); - } - else if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); - } - else if (parameter.initializer) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); - } + var parameter = ts.Debug.assertDefined(ts.getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion."); + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); + } + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); + } + if (parameter.initializer) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); } } return false; @@ -61781,10 +62527,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 === 159 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 160 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 159 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 160 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -61795,7 +62541,7 @@ var ts; } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: var decl = parent; if (decl.name.kind !== 73 /* Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); @@ -61807,13 +62553,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: if (!ts.hasModifier(parent, 32 /* Static */) || !ts.hasModifier(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 154 /* PropertySignature */: + case 155 /* PropertySignature */: if (!ts.hasModifier(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); } @@ -61823,7 +62569,7 @@ var ts; } } else if (node.operator === 134 /* ReadonlyKeyword */) { - if (node.type.kind !== 170 /* ArrayType */ && node.type.kind !== 171 /* TupleType */) { + if (node.type.kind !== 171 /* ArrayType */ && node.type.kind !== 172 /* TupleType */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(140 /* SymbolKeyword */)); } } @@ -61837,8 +62583,8 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 157 /* MethodDeclaration */) { - if (node.parent.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 158 /* MethodDeclaration */) { + if (node.parent.kind === 190 /* 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 === 122 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -61866,14 +62612,14 @@ var ts; if (node.flags & 4194304 /* 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 === 157 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 158 /* 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 === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 243 /* 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 === 169 /* TypeLiteral */) { + else if (node.parent.kind === 170 /* 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); } } @@ -61884,11 +62630,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 234 /* LabeledStatement */: + case 235 /* 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 === 229 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 230 /* 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); @@ -61896,8 +62642,8 @@ var ts; return false; } break; - case 233 /* SwitchStatement */: - if (node.kind === 230 /* BreakStatement */ && !node.label) { + case 234 /* SwitchStatement */: + if (node.kind === 231 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -61912,13 +62658,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 230 /* BreakStatement */ + var message = node.kind === 231 /* 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 === 230 /* BreakStatement */ + var message = node.kind === 231 /* 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); @@ -61942,12 +62688,12 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 10 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.kind === 204 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.kind === 204 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -61977,7 +62723,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 227 /* ForInStatement */ && node.parent.parent.kind !== 228 /* ForOfStatement */) { + if (node.parent.parent.kind !== 228 /* ForInStatement */ && node.parent.parent.kind !== 229 /* ForOfStatement */) { if (node.flags & 4194304 /* Ambient */) { checkAmbientInitializer(node); } @@ -61990,7 +62736,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 220 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 221 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && @@ -62052,15 +62798,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 224 /* IfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 233 /* WithStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: return false; - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -62141,7 +62887,7 @@ var ts; return true; } } - else if (node.parent.kind === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 243 /* 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; } @@ -62149,7 +62895,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 169 /* TypeLiteral */) { + else if (node.parent.kind === 170 /* 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; } @@ -62178,13 +62924,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 243 /* TypeAliasDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 256 /* ExportDeclaration */ || - node.kind === 255 /* ExportAssignment */ || - node.kind === 248 /* NamespaceExportDeclaration */ || + if (node.kind === 243 /* InterfaceDeclaration */ || + node.kind === 244 /* TypeAliasDeclaration */ || + node.kind === 251 /* ImportDeclaration */ || + node.kind === 250 /* ImportEqualsDeclaration */ || + node.kind === 257 /* ExportDeclaration */ || + node.kind === 256 /* ExportAssignment */ || + node.kind === 249 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -62193,7 +62939,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 === 220 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 221 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -62206,13 +62952,9 @@ var ts; } function checkGrammarStatementInAmbientContext(node) { if (node.flags & 4194304 /* Ambient */) { - // An accessors is already reported about the ambient context - if (ts.isAccessor(node.parent)) { - return getNodeLinks(node).hasReportedStatementInAmbientContext = true; - } // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); - if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { + if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } // We are either parented by another statement, or some sort of block. @@ -62220,7 +62962,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 === 219 /* Block */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 220 /* Block */ || node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 286 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -62242,10 +62984,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, 183 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 184 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 279 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 280 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -62254,8 +62996,27 @@ var ts; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + // Realism (size) checking + checkNumericLiteralValueSize(node); return false; } + function checkNumericLiteralValueSize(node) { + // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint + // Literals with 15 or fewer characters aren't long enough to reach past 2^53 - 1 + // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway + if (node.numericLiteralFlags & 16 /* Scientific */ || node.text.length <= 15 || node.text.indexOf(".") !== -1) { + return; + } + // We can't rely on the runtime to accurately store and compare extremely large numeric values + // Even for internal use, we use getTextOfNode: https://github.com/microsoft/TypeScript/issues/33298 + // Thus, if the runtime claims a too-large number is lower than Number.MAX_SAFE_INTEGER, + // it's likely addition operations on it will fail too + var apparentValue = +ts.getTextOfNode(node); + if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) { + return; + } + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers)); + } function checkGrammarBigIntLiteral(node) { var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); @@ -62310,11 +63071,19 @@ var ts; } } ts.createTypeChecker = createTypeChecker; + function isNotAccessor(declaration) { + // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks + return !ts.isAccessor(declaration); + } + function isNotOverload(declaration) { + return (declaration.kind !== 241 /* FunctionDeclaration */ && declaration.kind !== 158 /* 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 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -62322,21 +63091,20 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 251 /* ImportClause */: // For default import - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: // For rename import `x as y` + case 252 /* ImportClause */: // For default import + case 250 /* ImportEqualsDeclaration */: + case 253 /* NamespaceImport */: + case 255 /* ImportSpecifier */: // For rename import `x as y` return true; case 73 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 254 /* ImportSpecifier */; + return decl.parent.kind === 255 /* ImportSpecifier */; default: return false; } } var JsxNames; (function (JsxNames) { - // tslint:disable variable-name JsxNames.JSX = "JSX"; JsxNames.IntrinsicElements = "IntrinsicElements"; JsxNames.ElementClass = "ElementClass"; @@ -62346,7 +63114,6 @@ var ts; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; - // tslint:enable variable-name })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { @@ -62417,6 +63184,7 @@ var ts; if (typeof value === "number") { return createNumericLiteral(value + ""); } + // eslint-disable-next-line no-in-operator if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n"); } @@ -62609,7 +63377,7 @@ var ts; ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(149 /* QualifiedName */); + var node = createSynthesizedNode(150 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -62628,7 +63396,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(150 /* ComputedPropertyName */); + var node = createSynthesizedNode(151 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -62641,7 +63409,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(151 /* TypeParameter */); + var node = createSynthesizedNode(152 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -62657,7 +63425,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(152 /* Parameter */); + var node = createSynthesizedNode(153 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -62681,7 +63449,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(153 /* Decorator */); + var node = createSynthesizedNode(154 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -62694,7 +63462,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(154 /* PropertySignature */); + var node = createSynthesizedNode(155 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -62714,7 +63482,7 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(155 /* PropertyDeclaration */); + var node = createSynthesizedNode(156 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62738,7 +63506,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(156 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(157 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -62755,7 +63523,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(157 /* MethodDeclaration */); + var node = createSynthesizedNode(158 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -62783,7 +63551,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(158 /* Constructor */); + var node = createSynthesizedNode(159 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -62803,7 +63571,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(159 /* GetAccessor */); + var node = createSynthesizedNode(160 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62826,7 +63594,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(160 /* SetAccessor */); + var node = createSynthesizedNode(161 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62847,7 +63615,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(161 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(162 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -62855,7 +63623,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(162 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(163 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -62863,7 +63631,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(163 /* IndexSignature */); + var node = createSynthesizedNode(164 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -62903,7 +63671,7 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(164 /* TypePredicate */); + var node = createSynthesizedNode(165 /* TypePredicate */); node.parameterName = asName(parameterName); node.type = type; return node; @@ -62917,7 +63685,7 @@ var ts; } ts.updateTypePredicateNode = updateTypePredicateNode; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(165 /* TypeReference */); + var node = createSynthesizedNode(166 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -62931,7 +63699,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(166 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(167 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -62939,7 +63707,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(167 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(168 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -62947,7 +63715,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(168 /* TypeQuery */); + var node = createSynthesizedNode(169 /* TypeQuery */); node.exprName = exprName; return node; } @@ -62959,7 +63727,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(169 /* TypeLiteral */); + var node = createSynthesizedNode(170 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -62971,7 +63739,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(170 /* ArrayType */); + var node = createSynthesizedNode(171 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -62983,7 +63751,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(171 /* TupleType */); + var node = createSynthesizedNode(172 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -62995,7 +63763,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(172 /* OptionalType */); + var node = createSynthesizedNode(173 /* OptionalType */); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -63007,7 +63775,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(173 /* RestType */); + var node = createSynthesizedNode(174 /* RestType */); node.type = type; return node; } @@ -63019,7 +63787,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(174 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(175 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -63027,7 +63795,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(175 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(176 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -63046,7 +63814,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(176 /* ConditionalType */); + var node = createSynthesizedNode(177 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -63064,7 +63832,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(177 /* InferType */); + var node = createSynthesizedNode(178 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -63076,7 +63844,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(184 /* ImportType */); + var node = createSynthesizedNode(185 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = ts.parenthesizeTypeParameters(typeArguments); @@ -63094,7 +63862,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(178 /* ParenthesizedType */); + var node = createSynthesizedNode(179 /* ParenthesizedType */); node.type = type; return node; } @@ -63106,11 +63874,11 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(179 /* ThisType */); + return createSynthesizedNode(180 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(180 /* TypeOperator */); + var node = createSynthesizedNode(181 /* TypeOperator */); node.operator = typeof operatorOrType === "number" ? operatorOrType : 130 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; @@ -63121,7 +63889,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(181 /* IndexedAccessType */); + var node = createSynthesizedNode(182 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -63135,7 +63903,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(182 /* MappedType */); + var node = createSynthesizedNode(183 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -63153,7 +63921,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(183 /* LiteralType */); + var node = createSynthesizedNode(184 /* LiteralType */); node.literal = literal; return node; } @@ -63166,7 +63934,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(185 /* ObjectBindingPattern */); + var node = createSynthesizedNode(186 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63178,7 +63946,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(186 /* ArrayBindingPattern */); + var node = createSynthesizedNode(187 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63190,7 +63958,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(187 /* BindingElement */); + var node = createSynthesizedNode(188 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -63209,7 +63977,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(188 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(189 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -63223,7 +63991,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(189 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(190 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -63237,7 +64005,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(190 /* PropertyAccessExpression */); + var node = createSynthesizedNode(191 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072 /* NoIndentation */); @@ -63254,7 +64022,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(191 /* ElementAccessExpression */); + var node = createSynthesizedNode(192 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -63268,7 +64036,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(192 /* CallExpression */); + var node = createSynthesizedNode(193 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -63284,7 +64052,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(193 /* NewExpression */); + var node = createSynthesizedNode(194 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -63300,7 +64068,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(194 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(195 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -63323,7 +64091,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(195 /* TypeAssertionExpression */); + var node = createSynthesizedNode(196 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -63337,7 +64105,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(196 /* ParenthesizedExpression */); + var node = createSynthesizedNode(197 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -63349,7 +64117,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(197 /* FunctionExpression */); + var node = createSynthesizedNode(198 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -63373,7 +64141,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(198 /* ArrowFunction */); + var node = createSynthesizedNode(199 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); @@ -63395,7 +64163,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(199 /* DeleteExpression */); + var node = createSynthesizedNode(200 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63407,7 +64175,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(200 /* TypeOfExpression */); + var node = createSynthesizedNode(201 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63419,7 +64187,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(201 /* VoidExpression */); + var node = createSynthesizedNode(202 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63431,7 +64199,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(202 /* AwaitExpression */); + var node = createSynthesizedNode(203 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63443,7 +64211,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(203 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(204 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -63456,7 +64224,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(204 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(205 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -63469,7 +64237,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(205 /* BinaryExpression */); + var node = createSynthesizedNode(206 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -63486,7 +64254,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(206 /* ConditionalExpression */); + var node = createSynthesizedNode(207 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); @@ -63506,7 +64274,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(207 /* TemplateExpression */); + var node = createSynthesizedNode(208 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -63519,32 +64287,91 @@ var ts; : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createTemplateHead(text) { - var node = createSynthesizedNode(15 /* TemplateHead */); + var rawTextScanner; + var invalidValueSentinel = {}; + function getCookedText(kind, rawText) { + if (!rawTextScanner) { + rawTextScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + } + switch (kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + rawTextScanner.setText("`" + rawText + "`"); + break; + case 15 /* TemplateHead */: + rawTextScanner.setText("`" + rawText + "${"); + break; + case 16 /* TemplateMiddle */: + rawTextScanner.setText("}" + rawText + "${"); + break; + case 17 /* TemplateTail */: + rawTextScanner.setText("}" + rawText + "`"); + break; + } + var token = rawTextScanner.scan(); + if (token === 23 /* CloseBracketToken */) { + token = rawTextScanner.reScanTemplateToken(); + } + if (rawTextScanner.isUnterminated()) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + var tokenValue; + switch (token) { + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + tokenValue = rawTextScanner.getTokenValue(); + break; + } + if (rawTextScanner.scan() !== 1 /* EndOfFileToken */) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + rawTextScanner.setText(undefined); + return tokenValue; + } + function createTemplateLiteralLikeNode(kind, text, rawText) { + var node = createSynthesizedNode(kind); + node.text = text; + if (rawText === undefined || text === rawText) { + node.rawText = rawText; + } + else { + var cooked = getCookedText(kind, rawText); + if (typeof cooked === "object") { + return ts.Debug.fail("Invalid raw text"); + } + ts.Debug.assert(text === cooked, "Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'."); + node.rawText = rawText; + } + return node; + } + function createTemplateHead(text, rawText) { + var node = createTemplateLiteralLikeNode(15 /* TemplateHead */, text, rawText); node.text = text; return node; } ts.createTemplateHead = createTemplateHead; - function createTemplateMiddle(text) { - var node = createSynthesizedNode(16 /* TemplateMiddle */); + function createTemplateMiddle(text, rawText) { + var node = createTemplateLiteralLikeNode(16 /* TemplateMiddle */, text, rawText); node.text = text; return node; } ts.createTemplateMiddle = createTemplateMiddle; - function createTemplateTail(text) { - var node = createSynthesizedNode(17 /* TemplateTail */); + function createTemplateTail(text, rawText) { + var node = createTemplateLiteralLikeNode(17 /* TemplateTail */, text, rawText); node.text = text; return node; } ts.createTemplateTail = createTemplateTail; - function createNoSubstitutionTemplateLiteral(text) { - var node = createSynthesizedNode(14 /* NoSubstitutionTemplateLiteral */); - node.text = text; + function createNoSubstitutionTemplateLiteral(text, rawText) { + var node = createTemplateLiteralLikeNode(14 /* NoSubstitutionTemplateLiteral */, text, rawText); return node; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(208 /* YieldExpression */); + var node = createSynthesizedNode(209 /* YieldExpression */); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; @@ -63558,7 +64385,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(209 /* SpreadElement */); + var node = createSynthesizedNode(210 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -63570,7 +64397,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(210 /* ClassExpression */); + var node = createSynthesizedNode(211 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63591,11 +64418,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(211 /* OmittedExpression */); + return createSynthesizedNode(212 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(212 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(213 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -63609,7 +64436,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(213 /* AsExpression */); + var node = createSynthesizedNode(214 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -63623,7 +64450,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(214 /* NonNullExpression */); + var node = createSynthesizedNode(215 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -63635,7 +64462,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(215 /* MetaProperty */); + var node = createSynthesizedNode(216 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -63649,7 +64476,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(217 /* TemplateSpan */); + var node = createSynthesizedNode(218 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -63663,12 +64490,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(218 /* SemicolonClassElement */); + return createSynthesizedNode(219 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(219 /* Block */); + var block = createSynthesizedNode(220 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -63682,7 +64509,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(220 /* VariableStatement */); + var node = createSynthesizedNode(221 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -63697,11 +64524,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(221 /* EmptyStatement */); + return createSynthesizedNode(222 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(222 /* ExpressionStatement */); + var node = createSynthesizedNode(223 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -63717,7 +64544,7 @@ var ts; /** @deprecated Use `updateExpressionStatement` instead. */ ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(223 /* IfStatement */); + var node = createSynthesizedNode(224 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -63733,7 +64560,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(224 /* DoStatement */); + var node = createSynthesizedNode(225 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; return node; @@ -63747,7 +64574,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(225 /* WhileStatement */); + var node = createSynthesizedNode(226 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -63761,7 +64588,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(226 /* ForStatement */); + var node = createSynthesizedNode(227 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -63779,7 +64606,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(227 /* ForInStatement */); + var node = createSynthesizedNode(228 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -63795,7 +64622,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(228 /* ForOfStatement */); + var node = createSynthesizedNode(229 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -63813,7 +64640,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(229 /* ContinueStatement */); + var node = createSynthesizedNode(230 /* ContinueStatement */); node.label = asName(label); return node; } @@ -63825,7 +64652,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(230 /* BreakStatement */); + var node = createSynthesizedNode(231 /* BreakStatement */); node.label = asName(label); return node; } @@ -63837,7 +64664,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(231 /* ReturnStatement */); + var node = createSynthesizedNode(232 /* ReturnStatement */); node.expression = expression; return node; } @@ -63849,7 +64676,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(232 /* WithStatement */); + var node = createSynthesizedNode(233 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -63863,7 +64690,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(233 /* SwitchStatement */); + var node = createSynthesizedNode(234 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -63877,7 +64704,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(234 /* LabeledStatement */); + var node = createSynthesizedNode(235 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); return node; @@ -63891,7 +64718,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(235 /* ThrowStatement */); + var node = createSynthesizedNode(236 /* ThrowStatement */); node.expression = expression; return node; } @@ -63903,7 +64730,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(236 /* TryStatement */); + var node = createSynthesizedNode(237 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -63919,11 +64746,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(237 /* DebuggerStatement */); + return createSynthesizedNode(238 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(238 /* VariableDeclaration */); + var node = createSynthesizedNode(239 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -63940,7 +64767,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* VariableDeclarationList */); + var node = createSynthesizedNode(240 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -63953,7 +64780,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(240 /* FunctionDeclaration */); + var node = createSynthesizedNode(241 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -63979,7 +64806,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(241 /* ClassDeclaration */); + var node = createSynthesizedNode(242 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64001,7 +64828,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(242 /* InterfaceDeclaration */); + var node = createSynthesizedNode(243 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64023,7 +64850,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(243 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(244 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64043,7 +64870,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(244 /* EnumDeclaration */); + var node = createSynthesizedNode(245 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64062,7 +64889,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(245 /* ModuleDeclaration */); + var node = createSynthesizedNode(246 /* ModuleDeclaration */); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -64081,7 +64908,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(246 /* ModuleBlock */); + var node = createSynthesizedNode(247 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -64093,7 +64920,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(247 /* CaseBlock */); + var node = createSynthesizedNode(248 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -64105,7 +64932,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(248 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(249 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -64117,7 +64944,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(249 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(250 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64135,7 +64962,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ImportDeclaration */); + var node = createSynthesizedNode(251 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -64153,7 +64980,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(251 /* ImportClause */); + var node = createSynthesizedNode(252 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -64167,7 +64994,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(252 /* NamespaceImport */); + var node = createSynthesizedNode(253 /* NamespaceImport */); node.name = name; return node; } @@ -64179,7 +65006,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(253 /* NamedImports */); + var node = createSynthesizedNode(254 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -64191,7 +65018,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(254 /* ImportSpecifier */); + var node = createSynthesizedNode(255 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -64205,7 +65032,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(255 /* ExportAssignment */); + var node = createSynthesizedNode(256 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -64222,7 +65049,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(256 /* ExportDeclaration */); + var node = createSynthesizedNode(257 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -64240,7 +65067,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(257 /* NamedExports */); + var node = createSynthesizedNode(258 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -64252,7 +65079,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(258 /* ExportSpecifier */); + var node = createSynthesizedNode(259 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -64267,7 +65094,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(260 /* ExternalModuleReference */); + var node = createSynthesizedNode(261 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -64281,14 +65108,14 @@ var ts; // JSDoc /* @internal */ function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(289 /* JSDocTypeExpression */); + var node = createSynthesizedNode(290 /* JSDocTypeExpression */); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; /* @internal */ function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(309 /* JSDocTypeTag */, "type"); + var tag = createJSDocTag(311 /* JSDocTypeTag */, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64296,7 +65123,7 @@ var ts; ts.createJSDocTypeTag = createJSDocTypeTag; /* @internal */ function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(307 /* JSDocReturnTag */, "returns"); + var tag = createJSDocTag(309 /* JSDocReturnTag */, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64304,14 +65131,14 @@ var ts; ts.createJSDocReturnTag = createJSDocReturnTag; /** @internal */ function createJSDocThisTag(typeExpression) { - var tag = createJSDocTag(308 /* JSDocThisTag */, "this"); + var tag = createJSDocTag(310 /* JSDocThisTag */, "this"); tag.typeExpression = typeExpression; return tag; } ts.createJSDocThisTag = createJSDocThisTag; /* @internal */ function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(306 /* JSDocParameterTag */, "param"); + var tag = createJSDocTag(308 /* JSDocParameterTag */, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -64321,7 +65148,7 @@ var ts; ts.createJSDocParamTag = createJSDocParamTag; /* @internal */ function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(297 /* JSDocComment */); + var node = createSynthesizedNode(299 /* JSDocComment */); node.comment = comment; node.tags = tags; return node; @@ -64335,7 +65162,7 @@ var ts; } // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(261 /* JsxElement */); + var node = createSynthesizedNode(262 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -64351,7 +65178,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(262 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(263 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64367,7 +65194,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(263 /* JsxOpeningElement */); + var node = createSynthesizedNode(264 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64383,7 +65210,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(264 /* JsxClosingElement */); + var node = createSynthesizedNode(265 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -64395,7 +65222,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(265 /* JsxFragment */); + var node = createSynthesizedNode(266 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -64417,11 +65244,11 @@ var ts; } ts.updateJsxText = updateJsxText; function createJsxOpeningFragment() { - return createSynthesizedNode(266 /* JsxOpeningFragment */); + return createSynthesizedNode(267 /* JsxOpeningFragment */); } ts.createJsxOpeningFragment = createJsxOpeningFragment; function createJsxJsxClosingFragment() { - return createSynthesizedNode(267 /* JsxClosingFragment */); + return createSynthesizedNode(268 /* JsxClosingFragment */); } ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment; function updateJsxFragment(node, openingFragment, children, closingFragment) { @@ -64433,7 +65260,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(268 /* JsxAttribute */); + var node = createSynthesizedNode(269 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -64447,7 +65274,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(269 /* JsxAttributes */); + var node = createSynthesizedNode(270 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -64459,7 +65286,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(270 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(271 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -64471,7 +65298,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(271 /* JsxExpression */); + var node = createSynthesizedNode(272 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -64485,7 +65312,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(272 /* CaseClause */); + var node = createSynthesizedNode(273 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -64499,7 +65326,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(273 /* DefaultClause */); + var node = createSynthesizedNode(274 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -64511,7 +65338,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(274 /* HeritageClause */); + var node = createSynthesizedNode(275 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -64524,7 +65351,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(275 /* CatchClause */); + var node = createSynthesizedNode(276 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -64539,7 +65366,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(276 /* PropertyAssignment */); + var node = createSynthesizedNode(277 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -64554,7 +65381,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(277 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(278 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -64568,7 +65395,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(278 /* SpreadAssignment */); + var node = createSynthesizedNode(279 /* SpreadAssignment */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -64581,7 +65408,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(279 /* EnumMember */); + var node = createSynthesizedNode(280 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -64602,7 +65429,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(285 /* SourceFile */); + var updated = createSynthesizedNode(286 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -64686,7 +65513,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(314 /* NotEmittedStatement */); + var node = createSynthesizedNode(316 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -64698,7 +65525,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(318 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(320 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -64710,7 +65537,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(317 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(319 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -64725,7 +65552,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(315 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(317 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -64741,7 +65568,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 316 /* CommaListExpression */) { + if (node.kind === 318 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { @@ -64751,7 +65578,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(316 /* CommaListExpression */); + var node = createSynthesizedNode(318 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -64764,7 +65591,7 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(286 /* Bundle */); + var node = ts.createNode(287 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -64795,7 +65622,7 @@ var ts; ], function (helper) { return helper.name; })); } function createUnparsedSource() { - var node = ts.createNode(287 /* UnparsedSource */); + var node = ts.createNode(288 /* UnparsedSource */); node.prologues = ts.emptyArray; node.referencedFiles = ts.emptyArray; node.libReferenceDirectives = ts.emptyArray; @@ -64927,10 +65754,10 @@ var ts; } function mapBundleFileSectionKindToSyntaxKind(kind) { switch (kind) { - case "prologue" /* Prologue */: return 280 /* UnparsedPrologue */; - case "prepend" /* Prepend */: return 281 /* UnparsedPrepend */; - case "internal" /* Internal */: return 283 /* UnparsedInternalText */; - case "text" /* Text */: return 282 /* UnparsedText */; + case "prologue" /* Prologue */: return 281 /* UnparsedPrologue */; + case "prepend" /* Prepend */: return 282 /* UnparsedPrepend */; + case "internal" /* Internal */: return 284 /* UnparsedInternalText */; + case "text" /* Text */: return 283 /* UnparsedText */; case "emitHelpers" /* EmitHelpers */: case "no-default-lib" /* NoDefaultLib */: case "reference" /* Reference */: @@ -64948,14 +65775,14 @@ var ts; return node; } function createUnparsedSyntheticReference(section, parent) { - var node = ts.createNode(284 /* UnparsedSyntheticReference */, section.pos, section.end); + var node = ts.createNode(285 /* UnparsedSyntheticReference */, section.pos, section.end); node.parent = parent; node.data = section.data; node.section = section; return node; } function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { - var node = ts.createNode(288 /* InputFiles */); + var node = ts.createNode(289 /* InputFiles */); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -65001,8 +65828,8 @@ var ts; node.declarationMapPath = declarationMapPath; node.declarationMapText = declarationMapTextOrBuildInfoPath; node.javascriptPath = javascriptPath; - node.declarationPath = declarationPath, - node.buildInfoPath = buildInfoPath; + node.declarationPath = declarationPath; + node.buildInfoPath = buildInfoPath; node.buildInfo = buildInfo; node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } @@ -65145,7 +65972,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 === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -65210,7 +66037,6 @@ var ts; return node; } ts.setSourceMapRange = setSourceMapRange; - // tslint:disable-next-line variable-name var SourceMapSource; /** * Create an external source map source file reference @@ -65496,9 +66322,9 @@ var ts; ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createFunctionCall(func, thisArg, argumentsList, location) { return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ thisArg - ].concat(argumentsList)), location); + ], argumentsList)), location); } ts.createFunctionCall = createFunctionCall; function createFunctionApply(func, thisArg, argumentsExpression, location) { @@ -65599,29 +66425,34 @@ var ts; } ts.createExpressionForJsxFragment = createExpressionForJsxFragment; // Helpers - function getHelperName(name) { + /** + * Gets an identifier for the name of an *unscoped* emit helper. + */ + function getUnscopedHelperName(name) { return ts.setEmitFlags(ts.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } - ts.getHelperName = getHelperName; + ts.getUnscopedHelperName = getUnscopedHelperName; ts.valuesHelper = { name: "typescript:values", + importName: "__values", scoped: false, - text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };" + text: "\n var __values = (this && this.__values) || function(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n };" }; function createValuesHelper(context, expression, location) { context.requestEmitHelper(ts.valuesHelper); - return ts.setTextRange(ts.createCall(getHelperName("__values"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__values"), /*typeArguments*/ undefined, [expression]), location); } ts.createValuesHelper = createValuesHelper; ts.readHelper = { name: "typescript:read", + importName: "__read", scoped: false, text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };" }; function createReadHelper(context, iteratorRecord, count, location) { context.requestEmitHelper(ts.readHelper); - return ts.setTextRange(ts.createCall(getHelperName("__read"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__read"), /*typeArguments*/ undefined, count !== undefined ? [iteratorRecord, ts.createLiteral(count)] : [iteratorRecord]), location); @@ -65629,24 +66460,26 @@ var ts; ts.createReadHelper = createReadHelper; ts.spreadHelper = { name: "typescript:spread", + importName: "__spread", scoped: false, text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" }; function createSpreadHelper(context, argumentList, location) { context.requestEmitHelper(ts.readHelper); context.requestEmitHelper(ts.spreadHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spread"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spread"), /*typeArguments*/ undefined, argumentList), location); } ts.createSpreadHelper = createSpreadHelper; ts.spreadArraysHelper = { name: "typescript:spreadArrays", + importName: "__spreadArrays", scoped: false, text: "\n var __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n };" }; function createSpreadArraysHelper(context, argumentList, location) { context.requestEmitHelper(ts.spreadArraysHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spreadArrays"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spreadArrays"), /*typeArguments*/ undefined, argumentList), location); } ts.createSpreadArraysHelper = createSpreadArraysHelper; @@ -65668,7 +66501,7 @@ var ts; ts.createForOfBindingStatement = createForOfBindingStatement; function insertLeadingStatement(dest, source) { if (ts.isBlock(dest)) { - return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray([source].concat(dest.statements)), dest.statements)); + return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray(__spreadArrays([source], dest.statements)), dest.statements)); } else { return ts.createBlock(ts.createNodeArray([dest, source]), /*multiLine*/ true); @@ -65679,7 +66512,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 234 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 235 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -65698,13 +66531,13 @@ var ts; case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -65731,7 +66564,7 @@ var ts; } else { switch (callee.kind) { - case 190 /* PropertyAccessExpression */: { + case 191 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -65744,7 +66577,7 @@ var ts; } break; } - case 191 /* ElementAccessExpression */: { + case 192 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -65801,14 +66634,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -66115,9 +66948,9 @@ var ts; function ensureUseStrict(statements) { var foundUseStrict = findUseStrictPrologue(statements); if (!foundUseStrict) { - return ts.setTextRange(ts.createNodeArray([ + return ts.setTextRange(ts.createNodeArray(__spreadArrays([ startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) - ].concat(statements)), statements); + ], statements)), statements); } return statements; } @@ -66134,7 +66967,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 === 196 /* ParenthesizedExpression */) { + if (skipped.kind === 197 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -66168,10 +67001,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(205 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(205 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(206 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(206 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 198 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 199 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -66183,7 +67016,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 208 /* YieldExpression */) { + && operand.kind === 209 /* YieldExpression */) { return false; } return true; @@ -66271,22 +67104,20 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { + if (node.kind === 206 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0 /* Unknown */; + var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind : + 0 /* Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(206 /* ConditionalExpression */, 56 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(207 /* ConditionalExpression */, 56 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -66321,8 +67152,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: + case 211 /* ClassExpression */: + case 198 /* FunctionExpression */: needsParens = true; } } @@ -66338,9 +67169,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 192 /* CallExpression */: + case 193 /* CallExpression */: return ts.createParen(expression); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -66363,7 +67194,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 193 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 194 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -66401,7 +67232,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(205 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(206 /* BinaryExpression */, 27 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -66412,29 +67243,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 197 /* FunctionExpression */ || kind === 198 /* ArrowFunction */) { + if (kind === 198 /* FunctionExpression */ || kind === 199 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 189 /* ObjectLiteralExpression */ || leftmostExpressionKind === 197 /* FunctionExpression */) { + if (leftmostExpressionKind === 190 /* ObjectLiteralExpression */ || leftmostExpressionKind === 198 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 176 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 177 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -66442,9 +67273,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 168 /* TypeQuery */: - case 180 /* TypeOperator */: - case 177 /* InferType */: + case 169 /* TypeQuery */: + case 181 /* TypeOperator */: + case 178 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -66470,28 +67301,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: node = node.operand; continue; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: node = node.left; continue; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: node = node.condition; continue; - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: node = node.tag; continue; - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 213 /* AsExpression */: - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: - case 214 /* NonNullExpression */: - case 315 /* PartiallyEmittedExpression */: + case 214 /* AsExpression */: + case 192 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 215 /* NonNullExpression */: + case 317 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -66500,15 +67331,15 @@ var ts; } ts.getLeftmostExpression = getLeftmostExpression; function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 189 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 190 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 316 /* CommaListExpression */; + return node.kind === 206 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 318 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -66521,13 +67352,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 214 /* NonNullExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: + case 215 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -66552,7 +67383,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 214 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 215 /* NonNullExpression */) { node = node.expression; } return node; @@ -66560,11 +67391,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 196 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 195 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 213 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 214 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 315 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 197 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 196 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 214 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 215 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 317 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -66582,7 +67413,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 196 /* ParenthesizedExpression */ + return node.kind === 197 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -66607,6 +67438,60 @@ var ts; return emitNode && emitNode.externalHelpersModuleName; } ts.getExternalHelpersModuleName = getExternalHelpersModuleName; + function hasRecordedExternalHelpers(sourceFile) { + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = parseNode && parseNode.emitNode; + return !!emitNode && (!!emitNode.externalHelpersModuleName || !!emitNode.externalHelpers); + } + ts.hasRecordedExternalHelpers = hasRecordedExternalHelpers; + function createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault) { + if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + var namedBindings = void 0; + var moduleKind = ts.getEmitModuleKind(compilerOptions); + if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) { + // use named imports + var helpers = ts.getEmitHelpers(sourceFile); + if (helpers) { + var helperNames = []; + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; + if (!helper.scoped) { + var importName = helper.importName; + if (importName) { + ts.pushIfUnique(helperNames, importName); + } + } + } + if (ts.some(helperNames)) { + helperNames.sort(ts.compareStringsCaseSensitive); + // Alias the imports if the names are used somewhere in the file. + // NOTE: We don't need to care about global import collisions as this is a module. + namedBindings = ts.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name) + ? ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name)) + : ts.createImportSpecifier(ts.createIdentifier(name), getUnscopedHelperName(name)); })); + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = ts.getOrCreateEmitNode(parseNode); + emitNode.externalHelpers = true; + } + } + } + else { + // use a namespace import + var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar || hasImportDefault); + if (externalHelpersModuleName) { + namedBindings = ts.createNamespaceImport(externalHelpersModuleName); + } + } + if (namedBindings) { + var externalHelpersImportDeclaration = ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, namedBindings), ts.createLiteral(ts.externalHelpersModuleNameText)); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); + return externalHelpersImportDeclaration; + } + } + } + ts.createExternalHelpersImportDeclarationIfNeeded = createExternalHelpersImportDeclarationIfNeeded; function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault) { if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(node, compilerOptions)) { var externalHelpersModuleName = getExternalHelpersModuleName(node); @@ -66621,8 +67506,8 @@ var ts; if (!create) { var helpers = ts.getEmitHelpers(node); if (helpers) { - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; + for (var _i = 0, helpers_3 = helpers; _i < helpers_3.length; _i++) { + var helper = helpers_3[_i]; if (!helper.scoped) { create = true; break; @@ -66647,10 +67532,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 250 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 251 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 256 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 257 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -66769,7 +67654,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -66781,11 +67666,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -66817,12 +67702,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 153 /* Parameter */: + case 188 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 209 /* SpreadElement */: - case 278 /* SpreadAssignment */: + case 210 /* SpreadElement */: + case 279 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -66834,7 +67719,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 187 /* BindingElement */: + case 188 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -66846,7 +67731,7 @@ var ts; : propertyName; } break; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -66858,7 +67743,7 @@ var ts; : propertyName; } break; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -66881,13 +67766,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: + case 189 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -66927,11 +67812,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 187 /* ArrayBindingPattern */: + case 189 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 186 /* ObjectBindingPattern */: + case 190 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -67054,11 +67939,9 @@ var ts; function visitLexicalEnvironment(statements, visitor, context, start, ensureUseStrict) { context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); - if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); - } - var declarations = context.endLexicalEnvironment(); - return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); + if (ensureUseStrict) + statements = ts.ensureUseStrict(statements); // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier + return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment()); } ts.visitLexicalEnvironment = visitLexicalEnvironment; /** @@ -67092,278 +67975,278 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */) || kind === 179 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 149 /* LastToken */) || kind === 180 /* ThisType */) { return node; } switch (kind) { // Names case 73 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 152 /* Parameter */: + case 153 /* Parameter */: return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 153 /* Decorator */: + case 154 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 154 /* PropertySignature */: + case 155 /* PropertySignature */: return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too visitNode(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 156 /* MethodSignature */: + case 157 /* MethodSignature */: return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 158 /* Constructor */: + case 159 /* Constructor */: return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 159 /* GetAccessor */: + case 160 /* GetAccessor */: return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 161 /* CallSignature */: + case 162 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); // Types - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 166 /* FunctionType */: + case 167 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 167 /* ConstructorType */: + case 168 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 171 /* TupleType */: + case 172 /* TupleType */: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 172 /* OptionalType */: + case 173 /* OptionalType */: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 173 /* RestType */: + case 174 /* RestType */: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174 /* UnionType */: + case 175 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 175 /* IntersectionType */: + case 176 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 177 /* InferType */: + case 178 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 184 /* ImportType */: + case 185 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 182 /* MappedType */: + case 183 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 183 /* LiteralType */: + case 184 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 186 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 213 /* AsExpression */: + case 214 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 219 /* Block */: + case 220 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 229 /* ContinueStatement */: + case 230 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 230 /* BreakStatement */: + case 231 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 253 /* NamedImports */: + case 254 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 257 /* NamedExports */: + case 258 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 258 /* ExportSpecifier */: + case 259 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 261 /* JsxElement */: + case 262 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 263 /* JsxOpeningElement */: + case 264 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 272 /* CaseClause */: + case 273 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 279 /* EnumMember */: + case 280 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 285 /* SourceFile */: + case 286 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -67405,58 +68288,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 149 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 164 /* TypePredicate */ && kind <= 183 /* LiteralType */)) { + if ((kind >= 165 /* TypePredicate */ && kind <= 184 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 218 /* SemicolonClassElement */: - case 221 /* EmptyStatement */: - case 211 /* OmittedExpression */: - case 237 /* DebuggerStatement */: - case 314 /* NotEmittedStatement */: + case 219 /* SemicolonClassElement */: + case 222 /* EmptyStatement */: + case 212 /* OmittedExpression */: + case 238 /* DebuggerStatement */: + case 316 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 152 /* Parameter */: + case 153 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 153 /* Decorator */: + case 154 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 154 /* PropertySignature */: + case 155 /* PropertySignature */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67465,12 +68348,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 158 /* Constructor */: + case 159 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 159 /* GetAccessor */: + case 160 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67478,7 +68361,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67486,50 +68369,50 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 187 /* BindingElement */: + case 188 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 192 /* CallExpression */: + case 193 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 193 /* NewExpression */: + case 194 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -67537,123 +68420,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 196 /* ParenthesizedExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: + case 200 /* DeleteExpression */: + case 201 /* TypeOfExpression */: + case 202 /* VoidExpression */: + case 203 /* AwaitExpression */: + case 209 /* YieldExpression */: + case 210 /* SpreadElement */: + case 215 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 213 /* AsExpression */: + case 214 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 219 /* Block */: + case 220 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 223 /* IfStatement */: + case 224 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 224 /* DoStatement */: + case 225 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 225 /* WhileStatement */: - case 232 /* WithStatement */: + case 226 /* WhileStatement */: + case 233 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 226 /* ForStatement */: + case 227 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 232 /* ReturnStatement */: + case 236 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 236 /* TryStatement */: + case 237 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67662,7 +68545,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67670,140 +68553,140 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.members, cbNodes, result); break; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 251 /* ImportClause */: + case 252 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 254 /* NamedImports */: + case 258 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // Module references - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 261 /* JsxElement */: + case 262 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 272 /* CaseClause */: + case 273 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 275 /* CatchClause */: + case 276 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 279 /* EnumMember */: + case 280 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 285 /* SourceFile */: + case 286 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -67876,7 +68759,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 212 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 213 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -67949,19 +68832,20 @@ var ts; exit(); return sourceIndex; } + /* eslint-disable boolean-trivia, no-null/no-null */ function setSourceContent(sourceIndex, content) { enter(); if (content !== null) { if (!sourcesContent) sourcesContent = []; while (sourcesContent.length < sourceIndex) { - // tslint:disable-next-line:no-null-keyword boolean-trivia sourcesContent.push(null); } sourcesContent[sourceIndex] = content; } exit(); } + /* eslint-enable boolean-trivia, no-null/no-null */ function addName(name) { enter(); if (!nameToNameIndexMap) @@ -68164,12 +69048,11 @@ var ts; } } ts.tryGetSourceMappingURL = tryGetSourceMappingURL; + /* eslint-disable no-null/no-null */ function isStringOrNull(x) { - // tslint:disable-next-line:no-null-keyword return typeof x === "string" || x === null; } function isRawSourceMap(x) { - // tslint:disable-next-line:no-null-keyword return x !== null && typeof x === "object" && x.version === 3 @@ -68181,6 +69064,7 @@ var ts; && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString)); } ts.isRawSourceMap = isRawSourceMap; + /* eslint-enable no-null/no-null */ function tryParseRawSourceMap(text) { try { var parsed = JSON.parse(text); @@ -68549,7 +69433,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 285 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 286 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -68591,25 +69475,31 @@ var ts; var hasExportDefault = false; var exportEquals; var hasExportStarsToExportValues = false; - var hasImportStarOrImportDefault = false; + var hasImportStar = false; + var hasImportDefault = false; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); - hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); + if (!hasImportStar && getImportNeedsImportStarHelper(node)) { + hasImportStar = true; + } + if (!hasImportDefault && getImportNeedsImportDefaultHelper(node)) { + hasImportDefault = true; + } break; - case 249 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + case 250 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 261 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -68639,13 +69529,13 @@ var ts; } } break; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -68653,7 +69543,7 @@ var ts; } } break; - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -68673,7 +69563,7 @@ var ts; } } break; - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -68695,12 +69585,8 @@ var ts; break; } } - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault); - var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault); if (externalHelpersImportDeclaration) { - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); externalImports.unshift(externalHelpersImportDeclaration); } return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames, externalHelpersImportDeclaration: externalHelpersImportDeclaration }; @@ -68775,7 +69661,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 223 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -68839,7 +69725,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 155 /* PropertyDeclaration */ + return member.kind === 156 /* PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; @@ -69288,6 +70174,7 @@ var ts; } ts.restHelper = { name: "typescript:rest", + importName: "__rest", scoped: false, text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n };" }; @@ -69312,7 +70199,7 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), + return ts.createCall(ts.getUnscopedHelperName("__rest"), /*typeArguments*/ undefined, [ value, ts.setTextRange(ts.createArrayLiteral(propertyNames), location) @@ -69365,8 +70252,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(191 /* PropertyAccessExpression */); + context.enableSubstitution(192 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -69392,14 +70279,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 286 /* Bundle */) { + if (node.kind === 287 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288 /* InputFiles */) { + if (prepend.kind === 289 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -69450,16 +70337,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 246 /* ModuleBlock */: - case 219 /* Block */: + case 286 /* SourceFile */: + case 248 /* CaseBlock */: + case 247 /* ModuleBlock */: + case 220 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 241 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -69471,7 +70358,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 === 241 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 242 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -69514,10 +70401,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 256 /* ExportAssignment */: + case 257 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -69538,13 +70425,13 @@ var ts; return node; } switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -69564,11 +70451,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 256 /* ExportDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 251 /* ImportClause */ || - (node.kind === 249 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 260 /* ExternalModuleReference */)) { + if (node.kind === 257 /* ExportDeclaration */ || + node.kind === 251 /* ImportDeclaration */ || + node.kind === 252 /* ImportClause */ || + (node.kind === 250 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 261 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -69592,19 +70479,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: return visitConstructor(node); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 164 /* IndexSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 158 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 218 /* SemicolonClassElement */: + case 219 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -69642,14 +70529,15 @@ var ts; case 78 /* ConstKeyword */: case 126 /* DeclareKeyword */: case 134 /* ReadonlyKeyword */: - // TypeScript accessibility and readonly modifiers are elided. - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 169 /* TypeLiteral */: - case 164 /* TypePredicate */: - case 151 /* TypeParameter */: + // TypeScript accessibility and readonly modifiers are elided + // falls through + case 171 /* ArrayType */: + case 172 /* TupleType */: + case 173 /* OptionalType */: + case 174 /* RestType */: + case 170 /* TypeLiteral */: + case 165 /* TypePredicate */: + case 152 /* TypeParameter */: case 121 /* AnyKeyword */: case 144 /* UnknownKeyword */: case 124 /* BooleanKeyword */: @@ -69658,40 +70546,43 @@ var ts; case 133 /* NeverKeyword */: case 107 /* VoidKeyword */: case 140 /* SymbolKeyword */: - case 167 /* ConstructorType */: - case 166 /* FunctionType */: - case 168 /* TypeQuery */: - case 165 /* TypeReference */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 178 /* ParenthesizedType */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: + case 168 /* ConstructorType */: + case 167 /* FunctionType */: + case 169 /* TypeQuery */: + case 166 /* TypeReference */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: + case 177 /* ConditionalType */: + case 179 /* ParenthesizedType */: + case 180 /* ThisType */: + case 181 /* TypeOperator */: + case 182 /* IndexedAccessType */: + case 183 /* MappedType */: + case 184 /* LiteralType */: // TypeScript type nodes are elided. - case 163 /* IndexSignature */: + // falls through + case 164 /* IndexSignature */: // TypeScript index signatures are elided. - case 153 /* Decorator */: + // falls through + case 154 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 243 /* TypeAliasDeclaration */: + // falls through + case 244 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 155 /* PropertyDeclaration */: + case 156 /* 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 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 158 /* Constructor */: + case 159 /* Constructor */: return visitConstructor(node); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -69701,7 +70592,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -69711,35 +70602,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 159 /* GetAccessor */: + case 160 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 152 /* Parameter */: + case 153 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -69749,35 +70640,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return visitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -70081,7 +70972,7 @@ var ts; var members = []; var constructor = ts.getFirstConstructorWithBody(node); var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (parametersWithPropertyAssignments) { for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) { var parameter = parametersWithPropertyAssignments_1[_i]; @@ -70187,12 +71078,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -70345,7 +71236,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 155 /* PropertyDeclaration */ + ? member.kind === 156 /* 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`. ? ts.createVoidZero() @@ -70468,10 +71359,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 155 /* PropertyDeclaration */; + return kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */ + || kind === 156 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -70481,7 +71372,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 158 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -70492,12 +71383,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return true; } return false; @@ -70514,15 +71405,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 153 /* Parameter */: return serializeTypeNode(node.type); - case 160 /* SetAccessor */: - case 159 /* GetAccessor */: + case 161 /* SetAccessor */: + case 160 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 157 /* MethodDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 158 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -70559,7 +71450,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 159 /* GetAccessor */) { + if (container && node.kind === 160 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -70609,26 +71500,26 @@ var ts; case 97 /* NullKeyword */: case 133 /* NeverKeyword */: return ts.createVoidZero(); - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: return ts.createIdentifier("Function"); - case 170 /* ArrayType */: - case 171 /* TupleType */: + case 171 /* ArrayType */: + case 172 /* TupleType */: return ts.createIdentifier("Array"); - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: case 124 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); case 139 /* StringKeyword */: return ts.createIdentifier("String"); case 137 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 183 /* LiteralType */: + case 184 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: return ts.createIdentifier("String"); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); case 9 /* BigIntLiteral */: @@ -70647,26 +71538,26 @@ var ts; return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return serializeTypeReferenceNode(node); - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 176 /* IntersectionType */: + case 175 /* UnionType */: return serializeTypeList(node.types); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: if (node.operator === 134 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 168 /* TypeQuery */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 169 /* TypeLiteral */: + case 169 /* TypeQuery */: + case 182 /* IndexedAccessType */: + case 183 /* MappedType */: + case 170 /* TypeLiteral */: case 121 /* AnyKeyword */: case 144 /* UnknownKeyword */: - case 179 /* ThisType */: - case 184 /* ImportType */: + case 180 /* ThisType */: + case 185 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -70677,9 +71568,9 @@ var ts; // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var typeNode = types_18[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var typeNode = types_17[_i]; + while (typeNode.kind === 179 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 133 /* NeverKeyword */) { @@ -70794,7 +71685,7 @@ var ts; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. return name; - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -70928,7 +71819,7 @@ var ts; } function transformConstructorBody(body, constructor) { var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (!ts.some(parametersWithPropertyAssignments)) { return ts.visitFunctionBody(body, visitor, context); } @@ -71341,12 +72232,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 285 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 286 /* 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 === 244 /* EnumDeclaration */) { + if (node.kind === 245 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -71471,7 +72362,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 246 /* ModuleBlock */) { + if (body.kind === 247 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -71517,13 +72408,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 (body.kind !== 246 /* ModuleBlock */) { + if (body.kind !== 247 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 246 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -71564,7 +72455,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 252 /* NamespaceImport */) { + if (node.kind === 253 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -71796,16 +72687,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(73 /* Identifier */); - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); + context.enableSubstitution(278 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(245 /* ModuleDeclaration */); + context.enableEmitNotification(246 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 245 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 246 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 244 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 245 /* EnumDeclaration */; } /** * Hook for node emit. @@ -71866,9 +72757,9 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return substituteExpressionIdentifier(node); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -71906,9 +72797,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 !== 285 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 245 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 244 /* EnumDeclaration */); + if (container && container.kind !== 286 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 246 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 245 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -71958,18 +72849,19 @@ var ts; } } context.requestEmitHelper(ts.decorateHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray), location); } ts.decorateHelper = { name: "typescript:decorate", + importName: "__decorate", scoped: false, priority: 2, text: "\n var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n };" }; function createMetadataHelper(context, metadataKey, metadataValue) { context.requestEmitHelper(ts.metadataHelper); - return ts.createCall(ts.getHelperName("__metadata"), + return ts.createCall(ts.getUnscopedHelperName("__metadata"), /*typeArguments*/ undefined, [ ts.createLiteral(metadataKey), metadataValue @@ -71977,13 +72869,14 @@ var ts; } ts.metadataHelper = { name: "typescript:metadata", + importName: "__metadata", scoped: false, priority: 3, text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(ts.paramHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__param"), /*typeArguments*/ undefined, [ ts.createLiteral(parameterOffset), expression @@ -71991,6 +72884,7 @@ var ts; } ts.paramHelper = { name: "typescript:param", + importName: "__param", scoped: false, priority: 4, text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" @@ -72044,11 +72938,11 @@ var ts; if (!(node.transformFlags & 1048576 /* ContainsClassFields */)) return node; switch (node.kind) { - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return visitClassExpression(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); } return ts.visitEachChild(node, visitor, context); @@ -72060,20 +72954,20 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 158 /* MethodDeclaration */: // Visit the name of the member (if it's a computed property name). return ts.visitEachChild(node, classElementVisitor, context); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 218 /* SemicolonClassElement */: + case 219 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -72083,7 +72977,7 @@ var ts; var savedPendingStatements = pendingStatements; pendingStatements = []; var visitedNode = ts.visitEachChild(node, visitor, context); - var statement = ts.some(pendingStatements) ? [visitedNode].concat(pendingStatements) : + var statement = ts.some(pendingStatements) ? __spreadArrays([visitedNode], pendingStatements) : visitedNode; pendingStatements = savedPendingStatements; return statement; @@ -72253,7 +73147,7 @@ var ts; if (constructor && constructor.body) { var parameterPropertyDeclarationCount = 0; for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) { - if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]))) { + if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) { parameterPropertyDeclarationCount++; } else { @@ -72435,6 +73329,7 @@ var ts; var hasSuperElementAccess; /** A set of node IDs for generated super accessors (variable statements). */ var substitutedSuperAccessors = []; + var topLevel; // Save the previous transformation hooks. var previousOnEmitNode = context.onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; @@ -72446,10 +73341,23 @@ var ts; if (node.isDeclarationFile) { return node; } + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitor(node) { if ((node.transformFlags & 32 /* ContainsES2017 */) === 0) { return node; @@ -72458,26 +73366,32 @@ var ts; case 122 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return visitAwaitExpression(node); - case 157 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 240 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: - return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 241 /* FunctionDeclaration */: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 198 /* FunctionExpression */: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 199 /* ArrowFunction */: return visitArrowFunction(node); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 159 /* Constructor */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -72485,27 +73399,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 219 /* Block */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 232 /* WithStatement */: - case 234 /* LabeledStatement */: + case 220 /* Block */: + case 234 /* SwitchStatement */: + case 248 /* CaseBlock */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: + case 237 /* TryStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 224 /* IfStatement */: + case 233 /* WithStatement */: + case 235 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -72706,7 +73620,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 === 198 /* ArrowFunction */; + var isArrowFunction = node.kind === 199 /* 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 @@ -72729,7 +73643,7 @@ var ts; if (!isArrowFunction) { var statements = []; var statementOffset = ts.addPrologue(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); - statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); + statements.push(ts.createReturn(createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. @@ -72756,7 +73670,7 @@ var ts; result = block; } else { - var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); + var expression = createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); @@ -72797,17 +73711,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(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(193 /* CallExpression */); + context.enableSubstitution(191 /* PropertyAccessExpression */); + context.enableSubstitution(192 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(242 /* ClassDeclaration */); + context.enableEmitNotification(158 /* MethodDeclaration */); + context.enableEmitNotification(160 /* GetAccessor */); + context.enableEmitNotification(161 /* SetAccessor */); + context.enableEmitNotification(159 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(221 /* VariableStatement */); } } /** @@ -72855,11 +73769,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -72883,19 +73797,19 @@ var ts; ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 242 /* ClassDeclaration */ + || kind === 159 /* Constructor */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -72955,11 +73869,12 @@ var ts; ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; ts.awaiterHelper = { name: "typescript:awaiter", + importName: "__awaiter", scoped: false, priority: 5, text: "\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };" }; - function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { + function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression( /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), @@ -72969,9 +73884,9 @@ var ts; /*type*/ undefined, body); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; - return ts.createCall(ts.getHelperName("__awaiter"), + return ts.createCall(ts.getUnscopedHelperName("__awaiter"), /*typeArguments*/ undefined, [ - ts.createThis(), + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), generatorFunc @@ -73005,9 +73920,11 @@ var ts; context.onEmitNode = onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; + var exportedVariableStatement = false; var enabledSubstitutions; var enclosingFunctionFlags; var enclosingSuperContainerFlags = 0; + var topLevel; /** Keeps track of property names accessed on super (`super.x`) within async functions. */ var capturedSuperProperties; /** Whether the async function contains an element access on super (`super[x]`). */ @@ -73019,6 +73936,8 @@ var ts; if (node.isDeclarationFile) { return node; } + exportedVariableStatement = false; + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -73035,63 +73954,80 @@ var ts; } return node; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitorWorker(node, noDestructuringValue) { if ((node.transformFlags & 16 /* ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return visitAwaitExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return visitYieldExpression(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitReturnStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitLabeledStatement(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClause(node); - case 238 /* VariableDeclaration */: + case 221 /* VariableStatement */: + return visitVariableStatement(node); + case 239 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return visitVoidExpression(node); - case 158 /* Constructor */: - return visitConstructorDeclaration(node); - case 157 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - return visitGetAccessorDeclaration(node); - case 160 /* SetAccessor */: - return visitSetAccessorDeclaration(node); - case 240 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: - return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 159 /* Constructor */: + return doOutsideOfTopLevel(visitConstructorDeclaration, node); + case 158 /* MethodDeclaration */: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 160 /* GetAccessor */: + return doOutsideOfTopLevel(visitGetAccessorDeclaration, node); + case 161 /* SetAccessor */: + return doOutsideOfTopLevel(visitSetAccessorDeclaration, node); + case 241 /* FunctionDeclaration */: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 198 /* FunctionExpression */: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 199 /* ArrowFunction */: return visitArrowFunction(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return visitParameter(node); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return visitExpressionStatement(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -73124,7 +74060,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 228 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 229 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -73136,7 +74072,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 === 278 /* SpreadAssignment */) { + if (e.kind === 279 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -73145,7 +74081,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 276 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 277 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -73179,7 +74115,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 !== 189 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 190 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } var expression = objects[0]; @@ -73224,23 +74160,44 @@ var ts; var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { - block = ts.updateBlock(block, [ + block = ts.updateBlock(block, __spreadArrays([ ts.createVariableStatement(/*modifiers*/ undefined, visitedBindings) - ].concat(block.statements)); + ], block.statements)); } return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, /*type*/ undefined, /*initializer*/ undefined), block); } return ts.visitEachChild(node, visitor, context); } + function visitVariableStatement(node) { + if (ts.hasModifier(node, 1 /* Export */)) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = true; + var visited = ts.visitEachChild(node, visitor, context); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return ts.visitEachChild(node, visitor, context); + } /** * Visits a VariableDeclaration node with a binding pattern. * * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { + if (exportedVariableStatement) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = false; + var visited = visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ true); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ false); + } + 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 & 8192 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */); + return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, + /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); } @@ -73458,7 +74415,7 @@ var ts; /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))))); + /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !topLevel)); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); @@ -73524,17 +74481,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(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(193 /* CallExpression */); + context.enableSubstitution(191 /* PropertyAccessExpression */); + context.enableSubstitution(192 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(242 /* ClassDeclaration */); + context.enableEmitNotification(158 /* MethodDeclaration */); + context.enableEmitNotification(160 /* GetAccessor */); + context.enableEmitNotification(161 /* SetAccessor */); + context.enableEmitNotification(159 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(221 /* VariableStatement */); } } /** @@ -73582,11 +74539,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -73610,19 +74567,19 @@ var ts; ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 242 /* ClassDeclaration */ + || kind === 159 /* Constructor */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -73638,65 +74595,69 @@ var ts; ts.transformES2018 = transformES2018; ts.assignHelper = { name: "typescript:assign", + importName: "__assign", scoped: false, priority: 1, text: "\n var __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n };" }; function createAssignHelper(context, attributesSegments) { if (context.getCompilerOptions().target >= 2 /* ES2015 */) { - return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), - /*typeArguments*/ undefined, attributesSegments); + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } context.requestEmitHelper(ts.assignHelper); - return ts.createCall(ts.getHelperName("__assign"), + return ts.createCall(ts.getUnscopedHelperName("__assign"), /*typeArguments*/ undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; ts.awaitHelper = { name: "typescript:await", + importName: "__await", scoped: false, text: "\n var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }" }; function createAwaitHelper(context, expression) { context.requestEmitHelper(ts.awaitHelper); - return ts.createCall(ts.getHelperName("__await"), /*typeArguments*/ undefined, [expression]); + return ts.createCall(ts.getUnscopedHelperName("__await"), /*typeArguments*/ undefined, [expression]); } ts.asyncGeneratorHelper = { name: "typescript:asyncGenerator", + importName: "__asyncGenerator", scoped: false, text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n };" }; - function createAsyncGeneratorHelper(context, generatorFunc) { + function createAsyncGeneratorHelper(context, generatorFunc, hasLexicalThis) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */; - return ts.createCall(ts.getHelperName("__asyncGenerator"), + return ts.createCall(ts.getUnscopedHelperName("__asyncGenerator"), /*typeArguments*/ undefined, [ - ts.createThis(), + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), ts.createIdentifier("arguments"), generatorFunc ]); } ts.asyncDelegator = { name: "typescript:asyncDelegator", + importName: "__asyncDelegator", scoped: false, text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\n };" }; function createAsyncDelegatorHelper(context, expression, location) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncDelegator); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncDelegator"), /*typeArguments*/ undefined, [expression]), location); } ts.asyncValues = { name: "typescript:asyncValues", + importName: "__asyncValues", scoped: false, text: "\n var __asyncValues = (this && this.__asyncValues) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n };" }; function createAsyncValuesHelper(context, expression, location) { context.requestEmitHelper(ts.asyncValues); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncValues"), /*typeArguments*/ undefined, [expression]), location); } })(ts || (ts = {})); @@ -73716,7 +74677,7 @@ var ts; return node; } switch (node.kind) { - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -73785,13 +74746,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 261 /* JsxElement */: + case 262 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -73801,13 +74762,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return visitJsxExpression(node); - case 261 /* JsxElement */: + case 262 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -73882,7 +74843,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 271 /* JsxExpression */) { + else if (node.kind === 272 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -73976,7 +74937,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 261 /* JsxElement */) { + if (node.kind === 262 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -74282,7 +75243,7 @@ var ts; return node; } switch (node.kind) { - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74495,13 +75456,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 231 /* ReturnStatement */ + && node.kind === 232 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */))) + || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 220 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -74523,63 +75484,63 @@ var ts; switch (node.kind) { case 117 /* StaticKeyword */: return undefined; // elide static keyword - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return visitClassExpression(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return visitParameter(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return visitArrowFunction(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return visitFunctionExpression(node); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return visitVariableDeclaration(node); case 73 /* Identifier */: return visitIdentifier(node); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return visitCaseBlock(node); - case 219 /* Block */: + case 220 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitLabeledStatement(node); - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return visitExpressionStatement(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClause(node); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return visitNewExpression(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -74590,28 +75551,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return visitTemplateExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return visitYieldExpression(node); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return visitSpreadElement(node); case 99 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); case 101 /* ThisKeyword */: return visitThisKeyword(node); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return visitMetaProperty(node); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -74702,14 +75663,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 === 230 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 231 /* 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 === 230 /* BreakStatement */) { + if (node.kind === 231 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -74720,7 +75681,7 @@ var ts; } } else { - if (node.kind === 230 /* BreakStatement */) { + if (node.kind === 231 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -75116,11 +76077,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 231 /* ReturnStatement */) { + if (statement.kind === 232 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 223 /* IfStatement */) { + else if (statement.kind === 224 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -75128,7 +76089,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 219 /* Block */) { + else if (statement.kind === 220 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -75326,7 +76287,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 199 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, ts.createThis()); return true; } @@ -75347,22 +76308,22 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return statements; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 158 /* Constructor */: + case 159 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 198 /* 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 = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 95 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); @@ -75394,20 +76355,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 218 /* SemicolonClassElement */: + case 219 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 158 /* Constructor */: + case 159 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -75595,7 +76556,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 === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 241 /* FunctionDeclaration */ || node.kind === 198 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -75639,7 +76600,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 198 /* ArrowFunction */); + ts.Debug.assert(node.kind === 199 /* 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 @@ -75707,9 +76668,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -75728,9 +76689,9 @@ var ts; // expression. If we are in a state where we do not need the destructuring value, // we pass that information along to the children that care about it. switch (node.expression.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -75939,14 +76900,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -76134,7 +77095,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 150 /* ComputedPropertyName */) { + if (property.name.kind === 151 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -76255,11 +77216,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 226 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 227 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 228 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 224 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 225 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 227 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 228 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 229 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 225 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 226 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -76284,11 +77245,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 240 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -76687,20 +77648,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -76776,7 +77737,7 @@ var ts; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); - return ts.updateBlock(block, [statement].concat(transformedStatements)); + return ts.updateBlock(block, __spreadArrays([statement], transformedStatements)); } /** * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a @@ -76807,7 +77768,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 160 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -77044,7 +78005,7 @@ var ts; // [output] // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray(__spreadArrays([ts.createVoidZero()], node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), /*typeArguments*/ undefined, []); } return ts.visitEachChild(node, visitor, context); @@ -77208,13 +78169,16 @@ var ts; // Find original source text, since we need to emit the raw strings of the tagged template. // The raw strings contain the (escaped) strings of what the user wrote. // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), - // thus we need to remove those characters. - // First template piece starts with "`", others with "}" - // Last template piece ends with "`", others with "${" - var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; - text = text.substring(1, text.length - (isLast ? 1 : 2)); + var text = node.rawText; + if (text === undefined) { + text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), + // thus we need to remove those characters. + // First template piece starts with "`", others with "}" + // Last template piece ends with "`", others with "${" + var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; + text = text.substring(1, text.length - (isLast ? 1 : 2)); + } // Newline normalization: // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's // and LineTerminatorSequences are normalized to for both TV and TRV. @@ -77305,10 +78269,8 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ - && !isExpressionOfCall - ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") - : ts.createFileLevelUniqueName("_super"); + return hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") : + ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { if (node.keywordToken === 96 /* NewKeyword */ && node.name.escapedText === "target") { @@ -77354,13 +78316,13 @@ var ts; if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; context.enableSubstitution(101 /* ThisKeyword */); - context.enableEmitNotification(158 /* Constructor */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(198 /* ArrowFunction */); - context.enableEmitNotification(197 /* FunctionExpression */); - context.enableEmitNotification(240 /* FunctionDeclaration */); + context.enableEmitNotification(159 /* Constructor */); + context.enableEmitNotification(158 /* MethodDeclaration */); + context.enableEmitNotification(160 /* GetAccessor */); + context.enableEmitNotification(161 /* SetAccessor */); + context.enableEmitNotification(199 /* ArrowFunction */); + context.enableEmitNotification(198 /* FunctionExpression */); + context.enableEmitNotification(241 /* FunctionDeclaration */); } } /** @@ -77401,10 +78363,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 238 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 239 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -77486,11 +78448,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 222 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 223 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 192 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 193 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -77498,7 +78460,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 209 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 210 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -77508,7 +78470,7 @@ var ts; ts.transformES2015 = transformES2015; function createExtendsHelper(context, name) { context.requestEmitHelper(ts.extendsHelper); - return ts.createCall(ts.getHelperName("__extends"), + return ts.createCall(ts.getUnscopedHelperName("__extends"), /*typeArguments*/ undefined, [ name, ts.createFileLevelUniqueName("_super") @@ -77516,7 +78478,7 @@ var ts; } function createTemplateObjectHelper(context, cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); - return ts.createCall(ts.getHelperName("__makeTemplateObject"), + return ts.createCall(ts.getUnscopedHelperName("__makeTemplateObject"), /*typeArguments*/ undefined, [ cooked, raw @@ -77524,12 +78486,14 @@ var ts; } ts.extendsHelper = { name: "typescript:extends", + importName: "__extends", scoped: false, priority: 0, text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; ts.templateObjectHelper = { name: "typescript:makeTemplateObject", + importName: "__makeTemplateObject", scoped: false, priority: 0, text: "\n var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n };" @@ -77551,15 +78515,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(263 /* JsxOpeningElement */); - context.enableEmitNotification(264 /* JsxClosingElement */); - context.enableEmitNotification(262 /* JsxSelfClosingElement */); + context.enableEmitNotification(264 /* JsxOpeningElement */); + context.enableEmitNotification(265 /* JsxClosingElement */); + context.enableEmitNotification(263 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(276 /* PropertyAssignment */); + context.enableSubstitution(191 /* PropertyAccessExpression */); + context.enableSubstitution(277 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -77578,9 +78542,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 265 /* JsxClosingElement */: + case 263 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -77912,13 +78876,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 224 /* DoStatement */: + case 225 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return visitWhileStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return visitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -77931,24 +78895,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return visitFunctionExpression(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatement(node); - case 230 /* BreakStatement */: + case 231 /* BreakStatement */: return visitBreakStatement(node); - case 229 /* ContinueStatement */: + case 230 /* ContinueStatement */: return visitContinueStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 131072 /* ContainsYield */) { @@ -77969,21 +78933,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return visitConditionalExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return visitYieldExpression(node); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -77996,9 +78960,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -78226,7 +79190,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -78238,7 +79202,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -78464,13 +79428,13 @@ var ts; temp = declareLocal(); var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements); emitAssignment(temp, ts.createArrayLiteral(leadingElement - ? [leadingElement].concat(initialElements) : initialElements)); + ? __spreadArrays([leadingElement], initialElements) : initialElements)); leadingElement = undefined; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return temp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { var hasAssignedTemp = temp !== undefined; @@ -78479,7 +79443,7 @@ var ts; } emitAssignment(temp, hasAssignedTemp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); + : ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine)); leadingElement = undefined; expressions = []; } @@ -78614,35 +79578,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 219 /* Block */: + case 220 /* Block */: return transformAndEmitBlock(node); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return transformAndEmitIfStatement(node); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return transformAndEmitDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return transformAndEmitForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 229 /* ContinueStatement */: + case 230 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 230 /* BreakStatement */: + case 231 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return transformAndEmitWithStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -79072,7 +80036,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 273 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 274 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -79085,7 +80049,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 273 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -79258,11 +80222,10 @@ var ts; return node; } function cacheExpression(node) { - var temp; if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { return node; } - temp = ts.createTempVariable(hoistVariableDeclaration); + var temp = ts.createTempVariable(hoistVariableDeclaration); emitAssignment(temp, node, /*location*/ node); return temp; } @@ -80223,7 +81186,7 @@ var ts; ts.transformGenerators = transformGenerators; function createGeneratorHelper(context, body) { context.requestEmitHelper(ts.generatorHelper); - return ts.createCall(ts.getHelperName("__generator"), + return ts.createCall(ts.getUnscopedHelperName("__generator"), /*typeArguments*/ undefined, [ts.createThis(), body]); } // The __generator helper is used by down-level transformations to emulate the runtime @@ -80287,6 +81250,7 @@ var ts; // For examples of how these are used, see the comments in ./transformers/generators.ts ts.generatorHelper = { name: "typescript:generator", + importName: "__generator", scoped: false, priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" @@ -80314,11 +81278,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(206 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(204 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(205 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(278 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(286 /* 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. @@ -80416,14 +81380,14 @@ var ts; // define(moduleName?, ["module1", "module2"], function ... var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createExpressionStatement(ts.createCall(define, - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ + /*typeArguments*/ undefined, __spreadArrays((moduleName ? [moduleName] : []), [ // Add the dependency array argument: // // ["require", "exports", module1", "module2", ...] - ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : [ + ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : __spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), // Add the module body function argument: // // function (require, exports, module1, module2) ... @@ -80433,10 +81397,10 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ + /*typeParameters*/ undefined, __spreadArrays([ ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), + ], importAliasNames), /*type*/ undefined, transformAsynchronousModuleBody(node)) ]))) ]), @@ -80471,11 +81435,11 @@ var ts; ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ - ts.createArrayLiteral([ + /*typeArguments*/ undefined, __spreadArrays((moduleName ? [moduleName] : []), [ + ts.createArrayLiteral(__spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), ts.createIdentifier("factory") ]))) ]))) @@ -80503,10 +81467,10 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ + /*typeParameters*/ undefined, __spreadArrays([ ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), + ], importAliasNames), /*type*/ undefined, transformAsynchronousModuleBody(node)) ])) ]), @@ -80646,23 +81610,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return visitExportDeclaration(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitExportAssignment(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return visitClassDeclaration(node); - case 317 /* MergeDeclarationMarker */: + case 319 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 318 /* EndOfDeclarationMarker */: + case 320 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -80689,24 +81653,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -80821,7 +81785,7 @@ var ts; var promise = ts.createNew(ts.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getHelperName("__importStar")]); + return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getUnscopedHelperName("__importStar")]); } return promise; } @@ -80835,7 +81799,7 @@ var ts; var requireCall = ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - requireCall = ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); + requireCall = ts.createCall(ts.getUnscopedHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); } var func; if (languageVersion >= 2 /* ES2015 */) { @@ -80869,11 +81833,11 @@ var ts; } if (ts.getImportNeedsImportStarHelper(node)) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); } if (ts.getImportNeedsImportDefaultHelper(node)) { context.requestEmitHelper(ts.importDefaultHelper); - return ts.createCall(ts.getHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); } return innerExpr; } @@ -81184,7 +82148,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 221 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -81239,10 +82203,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 254 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -81441,7 +82405,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -81505,10 +82469,10 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return substituteBinaryExpression(node); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -81529,7 +82493,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 286 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -81604,7 +82568,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 /* PostfixUnaryExpression */ + var expression = node.kind === 205 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 /* PlusPlusToken */ ? 61 /* PlusEqualsToken */ : 62 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; @@ -81645,7 +82609,7 @@ var ts; function createExportStarHelper(context, module) { var compilerOptions = context.getCompilerOptions(); return compilerOptions.importHelpers - ? ts.createCall(ts.getHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]) + ? ts.createCall(ts.getUnscopedHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]) : ts.createCall(ts.createIdentifier("__export"), /*typeArguments*/ undefined, [module]); } // emit helper for dynamic import @@ -81657,12 +82621,14 @@ var ts; // emit helper for `import * as Name from "foo"` ts.importStarHelper = { name: "typescript:commonjsimportstar", + importName: "__importStar", scoped: false, text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};" }; // emit helper for `import Name from "foo"` ts.importDefaultHelper = { name: "typescript:commonjsimportdefault", + importName: "__importDefault", scoped: false, text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};" }; @@ -81680,15 +82646,17 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(278 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(206 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(204 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(205 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(216 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(286 /* 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. var noSubstitutionMap = []; // Set of nodes for which substitution rules should be ignored for each file. + var contextObjectMap = []; // The context object associated with a source file. var currentSourceFile; // The current file. var moduleInfo; // ExternalModuleInfo for the current file. var exportFunction; // The export function for the current file. @@ -81727,7 +82695,7 @@ var ts; // existing identifiers. exportFunction = ts.createUniqueName("exports"); exportFunctionsMap[id] = exportFunction; - contextObject = ts.createUniqueName("context"); + contextObject = contextObjectMap[id] = ts.createUniqueName("context"); // Add the body of the module. var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups); @@ -81905,7 +82873,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 256 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 257 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -81930,7 +82898,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 256 /* ExportDeclaration */) { + if (externalImport.kind !== 257 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -82008,19 +82976,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -82070,15 +83038,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -82254,7 +83222,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 === 285 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 286 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -82318,7 +83286,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 === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 221 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -82380,10 +83348,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 254 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -82563,43 +83531,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatement(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatement(node); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return visitWhileStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitLabeledStatement(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return visitWithStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return visitCaseBlock(node); - case 272 /* CaseClause */: + case 273 /* CaseClause */: return visitCaseClause(node); - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: return visitDefaultClause(node); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return visitTryStatement(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClause(node); - case 219 /* Block */: + case 220 /* Block */: return visitBlock(node); - case 317 /* MergeDeclarationMarker */: + case 319 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 318 /* EndOfDeclarationMarker */: + case 320 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -82846,7 +83814,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 285 /* SourceFile */; + return container !== undefined && container.kind === 286 /* SourceFile */; } else { return false; @@ -82879,12 +83847,13 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; exportFunction = exportFunctionsMap[id]; noSubstitution = noSubstitutionMap[id]; + contextObject = contextObjectMap[id]; if (noSubstitution) { delete noSubstitutionMap[id]; } @@ -82892,6 +83861,7 @@ var ts; currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; + contextObject = undefined; noSubstitution = undefined; } else { @@ -82927,7 +83897,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -82963,11 +83933,13 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return substituteBinaryExpression(node); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); + case 216 /* MetaProperty */: + return substituteMetaProperty(node); } return node; } @@ -83059,14 +84031,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 /* PostfixUnaryExpression */ + var expression = node.kind === 205 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(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 === 204 /* PostfixUnaryExpression */) { + if (node.kind === 205 /* PostfixUnaryExpression */) { expression = node.operator === 44 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -83076,6 +84048,12 @@ var ts; } return node; } + function substituteMetaProperty(node) { + if (ts.isImportMeta(node)) { + return ts.createPropertyAccess(contextObject, ts.createIdentifier("meta")); + } + return node; + } /** * Gets the exports of a name. * @@ -83088,7 +84066,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 286 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -83127,24 +84105,20 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(285 /* SourceFile */); + context.enableEmitNotification(286 /* SourceFile */); context.enableSubstitution(73 /* Identifier */); - var currentSourceFile; + var helperNameSubstitutions; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { return node; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); - if (externalHelpersModuleName) { + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(node, compilerOptions); + if (externalHelpersImportDeclaration) { var statements = []; var statementOffset = ts.addPrologue(statements, node.statements); - var tslibImport = ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); - ts.addEmitFlags(tslibImport, 67108864 /* NeverApplyImportHelper */); - ts.append(statements, tslibImport); + ts.append(statements, externalHelpersImportDeclaration); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } @@ -83156,10 +84130,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -83180,9 +84154,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { if (ts.isSourceFile(node)) { - currentSourceFile = node; + helperNameSubstitutions = ts.createMap(); previousOnEmitNode(hint, node, emitCallback); - currentSourceFile = undefined; + helperNameSubstitutions = undefined; } else { previousOnEmitNode(hint, node, emitCallback); @@ -83199,19 +84173,18 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (ts.isIdentifier(node) && hint === 1 /* Expression */) { - return substituteExpressionIdentifier(node); + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* HelperName */) { + return substituteHelperName(node); } return node; } - function substituteExpressionIdentifier(node) { - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { - var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); - if (externalHelpersModuleName) { - return ts.createPropertyAccess(externalHelpersModuleName, node); - } + function substituteHelperName(node) { + var name = ts.idText(node); + var substitution = helperNameSubstitutions.get(name); + if (!substitution) { + helperNameSubstitutions.set(name, substitution = ts.createFileLevelUniqueName(name)); } - return node; + return substitution; } } ts.transformES2015Module = transformES2015Module; @@ -83267,7 +84240,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 242 /* 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 : @@ -83296,7 +84269,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 242 /* 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 : @@ -83322,7 +84295,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node) && ts.hasModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8 /* Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -83343,7 +84316,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 === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 239 /* VariableDeclaration */ || node.kind === 188 /* 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 : @@ -83352,8 +84325,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 === 155 /* PropertyDeclaration */ || node.kind === 190 /* PropertyAccessExpression */ || node.kind === 154 /* PropertySignature */ || - (node.kind === 152 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 156 /* PropertyDeclaration */ || node.kind === 191 /* PropertyAccessExpression */ || node.kind === 155 /* PropertySignature */ || + (node.kind === 153 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -83362,7 +84335,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 === 241 /* ClassDeclaration */ || node.kind === 152 /* Parameter */) { + else if (node.parent.kind === 242 /* ClassDeclaration */ || node.kind === 153 /* 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 : @@ -83387,7 +84360,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 161 /* 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.hasModifier(node, 32 /* Static */)) { @@ -83426,26 +84399,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 162 /* ConstructSignature */: + case 163 /* 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 161 /* CallSignature */: + case 162 /* 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 163 /* IndexSignature */: + case 164 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -83453,7 +84426,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 242 /* 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 : @@ -83467,7 +84440,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 240 /* FunctionDeclaration */: + case 241 /* 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 : @@ -83492,30 +84465,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 158 /* Constructor */: + case 159 /* 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 162 /* ConstructSignature */: - case 167 /* ConstructorType */: + case 163 /* ConstructSignature */: + case 168 /* 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 161 /* CallSignature */: + case 162 /* 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 163 /* IndexSignature */: + case 164 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -83523,7 +84496,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 === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 242 /* 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 : @@ -83536,8 +84509,8 @@ 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 240 /* FunctionDeclaration */: - case 166 /* FunctionType */: + case 241 /* FunctionDeclaration */: + case 167 /* 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 : @@ -83551,39 +84524,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 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 182 /* MappedType */: + case 183 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 168 /* ConstructorType */: + case 163 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 161 /* CallSignature */: + case 162 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.hasModifier(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 === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 242 /* 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 166 /* FunctionType */: - case 240 /* FunctionDeclaration */: + case 167 /* FunctionType */: + case 241 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -83598,7 +84571,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + if (node.parent.parent.kind === 242 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 110 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -83649,7 +84622,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 152 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 153 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -83710,6 +84683,7 @@ var ts; var currentSourceFile; var refs; var libs; + var emittedImports; // must be declared in container so it can be `undefined` while transformer's first pass var resolver = context.getEmitResolver(); var options = context.getCompilerOptions(); var newLine = ts.getNewLineCharacter(options); @@ -83799,10 +84773,10 @@ var ts; return ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createNamedExports([]), /*moduleSpecifier*/ undefined); } function transformRoot(node) { - if (node.kind === 285 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 286 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { return node; } - if (node.kind === 286 /* Bundle */) { + if (node.kind === 287 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); @@ -83832,7 +84806,7 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288 /* InputFiles */) { + if (prepend.kind === 289 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -83872,9 +84846,9 @@ var ts; var statements = ts.visitNodes(node.statements, visitDeclarationStatements); var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); refs.forEach(referenceVisitor); - var emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { - combinedStatements = ts.setTextRange(ts.createNodeArray(combinedStatements.concat([createEmptyExports()])), combinedStatements); + combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [createEmptyExports()])), combinedStatements); } var updated = ts.updateSourceFileNode(node, combinedStatements, /*isDeclarationFile*/ true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences()); updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit; @@ -83916,6 +84890,15 @@ 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, host.getSourceFiles(), + /*preferences*/ undefined, host.redirectTargetsMap); + if (!ts.pathIsRelative(specifier)) { + // If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration + // via a non-relative name, emit a type reference directive to that non-relative name, rather than + // a relative path to the declaration file + recordTypeReferenceDirectivesIfNecessary([specifier]); + return; + } var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); if (ts.startsWith(fileName, "./") && ts.hasExtension(fileName)) { @@ -83956,7 +84939,7 @@ var ts; return name; } else { - if (name.kind === 186 /* ArrayBindingPattern */) { + if (name.kind === 187 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -83964,20 +84947,20 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 211 /* OmittedExpression */) { + if (elem.kind === 212 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); } } - function ensureParameter(p, modifierMask) { + function ensureParameter(p, modifierMask, type) { var oldDiag; if (!suppressNewDiagnosticContexts) { oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } var newParam = ts.updateParameter(p, - /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(56 /* QuestionToken */)) : undefined, ensureType(p, p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param + /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(56 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -84002,7 +84985,7 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 152 /* Parameter */ && + var shouldUseResolverType = node.kind === 153 /* Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { @@ -84011,7 +84994,7 @@ var ts; if (!ts.getParseTreeNode(node)) { return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(121 /* AnyKeyword */); } - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 161 /* 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 ts.createKeywordTypeNode(121 /* AnyKeyword */); @@ -84022,12 +85005,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 239 /* VariableDeclaration */ || node.kind === 188 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 152 /* Parameter */ - || node.kind === 155 /* PropertyDeclaration */ - || node.kind === 154 /* PropertySignature */) { + if (node.kind === 153 /* Parameter */ + || node.kind === 156 /* PropertyDeclaration */ + || node.kind === 155 /* 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)); @@ -84044,20 +85027,20 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 241 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 243 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 245 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 250 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: + case 256 /* ExportAssignment */: return false; } return false; @@ -84084,6 +85067,33 @@ var ts; } return ts.createNodeArray(newParams, params.hasTrailingComma); } + function updateAccessorParamsList(input, isPrivate) { + var newParams; + if (!isPrivate) { + var thisParameter = ts.getThisParameter(input); + if (thisParameter) { + newParams = [ensureParameter(thisParameter)]; + } + } + if (ts.isSetAccessorDeclaration(input)) { + var newValueParameter = void 0; + if (!isPrivate) { + var valueParameter = ts.getSetAccessorValueParameter(input); + if (valueParameter) { + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + newValueParameter = ensureParameter(valueParameter, /*modifierMask*/ undefined, accessorType); + } + } + if (!newValueParameter) { + newValueParameter = ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "value"); + } + newParams = ts.append(newParams, newValueParameter); + } + return ts.createNodeArray(newParams || ts.emptyArray); + } function ensureTypeParams(node, params) { return ts.hasModifier(node, 8 /* Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } @@ -84111,7 +85121,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 245 /* ModuleDeclaration */ && parent.kind !== 184 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 246 /* ModuleDeclaration */ && parent.kind !== 185 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -84131,7 +85141,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 261 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -84158,7 +85168,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 253 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -84250,6 +85260,11 @@ var ts; enclosingDeclaration = input; } var oldDiag = getSymbolAccessibilityDiagnostic; + // Setup diagnostic-related flags before first potential `cleanup` call, otherwise + // We'd see a TDZ violation at runtime + var canProduceDiagnostic = ts.canProduceDiagnostics(input); + var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 170 /* TypeLiteral */ || input.kind === 183 /* MappedType */) && input.parent.kind !== 244 /* TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { if (ts.hasModifier(input, 8 /* Private */)) { @@ -84258,76 +85273,87 @@ var ts; return cleanup(ts.createProperty(/*decorators*/ undefined, ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); } } - var canProdiceDiagnostic = ts.canProduceDiagnostics(input); - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input); } if (ts.isTypeQueryNode(input)) { checkEntityNameVisibility(input.exprName, enclosingDeclaration); } - var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 169 /* TypeLiteral */ || input.kind === 182 /* MappedType */) && input.parent.kind !== 243 /* TypeAliasDeclaration */); if (shouldEnterSuppressNewDiagnosticsContextContext) { // We stop making new diagnostic contexts within object literal types. Unless it's an object type on the RHS of a type alias declaration. Then we do. suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 212 /* ExpressionWithTypeArguments */: { + case 213 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 165 /* TypeReference */: { + case 166 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 158 /* Constructor */: { + case 159 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(158 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + var ctor = ts.createSignatureDeclaration(159 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), // TODO: GH#18217 isPrivate ? undefined : updateParamsList(input, input.parameters, 0 /* None */), /*type*/ undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 157 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(156 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 158 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(157 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 159 /* GetAccessor */: { + case 160 /* GetAccessor */: { + // For now, only emit class accessors as accessors if they were already declared in an ambient context. + if (input.flags & 4194304 /* Ambient */) { + var isPrivate = ts.hasModifier(input, 8 /* Private */); + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + return cleanup(ts.updateGetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, + /*body*/ undefined)); + } var newNode = ensureAccessor(input); return cleanup(newNode); } - case 160 /* SetAccessor */: { + case 161 /* SetAccessor */: { + // For now, only emit class accessors as accessors if they were already declared in an ambient context. + if (input.flags & 4194304 /* Ambient */) { + return cleanup(ts.updateSetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8 /* Private */)), + /*body*/ undefined)); + } var newNode = ensureAccessor(input); return cleanup(newNode); } - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return cleanup(ts.updateProperty(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 154 /* PropertySignature */: + case 155 /* PropertySignature */: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 156 /* MethodSignature */: { + case 157 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 161 /* CallSignature */: { + case 162 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 163 /* IndexSignature */: { + case 164 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(121 /* AnyKeyword */))); } - case 238 /* VariableDeclaration */: { + case 239 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -84335,13 +85361,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(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 151 /* TypeParameter */: { + case 152 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 176 /* ConditionalType */: { + case 177 /* 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); @@ -84353,13 +85379,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 166 /* FunctionType */: { + case 167 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 167 /* ConstructorType */: { + case 168 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 184 /* ImportType */: { + case 185 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -84369,13 +85395,13 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { - if (returnValue && canProdiceDiagnostic && ts.hasDynamicName(input)) { + if (returnValue && canProduceDiagnostic && ts.hasDynamicName(input)) { checkName(input); } if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; } - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } if (shouldEnterSuppressNewDiagnosticsContextContext) { @@ -84388,7 +85414,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 157 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 158 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -84398,7 +85424,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 256 /* ExportDeclaration */: { + case 257 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -84407,7 +85433,7 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 255 /* ExportAssignment */: { + case 256 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; @@ -84448,10 +85474,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249 /* ImportEqualsDeclaration */: { + case 250 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 250 /* ImportDeclaration */: { + case 251 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -84472,14 +85498,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 243 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 244 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 242 /* InterfaceDeclaration */: { + case 243 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 240 /* FunctionDeclaration */: { + case 241 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -84527,10 +85553,10 @@ var ts; return clean; } } - case 245 /* ModuleDeclaration */: { + case 246 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 246 /* ModuleBlock */) { + if (inner && inner.kind === 247 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; @@ -84546,7 +85572,7 @@ var ts; // 3. Some things are exported, some are not, and there's no marker - add an empty marker if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) { if (needsScopeFixMarker) { - lateStatements = ts.createNodeArray(lateStatements.concat([createEmptyExports()])); + lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [createEmptyExports()])); } else { lateStatements = ts.visitNodes(lateStatements, stripExportModifiers); @@ -84573,7 +85599,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 241 /* ClassDeclaration */: { + case 242 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -84644,10 +85670,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 220 /* VariableStatement */: { + case 221 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 244 /* EnumDeclaration */: { + case 245 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -84666,7 +85692,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 245 /* ModuleDeclaration */) { + if (input.kind === 246 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -84687,7 +85713,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 211 /* OmittedExpression */) { + if (e.kind === 212 /* OmittedExpression */) { return; } if (e.name) { @@ -84737,24 +85763,33 @@ var ts; function ensureModifierFlags(node) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 285 /* SourceFile */; + var parentIsFile = node.parent.kind === 286 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; } return maskModifierFlags(node, mask, additions); } - function ensureAccessor(node) { - var accessors = resolver.getAllAccessorDeclarations(node); - if (node.kind !== accessors.firstAccessor.kind) { - return; - } + function getTypeAnnotationFromAllAccessorDeclarations(node, accessors) { var accessorType = getTypeAnnotationFromAccessor(node); - if (!accessorType && accessors.secondAccessor) { + if (!accessorType && node !== accessors.firstAccessor) { + accessorType = getTypeAnnotationFromAccessor(accessors.firstAccessor); + // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message + getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.firstAccessor); + } + if (!accessorType && accessors.secondAccessor && node !== accessors.secondAccessor) { accessorType = getTypeAnnotationFromAccessor(accessors.secondAccessor); // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.secondAccessor); } + return accessorType; + } + function ensureAccessor(node) { + var accessors = resolver.getAllAccessorDeclarations(node); + if (node.kind !== accessors.firstAccessor.kind) { + return; + } + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(node, accessors); var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); if (leadingsSyntheticCommentRanges) { @@ -84765,7 +85800,7 @@ var ts; if (lines.length > 1) { var lastLines = lines.slice(1); var indentation_1 = ts.guessIndentation(lastLines); - text = [lines[0]].concat(ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); + text = __spreadArrays([lines[0]], ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); } ts.addSyntheticLeadingComment(prop, range.kind, text, range.hasTrailingNewLine); } @@ -84785,7 +85820,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 243 /* InterfaceDeclaration */) { return true; } return false; @@ -84810,7 +85845,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 159 /* GetAccessor */ + return accessor.kind === 160 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -84819,52 +85854,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return !ts.hasModifier(node, 8 /* Private */); - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 153 /* Parameter */: + case 239 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 220 /* VariableStatement */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 241 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 243 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 245 /* EnumDeclaration */: + case 221 /* VariableStatement */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: + case 256 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 238 /* VariableDeclaration */: - case 151 /* TypeParameter */: - case 212 /* ExpressionWithTypeArguments */: - case 165 /* TypeReference */: - case 176 /* ConditionalType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 184 /* ImportType */: + case 163 /* ConstructSignature */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 164 /* IndexSignature */: + case 239 /* VariableDeclaration */: + case 152 /* TypeParameter */: + case 213 /* ExpressionWithTypeArguments */: + case 166 /* TypeReference */: + case 177 /* ConditionalType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 185 /* ImportType */: return true; } return false; @@ -84993,7 +86028,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(319 /* Count */); + var enabledSyntaxKindFeatures = new Array(321 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -85200,7 +86235,7 @@ var ts; var statements; if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) { if (lexicalEnvironmentFunctionDeclarations) { - statements = lexicalEnvironmentFunctionDeclarations.slice(); + statements = __spreadArrays(lexicalEnvironmentFunctionDeclarations); } if (lexicalEnvironmentVariableDeclarations) { var statement = ts.createVariableStatement( @@ -85278,15 +86313,15 @@ var ts; * If an array, the full list of source files to emit. * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) { + if (forceDtsEmit === void 0) { forceDtsEmit = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { var prepends = host.getPrependNodes(); if (sourceFiles.length || prepends.length) { var bundle = ts.createBundle(sourceFiles, prepends); - var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); + var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle); if (result) { return result; } @@ -85296,7 +86331,7 @@ var ts; if (!onlyBuildInfo) { for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { var sourceFile = sourceFiles_1[_a]; - var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); + var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile); if (result) { return result; } @@ -85349,7 +86384,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 286 /* Bundle */) { + if (sourceFile.kind === 287 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -85407,6 +86442,8 @@ var ts; } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; function getOutputJSFileName(inputFileName, configFile, ignoreCase) { + if (configFile.options.emitDeclarationOnly) + return undefined; var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ? ".json" /* Json */ : @@ -85438,7 +86475,7 @@ var ts; addOutput(js); if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) continue; - if (configFile.options.sourceMap) { + if (js && configFile.options.sourceMap) { addOutput(js + ".map"); } if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { @@ -85467,6 +86504,11 @@ var ts; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase); if (jsFilePath) return jsFilePath; + if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + continue; + if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { + return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + } } var buildInfoPath = getOutputPathForBuildInfo(configFile.options); if (buildInfoPath) @@ -85476,7 +86518,7 @@ var ts; ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo) { + function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) { var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers; var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; @@ -85490,7 +86532,7 @@ var ts; var exportedModulesFromDeclarationEmit; // Emit each output file enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), forceDtsEmit, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -85628,7 +86670,7 @@ var ts; }); var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit; emitSkipped = emitSkipped || declBlocked; - if (!declBlocked || emitOnlyDtsFiles) { + 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, @@ -85636,12 +86678,8 @@ var ts; mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 285 /* SourceFile */) { - // Improved narrowing in master/3.6 makes this cast unnecessary, triggering a lint rule. - // But at the same time, the LKG (3.5) necessitates it because it doesn’t narrow. - // Once the LKG is updated to 3.6, this comment, the cast to `SourceFile`, and the - // tslint directive can be all be removed. - var sourceFile = declarationTransform.transformed[0]; // tslint:disable-line + if (forceDtsEmit && declarationTransform.transformed[0].kind === 286 /* SourceFile */) { + var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } } @@ -85663,8 +86701,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 286 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 285 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 287 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 286 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -85705,7 +86743,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 285 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 286 /* 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 @@ -85815,7 +86853,7 @@ var ts; }; function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) { var sourceFiles = bundle.sourceFiles.map(function (fileName) { - var sourceFile = ts.createNode(285 /* SourceFile */, 0, 0); + var sourceFile = ts.createNode(286 /* SourceFile */, 0, 0); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = ""; sourceFile.statements = ts.createNodeArray(); @@ -85827,7 +86865,7 @@ var ts; sourceFile.text = prologueInfo.text; sourceFile.end = prologueInfo.text.length; sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { - var statement = ts.createNode(222 /* ExpressionStatement */, directive.pos, directive.end); + var statement = ts.createNode(223 /* ExpressionStatement */, directive.pos, directive.end); statement.expression = ts.createNode(10 /* StringLiteral */, directive.expression.pos, directive.expression.end); statement.expression.text = directive.expression.text; return statement; @@ -85866,7 +86904,7 @@ var ts; var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); }); var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host); var emitHost = { - getPrependNodes: ts.memoize(function () { return prependNodes.concat([ownPrependInput]); }), + getPrependNodes: ts.memoize(function () { return __spreadArrays(prependNodes, [ownPrependInput]); }), getCanonicalFileName: host.getCanonicalFileName, getCommonSourceDirectory: function () { return ts.getNormalizedAbsolutePath(buildInfo.bundle.commonSourceDirectory, buildInfoDirectory); }, getCompilerOptions: function () { return config.options; }, @@ -85920,6 +86958,7 @@ var ts; useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: ts.returnUndefined, getSourceFileFromReference: ts.returnUndefined, + redirectTargetsMap: ts.createMultiMap() }; emitFiles(ts.notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers)); @@ -86000,9 +87039,9 @@ var ts; break; } switch (node.kind) { - case 285 /* SourceFile */: return printFile(node); - case 286 /* Bundle */: return printBundle(node); - case 287 /* UnparsedSource */: return printUnparsedSource(node); + case 286 /* SourceFile */: return printFile(node); + case 287 /* Bundle */: return printBundle(node); + case 288 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -86184,7 +87223,7 @@ var ts; } function setWriter(_writer, _sourceMapGenerator) { if (_writer && printerOptions.omitTrailingSemicolon) { - _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + _writer = ts.getTrailingSemicolonDeferringWriter(_writer); } writer = _writer; // TODO: GH#18217 sourceMapGenerator = _sourceMapGenerator; @@ -86238,12 +87277,12 @@ var ts; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 285 /* SourceFile */) { + if (!commentsDisabled && node.kind !== 286 /* SourceFile */) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 285 /* SourceFile */ && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 286 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through @@ -86280,272 +87319,272 @@ var ts; case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node); - case 287 /* UnparsedSource */: - case 281 /* UnparsedPrepend */: + case 288 /* UnparsedSource */: + case 282 /* UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 280 /* UnparsedPrologue */: + case 281 /* UnparsedPrologue */: return writeUnparsedNode(node); - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 283 /* UnparsedText */: + case 284 /* UnparsedInternalText */: return emitUnparsedTextLike(node); - case 284 /* UnparsedSyntheticReference */: + case 285 /* UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Identifiers case 73 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return emitQualifiedName(node); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return emitTypeParameter(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return emitParameter(node); - case 153 /* Decorator */: + case 154 /* Decorator */: return emitDecorator(node); // Type members - case 154 /* PropertySignature */: + case 155 /* PropertySignature */: return emitPropertySignature(node); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 156 /* MethodSignature */: + case 157 /* MethodSignature */: return emitMethodSignature(node); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 158 /* Constructor */: + case 159 /* Constructor */: return emitConstructor(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return emitAccessorDeclaration(node); - case 161 /* CallSignature */: + case 162 /* CallSignature */: return emitCallSignature(node); - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: return emitConstructSignature(node); - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: return emitIndexSignature(node); // Types - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return emitTypePredicate(node); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return emitTypeReference(node); - case 166 /* FunctionType */: + case 167 /* FunctionType */: return emitFunctionType(node); - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 167 /* ConstructorType */: + case 168 /* ConstructorType */: return emitConstructorType(node); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return emitTypeQuery(node); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return emitTypeLiteral(node); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return emitArrayType(node); - case 171 /* TupleType */: + case 172 /* TupleType */: return emitTupleType(node); - case 172 /* OptionalType */: + case 173 /* OptionalType */: return emitOptionalType(node); - case 174 /* UnionType */: + case 175 /* UnionType */: return emitUnionType(node); - case 175 /* IntersectionType */: + case 176 /* IntersectionType */: return emitIntersectionType(node); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return emitConditionalType(node); - case 177 /* InferType */: + case 178 /* InferType */: return emitInferType(node); - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return emitParenthesizedType(node); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 179 /* ThisType */: + case 180 /* ThisType */: return emitThisType(); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: return emitTypeOperator(node); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 182 /* MappedType */: + case 183 /* MappedType */: return emitMappedType(node); - case 183 /* LiteralType */: + case 184 /* LiteralType */: return emitLiteralType(node); - case 184 /* ImportType */: + case 185 /* ImportType */: return emitImportTypeNode(node); - case 290 /* JSDocAllType */: + case 291 /* JSDocAllType */: writePunctuation("*"); return; - case 291 /* JSDocUnknownType */: + case 292 /* JSDocUnknownType */: writePunctuation("?"); return; - case 292 /* JSDocNullableType */: + case 293 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 293 /* JSDocNonNullableType */: + case 294 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 294 /* JSDocOptionalType */: + case 295 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 173 /* RestType */: - case 296 /* JSDocVariadicType */: + case 174 /* RestType */: + case 297 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 186 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return emitBindingElement(node); // Misc - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return emitTemplateSpan(node); - case 218 /* SemicolonClassElement */: + case 219 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 219 /* Block */: + case 220 /* Block */: return emitBlock(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return emitVariableStatement(node); - case 221 /* EmptyStatement */: + case 222 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return emitExpressionStatement(node); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return emitIfStatement(node); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return emitDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return emitWhileStatement(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return emitForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return emitForInStatement(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return emitForOfStatement(node); - case 229 /* ContinueStatement */: + case 230 /* ContinueStatement */: return emitContinueStatement(node); - case 230 /* BreakStatement */: + case 231 /* BreakStatement */: return emitBreakStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return emitReturnStatement(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return emitWithStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return emitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return emitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return emitThrowStatement(node); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return emitTryStatement(node); - case 237 /* DebuggerStatement */: + case 238 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return emitClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return emitModuleBlock(node); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return emitCaseBlock(node); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return emitImportDeclaration(node); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return emitImportClause(node); - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return emitNamespaceImport(node); - case 253 /* NamedImports */: + case 254 /* NamedImports */: return emitNamedImports(node); - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return emitImportSpecifier(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return emitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return emitExportDeclaration(node); - case 257 /* NamedExports */: + case 258 /* NamedExports */: return emitNamedExports(node); - case 258 /* ExportSpecifier */: + case 259 /* ExportSpecifier */: return emitExportSpecifier(node); - case 259 /* MissingDeclaration */: + case 260 /* MissingDeclaration */: return; // Module references - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: + case 264 /* JsxOpeningElement */: + case 267 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 264 /* JsxClosingElement */: - case 267 /* JsxClosingFragment */: + case 265 /* JsxClosingElement */: + case 268 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return emitJsxAttribute(node); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return emitJsxAttributes(node); - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 272 /* CaseClause */: + case 273 /* CaseClause */: return emitCaseClause(node); - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: return emitDefaultClause(node); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: return emitHeritageClause(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 279 /* EnumMember */: + case 280 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: + case 314 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 308 /* JSDocThisTag */: - case 305 /* JSDocEnumTag */: + case 309 /* JSDocReturnTag */: + case 311 /* JSDocTypeTag */: + case 310 /* JSDocThisTag */: + case 307 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); - case 301 /* JSDocAugmentsTag */: + case 303 /* JSDocAugmentsTag */: return emitJSDocAugmentsTag(node); - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 311 /* JSDocTypedefTag */: + case 313 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 304 /* JSDocCallbackTag */: + case 306 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); - case 299 /* JSDocSignature */: + case 301 /* JSDocSignature */: return emitJSDocSignature(node); - case 298 /* JSDocTypeLiteral */: + case 300 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 303 /* JSDocClassTag */: - case 300 /* JSDocTag */: + case 305 /* JSDocClassTag */: + case 302 /* JSDocTag */: return emitJSDocSimpleTag(node); - case 297 /* JSDocComment */: + case 299 /* JSDocComment */: return emitJSDoc(node); // Transformation nodes (ignored) } @@ -86582,71 +87621,71 @@ var ts; writeTokenNode(node, writeKeyword); return; // Expressions - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return emitCallExpression(node); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return emitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return emitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return emitArrowFunction(node); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return emitDeleteExpression(node); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return emitVoidExpression(node); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return emitAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return emitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return emitConditionalExpression(node); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return emitTemplateExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return emitYieldExpression(node); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return emitSpreadExpression(node); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return emitClassExpression(node); - case 211 /* OmittedExpression */: + case 212 /* OmittedExpression */: return; - case 213 /* AsExpression */: + case 214 /* AsExpression */: return emitAsExpression(node); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: return emitNonNullExpression(node); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 261 /* JsxElement */: + case 262 /* JsxElement */: return emitJsxElement(node); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: return emitCommaList(node); } } @@ -86674,8 +87713,8 @@ var ts; var helpers = getSortedEmitHelpers(sourceFile); if (!helpers) continue; - for (var _c = 0, helpers_3 = helpers; _c < helpers_3.length; _c++) { - var helper = helpers_3[_c]; + for (var _c = 0, helpers_4 = helpers; _c < helpers_4.length; _c++) { + var helper = helpers_4[_c]; if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) { bundledHelpers.set(helper.name, true); (result || (result = [])).push(helper.name); @@ -86686,7 +87725,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 286 /* Bundle */ ? node : undefined; + var bundle = node.kind === 287 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -86695,12 +87734,12 @@ var ts; for (var i = 0; i < numNodes; i++) { var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node; var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile; - var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.hasRecordedExternalHelpers(sourceFile)); var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit; var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode); if (helpers) { - for (var _a = 0, helpers_4 = helpers; _a < helpers_4.length; _a++) { - var helper = helpers_4[_a]; + for (var _a = 0, helpers_5 = helpers; _a < helpers_5.length; _a++) { + var helper = helpers_5[_a]; if (!helper.scoped) { // Skip the helper if it can be skipped and the noEmitHelpers compiler // option is set, or if it can be imported and the importHelpers compiler @@ -86786,7 +87825,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 282 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 283 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -86855,7 +87894,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 295 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 296 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -86917,7 +87956,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 159 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 160 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -87324,7 +88363,7 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 203 /* PrefixUnaryExpression */ + return operand.kind === 204 /* PrefixUnaryExpression */ && ((node.operator === 38 /* PlusToken */ && (operand.operator === 38 /* PlusToken */ || operand.operator === 44 /* PlusPlusToken */)) || (node.operator === 39 /* MinusToken */ && (operand.operator === 39 /* MinusToken */ || operand.operator === 45 /* MinusMinusToken */))); } @@ -87453,7 +88492,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); emitTokenWithComment(84 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 223 /* IfStatement */) { + if (node.elseStatement.kind === 224 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -87479,7 +88518,7 @@ var ts; writeLineOrSpace(node); } emitWhileClause(node, node.statement.end); - writePunctuation(";"); + writeTrailingSemicolon(); } function emitWhileStatement(node) { emitWhileClause(node, node.pos); @@ -87516,7 +88555,7 @@ var ts; emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(148 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(149 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -87524,7 +88563,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 240 /* VariableDeclarationList */) { emit(node); } else { @@ -87639,7 +88678,7 @@ var ts; writeKeyword("function"); emit(node.asteriskToken); writeSpace(); - emitIdentifierName(node.name); // TODO: GH#18217 + emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } function emitBlockCallback(_hint, body) { @@ -87819,7 +88858,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 245 /* ModuleDeclaration */) { + while (body.kind === 246 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -88140,7 +89179,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 309 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 311 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -88174,7 +89213,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 290 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -88193,7 +89232,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 298 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 300 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -88327,8 +89366,8 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } - for (var _d = 0, types_19 = types; _d < types_19.length; _d++) { - var directive = types_19[_d]; + for (var _d = 0, types_18 = types; _d < types_18.length; _d++) { + var directive = types_18[_d]; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) @@ -88971,7 +90010,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 197 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -89036,81 +90075,81 @@ var ts; if (!node) return; switch (node.kind) { - case 219 /* Block */: + case 220 /* Block */: ts.forEach(node.statements, generateNames); break; - case 234 /* LabeledStatement */: - case 232 /* WithStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 235 /* LabeledStatement */: + case 233 /* WithStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: generateNames(node.statement); break; - case 223 /* IfStatement */: + case 224 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 227 /* ForStatement */: + case 229 /* ForOfStatement */: + case 228 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 236 /* TryStatement */: + case 237 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 275 /* CatchClause */: + case 276 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: generateNames(node.declarationList); break; - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: + case 239 /* VariableDeclaration */: + case 153 /* Parameter */: + case 188 /* BindingElement */: + case 242 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: generateNames(node.importClause); break; - case 251 /* ImportClause */: + case 252 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 253 /* NamedImports */: + case 254 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -89119,12 +90158,12 @@ var ts; if (!node) return; switch (node.kind) { - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -89182,7 +90221,7 @@ var ts; if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (local && local.flags & (67220415 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { + if (local && local.flags & (111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { return false; } } @@ -89306,23 +90345,23 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 255 /* ExportAssignment */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 256 /* ExportAssignment */: return generateNameForExportDefault(); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return generateNameForClassExpression(); - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -89369,7 +90408,7 @@ var ts; hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 314 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 316 /* 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 */; @@ -89393,7 +90432,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 240 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -89650,7 +90689,7 @@ var ts; 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 !== 314 /* NotEmittedStatement */ + if (node.kind !== 316 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -89663,7 +90702,7 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 314 /* NotEmittedStatement */ + if (node.kind !== 316 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); @@ -90031,6 +91070,9 @@ var ts; var createFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile); var createFilePathWatcher = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher; var createDirectoryWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory); + if (watchLogLevel === WatchLogLevel.Verbose && ts.sysLog === ts.noop) { + ts.sysLog = function (s) { return log(s); }; + } return { watchFile: function (host, file, callback, pollingInterval, detailInfo1, detailInfo2) { return createFileWatcher(host, file, callback, pollingInterval, /*passThrough*/ undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo); @@ -90386,7 +91428,7 @@ var ts; } ts.changeCompilerHostLikeToUseCache = changeCompilerHostLikeToUseCache; function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { - var diagnostics = program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (ts.getEmitDeclarations(program.getCompilerOptions())) { ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } @@ -90575,8 +91617,8 @@ var ts; } var resolutions = []; var cache = ts.createMap(); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name = names_1[_i]; + for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { + var name = names_2[_i]; var result = void 0; if (cache.has(name)) { result = cache.get(name); @@ -90663,7 +91705,7 @@ var ts; } ts.isProgramUptoDate = isProgramUptoDate; function getConfigFileParsingDiagnostics(configFileParseResult) { - return configFileParseResult.options.configFile ? configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : + return configFileParseResult.options.configFile ? __spreadArrays(configFileParseResult.options.configFile.parseDiagnostics, configFileParseResult.errors) : configFileParseResult.errors; } ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; @@ -90693,7 +91735,6 @@ var ts; var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217 var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; var oldProgram = createProgramOptions.oldProgram; - var program; var processingDefaultLibFiles; var processingOtherFiles; var files; @@ -90702,6 +91743,8 @@ var ts; var noDiagnosticsTypeChecker; var classifiableNames; var ambientModuleNameToUnmodifiedFileName = ts.createMap(); + // Todo:: Use this to report why file was included in --extendedDiagnostics + var refFileMap; var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -90737,7 +91780,7 @@ var ts; var resolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference).map(function (resolved) { + resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).map(function (resolved) { // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName. if (!resolved || resolved.extension !== undefined) { return resolved; @@ -90754,7 +91797,7 @@ var ts; } var resolveTypeReferenceDirectiveNamesWorker; if (host.resolveTypeReferenceDirectives) { - resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference); }; + resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); }; } else { var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 @@ -90784,7 +91827,10 @@ var ts; var projectReferenceRedirects; var mapFromFileToProjectReferenceRedirects; var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); - var structuralIsReused = tryReuseStructureFromOldProgram(); + // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks + // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. + var structuralIsReused; + structuralIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const if (structuralIsReused !== 2 /* Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -90871,12 +91917,13 @@ var ts; } // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; - program = { + var program = { getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFileByPath: getSourceFileByPath, getSourceFiles: function () { return files; }, getMissingFilePaths: function () { return missingFilePaths; }, + getRefFileMap: function () { return refFileMap; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, getOptionsDiagnostics: getOptionsDiagnostics, @@ -91308,6 +92355,7 @@ var ts; return oldProgram.structureIsReused = 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); + refFileMap = oldProgram.getRefFileMap(); // update fileName -> file mapping for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) { var newSourceFile = newSourceFiles_1[_f]; @@ -91330,7 +92378,7 @@ var ts; return oldProgram.structureIsReused = 2 /* Completely */; } function getEmitHost(writeFileCallback) { - return __assign({ getPrependNodes: getPrependNodes, + return __assign(__assign({ getPrependNodes: getPrependNodes, getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { // Use local caches @@ -91341,7 +92389,7 @@ var ts; return false; // Before falling back to the host return host.fileExists(f); - } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); } }); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); }, redirectTargetsMap: redirectTargetsMap }); } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!options.out && !options.outFile); @@ -91397,15 +92445,15 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.has(toPath(emitFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) { var declarationDiagnostics = []; - if (!emitOnlyDtsFiles) { + if (!forceDtsEmit) { if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; } @@ -91413,7 +92461,7 @@ var ts; // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we // get any preEmit diagnostics, not just the ones if (options.noEmitOnError) { - var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (diagnostics.length === 0 && ts.getEmitDeclarations(program.getCompilerOptions())) { declarationDiagnostics = program.getDeclarationDiagnostics(/*sourceFile*/ undefined, cancellationToken); } @@ -91437,7 +92485,8 @@ var ts; // checked is to not pass the file to getEmitResolver. var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, + /*onlyBuildInfo*/ false, forceDtsEmit); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -91579,22 +92628,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 152 /* Parameter */: - case 155 /* PropertyDeclaration */: + case 153 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 238 /* VariableDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: + case 239 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -91602,41 +92651,41 @@ var ts; } } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 110 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 213 /* AsExpression */: + case 214 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -91649,28 +92698,28 @@ 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 241 /* ClassDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // falls through - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 220 /* VariableStatement */); + return checkModifiers(parent.modifiers, parent.kind === 221 /* VariableStatement */); } break; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { @@ -91682,18 +92731,19 @@ var ts; return; } break; - case 152 /* Parameter */: + case 153 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 213 /* ExpressionWithTypeArguments */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 195 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -91884,7 +92934,7 @@ var ts; } function collectDynamicImportOrRequireCalls(file) { var r = /import|require/g; - while (r.exec(file.text) !== null) { + while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null var node = getNodeAtPosition(file, r.lastIndex); if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { imports = ts.append(imports, node.arguments[0]); @@ -91965,24 +93015,18 @@ var ts; } } /** This has side effects through `findSourceFile`. */ - function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId); }, // TODO: GH#18217 + function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, // TODO: GH#18217 function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined - ? ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(args)) : ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(args))); - }, refFile); + return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args))); + }, refFile && refFile.file); } - function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile) { + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { var redirect = Object.create(redirectTarget); @@ -92005,7 +93049,7 @@ var ts; return redirect; } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId) { + function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) { var originalFileName = fileName; if (filesByName.has(path)) { var file_1 = filesByName.get(path); @@ -92022,7 +93066,7 @@ var ts; var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory); var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory); if (checkedAbsolutePath !== inputAbsolutePath) { - reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile); } } // If the file was previously found via a node_modules search, but is now being processed as a root file, @@ -92046,6 +93090,7 @@ var ts; processImportedModules(file_1); } } + addFileToRefFileMap(file_1 || undefined, refFile); return file_1 || undefined; } var redirectedPath; @@ -92067,14 +93112,7 @@ var ts; } } // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }, shouldCreateNewSourceFile); + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { return fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); }, shouldCreateNewSourceFile); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); @@ -92105,7 +93143,7 @@ var ts; // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case var existingFile = filesByNameIgnoreCase.get(pathLowerCase); if (existingFile) { - reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile); } else { filesByNameIgnoreCase.set(pathLowerCase, file); @@ -92128,8 +93166,18 @@ var ts; processingOtherFiles.push(file); } } + addFileToRefFileMap(file, refFile); return file; } + function addFileToRefFileMap(file, refFile) { + if (refFile && file) { + (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, { + kind: refFile.kind, + index: refFile.index, + file: refFile.file.path + }); + } + } function addFileToFilesByName(file, path, redirectedPath) { if (redirectedPath) { filesByName.set(redirectedPath, file); @@ -92218,9 +93266,17 @@ var ts; return projectReferenceRedirects.get(projectReferencePath) || undefined; } function processReferencedFiles(file, isDefaultLib) { - ts.forEach(file.referencedFiles, function (ref) { + ts.forEach(file.referencedFiles, function (ref, index) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); - processSourceFile(referencedFileName, isDefaultLib, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, + /*ignoreNoDefaultLib*/ false, + /*packageId*/ undefined, { + kind: ts.RefFileKind.ReferenceFile, + index: index, + file: file, + pos: ref.pos, + end: ref.end + }); }); } function processTypeReferenceDirectives(file) { @@ -92236,10 +93292,16 @@ var ts; // store resolved type directive on the file var fileName = ref.fileName.toLocaleLowerCase(); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); - processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); + processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { + kind: ts.RefFileKind.TypeReferenceDirective, + index: i, + file: file, + pos: ref.pos, + end: ref.end + }); } } - function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { + function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) { // If we already found this library as a primary reference - nothing to do var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { @@ -92251,7 +93313,7 @@ var ts; currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); // TODO: GH#18217 } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -92261,8 +93323,7 @@ var ts; if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, // TODO: GH#18217 - ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); } } // don't overwrite previous resolution result @@ -92270,14 +93331,14 @@ var ts; } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); } } if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--; } else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); @@ -92295,20 +93356,20 @@ var ts; var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts"); var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; - fileProcessingDiagnostics.add(createDiagnostic(file, libReference.pos, libReference.end, message, libName, suggestion)); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion)); } }); } - function createDiagnostic(refFile, refPos, refEnd, message) { + function createRefFileDiagnostic(refFile, message) { var args = []; - for (var _i = 4; _i < arguments.length; _i++) { - args[_i - 4] = arguments[_i]; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; } - if (refFile === undefined || refPos === undefined || refEnd === undefined) { - return ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)); + if (!refFile) { + return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)); } else { - return ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, message].concat(args)); + return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args)); } } function getCanonicalFileName(fileName) { @@ -92355,7 +93416,15 @@ var ts; else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, file, pos, file.imports[i].end, resolution.packageId); + findSourceFile(resolvedFileName, path, + /*isDefaultLib*/ false, + /*ignoreNoDefaultLib*/ false, { + kind: ts.RefFileKind.Import, + index: i, + file: file, + pos: pos, + end: file.imports[i].end + }, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -92374,12 +93443,15 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + var rootPaths; for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { var sourceFile = sourceFiles_2[_i]; if (!sourceFile.isDeclarationFile) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory)); + if (!rootPaths) + rootPaths = ts.arrayToSet(rootNames, toPath); + addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory); allFilesBelongToPath = false; } } @@ -92473,17 +93545,20 @@ var ts; else if (options.incremental && !options.outFile && !options.out && !options.configFilePath) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified)); } + if (options.noEmit && ts.isIncrementalCompilation(options)) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", options.incremental ? "incremental" : "composite"); + } verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { - var rootPaths = rootNames.map(toPath); + var rootPaths = ts.arrayToSet(rootNames, toPath); for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { var file = files_3[_i]; // Ignore file that is not emitted if (!ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) continue; - if (rootPaths.indexOf(file.path) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || "")); + if (!rootPaths.has(file.path)) { + addProgramDiagnosticAtRefPath(file, rootPaths, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || ""); } } } @@ -92665,6 +93740,39 @@ var ts; } } } + function addProgramDiagnosticAtRefPath(file, rootPaths, message) { + var _a, _b; + var args = []; + for (var _i = 3; _i < arguments.length; _i++) { + args[_i - 3] = arguments[_i]; + } + var refPaths = refFileMap && refFileMap.get(file.path); + var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) || + ts.elementAt(refPaths, 0); + if (refPathToReportErrorOn) { + var refFile = ts.Debug.assertDefined(getSourceFileByPath(refPathToReportErrorOn.file)); + var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index; + var pos = void 0, end = void 0; + switch (kind) { + case ts.RefFileKind.Import: + pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos); + end = refFile.imports[index].end; + break; + case ts.RefFileKind.ReferenceFile: + (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end); + break; + case ts.RefFileKind.TypeReferenceDirective: + (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end); + break; + default: + return ts.Debug.assertNever(kind); + } + programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args))); + } + else { + programDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); + } + } function verifyProjectReferences() { var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { @@ -92768,7 +93876,7 @@ var ts; } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { - _compilerOptionsObjectLiteralSyntax = null; // tslint:disable-line:no-null-keyword + _compilerOptionsObjectLiteralSyntax = null; // eslint-disable-line no-null/no-null var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); if (jsonObjectLiteral) { for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) { @@ -92924,9 +94032,9 @@ var ts; /*@internal*/ var ts; (function (ts) { - function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers) { + function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit); return { outputFiles: outputFiles, emitSkipped: emitResult.emitSkipped, exportedModulesFromDeclarationEmit: emitResult.exportedModulesFromDeclarationEmit }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); @@ -93172,11 +94280,19 @@ var ts; } } else { - var emitOutput = ts.getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken); - if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { - latestSignature = computeHash(emitOutput.outputFiles[0].text); + var emitOutput_1 = ts.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; + 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(firstDts_1.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { - updateExportedModules(sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache); + updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); } } else { @@ -93382,6 +94498,11 @@ var ts; /*@internal*/ var ts; (function (ts) { + var BuilderFileEmit; + (function (BuilderFileEmit) { + BuilderFileEmit[BuilderFileEmit["DtsOnly"] = 0] = "DtsOnly"; + BuilderFileEmit[BuilderFileEmit["Full"] = 1] = "Full"; + })(BuilderFileEmit = ts.BuilderFileEmit || (ts.BuilderFileEmit = {})); function hasSameKeys(map1, map2) { // Has same size and every key is present in both maps return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); @@ -93419,7 +94540,8 @@ var ts; ts.copyEntries(changedFilesSet, state.changedFilesSet); } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; + state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice(); + state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind); state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; } } @@ -93465,7 +94587,7 @@ var ts; }); if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - addToAffectedFilesPendingEmit(state, newProgram.getSourceFiles().map(function (f) { return f.path; })); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.path, 1 /* Full */); }); ts.Debug.assert(state.seenAffectedFiles === undefined); state.seenAffectedFiles = ts.createMap(); } @@ -93493,7 +94615,7 @@ var ts; } function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); } /** * Releases program and other related not needed properties @@ -93519,7 +94641,8 @@ var ts; newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState); newState.program = state.program; newState.compilerOptions = state.compilerOptions; - newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit; + newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); + newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind); newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles); newState.programEmitComplete = state.programEmitComplete; @@ -93551,7 +94674,6 @@ var ts; handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash); return affectedFile; } - seenAffectedFiles.set(affectedFile.path, true); affectedFilesIndex++; } // Remove the changed file from the change set @@ -93597,13 +94719,18 @@ var ts; var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap()); for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) { var affectedFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]); - if (affectedFile && !seenEmittedFiles.has(affectedFile.path)) { - // emit this file - state.affectedFilesPendingEmitIndex = i; - return affectedFile; + if (affectedFile) { + var seenKind = seenEmittedFiles.get(affectedFile.path); + var emitKind = ts.Debug.assertDefined(ts.Debug.assertDefined(state.affectedFilesPendingEmitKind).get(affectedFile.path)); + if (seenKind === undefined || seenKind < emitKind) { + // emit this file + state.affectedFilesPendingEmitIndex = i; + return { affectedFile: affectedFile, emitKind: emitKind }; + } } } state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; state.affectedFilesPendingEmitIndex = undefined; } return undefined; @@ -93647,7 +94774,7 @@ var ts; ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.assertDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, [path]); + addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); } } } @@ -93741,7 +94868,7 @@ var ts; * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly */ - function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit) { + function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) { if (isBuildInfoEmit) { state.emittedBuildInfo = true; } @@ -93751,6 +94878,9 @@ var ts; } else { state.seenAffectedFiles.set(affected.path, true); + if (emitKind !== undefined) { + (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, emitKind); + } if (isPendingEmit) { state.affectedFilesPendingEmitIndex++; } @@ -93762,8 +94892,15 @@ var ts; /** * Returns the result with affected file */ - function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); + function toAffectedFileResult(state, result, affected) { + doneWithAffectedFile(state, affected); + return { result: result, affected: affected }; + } + /** + * Returns the result with affected file + */ + function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } /** @@ -93888,7 +95025,7 @@ var ts; } function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? relativeToBuildInfo(file.path) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.path) : undefined }); } var BuilderProgramKind; (function (BuilderProgramKind) { @@ -93986,22 +95123,24 @@ var ts; */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var emitKind = 1 /* Full */; var isPendingEmitFile = false; if (!affected) { if (!state.compilerOptions.out && !state.compilerOptions.outFile) { - affected = getNextAffectedFilePendingEmit(state); - if (!affected) { + var pendingAffectedFile = getNextAffectedFilePendingEmit(state); + if (!pendingAffectedFile) { if (state.emittedBuildInfo) { return undefined; } var affected_1 = ts.Debug.assertDefined(state.program); - return toAffectedFileResult(state, + return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } + (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind); isPendingEmitFile = true; } else { @@ -94014,10 +95153,10 @@ var ts; affected = program; } } - return toAffectedFileResult(state, + return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers), affected, isPendingEmitFile); + ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); } /** * Emits the JavaScript and declaration files. @@ -94073,7 +95212,7 @@ var ts; } // Add file to affected file pending emit to handle for later emit time if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - addToAffectedFilesPendingEmit(state, [affected.path]); + addToAffectedFilesPendingEmit(state, affected.path, 1 /* Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -94105,7 +95244,7 @@ var ts; } // When semantic builder asks for diagnostics of the whole program, // ensure that all the affected files are handled - // tslint:disable-next-line no-empty + // eslint-disable-next-line no-empty while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) { } var diagnostics; @@ -94117,8 +95256,14 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; - function addToAffectedFilesPendingEmit(state, affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit); + function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) { + if (!state.affectedFilesPendingEmit) + state.affectedFilesPendingEmit = []; + if (!state.affectedFilesPendingEmitKind) + state.affectedFilesPendingEmitKind = ts.createMap(); + var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit); + state.affectedFilesPendingEmit.push(affectedFilePendingEmit); + state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind); // affectedFilesPendingEmitIndex === undefined // - means the emit state.affectedFilesPendingEmit was undefined before adding current affected files // so start from 0 as array would be affectedFilesPendingEmit @@ -94154,7 +95299,7 @@ var ts; compilerOptions: convertFromReusableCompilerOptions(program.options, toAbsolutePath), referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), - semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return ts.isString(value) ? value : value[0]; }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), + 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]; }), hasReusableDiagnostic: true }; return { @@ -94280,15 +95425,27 @@ var ts; // ignore "/user", "c:/users" or "c:/folderAtRoot" return false; } - if (dirPath.charCodeAt(0) !== 47 /* slash */ && - dirPath.substr(rootLength, nextDirectorySeparator).search(/users/i) === -1) { + var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + if (isNonDirectorySeparatorRoot && + dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths + pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart + nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1); + if (nextDirectorySeparator === -1) { + // ignore "//vda1cs4850/c$/folderAtRoot" + return false; + } + pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1); + } + if (isNonDirectorySeparatorRoot && + pathPartForUserCheck.search(/users\//i) !== 0) { // Paths like c:/folderAtRoot/subFolder are allowed return true; } for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) { searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1; if (searchIndex === 0) { - // Folder isnt at expected minimun levels + // Folder isnt at expected minimum levels return false; } } @@ -94453,8 +95610,8 @@ var ts; !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path : !!redirectedReference; var seenNamesInFile = ts.createMap(); - for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name = names_2[_i]; + for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { + var name = names_3[_i]; var resolution = resolutionsInFile.get(name); // Resolution is valid if it is present and not invalidated if (!seenNamesInFile.has(name) && @@ -94534,7 +95691,7 @@ var ts; if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { // Ensure failed look up is normalized path failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); - ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); // tslint:disable-line + ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); var subDirectoryInRoot = failedLookupLocationPath.indexOf(ts.directorySeparator, rootPath.length + 1); if (subDirectoryInRoot !== -1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution @@ -94930,8 +96087,9 @@ var ts; function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, - ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? + 2 /* JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, oldImportSpecifier) { @@ -94960,7 +96118,7 @@ var ts; return [ambient]; var info = getInfo(importingSourceFile.path, host); var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); - var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.fileName, info.getCanonicalFileName, host, redirectTargetsMap); + var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.originalFileName, info.getCanonicalFileName, host, redirectTargetsMap); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); var global = ts.mapDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }); return global.length ? global : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifier(moduleFileName, info, compilerOptions, preferences); }); @@ -94976,7 +96134,7 @@ var ts; var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; var ending = _b.ending, relativePreference = _b.relativePreference; var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; - var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); if (!baseUrl || relativePreference === 0 /* Relative */) { return relativePath; @@ -95051,7 +96209,7 @@ var ts; */ function getAllModulePaths(files, importingFileName, importedFileName, getCanonicalFileName, host, redirectTargetsMap) { var redirects = redirectTargetsMap.get(importedFileName); - var importedFileNames = redirects ? redirects.concat([importedFileName]) : [importedFileName]; + var importedFileNames = redirects ? __spreadArrays(redirects, [importedFileName]) : [importedFileName]; var cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); var links = discoverProbableSymlinks(files, getCanonicalFileName, cwd); @@ -95102,14 +96260,16 @@ var ts; } } } - function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) { + function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) { var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName); if (normalizedTargetPath === undefined) { return undefined; } var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName); var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath; - return ts.removeFileExtension(relativePath); + return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs + ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) + : ts.removeFileExtension(relativePath); } function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; @@ -95541,7 +96701,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); if (result) { result.version = computeHash.call(host, result.text); } @@ -95555,7 +96715,9 @@ var ts; function createProgramHost(system, createProgram) { var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); }); var host = system; - host; // tslint:disable-line no-unused-expression (TODO: `host` is unused!) + // TODO: `host` is unused! + // eslint-disable-next-line no-unused-expressions + host; return { useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; }, getNewLine: function () { return system.newLine; }, @@ -95589,7 +96751,7 @@ var ts; result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); }); }; return result; } @@ -95731,7 +96893,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - return getVersionedSourceFileByPath.apply(void 0, [fileName, toPath(fileName)].concat(args)); + return getVersionedSourceFileByPath.apply(void 0, __spreadArrays([fileName, toPath(fileName)], args)); }; compilerHost.getSourceFileByPath = getVersionedSourceFileByPath; compilerHost.getNewLine = function () { return newLine; }; @@ -95759,10 +96921,22 @@ var ts; /*logChangesWhenResolvingModule*/ false); // Resolve module using host module resolution strategy if provided otherwise use resolution cache to resolve module names compilerHost.resolveModuleNames = host.resolveModuleNames ? - (function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveModuleNames.apply(host, args); + }) : (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }); compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ? - (function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveTypeReferenceDirectives.apply(host, args); + }) : (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; builderProgram = readBuilderProgram(compilerOptions, compilerHost); @@ -95988,13 +97162,19 @@ var ts; reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); switch (reloadLevel) { case ts.ConfigFileProgramReloadLevel.Partial: - return reloadFileNamesFromConfigFile(); + ts.perfLogger.logStartUpdateProgram("PartialConfigReload"); + reloadFileNamesFromConfigFile(); + break; case ts.ConfigFileProgramReloadLevel.Full: - return reloadConfigFile(); + ts.perfLogger.logStartUpdateProgram("FullConfigReload"); + reloadConfigFile(); + break; default: + ts.perfLogger.logStartUpdateProgram("SynchronizeProgram"); synchronizeProgram(); - return; + break; } + ts.perfLogger.logStopUpdateProgram("Done"); } function reloadFileNamesFromConfigFile() { writeLog("Reloading new file names and options"); @@ -96178,6 +97358,16 @@ var ts; function isDeclarationFile(fileName) { return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */); } + /*@internal*/ + function isCircularBuildOrder(buildOrder) { + return !!buildOrder && !!buildOrder.buildOrder; + } + ts.isCircularBuildOrder = isCircularBuildOrder; + /*@internal*/ + function getBuildOrderFromAnyBuildOrder(anyBuildOrder) { + return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder; + } + ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ @@ -96339,11 +97529,14 @@ var ts; var permanentMarks = ts.createMap(); var circularityReportStack = []; var buildOrder; + var circularDiagnostics; for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { var root = roots_1[_i]; visit(root); } - return buildOrder || ts.emptyArray; + return circularDiagnostics ? + { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } : + buildOrder || ts.emptyArray; function visit(configFileName, inCircularContext) { var projPath = toResolvedConfigFilePath(state, configFileName); // Already visited @@ -96352,8 +97545,7 @@ var ts; // Circular if (temporaryMarks.has(projPath)) { if (!inCircularContext) { - // TODO:: Do we report this as error? - reportStatus(state, ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")); + (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n"))); } return; } @@ -96373,12 +97565,35 @@ var ts; } } function getBuildOrder(state) { - return state.buildOrder || - (state.buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }))); + return state.buildOrder || createStateBuildOrder(state); + } + function createStateBuildOrder(state) { + var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); })); + // Clear all to ResolvedConfigFilePaths cache to start fresh + state.resolvedConfigFilePaths.clear(); + var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); }); + var noopOnDelete = { onDeleteValue: ts.noop }; + // Config file cache + ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete); + // Remove watches for the program no longer in the solution + if (state.watch) { + ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher }); + ts.mutateMapSkippingNewValues(state.allWatchedWildcardDirectories, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcherOf); } }); + ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } }); + } + return state.buildOrder = buildOrder; } function getBuildOrderFor(state, project, onlyReferences) { var resolvedProject = project && resolveProjectName(state, project); var buildOrderFromState = getBuildOrder(state); + if (isCircularBuildOrder(buildOrderFromState)) + return buildOrderFromState; if (resolvedProject) { var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject); var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; }); @@ -96386,6 +97601,7 @@ var ts; return undefined; } var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState; + ts.Debug.assert(!isCircularBuildOrder(buildOrder)); ts.Debug.assert(!onlyReferences || resolvedProject !== undefined); ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject); return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder; @@ -96402,7 +97618,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); }), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, getSourceFileWithCache = _a.getSourceFileWithCache, readFileWithCache = _a.readFileWithCache; state.readFileWithCache = readFileWithCache; compilerHost.getSourceFile = getSourceFileWithCache; @@ -96457,7 +97673,7 @@ var ts; reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode); } enableCache(state); - var buildOrder = getBuildOrder(state); + var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state)); buildOrder.forEach(function (configFileName) { return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None); }); @@ -96629,7 +97845,7 @@ var ts; } function getSyntaxDiagnostics(cancellationToken) { ts.Debug.assertDefined(program); - handleDiagnostics(program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); + handleDiagnostics(__spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); } function getSemanticDiagnostics(cancellationToken) { handleDiagnostics(ts.Debug.assertDefined(program).getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic"); @@ -96797,6 +98013,8 @@ var ts; function getNextInvalidatedProject(state, buildOrder, reportQueue) { if (!state.projectPendingBuild.size) return undefined; + if (isCircularBuildOrder(buildOrder)) + return undefined; if (state.currentInvalidatedProject) { // Only if same buildOrder the currentInvalidated project can be sent again return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ? @@ -96853,8 +98071,11 @@ var ts; if (status.type === ts.UpToDateStatusType.UpstreamBlocked) { reportAndStoreErrors(state, projectPath, config.errors); projectPendingBuild.delete(projectPath); - if (options.verbose) - reportStatus(state, ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + if (options.verbose) { + reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built : + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + } continue; } if (status.type === ts.UpToDateStatusType.ContainerOnly) { @@ -97025,10 +98246,12 @@ var ts; continue; } // An upstream project is blocked - if (refStatus.type === ts.UpToDateStatusType.Unbuildable) { + if (refStatus.type === ts.UpToDateStatusType.Unbuildable || + refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) { return { type: ts.UpToDateStatusType.UpstreamBlocked, - upstreamProjectName: ref.path + upstreamProjectName: ref.path, + upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked }; } // If the upstream project is out of date, then so are we (someone shouldn't have asked, though?) @@ -97252,16 +98475,22 @@ var ts; disableCache(state); reportErrorSummary(state, buildOrder); startWatching(state, buildOrder); - return errorProjects ? - successfulProjects ? - ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : - ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : - ts.ExitStatus.Success; + return isCircularBuildOrder(buildOrder) ? + ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped : + errorProjects ? + successfulProjects ? + ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : + ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : + ts.ExitStatus.Success; } function clean(state, project, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; + if (isCircularBuildOrder(buildOrder)) { + reportErrors(state, buildOrder.circularDiagnostics); + return ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped; + } var options = state.options, host = state.host; var filesToDelete = options.dry ? [] : undefined; for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) { @@ -97404,8 +98633,8 @@ var ts; if (!state.watchAllProjectsPending) return; state.watchAllProjectsPending = false; - for (var _i = 0, buildOrder_2 = buildOrder; _i < buildOrder_2.length; _i++) { - var resolved = buildOrder_2[_i]; + for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) { + var resolved = _a[_i]; var resolvedPath = toResolvedConfigFilePath(state, resolved); // Watch this file watchConfigFile(state, resolved, resolvedPath); @@ -97437,6 +98666,7 @@ var ts; }, invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); }, buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); }, + getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); }, }; } function relName(state, path) { @@ -97447,7 +98677,7 @@ var ts; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } - state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args))); + state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); } function reportWatchStatus(state, message) { var args = []; @@ -97455,7 +98685,7 @@ var ts; args[_i - 2] = arguments[_i]; } if (state.hostWithWatch.onWatchStatusChange) { - state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)), state.host.getNewLine(), state.baseCompilerOptions); + state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)), state.host.getNewLine(), state.baseCompilerOptions); } } function reportErrors(_a, errors) { @@ -97473,23 +98703,33 @@ var ts; reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]); } function reportErrorSummary(state, buildOrder) { - if (!state.needsSummary || (!state.watch && !state.host.reportErrorSummary)) + if (!state.needsSummary) return; state.needsSummary = false; + var canReportSummary = state.watch || !!state.host.reportErrorSummary; var diagnostics = state.diagnostics; - // Report errors from the other projects - buildOrder.forEach(function (project) { - var projectPath = toResolvedConfigFilePath(state, project); - if (!state.projectErrorsReported.has(projectPath)) { - reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); - } - }); var totalErrors = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + if (isCircularBuildOrder(buildOrder)) { + reportBuildQueue(state, buildOrder.buildOrder); + reportErrors(state, buildOrder.circularDiagnostics); + if (canReportSummary) + totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics); + } + else { + // Report errors from the other projects + buildOrder.forEach(function (project) { + var projectPath = toResolvedConfigFilePath(state, project); + if (!state.projectErrorsReported.has(projectPath)) { + reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); + } + }); + if (canReportSummary) + diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + } if (state.watch) { reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors); } - else { + else if (state.host.reportErrorSummary) { state.host.reportErrorSummary(totalErrors); } } @@ -97522,13 +98762,16 @@ var ts; case ts.UpToDateStatusType.UpstreamOutOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.UpstreamBlocked: - return reportStatus(state, ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); + return reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built : + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.Unbuildable: return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason); case ts.UpToDateStatusType.TsVersionOutputOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relName(state, configFileName), status.version, ts.version); case ts.UpToDateStatusType.ContainerOnly: // Don't report status on "solution" projects + // falls through case ts.UpToDateStatusType.ComputingUpstream: // Should never leak from getUptoDateStatusWorker break; @@ -97838,37 +99081,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 275 /* CatchClause */: - case 268 /* JsxAttribute */: + case 153 /* Parameter */: + case 188 /* BindingElement */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 276 /* CatchClause */: + case 269 /* JsxAttribute */: return 1 /* Value */; - case 151 /* TypeParameter */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 169 /* TypeLiteral */: + case 152 /* TypeParameter */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 170 /* TypeLiteral */: return 2 /* Type */; - case 311 /* JSDocTypedefTag */: + case 313 /* 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 279 /* EnumMember */: - case 241 /* ClassDeclaration */: + case 280 /* EnumMember */: + case 242 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -97878,26 +99121,26 @@ var ts; else { return 4 /* Namespace */; } - case 244 /* EnumDeclaration */: - case 253 /* NamedImports */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 245 /* EnumDeclaration */: + case 254 /* NamedImports */: + case 255 /* ImportSpecifier */: + case 250 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: + case 256 /* ExportAssignment */: + case 257 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 285 /* SourceFile */: + case 286 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 255 /* ExportAssignment */ || node.parent.kind === 260 /* ExternalModuleReference */) { + else if (node.parent.kind === 256 /* ExportAssignment */ || node.parent.kind === 261 /* ExternalModuleReference */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -97929,11 +99172,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 149 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 249 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 150 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 250 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 150 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -97945,27 +99188,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 149 /* QualifiedName */) { - while (root.parent && root.parent.kind === 149 /* QualifiedName */) { + if (root.parent.kind === 150 /* QualifiedName */) { + while (root.parent && root.parent.kind === 150 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 165 /* TypeReference */ && !isLastClause; + return root.parent.kind === 166 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 190 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 190 /* PropertyAccessExpression */) { + if (root.parent.kind === 191 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 191 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 212 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 274 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 213 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 275 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 241 /* ClassDeclaration */ && root.parent.parent.token === 110 /* ImplementsKeyword */) || - (decl.kind === 242 /* InterfaceDeclaration */ && root.parent.parent.token === 87 /* ExtendsKeyword */); + return (decl.kind === 242 /* ClassDeclaration */ && root.parent.parent.token === 110 /* ImplementsKeyword */) || + (decl.kind === 243 /* InterfaceDeclaration */ && root.parent.parent.token === 87 /* ExtendsKeyword */); } return false; } @@ -97976,15 +99219,15 @@ var ts; switch (node.kind) { case 101 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 179 /* ThisType */: + case 180 /* ThisType */: return true; } switch (node.parent.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return true; - case 184 /* ImportType */: + case 185 /* ImportType */: return !node.parent.isTypeOf; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -98011,7 +99254,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 234 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 235 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -98043,15 +99286,15 @@ var ts; } ts.isTagName = isTagName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 150 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 191 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 245 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 246 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -98061,22 +99304,22 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 279 /* EnumMember */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 245 /* ModuleDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 277 /* PropertyAssignment */: + case 280 /* EnumMember */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 246 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return true; - case 183 /* LiteralType */: - return node.parent.parent.kind === 181 /* IndexedAccessType */; + case 184 /* LiteralType */: + return node.parent.parent.kind === 182 /* IndexedAccessType */; default: return false; } @@ -98100,17 +99343,17 @@ var ts; return undefined; } switch (node.kind) { - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 286 /* SourceFile */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 246 /* ModuleDeclaration */: return node; } } @@ -98118,48 +99361,53 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return "class" /* classElement */; - case 242 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 243 /* TypeAliasDeclaration */: - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 243 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 244 /* TypeAliasDeclaration */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 244 /* EnumDeclaration */: return "enum" /* enumElement */; - case 238 /* VariableDeclaration */: + case 245 /* EnumDeclaration */: return "enum" /* enumElement */; + case 239 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: return "function" /* functionElement */; - case 159 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 160 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 161 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 277 /* PropertyAssignment */: + var initializer = node.initializer; + return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 278 /* ShorthandPropertyAssignment */: + case 279 /* SpreadAssignment */: return "property" /* memberVariableElement */; - case 163 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 162 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 161 /* CallSignature */: return "call" /* callSignatureElement */; - case 158 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 151 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 279 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 152 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 164 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 163 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 162 /* CallSignature */: return "call" /* callSignatureElement */; + case 159 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 152 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 280 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 153 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 250 /* ImportEqualsDeclaration */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: + case 253 /* NamespaceImport */: return "alias" /* alias */; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { @@ -98207,7 +99455,7 @@ var ts; return true; case 73 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 152 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 153 /* Parameter */; default: return false; } @@ -98272,42 +99520,42 @@ var ts; return false; } switch (n.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 185 /* ObjectBindingPattern */: - case 169 /* TypeLiteral */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 247 /* CaseBlock */: - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 190 /* ObjectLiteralExpression */: + case 186 /* ObjectBindingPattern */: + case 170 /* TypeLiteral */: + case 220 /* Block */: + case 247 /* ModuleBlock */: + case 248 /* CaseBlock */: + case 254 /* NamedImports */: + case 258 /* NamedExports */: return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 193 /* NewExpression */: + case 194 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 192 /* CallExpression */: - case 196 /* ParenthesizedExpression */: - case 178 /* ParenthesizedType */: + case 193 /* CallExpression */: + case 197 /* ParenthesizedExpression */: + case 179 /* ParenthesizedType */: return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 198 /* ArrowFunction */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 163 /* ConstructSignature */: + case 162 /* CallSignature */: + case 199 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -98317,65 +99565,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 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 223 /* IfStatement */: + case 224 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 188 /* ArrayLiteralExpression */: - case 186 /* ArrayBindingPattern */: - case 191 /* ElementAccessExpression */: - case 150 /* ComputedPropertyName */: - case 171 /* TupleType */: + case 189 /* ArrayLiteralExpression */: + case 187 /* ArrayBindingPattern */: + case 192 /* ElementAccessExpression */: + case 151 /* ComputedPropertyName */: + case 172 /* TupleType */: return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 226 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 224 /* DoStatement */: + case 225 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; return hasChildOfKind(n, 108 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 200 /* TypeOfExpression */: - case 199 /* DeleteExpression */: - case 201 /* VoidExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: + case 201 /* TypeOfExpression */: + case 200 /* DeleteExpression */: + case 202 /* VoidExpression */: + case 209 /* YieldExpression */: + case 210 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -98554,7 +99802,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 285 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 286 /* 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. @@ -98624,17 +99872,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 272 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 272 /* JsxExpression */) { return true; } //
|
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 264 /* JsxClosingElement */) { + if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 265 /* JsxClosingElement */) { return true; } return false; @@ -98753,12 +100001,14 @@ var ts; nTypeArguments++; break; case 37 /* EqualsGreaterThanToken */: + // falls through case 73 /* Identifier */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 103 /* TrueKeyword */: case 88 /* FalseKeyword */: + // falls through case 105 /* TypeOfKeyword */: case 87 /* ExtendsKeyword */: case 130 /* KeyOfKeyword */: @@ -98820,10 +100070,10 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 165 /* TypeReference */ || node.kind === 192 /* CallExpression */) { + if (node.kind === 166 /* TypeReference */ || node.kind === 193 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 241 /* ClassDeclaration */ || node.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 242 /* ClassDeclaration */ || node.kind === 243 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -98868,18 +100118,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 188 /* ArrayLiteralExpression */ || - node.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 189 /* ArrayLiteralExpression */ || + node.kind === 190 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 205 /* BinaryExpression */ && + if (node.parent.kind === 206 /* BinaryExpression */ && node.parent.left === node && node.parent.operatorToken.kind === 60 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 228 /* ForOfStatement */ && + if (node.parent.kind === 229 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -98887,7 +100137,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 276 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 277 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -98983,7 +100233,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 150 /* ComputedPropertyName */ + return name.kind === 151 /* 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.getTextOfIdentifierOrLiteral(name); @@ -99148,7 +100398,7 @@ var ts; /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 152 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 153 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -99610,15 +100860,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 193 /* NewExpression */: + case 194 /* NewExpression */: return checker.getContextualType(parent); - case 205 /* BinaryExpression */: { + case 206 /* 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 272 /* CaseClause */: + case 273 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -99660,8 +100910,8 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: + case 208 /* TemplateExpression */: + case 195 /* TaggedTemplateExpression */: return true; default: return false; @@ -99701,19 +100951,19 @@ var ts; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; function syntaxUsuallyHasTrailingSemicolon(kind) { - return kind === 220 /* VariableStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 224 /* DoStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 230 /* BreakStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 155 /* PropertyDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */; + return kind === 221 /* VariableStatement */ + || kind === 223 /* ExpressionStatement */ + || kind === 225 /* DoStatement */ + || kind === 230 /* ContinueStatement */ + || kind === 231 /* BreakStatement */ + || kind === 232 /* ReturnStatement */ + || kind === 236 /* ThrowStatement */ + || kind === 238 /* DebuggerStatement */ + || kind === 156 /* PropertyDeclaration */ + || kind === 244 /* TypeAliasDeclaration */ + || kind === 251 /* ImportDeclaration */ + || kind === 250 /* ImportEqualsDeclaration */ + || kind === 257 /* ExportDeclaration */; } ts.syntaxUsuallyHasTrailingSemicolon = syntaxUsuallyHasTrailingSemicolon; function probablyUsesSemicolons(sourceFile) { @@ -99747,6 +100997,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier() { var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false); function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { @@ -100179,10 +101430,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 241 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -100375,6 +101626,11 @@ var ts; return; } } + else if (kind === 2 /* SingleLineCommentTrivia */) { + if (tryClassifyTripleSlashComment(start, width)) { + return; + } + } // Simple comment. Just add as is. pushCommentRange(start, width); } @@ -100395,18 +101651,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 306 /* JSDocParameterTag */: + case 308 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 309 /* JSDocTypeTag */: + case 311 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 307 /* JSDocReturnTag */: + case 309 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -100435,6 +101691,70 @@ var ts; } } } + function tryClassifyTripleSlashComment(start, width) { + var tripleSlashXMLCommentRegEx = /^(\/\/\/\s*)(<)(?:(\S+)((?:[^/]|\/[^>])*)(\/>)?)?/im; + var attributeRegex = /(\S+)(\s*)(=)(\s*)('[^']+'|"[^"]+")/img; + var text = sourceFile.text.substr(start, width); + var match = tripleSlashXMLCommentRegEx.exec(text); + if (!match) { + return false; + } + // Limiting classification to exactly the elements and attributes + // defined in `ts.commentPragmas` would be excessive, but we can avoid + // some obvious false positives (e.g. in XML-like doc comments) by + // checking the element name. + // eslint-disable-next-line no-in-operator + if (!match[3] || !(match[3] in ts.commentPragmas)) { + return false; + } + var pos = start; + pushCommentRange(pos, match[1].length); // /// + pos += match[1].length; + pushClassification(pos, match[2].length, 10 /* punctuation */); // < + pos += match[2].length; + pushClassification(pos, match[3].length, 21 /* jsxSelfClosingTagName */); // element name + pos += match[3].length; + var attrText = match[4]; + var attrPos = pos; + while (true) { + var attrMatch = attributeRegex.exec(attrText); + if (!attrMatch) { + break; + } + var newAttrPos = pos + attrMatch.index; + if (newAttrPos > attrPos) { + pushCommentRange(attrPos, newAttrPos - attrPos); + attrPos = newAttrPos; + } + pushClassification(attrPos, attrMatch[1].length, 22 /* jsxAttribute */); // attribute name + attrPos += attrMatch[1].length; + if (attrMatch[2].length) { + pushCommentRange(attrPos, attrMatch[2].length); // whitespace + attrPos += attrMatch[2].length; + } + pushClassification(attrPos, attrMatch[3].length, 5 /* operator */); // = + attrPos += attrMatch[3].length; + if (attrMatch[4].length) { + pushCommentRange(attrPos, attrMatch[4].length); // whitespace + attrPos += attrMatch[4].length; + } + pushClassification(attrPos, attrMatch[5].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value + attrPos += attrMatch[5].length; + } + pos += match[4].length; + if (pos > attrPos) { + pushCommentRange(attrPos, pos - attrPos); + } + if (match[5]) { + pushClassification(pos, match[5].length, 10 /* punctuation */); // /> + pos += match[5].length; + } + var end = start + width; + if (pos < end) { + pushCommentRange(pos, end - pos); + } + return true; + } function processJSDocTemplateTag(tag) { for (var _i = 0, _a = tag.getChildren(); _i < _a.length; _i++) { var child = _a[_i]; @@ -100493,22 +101813,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 263 /* JsxOpeningElement */: + case 264 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -100537,17 +101857,17 @@ var ts; var parent = token.parent; if (tokenKind === 60 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 238 /* VariableDeclaration */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 152 /* Parameter */ || - parent.kind === 268 /* JsxAttribute */) { + if (parent.kind === 239 /* VariableDeclaration */ || + parent.kind === 156 /* PropertyDeclaration */ || + parent.kind === 153 /* Parameter */ || + parent.kind === 269 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 205 /* BinaryExpression */ || - parent.kind === 203 /* PrefixUnaryExpression */ || - parent.kind === 204 /* PostfixUnaryExpression */ || - parent.kind === 206 /* ConditionalExpression */) { + if (parent.kind === 206 /* BinaryExpression */ || + parent.kind === 204 /* PrefixUnaryExpression */ || + parent.kind === 205 /* PostfixUnaryExpression */ || + parent.kind === 207 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -100561,7 +101881,7 @@ var ts; } else if (tokenKind === 10 /* StringLiteral */) { // TODO: GH#18217 - return token.parent.kind === 268 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 269 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -100577,32 +101897,32 @@ var ts; else if (tokenKind === 73 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 152 /* Parameter */: + case 153 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -100725,11 +102045,11 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { var parent = node.parent; switch (parent.kind) { - case 183 /* LiteralType */: + case 184 /* LiteralType */: switch (parent.parent.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent)), isNewIdentifier: false }; - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -100737,9 +102057,9 @@ var ts; // } // let x: Foo["/*completion position*/"] return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(parent.parent.objectType)); - case 184 /* ImportType */: + case 185 /* ImportType */: return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 174 /* UnionType */: { + case 175 /* UnionType */: { if (!ts.isTypeReferenceNode(parent.parent.parent)) return undefined; var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(parent.parent, parent); @@ -100749,7 +102069,7 @@ var ts; default: return undefined; } - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -100766,7 +102086,7 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(parent.parent)); } return fromContextualType(); - case 191 /* ElementAccessExpression */: { + case 192 /* ElementAccessExpression */: { var _a = parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { // Get all names of properties on the expression @@ -100779,8 +102099,8 @@ var ts; } return undefined; } - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* 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 @@ -100789,9 +102109,9 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 260 /* ExternalModuleReference */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: + case 261 /* 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*/"); @@ -100835,11 +102155,8 @@ var ts; if (!type) return ts.emptyArray; type = ts.skipConstraint(type); - return type.isUnion() - ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) - : type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) - ? [type] - : ts.emptyArray; + return type.isUnion() ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) : + type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; } function nameAndKind(name, kind, extension) { return { name: name, kind: kind, extension: extension }; @@ -100896,7 +102213,7 @@ var ts; return ts.containsPath(rootDirectory, scriptDirectory, basePath, ignoreCase) ? scriptDirectory.substr(rootDirectory.length) : undefined; }); // TODO: GH#18217 // Now find a path for each potential directory that is to be merged with the one containing the script - return ts.deduplicate(rootDirs.map(function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }).concat([scriptDirectory]), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); + return ts.deduplicate(__spreadArrays(rootDirs.map(function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }), [scriptDirectory]), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptDirectory, extensionOptions, compilerOptions, host, exclude) { var basePath = compilerOptions.project || host.getCurrentDirectory(); @@ -101103,7 +102420,7 @@ var ts; var name = trimPrefixAndSuffix(dir); return name === undefined ? undefined : directoryResult(name); }); - return matches.concat(directories); + return __spreadArrays(matches, directories); function trimPrefixAndSuffix(path) { var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix); return inner === undefined ? undefined : removeLeadingDirectorySeparator(inner); @@ -101304,10 +102621,12 @@ var ts; var SortText; (function (SortText) { SortText["LocationPriority"] = "0"; - SortText["SuggestedClassMembers"] = "1"; - SortText["GlobalsOrKeywords"] = "2"; - SortText["AutoImportSuggestions"] = "3"; - SortText["JavascriptIdentifiers"] = "4"; + SortText["OptionalMember"] = "1"; + SortText["MemberDeclaredBySpreadAssignment"] = "2"; + SortText["SuggestedClassMembers"] = "3"; + SortText["GlobalsOrKeywords"] = "4"; + SortText["AutoImportSuggestions"] = "5"; + SortText["JavascriptIdentifiers"] = "6"; })(SortText = Completions.SortText || (Completions.SortText = {})); var SymbolOriginInfoKind; (function (SymbolOriginInfoKind) { @@ -101315,6 +102634,7 @@ var ts; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 1] = "SymbolMemberNoExport"; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 2] = "SymbolMemberExport"; SymbolOriginInfoKind[SymbolOriginInfoKind["Export"] = 3] = "Export"; + SymbolOriginInfoKind[SymbolOriginInfoKind["Promise"] = 4] = "Promise"; })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {})); function originIsSymbolMember(origin) { return origin.kind === 2 /* SymbolMemberExport */ || origin.kind === 1 /* SymbolMemberNoExport */; @@ -101322,6 +102642,9 @@ var ts; function originIsExport(origin) { return origin.kind === 2 /* SymbolMemberExport */ || origin.kind === 3 /* Export */; } + function originIsPromise(origin) { + return origin.kind === 4 /* Promise */; + } var KeywordCompletionFilters; (function (KeywordCompletionFilters) { KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None"; @@ -101482,6 +102805,13 @@ var ts; replacementSpan = ts.createTextSpanFromNode(isJsxInitializer, sourceFile); } } + if (origin && originIsPromise(origin) && propertyAccessToConvert) { + if (insertText === undefined) + insertText = name; + var awaitText = "(await " + propertyAccessToConvert.expression.getText() + ")"; + insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : awaitText + "." + insertText; + replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); + } if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) { return undefined; } @@ -101712,11 +103042,11 @@ var ts; return ts.getContextualTypeFromParent(previousToken, checker); case 60 /* EqualsToken */: switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; @@ -101726,16 +103056,16 @@ var ts; case 75 /* CaseKeyword */: return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 18 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 261 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 262 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); - return argInfo + return argInfo ? // At `,`, treat this as the next argument after the comma. - ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) - : ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) + checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) : + ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) ? // completion at `x ===/**/` should be for the right side - ? checker.getTypeAtLocation(parent.left) - : checker.getContextualType(previousToken); + checker.getTypeAtLocation(parent.left) : + checker.getContextualType(previousToken); } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { @@ -101745,7 +103075,7 @@ 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 === 285 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 286 /* SourceFile */; }); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { var typeChecker = program.getTypeChecker(); @@ -101796,11 +103126,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 290 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 312 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 314 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -101850,7 +103180,7 @@ var ts; if (contextToken.kind === 24 /* DotToken */) { isRightOfDot = true; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; if (node.end === contextToken.pos && @@ -101862,14 +103192,14 @@ var ts; return undefined; } break; - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: node = parent.left; break; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: node = parent.name; break; - case 184 /* ImportType */: - case 215 /* MetaProperty */: + case 185 /* ImportType */: + case 216 /* MetaProperty */: node = parent; break; default: @@ -101882,7 +103212,7 @@ var ts; // // If the tagname is a property access expression, we will then walk up to the top most of property access expression. // Then, try to get a JSX container and its associated attributes type. - if (parent && parent.kind === 190 /* PropertyAccessExpression */) { + if (parent && parent.kind === 191 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } @@ -101890,38 +103220,38 @@ var ts; if (currentToken.parent === location) { switch (currentToken.kind) { case 30 /* GreaterThanToken */: - if (currentToken.parent.kind === 261 /* JsxElement */ || currentToken.parent.kind === 263 /* JsxOpeningElement */) { + if (currentToken.parent.kind === 262 /* JsxElement */ || currentToken.parent.kind === 264 /* JsxOpeningElement */) { location = currentToken; } break; case 42 /* SlashToken */: - if (currentToken.parent.kind === 262 /* JsxSelfClosingElement */) { + if (currentToken.parent.kind === 263 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: if (contextToken.kind === 42 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: - case 263 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 262 /* JsxElement */: + case 264 /* JsxOpeningElement */: if (contextToken.kind === 28 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: switch (previousToken.kind) { case 60 /* EqualsToken */: isJsxInitializer = true; @@ -101996,11 +103326,11 @@ var ts; }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 311 /* JSDocTypedefTag */: + case 308 /* JSDocParameterTag */: + case 314 /* JSDocPropertyTag */: + case 309 /* JSDocReturnTag */: + case 311 /* JSDocTypeTag */: + case 313 /* JSDocTypedefTag */: return true; default: return false; @@ -102044,8 +103374,8 @@ 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 !== 285 /* SourceFile */ && d.kind !== 245 /* ModuleDeclaration */ && d.kind !== 244 /* EnumDeclaration */; })) { - addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); + symbol.declarations.some(function (d) { return d.kind !== 286 /* SourceFile */ && d.kind !== 246 /* ModuleDeclaration */ && d.kind !== 245 /* EnumDeclaration */; })) { + addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node), !!(node.flags & 16384 /* AwaitContext */)); } return; } @@ -102057,11 +103387,12 @@ var ts; return; } if (!isTypeLocation) { - addTypeProperties(typeChecker.getTypeAtLocation(node)); + addTypeProperties(typeChecker.getTypeAtLocation(node), !!(node.flags & 16384 /* AwaitContext */)); } } - function addTypeProperties(type) { + function addTypeProperties(type, insertAwait) { isNewIdentifierLocation = !!type.getStringIndexType(); + var propertyAccess = node.kind === 185 /* 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 @@ -102073,13 +103404,24 @@ var ts; else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 184 /* ImportType */ ? node : node.parent, type, symbol)) { + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) { addPropertySymbol(symbol); } } } + if (insertAwait && preferences.includeCompletionsWithInsertText) { + var promiseType = typeChecker.getPromisedTypeOfPromise(type); + if (promiseType) { + for (var _b = 0, _c = promiseType.getApparentProperties(); _b < _c.length; _b++) { + var symbol = _c[_b]; + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, promiseType, symbol)) { + addPropertySymbol(symbol, /* insertAwait */ true); + } + } + } + } } - function addPropertySymbol(symbol) { + function addPropertySymbol(symbol, insertAwait) { // For a computed property with an accessible name like `Symbol.iterator`, // we'll add a completion for the *name* `Symbol` instead of for the property. // If this is e.g. [Symbol.iterator], add a completion for `Symbol`. @@ -102096,12 +103438,19 @@ var ts; !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) ? { kind: 1 /* SymbolMemberNoExport */ } : { kind: 2 /* SymbolMemberExport */, moduleSymbol: moduleSymbol, isDefaultExport: false }; } else if (preferences.includeCompletionsWithInsertText) { + addPromiseSymbolOriginInfo(symbol); symbols.push(symbol); } } else { + addPromiseSymbolOriginInfo(symbol); symbols.push(symbol); } + function addPromiseSymbolOriginInfo(symbol) { + if (insertAwait && preferences.includeCompletionsWithInsertText && !symbolToOriginInfoMap[ts.getSymbolId(symbol)]) { + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 4 /* Promise */ }; + } + } } /** Given 'a.b.c', returns 'a'. */ function getLeftMostName(e) { @@ -102134,6 +103483,7 @@ var ts; if (!attrsType) return 0 /* Continue */; symbols = filterJsxAttributes(getPropertiesForObjectExpression(attrsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties); + setSortTextToOptionalMember(); completionKind = 3 /* MemberLike */; isNewIdentifierLocation = false; return 1 /* Success */; @@ -102177,7 +103527,7 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; isInSnippetScope = isSnippetScope(scopeNode); var isTypeOnly = isTypeOnlyCompletion(); - var symbolMeanings = (isTypeOnly ? 0 /* None */ : 67220415 /* Value */) | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; + var symbolMeanings = (isTypeOnly ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { var symbol = symbols_2[_i]; @@ -102187,7 +103537,7 @@ var ts; } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 285 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 286 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType) { for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) { @@ -102221,10 +103571,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 285 /* SourceFile */: - case 207 /* TemplateExpression */: - case 271 /* JsxExpression */: - case 219 /* Block */: + case 286 /* SourceFile */: + case 208 /* TemplateExpression */: + case 272 /* JsxExpression */: + case 220 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -102254,7 +103604,7 @@ var ts; } } // expressions are value space (which includes the value namespaces) - return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 67220415 /* Value */); + return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */); }); } function isTypeAssertion() { @@ -102270,27 +103620,27 @@ var ts; function isContextTokenValueLocation(contextToken) { return contextToken && contextToken.kind === 105 /* TypeOfKeyword */ && - (contextToken.parent.kind === 168 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + (contextToken.parent.kind === 169 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { case 57 /* ColonToken */: - return parentKind === 155 /* PropertyDeclaration */ || - parentKind === 154 /* PropertySignature */ || - parentKind === 152 /* Parameter */ || - parentKind === 238 /* VariableDeclaration */ || + return parentKind === 156 /* PropertyDeclaration */ || + parentKind === 155 /* PropertySignature */ || + parentKind === 153 /* Parameter */ || + parentKind === 239 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); case 60 /* EqualsToken */: - return parentKind === 243 /* TypeAliasDeclaration */; + return parentKind === 244 /* TypeAliasDeclaration */; case 120 /* AsKeyword */: - return parentKind === 213 /* AsExpression */; + return parentKind === 214 /* AsExpression */; case 28 /* LessThanToken */: - return parentKind === 165 /* TypeReference */ || - parentKind === 195 /* TypeAssertionExpression */; + return parentKind === 166 /* TypeReference */ || + parentKind === 196 /* TypeAssertionExpression */; case 87 /* ExtendsKeyword */: - return parentKind === 151 /* TypeParameter */; + return parentKind === 152 /* TypeParameter */; } } return false; @@ -102299,7 +103649,7 @@ var ts; function symbolCanBeReferencedAtTypeLocation(symbol, seenModules) { if (seenModules === void 0) { seenModules = ts.createMap(); } var sym = ts.skipAlias(symbol.exportSymbol || symbol, typeChecker); - return !!(sym.flags & 67897832 /* Type */) || + 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); }); @@ -102320,7 +103670,7 @@ var ts; if (resolvedModuleSymbol !== moduleSymbol && // 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`. - ts.some(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) { + ts.every(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) { symbols.push(resolvedModuleSymbol); symbolToSortTextMap[ts.getSymbolId(resolvedModuleSymbol)] = SortText.AutoImportSuggestions; symbolToOriginInfoMap[ts.getSymbolId(resolvedModuleSymbol)] = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: false }; @@ -102399,11 +103749,11 @@ var ts; return true; } if (contextToken.kind === 30 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 263 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 264 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 264 /* JsxClosingElement */ || contextToken.parent.kind === 262 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 261 /* JsxElement */; + if (contextToken.parent.kind === 265 /* JsxClosingElement */ || contextToken.parent.kind === 263 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 262 /* JsxElement */; } } return false; @@ -102414,40 +103764,40 @@ var ts; // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(previousToken)) { case 27 /* CommaToken */: - return containingNodeKind === 192 /* CallExpression */ // func( a, | - || containingNodeKind === 158 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 193 /* NewExpression */ // new C(a, | - || containingNodeKind === 188 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 205 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 166 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 193 /* CallExpression */ // func( a, | + || containingNodeKind === 159 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 194 /* NewExpression */ // new C(a, | + || containingNodeKind === 189 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 206 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 167 /* FunctionType */; // var x: (s: string, list| case 20 /* OpenParenToken */: - return containingNodeKind === 192 /* CallExpression */ // func( | - || containingNodeKind === 158 /* Constructor */ // constructor( | - || containingNodeKind === 193 /* NewExpression */ // new C(a| - || containingNodeKind === 196 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 178 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 193 /* CallExpression */ // func( | + || containingNodeKind === 159 /* Constructor */ // constructor( | + || containingNodeKind === 194 /* NewExpression */ // new C(a| + || containingNodeKind === 197 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 179 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 22 /* OpenBracketToken */: - return containingNodeKind === 188 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 163 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 150 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + return containingNodeKind === 189 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 164 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 151 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 131 /* ModuleKeyword */: // module | case 132 /* NamespaceKeyword */: // namespace | return true; case 24 /* DotToken */: - return containingNodeKind === 245 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 246 /* ModuleDeclaration */; // module A.| case 18 /* OpenBraceToken */: - return containingNodeKind === 241 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 242 /* ClassDeclaration */; // class A{ | case 60 /* EqualsToken */: - return containingNodeKind === 238 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 205 /* BinaryExpression */; // x = a| + return containingNodeKind === 239 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 206 /* BinaryExpression */; // x = a| case 15 /* TemplateHead */: - return containingNodeKind === 207 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 208 /* TemplateExpression */; // `aa ${| case 16 /* TemplateMiddle */: - return containingNodeKind === 217 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 218 /* TemplateSpan */; // `aa ${10} dd ${| case 116 /* PublicKeyword */: case 114 /* PrivateKeyword */: case 115 /* ProtectedKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 156 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -102474,7 +103824,7 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 189 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 190 /* ObjectLiteralExpression */) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2 /* Fail */; @@ -102483,7 +103833,7 @@ var ts; existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 185 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 186 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -102494,12 +103844,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 === 228 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 152 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 229 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 153 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 157 /* MethodDeclaration */ || rootDeclaration.parent.kind === 160 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 158 /* MethodDeclaration */ || rootDeclaration.parent.kind === 161 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -102516,6 +103866,7 @@ var ts; // Add filtered items to the completion list symbols = filterObjectMembersList(typeMembers, ts.Debug.assertDefined(existingMembers)); } + setSortTextToOptionalMember(); return 1 /* Success */; } /** @@ -102541,7 +103892,7 @@ var ts; return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 253 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 254 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -102569,7 +103920,7 @@ var ts; // If you're in an interface you don't want to repeat things from super-interface. So just stop here. if (!ts.isClassLike(decl)) return 1 /* Success */; - var classElement = contextToken.parent; + var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getModifierFlags(classElement) : 0 /* None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier if (contextToken.kind === 73 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { @@ -102663,11 +104014,11 @@ var ts; case 29 /* LessThanSlashToken */: case 42 /* SlashToken */: case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 269 /* JsxAttributes */: - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 262 /* JsxSelfClosingElement */ || parent.kind === 263 /* JsxOpeningElement */)) { + case 191 /* PropertyAccessExpression */: + case 270 /* JsxAttributes */: + case 269 /* JsxAttribute */: + case 271 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 263 /* JsxSelfClosingElement */ || parent.kind === 264 /* JsxOpeningElement */)) { if (contextToken.kind === 30 /* GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); if (!parent.typeArguments || (precedingToken && precedingToken.kind === 42 /* SlashToken */)) @@ -102675,7 +104026,7 @@ var ts; } return parent; } - else if (parent.kind === 268 /* JsxAttribute */) { + else if (parent.kind === 269 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -102687,7 +104038,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 === 268 /* JsxAttribute */) || (parent.kind === 270 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 269 /* JsxAttribute */) || (parent.kind === 271 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -102697,8 +104048,8 @@ var ts; break; case 19 /* CloseBraceToken */: if (parent && - parent.kind === 271 /* JsxExpression */ && - parent.parent && parent.parent.kind === 268 /* JsxAttribute */) { + parent.kind === 272 /* JsxExpression */ && + parent.parent && parent.parent.kind === 269 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -102706,7 +104057,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 270 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 271 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -102726,49 +104077,49 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 27 /* CommaToken */: - return containingNodeKind === 238 /* VariableDeclaration */ || - containingNodeKind === 239 /* VariableDeclarationList */ || - containingNodeKind === 220 /* VariableStatement */ || - containingNodeKind === 244 /* EnumDeclaration */ || // enum a { foo, | + return containingNodeKind === 239 /* VariableDeclaration */ || + containingNodeKind === 240 /* VariableDeclarationList */ || + containingNodeKind === 221 /* VariableStatement */ || + containingNodeKind === 245 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 24 /* DotToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 187 /* ArrayBindingPattern */; // var [.| case 57 /* ColonToken */: - return containingNodeKind === 187 /* BindingElement */; // var {x :html| + return containingNodeKind === 188 /* BindingElement */; // var {x :html| case 22 /* OpenBracketToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 187 /* ArrayBindingPattern */; // var [x| case 20 /* OpenParenToken */: - return containingNodeKind === 275 /* CatchClause */ || + return containingNodeKind === 276 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 18 /* OpenBraceToken */: - return containingNodeKind === 244 /* EnumDeclaration */; // enum a { | + return containingNodeKind === 245 /* EnumDeclaration */; // enum a { | case 28 /* LessThanToken */: - return containingNodeKind === 241 /* ClassDeclaration */ || // class A< | - containingNodeKind === 210 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 243 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 242 /* ClassDeclaration */ || // class A< | + containingNodeKind === 211 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 243 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 244 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); case 117 /* StaticKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + return containingNodeKind === 156 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 25 /* DotDotDotToken */: - return containingNodeKind === 152 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 186 /* ArrayBindingPattern */); // var [...z| + return containingNodeKind === 153 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 187 /* ArrayBindingPattern */); // var [...z| case 116 /* PublicKeyword */: case 114 /* PrivateKeyword */: case 115 /* ProtectedKeyword */: - return containingNodeKind === 152 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + return containingNodeKind === 153 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); case 120 /* AsKeyword */: - return containingNodeKind === 254 /* ImportSpecifier */ || - containingNodeKind === 258 /* ExportSpecifier */ || - containingNodeKind === 252 /* NamespaceImport */; + return containingNodeKind === 255 /* ImportSpecifier */ || + containingNodeKind === 259 /* ExportSpecifier */ || + containingNodeKind === 253 /* NamespaceImport */; case 127 /* GetKeyword */: case 138 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); @@ -102829,7 +104180,7 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 158 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 159 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -102848,16 +104199,18 @@ var ts; if (existingMembers.length === 0) { return contextualMemberSymbols; } + var membersDeclaredBySpreadAssignment = ts.createMap(); var existingMemberNames = ts.createUnderscoreEscapedMap(); 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 !== 276 /* PropertyAssignment */ && - m.kind !== 277 /* ShorthandPropertyAssignment */ && - m.kind !== 187 /* BindingElement */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 277 /* PropertyAssignment */ && + m.kind !== 278 /* ShorthandPropertyAssignment */ && + m.kind !== 188 /* BindingElement */ && + m.kind !== 158 /* MethodDeclaration */ && + m.kind !== 160 /* GetAccessor */ && + m.kind !== 161 /* SetAccessor */ && + m.kind !== 279 /* SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -102865,7 +104218,10 @@ var ts; continue; } var existingName = void 0; - if (ts.isBindingElement(m) && m.propertyName) { + if (ts.isSpreadAssignment(m)) { + setMembersDeclaredBySpreadAssignment(m, membersDeclaredBySpreadAssignment); + } + else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list if (m.propertyName.kind === 73 /* Identifier */) { existingName = m.propertyName.escapedText; @@ -102880,7 +104236,40 @@ var ts; } existingMemberNames.set(existingName, true); // TODO: GH#18217 } - return contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + var filteredSymbols = contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; + } + function setMembersDeclaredBySpreadAssignment(declaration, membersDeclaredBySpreadAssignment) { + var expression = declaration.expression; + var symbol = typeChecker.getSymbolAtLocation(expression); + var type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, expression); + var properties = type && type.properties; + if (properties) { + properties.forEach(function (property) { + membersDeclaredBySpreadAssignment.set(property.name, true); + }); + } + } + // Set SortText to OptionalMember if it is an optinoal member + function setSortTextToOptionalMember() { + symbols.forEach(function (m) { + if (m.flags & 16777216 /* Optional */) { + symbolToSortTextMap[ts.getSymbolId(m)] = symbolToSortTextMap[ts.getSymbolId(m)] || SortText.OptionalMember; + } + }); + } + // Set SortText to MemberDeclaredBySpreadAssignment if it is fulfilled by spread assignment + function setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, contextualMemberSymbols) { + if (membersDeclaredBySpreadAssignment.size === 0) { + return; + } + for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) { + var contextualMemberSymbol = contextualMemberSymbols_1[_i]; + if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) { + symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = SortText.MemberDeclaredBySpreadAssignment; + } + } } /** * Filters out completion suggestions for class elements. @@ -102892,10 +104281,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 !== 155 /* PropertyDeclaration */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 156 /* PropertyDeclaration */ && + m.kind !== 158 /* MethodDeclaration */ && + m.kind !== 160 /* GetAccessor */ && + m.kind !== 161 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -102929,17 +104318,23 @@ var ts; */ function filterJsxAttributes(symbols, attributes) { var seenNames = ts.createUnderscoreEscapedMap(); + var membersDeclaredBySpreadAssignment = ts.createMap(); for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) { var attr = attributes_1[_i]; // If this is the current item we are editing right now, do not filter it out if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 268 /* JsxAttribute */) { + if (attr.kind === 269 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } + else if (ts.isJsxSpreadAttribute(attr)) { + setMembersDeclaredBySpreadAssignment(attr, membersDeclaredBySpreadAssignment); + } } - return symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + var filteredSymbols = symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; } function isCurrentlyEditingNode(node) { return node.getStart(sourceFile) <= position && position <= node.getEnd(); @@ -102979,7 +104374,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 74 /* FirstKeyword */; i <= 148 /* LastKeyword */; i++) { + for (var i = 74 /* FirstKeyword */; i <= 149 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -103113,7 +104508,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 313 /* SyntaxList */: + case 315 /* 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); @@ -103308,7 +104703,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 285 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 286 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -103340,16 +104735,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 233 /* SwitchStatement */: - if (statement.kind === 229 /* ContinueStatement */) { + case 234 /* SwitchStatement */: + if (statement.kind === 230 /* ContinueStatement */) { return false; } // falls through - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 226 /* WhileStatement */: + case 225 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -103365,35 +104760,37 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 219 /* Block */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 247 /* ModuleBlock */: + case 286 /* SourceFile */: + case 220 /* Block */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { - return declaration.members.concat([declaration]); + return __spreadArrays(declaration.members, [declaration]); } else { return container.statements; } - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + return __spreadArrays(container.parameters, (ts.isClassLike(container.parent) ? container.parent.members : [])); + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 170 /* TypeLiteral */: var nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & 28 /* AccessibilityModifier */) { + if (modifierFlag & (28 /* AccessibilityModifier */ | 64 /* Readonly */)) { var constructor = ts.find(container.members, ts.isConstructorDeclaration); if (constructor) { - return nodes.concat(constructor.parameters); + return __spreadArrays(nodes, constructor.parameters); } } else if (modifierFlag & 128 /* Abstract */) { - return nodes.concat([container]); + return __spreadArrays(nodes, [container]); } return nodes; default: @@ -103415,7 +104812,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 90 /* ForKeyword */, 108 /* WhileKeyword */, 83 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 224 /* DoStatement */) { + if (loopNode.kind === 225 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 108 /* WhileKeyword */)) { @@ -103435,13 +104832,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -103808,10 +105205,10 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 238 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 239 /* VariableDeclaration */) { var name = parent.name; if (name.kind === 73 /* Identifier */) { directImports.push(name); @@ -103824,20 +105221,20 @@ var ts; break; case 73 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 253 /* 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 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -103847,7 +105244,7 @@ var ts; directImports.push(direct); } break; - case 184 /* ImportType */: + case 185 /* ImportType */: directImports.push(direct); break; default: @@ -103864,7 +105261,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 285 /* SourceFile */ || sourceFileLike.kind === 245 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 286 /* SourceFile */ || sourceFileLike.kind === 246 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -103919,7 +105316,7 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 249 /* ImportEqualsDeclaration */) { + if (decl.kind === 250 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } @@ -103929,7 +105326,7 @@ var ts; handleNamespaceImportLike(decl); return; } - if (decl.kind === 184 /* ImportType */) { + if (decl.kind === 185 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -103944,17 +105341,17 @@ var ts; if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 256 /* ExportDeclaration */) { + if (decl.kind === 257 /* ExportDeclaration */) { searchForNamedImport(decl.exportClause); return; } var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 253 /* NamedImports */: + case 254 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -104004,7 +105401,7 @@ var ts; } } else { - var localSymbol = element.kind === 258 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 259 /* 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); @@ -104033,7 +105430,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 === 285 /* SourceFile */) { + if (searchSourceFile.kind === 286 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -104081,7 +105478,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 === 285 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 286 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -104096,15 +105493,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: { + case 257 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 249 /* ImportEqualsDeclaration */: { + case 250 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -104118,7 +105515,7 @@ var ts; /** * Given a local reference, we might notice that it's an import/export and recursively search for references of that. * If at an import, look locally for the symbol it imports. - * If an an export, look for all imports of it. + * If at an export, look for all imports of it. * This doesn't handle export specifiers; that is done in `getReferencesAtExportSpecifier`. * @param comingFromExport If we are doing a search for all exports, don't bother looking backwards for the imported symbol, since that's the reason we're here. */ @@ -104128,7 +105525,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 190 /* PropertyAccessExpression */) { + if (parent.kind === 191 /* 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) @@ -104250,10 +105647,10 @@ var ts; // If a reference is a class expression, the exported node would be its parent. // If a reference is a variable declaration, the exported node would be the variable statement. function getExportNode(parent, node) { - if (parent.kind === 238 /* VariableDeclaration */) { - var p = parent; - return p.name !== node ? undefined : - p.parent.kind === 275 /* CatchClause */ ? undefined : p.parent.parent.kind === 220 /* VariableStatement */ ? p.parent.parent : undefined; + var declaration = ts.isVariableDeclaration(parent) ? parent : ts.isBindingElement(parent) ? ts.walkUpBindingElementsAndPatterns(parent) : undefined; + if (declaration) { + return parent.name !== node ? undefined : + ts.isCatchClause(declaration.parent) ? undefined : ts.isVariableStatement(declaration.parent.parent) ? declaration.parent.parent : undefined; } else { return parent; @@ -104262,13 +105659,13 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 254 /* ImportSpecifier */: + case 255 /* 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 251 /* ImportClause */: - case 252 /* NamespaceImport */: + case 252 /* ImportClause */: + case 253 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return true; default: @@ -104301,21 +105698,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 193 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 285 /* SourceFile */) { + if (parent.kind === 286 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 246 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 247 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 246 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 260 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 261 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -104417,7 +105814,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -104425,27 +105822,27 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 187 /* BindingElement */: + case 188 /* BindingElement */: return getContextNode(node.parent.parent); - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return node.parent.parent.parent; - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 259 /* ExportSpecifier */: + case 253 /* NamespaceImport */: return node.parent.parent; - case 251 /* ImportClause */: + case 252 /* ImportClause */: return node.parent; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 228 /* ForInStatement */: return { start: node.initializer, end: node.expression }; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -104489,13 +105886,13 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* 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 === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 278 /* ShorthandPropertyAssignment */) { var result_1 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); return result_1; @@ -104580,16 +105977,16 @@ var ts; return { displayParts: displayParts, kind: symbolKind }; } function toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixText) { - return __assign({}, entryToDocumentSpan(entry), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker))); + return __assign(__assign({}, entryToDocumentSpan(entry)), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker))); } FindAllReferences.toRenameLocation = toRenameLocation; function toReferenceEntry(entry) { var documentSpan = entryToDocumentSpan(entry); if (entry.kind === 0 /* Span */) { - return __assign({}, documentSpan, { isWriteAccess: false, isDefinition: false }); + return __assign(__assign({}, documentSpan), { isWriteAccess: false, isDefinition: false }); } var kind = entry.kind, node = entry.node; - return __assign({}, documentSpan, { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 81 /* DefaultKeyword */ + return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 81 /* DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); } @@ -104633,10 +106030,10 @@ var ts; var documentSpan = entryToDocumentSpan(entry); if (entry.kind !== 0 /* Span */) { var node = entry.node; - return __assign({}, documentSpan, implementationKindDisplayParts(node, checker)); + return __assign(__assign({}, documentSpan), implementationKindDisplayParts(node, checker)); } else { - return __assign({}, documentSpan, { kind: "" /* unknown */, displayParts: [] }); + return __assign(__assign({}, documentSpan), { kind: "" /* unknown */, displayParts: [] }); } } function implementationKindDisplayParts(node, checker) { @@ -104644,13 +106041,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 190 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 210 /* ClassExpression */) { + else if (node.kind === 211 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] @@ -104705,46 +106102,46 @@ var ts; if (!!(decl.flags & 4194304 /* Ambient */)) return true; switch (decl.kind) { - case 205 /* BinaryExpression */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 206 /* BinaryExpression */: + case 188 /* BindingElement */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: case 81 /* DefaultKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 258 /* ExportSpecifier */: - case 251 /* ImportClause */: // default import - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 242 /* InterfaceDeclaration */: - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: - case 268 /* JsxAttribute */: - case 245 /* ModuleDeclaration */: - case 248 /* NamespaceExportDeclaration */: - case 252 /* NamespaceImport */: - case 152 /* Parameter */: - case 277 /* ShorthandPropertyAssignment */: - case 243 /* TypeAliasDeclaration */: - case 151 /* TypeParameter */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 259 /* ExportSpecifier */: + case 252 /* ImportClause */: // default import + case 250 /* ImportEqualsDeclaration */: + case 255 /* ImportSpecifier */: + case 243 /* InterfaceDeclaration */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 269 /* JsxAttribute */: + case 246 /* ModuleDeclaration */: + case 249 /* NamespaceExportDeclaration */: + case 253 /* NamespaceImport */: + case 153 /* Parameter */: + case 278 /* ShorthandPropertyAssignment */: + case 244 /* TypeAliasDeclaration */: + case 152 /* TypeParameter */: return true; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return !!decl.body; - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: + case 239 /* VariableDeclaration */: + case 156 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 156 /* MethodSignature */: - case 154 /* PropertySignature */: - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: + case 157 /* MethodSignature */: + case 155 /* PropertySignature */: + case 314 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -104904,10 +106301,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 285 /* SourceFile */: + case 286 /* 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 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(FindAllReferences.nodeEntry(decl.name)); } @@ -104924,21 +106321,32 @@ var ts; var sourceFile = decl.getSourceFile(); if (sourceFilesSet.has(sourceFile.fileName)) { // At `module.exports = ...`, reference node is `module` - var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) - ? decl.left.expression - : ts.isExportAssignment(decl) - ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 86 /* ExportKeyword */, sourceFile)) - : ts.getNameOfDeclaration(decl) || decl; + var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : + ts.isExportAssignment(decl) ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 86 /* ExportKeyword */, sourceFile)) : + ts.getNameOfDeclaration(decl) || decl; references.push(FindAllReferences.nodeEntry(node)); } } } return references.length ? [{ definition: { type: 0 /* Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; } + /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ + function isReadonlyTypeOperator(node) { + return node.kind === 134 /* ReadonlyKeyword */ + && ts.isTypeOperatorNode(node.parent) + && node.parent.operator === 134 /* ReadonlyKeyword */; + } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { if (ts.isTypeKeyword(node.kind)) { - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + // A modifier readonly (like on a property declaration) is not special; + // a readonly type keyword (like `readonly string[]`) is. + if (node.kind === 134 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + return undefined; + } + // Likewise, when we *are* looking for a special keyword, make sure we + // *don’t* include readonly member modifiers. + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 134 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } // Labels if (ts.isJumpStatementTarget(node)) { @@ -105237,7 +106645,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 === 197 /* FunctionExpression */ || valueDeclaration.kind === 210 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 198 /* FunctionExpression */ || valueDeclaration.kind === 211 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -105247,7 +106655,7 @@ var ts; if (flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.find(declarations, function (d) { return ts.hasModifier(d, 8 /* Private */); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 241 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 242 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -105276,7 +106684,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 286 /* 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; @@ -105297,7 +106705,7 @@ var ts; } Core.isSymbolReferencedInFile = isSymbolReferencedInFile; function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) { - var symbol = ts.isParameterPropertyDeclaration(definition.parent) + var symbol = ts.isParameterPropertyDeclaration(definition.parent, definition.parent.parent) ? ts.first(checker.getSymbolsOfParameterPropertyDeclaration(definition.parent, definition.text)) : checker.getSymbolAtLocation(definition); if (!symbol) @@ -105399,11 +106807,13 @@ var ts; return false; } } - function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { + function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken, filter) { var references = ts.flatMap(sourceFiles, function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, ts.tokenToString(keywordKind), sourceFile), function (referenceLocation) { - return referenceLocation.kind === keywordKind ? FindAllReferences.nodeEntry(referenceLocation) : undefined; + if (referenceLocation.kind === keywordKind && (!filter || filter(referenceLocation))) { + return FindAllReferences.nodeEntry(referenceLocation); + } }); }); return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; @@ -105577,7 +106987,7 @@ var ts; } } function addReference(referenceLocation, relatedSymbol, state) { - var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; + var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator var addRef = state.referenceAdder(symbol); if (state.options.implementations) { addImplementationReferences(referenceLocation, addRef, state); @@ -105640,14 +107050,14 @@ var ts; for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var ctrKeyword = ts.findChildOfKind(decl, 125 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 158 /* Constructor */ && !!ctrKeyword); + ts.Debug.assert(decl.kind === 159 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 157 /* MethodDeclaration */) { + if (decl && decl.kind === 158 /* MethodDeclaration */) { var body = decl.body; if (body) { forEachDescendantOfKind(body, 101 /* ThisKeyword */, function (thisKeyword) { @@ -105671,7 +107081,7 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 158 /* Constructor */); + ts.Debug.assert(decl.kind === 159 /* Constructor */); var body = decl.body; if (body) { forEachDescendantOfKind(body, 99 /* SuperKeyword */, function (node) { @@ -105701,7 +107111,7 @@ var ts; if (refNode.kind !== 73 /* Identifier */) { return; } - if (refNode.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 278 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -105721,7 +107131,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 219 /* Block */) { + if (body.kind === 220 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -105749,13 +107159,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 188 /* ArrayLiteralExpression */: + case 199 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 190 /* ObjectLiteralExpression */: + case 211 /* ClassExpression */: + case 189 /* ArrayLiteralExpression */: return true; default: return false; @@ -105808,13 +107218,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -105835,41 +107245,41 @@ var ts; return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 73 /* Identifier */ && node.parent.kind === 152 /* Parameter */ && node.parent.name === node; + return node.kind === 73 /* Identifier */ && node.parent.kind === 153 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 198 /* 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 === 285 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 286 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -105877,19 +107287,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 242 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 285 /* SourceFile */: - return container.kind === 285 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 286 /* SourceFile */: + return container.kind === 286 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -105966,7 +107376,7 @@ var ts; var res = fromRoot(symbol); if (res) return res; - if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) { // For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property). var paramProps = checker.getSymbolsOfParameterPropertyDeclaration(ts.cast(symbol.valueDeclaration, ts.isParameter), symbol.name); ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] @@ -106008,7 +107418,7 @@ var ts; }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 187 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 188 /* BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -106058,11 +107468,10 @@ var ts; } Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations; function isImplementation(node) { - return !!(node.flags & 4194304 /* Ambient */) - ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) - : (ts.isVariableLike(node) ? ts.hasInitializer(node) - : ts.isFunctionLikeDeclaration(node) ? !!node.body - : ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); + return !!(node.flags & 4194304 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : + (ts.isVariableLike(node) ? ts.hasInitializer(node) : + ts.isFunctionLikeDeclaration(node) ? !!node.body : + ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); } function getReferenceEntriesForShorthandPropertyAssignment(node, checker, addReference) { var refSymbol = checker.getSymbolAtLocation(node); @@ -106365,9 +107774,9 @@ var ts; return [sigInfo]; } else { - var defs = getDefinitionFromSymbol(typeChecker, symbol, node) || ts.emptyArray; + var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 99 /* SuperKeyword */ ? [sigInfo].concat(defs) : defs.concat([sigInfo]); + return node.kind === 99 /* SuperKeyword */ ? __spreadArrays([sigInfo], defs) : __spreadArrays(defs, [sigInfo]); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -106375,7 +107784,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 278 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -106535,28 +107944,32 @@ var ts; return true; } switch (declaration.kind) { - case 251 /* ImportClause */: - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportClause */: + case 250 /* ImportEqualsDeclaration */: return true; - case 254 /* ImportSpecifier */: - return declaration.parent.kind === 253 /* NamedImports */; + case 255 /* ImportSpecifier */: + return declaration.parent.kind === 254 /* NamedImports */; default: return false; } } - function getDefinitionFromSymbol(typeChecker, symbol, node) { - return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(symbol.declarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); + function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) { + // There are cases when you extend a function by adding properties to it afterwards, + // we want to strip those extra properties. + // For deduping purposes, we also want to exclude any declarationNodes if provided. + var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); }) || undefined; + return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); function getConstructSignatureDefinition() { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (symbol.flags & 32 /* Class */ && (ts.isNewExpressionTarget(node) || node.kind === 125 /* ConstructorKeyword */)) { - var cls = ts.find(symbol.declarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); + if (symbol.flags & 32 /* Class */ && !(symbol.flags & 16 /* Function */) && (ts.isNewExpressionTarget(node) || node.kind === 125 /* ConstructorKeyword */)) { + var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } } function getCallSignatureDefinition() { return ts.isCallOrNewExpressionTarget(node) || ts.isNameOfFunctionDeclaration(node) - ? getSignatureDefinition(symbol.declarations, /*selectConstructors*/ false) + ? getSignatureDefinition(filteredDeclarations, /*selectConstructors*/ false) : undefined; } function getSignatureDefinition(signatureDeclarations, selectConstructors) { @@ -106564,8 +107977,12 @@ var ts; return undefined; } var declarations = signatureDeclarations.filter(selectConstructors ? ts.isConstructorDeclaration : ts.isFunctionLike); + var declarationsWithBody = declarations.filter(function (d) { return !!d.body; }); + // declarations defined on the global scope can be defined on multiple files. Get all of them. return declarations.length - ? [createDefinitionInfo(ts.find(declarations, function (d) { return !!d.body; }) || ts.last(declarations), typeChecker, symbol, node)] + ? declarationsWithBody.length !== 0 + ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); }) + : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)] : undefined; } } @@ -106618,9 +108035,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 159 /* Constructor */: + case 168 /* ConstructorType */: + case 163 /* ConstructSignature */: return true; default: return false; @@ -106738,11 +108155,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: + case 314 /* JSDocPropertyTag */: return [declaration]; - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -106763,16 +108180,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 301 /* JSDocAugmentsTag */: + case 303 /* JSDocAugmentsTag */: return withNode(tag.class); - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 309 /* JSDocTypeTag */: + case 311 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 314 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -106959,23 +108376,23 @@ var ts; } function getCommentOwnerInfoWorker(commentOwner) { switch (commentOwner.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 156 /* MethodSignature */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 157 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer); - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 154 /* PropertySignature */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 243 /* TypeAliasDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 155 /* PropertySignature */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 244 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 220 /* VariableStatement */: { + case 221 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -106983,14 +108400,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 285 /* SourceFile */: + case 286 /* SourceFile */: return "quit"; - case 245 /* ModuleDeclaration */: + case 246 /* 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 === 245 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 205 /* BinaryExpression */: { + return commentOwner.parent.kind === 246 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 206 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; @@ -107009,14 +108426,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 196 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 197 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return rightHandSide.parameters; - case 210 /* ClassExpression */: { + case 211 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -107078,9 +108495,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 251 /* ImportClause */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportClause */: + case 255 /* ImportSpecifier */: + case 250 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -107090,7 +108507,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 150 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 151 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -107107,7 +108524,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 === 150 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 151 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -107151,6 +108568,7 @@ var ts; (function (ts) { var NavigationBar; (function (NavigationBar) { + var _a; /** * Matches all whitespace characters in a string. Eg: * @@ -107165,6 +108583,11 @@ var ts; * does not match. */ var whiteSpaceRegex = /\s+/g; + /** + * Maximum amount of characters to return + * The amount was choosen arbitrarily. + */ + var maxLength = 150; // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. var curCancellationToken; var curSourceFile; @@ -107175,13 +108598,15 @@ var ts; */ var parentsStack = []; var parent; + var trackedEs5ClassesStack = []; + var trackedEs5Classes; // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. var emptyChildItemArray = []; function getNavigationBarItems(sourceFile, cancellationToken) { curCancellationToken = cancellationToken; curSourceFile = sourceFile; try { - return ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); + return ts.map(primaryNavBarMenuItems(rootNavigationBarNode(sourceFile)), convertToPrimaryNavBarMenuItem); } finally { reset(); @@ -107207,7 +108632,7 @@ var ts; emptyChildItemArray = []; } function nodeText(node) { - return node.getText(curSourceFile); + return cleanText(node.getText(curSourceFile)); } function navigationBarNodeKind(n) { return n.node.kind; @@ -107232,28 +108657,55 @@ var ts; ts.Debug.assert(!parent && !parentsStack.length); return root; } - function addLeafNode(node) { - pushChild(parent, emptyNavigationBarNode(node)); + function addLeafNode(node, name) { + pushChild(parent, emptyNavigationBarNode(node, name)); } - function emptyNavigationBarNode(node) { + function emptyNavigationBarNode(node, name) { return { node: node, - name: ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined, + name: name || (ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined), additionalNodes: undefined, parent: parent, children: undefined, indent: parent.indent + 1 }; } + function addTrackedEs5Class(name) { + if (!trackedEs5Classes) { + trackedEs5Classes = ts.createMap(); + } + trackedEs5Classes.set(name, true); + } + function endNestedNodes(depth) { + for (var i = 0; i < depth; i++) + endNode(); + } + function startNestedNodes(targetNode, entityName) { + var names = []; + while (!ts.isIdentifier(entityName)) { + var name = entityName.name; + entityName = entityName.expression; + if (name.escapedText === "prototype") + continue; + names.push(name); + } + names.push(entityName); + for (var i = names.length - 1; i > 0; i--) { + var name = names[i]; + startNode(targetNode, name); + } + return [names.length - 1, names[0]]; + } /** * Add a new level of NavigationBarNodes. * This pushes to the stack, so you must call `endNode` when you are done adding to this node. */ - function startNode(node) { - var navNode = emptyNavigationBarNode(node); + function startNode(node, name) { + var navNode = emptyNavigationBarNode(node, name); pushChild(parent, navNode); // Save the old parent parentsStack.push(parent); + trackedEs5ClassesStack.push(trackedEs5Classes); parent = navNode; } /** Call after calling `startNode` and adding children to it. */ @@ -107263,46 +108715,48 @@ var ts; sortChildren(parent.children); } parent = parentsStack.pop(); + trackedEs5Classes = trackedEs5ClassesStack.pop(); } - function addNodeWithRecursiveChild(node, child) { - startNode(node); + function addNodeWithRecursiveChild(node, child, name) { + startNode(node, name); addChildrenRecursively(child); endNode(); } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ function addChildrenRecursively(node) { + var _a; curCancellationToken.throwIfCancellationRequested(); if (!node || ts.isToken(node)) { return; } switch (node.kind) { - case 158 /* Constructor */: + case 159 /* 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); // Parameter properties are children of the class, not the constructor. - for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { - var param = _a[_i]; - if (ts.isParameterPropertyDeclaration(param)) { + for (var _i = 0, _b = ctr.parameters; _i < _b.length; _i++) { + var param = _b[_i]; + if (ts.isParameterPropertyDeclaration(param, ctr)) { addLeafNode(param); } } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 157 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 251 /* ImportClause */: + case 252 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -107314,90 +108768,168 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 253 /* NamespaceImport */) { addLeafNode(namedBindings); } else { - for (var _b = 0, _c = namedBindings.elements; _b < _c.length; _b++) { - var element = _c[_b]; + for (var _c = 0, _d = namedBindings.elements; _c < _d.length; _c++) { + var element = _d[_c]; addLeafNode(element); } } } break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: - var _d = node, name = _d.name, initializer = _d.initializer; + case 278 /* ShorthandPropertyAssignment */: + addNodeWithRecursiveChild(node, node.name); + break; + case 279 /* 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 188 /* BindingElement */: + case 277 /* PropertyAssignment */: + case 239 /* VariableDeclaration */: + var _e = node, name = _e.name, initializer = _e.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); } else if (initializer && isFunctionOrClassExpression(initializer)) { - if (initializer.name) { - // Don't add a node for the VariableDeclaration, just for the initializer. - addChildrenRecursively(initializer); - } - else { - // Add a node for the VariableDeclaration, but not for the initializer. - startNode(node); - ts.forEachChild(initializer, addChildrenRecursively); - endNode(); - } + // Add a node for the VariableDeclaration, but not for the initializer. + startNode(node); + ts.forEachChild(initializer, addChildrenRecursively); + endNode(); } else { addNodeWithRecursiveChild(node, initializer); } break; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + var nameNode = node.name; + // If we see a function declaration track as a possible ES5 class + if (nameNode && ts.isIdentifier(nameNode)) { + addTrackedEs5Class(nameNode.text); + } + addNodeWithRecursiveChild(node, node.body); + break; + case 199 /* ArrowFunction */: + case 198 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: startNode(node); - for (var _e = 0, _f = node.members; _e < _f.length; _e++) { - var member = _f[_e]; + for (var _f = 0, _g = node.members; _f < _g.length; _f++) { + var member = _g[_f]; if (!isComputedProperty(member)) { addLeafNode(member); } } endNode(); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: startNode(node); - for (var _g = 0, _h = node.members; _g < _h.length; _g++) { - var member = _h[_g]; + for (var _h = 0, _j = node.members; _h < _j.length; _h++) { + var member = _j[_h]; addChildrenRecursively(member); } endNode(); break; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 258 /* ExportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 163 /* IndexSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 243 /* TypeAliasDeclaration */: + case 259 /* ExportSpecifier */: + case 250 /* ImportEqualsDeclaration */: + case 164 /* IndexSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 244 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 205 /* BinaryExpression */: { + case 193 /* CallExpression */: + case 206 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: case 2 /* ModuleExports */: - case 3 /* PrototypeProperty */: - case 6 /* Prototype */: addNodeWithRecursiveChild(node, node.right); return; + case 6 /* Prototype */: + case 3 /* PrototypeProperty */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var prototypeAccess = special === 3 /* PrototypeProperty */ ? + assignmentTarget.expression : + assignmentTarget; + var depth = 0; + var className = void 0; + // If we see a prototype assignment, start tracking the target as a class + // This is only done for simple classes not nested assignments. + if (ts.isIdentifier(prototypeAccess.expression)) { + addTrackedEs5Class(prototypeAccess.expression.text); + className = prototypeAccess.expression; + } + else { + _a = startNestedNodes(binaryExpression, prototypeAccess.expression), depth = _a[0], className = _a[1]; + } + if (special === 6 /* Prototype */) { + if (ts.isObjectLiteralExpression(binaryExpression.right)) { + if (binaryExpression.right.properties.length > 0) { + startNode(binaryExpression, className); + ts.forEachChild(binaryExpression.right, addChildrenRecursively); + endNode(); + } + } + } + else if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, className); + } + else { + startNode(binaryExpression, className); + addNodeWithRecursiveChild(node, binaryExpression.right, assignmentTarget.name); + endNode(); + } + endNestedNodes(depth); + return; + } + case 7 /* ObjectDefinePropertyValue */: + case 9 /* ObjectDefinePrototypeProperty */: { + var defineCall = node; + var className = special === 7 /* ObjectDefinePropertyValue */ ? + defineCall.arguments[0] : + defineCall.arguments[0].expression; + var memberName = defineCall.arguments[1]; + var _k = startNestedNodes(node, className), depth = _k[0], classNameIdentifier = _k[1]; + startNode(node, classNameIdentifier); + startNode(node, ts.setTextRange(ts.createIdentifier(memberName.text), memberName)); + addChildrenRecursively(node.arguments[2]); + endNode(); + endNode(); + endNestedNodes(depth); + return; + } + case 5 /* Property */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var targetFunction = assignmentTarget.expression; + if (ts.isIdentifier(targetFunction) && assignmentTarget.name.escapedText !== "prototype" && + trackedEs5Classes && trackedEs5Classes.has(targetFunction.text)) { + if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, targetFunction); + } + else { + startNode(binaryExpression, targetFunction); + addNodeWithRecursiveChild(binaryExpression.left, binaryExpression.right, assignmentTarget.name); + endNode(); + } + return; + } + break; + } case 4 /* ThisProperty */: - case 5 /* Property */: case 0 /* None */: - case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: break; default: ts.Debug.assertNever(special); @@ -107420,8 +108952,8 @@ var ts; /** Merge declarations of the same kind. */ function mergeChildren(children, node) { var nameToItems = ts.createMap(); - ts.filterMutate(children, function (child) { - var declName = ts.getNameOfDeclaration(child.node); + ts.filterMutate(children, function (child, index) { + var declName = child.name || ts.getNameOfDeclaration(child.node); var name = declName && nodeText(declName); if (!name) { // Anonymous items are never merged. @@ -107435,7 +108967,7 @@ var ts; if (itemsWithSameName instanceof Array) { for (var _i = 0, itemsWithSameName_1 = itemsWithSameName; _i < itemsWithSameName_1.length; _i++) { var itemWithSameName = itemsWithSameName_1[_i]; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } } @@ -107444,7 +108976,7 @@ var ts; } else { var itemWithSameName = itemsWithSameName; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } nameToItems.set(name, [itemWithSameName, child]); @@ -107452,7 +108984,100 @@ var ts; } }); } - function tryMerge(a, b, parent) { + var isEs5ClassMember = (_a = {}, + _a[5 /* Property */] = true, + _a[3 /* PrototypeProperty */] = true, + _a[7 /* ObjectDefinePropertyValue */] = true, + _a[9 /* ObjectDefinePrototypeProperty */] = true, + _a[0 /* None */] = false, + _a[1 /* ExportsProperty */] = false, + _a[2 /* ModuleExports */] = false, + _a[8 /* ObjectDefinePropertyExports */] = false, + _a[6 /* Prototype */] = true, + _a[4 /* ThisProperty */] = false, + _a); + function tryMergeEs5Class(a, b, bIndex, parent) { + function isPossibleConstructor(node) { + return ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node) || ts.isVariableDeclaration(node); + } + var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? + ts.getAssignmentDeclarationKind(b.node) : + 0 /* None */; + var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? + ts.getAssignmentDeclarationKind(a.node) : + 0 /* None */; + // We treat this as an es5 class and merge the nodes in in one of several cases + if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements + || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member + || (isPossibleConstructor(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & ctor function + || (ts.isClassDeclaration(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // class (generated) & member + || (ts.isClassDeclaration(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & class (generated) + || (ts.isClassDeclaration(a.node) && isPossibleConstructor(b.node)) // class (generated) & ctor + || (ts.isClassDeclaration(b.node) && isPossibleConstructor(a.node)) // ctor & class (generated) + ) { + var lastANode = a.additionalNodes && ts.lastOrUndefined(a.additionalNodes) || a.node; + if ((!ts.isClassDeclaration(a.node) && !ts.isClassDeclaration(b.node)) // If neither outline node is a class + || isPossibleConstructor(a.node) || isPossibleConstructor(b.node) // If either function is a constructor function + ) { + var ctorFunction = isPossibleConstructor(a.node) ? a.node : + isPossibleConstructor(b.node) ? b.node : + undefined; + if (ctorFunction !== undefined) { + var ctorNode = ts.setTextRange(ts.createConstructor(/* decorators */ undefined, /* modifiers */ undefined, [], /* body */ undefined), ctorFunction); + var ctor = emptyNavigationBarNode(ctorNode); + ctor.indent = a.indent + 1; + ctor.children = a.node === ctorFunction ? a.children : b.children; + a.children = a.node === ctorFunction ? ts.concatenate([ctor], b.children || [b]) : ts.concatenate(a.children || [a], [ctor]); + } + else { + if (a.children || b.children) { + a.children = ts.concatenate(a.children || [a], b.children || [b]); + if (a.children) { + mergeChildren(a.children, a); + sortChildren(a.children); + } + } + } + lastANode = a.node = ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), a.node); + } + else { + a.children = ts.concatenate(a.children, b.children); + if (a.children) { + mergeChildren(a.children, a); + } + } + var bNode = b.node; + // We merge if the outline node previous to b (bIndex - 1) is already part of the current class + // We do this so that statements between class members that do not generate outline nodes do not split up the class outline: + // Ex This should produce one outline node C: + // function C() {}; a = 1; C.prototype.m = function () {} + // Ex This will produce 3 outline nodes: C, a, C + // function C() {}; let a = 1; C.prototype.m = function () {} + if (parent.children[bIndex - 1].node.end === lastANode.end) { + ts.setTextRange(lastANode, { pos: lastANode.pos, end: bNode.end }); + } + else { + if (!a.additionalNodes) + a.additionalNodes = []; + a.additionalNodes.push(ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), b.node)); + } + return true; + } + return bAssignmentDeclarationKind === 0 /* None */ ? false : true; + } + function tryMerge(a, b, bIndex, parent) { + // const v = false as boolean; + if (tryMergeEs5Class(a, b, bIndex, parent)) { + return true; + } if (shouldReallyMerge(a.node, b.node, parent)) { merge(a, b); return true; @@ -107465,12 +109090,12 @@ var ts; return false; } switch (a.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -107486,7 +109111,7 @@ var ts; // 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 !== 245 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 246 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -107516,7 +109141,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 245 /* ModuleDeclaration */) { + if (node.kind === 246 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -107524,35 +109149,35 @@ var ts; return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 } switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 211 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 245 /* ModuleDeclaration */) { - return getModuleName(node); + if (node.kind === 246 /* ModuleDeclaration */) { + return cleanText(getModuleName(node)); } if (name) { - var text = nodeText(name); + var text = ts.isIdentifier(name) ? name.text : nodeText(name); if (text.length > 0) { - return text; + return cleanText(text); } } switch (node.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 199 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -107560,24 +109185,27 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 158 /* Constructor */: + case 159 /* Constructor */: return "constructor"; - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: return "new()"; - case 161 /* CallSignature */: + case 162 /* CallSignature */: return "()"; - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: return "[]"; default: return ""; } } - /** Flattens the NavNode tree to a list, keeping only the top-level items. */ - function topLevelItems(root) { - var topLevel = []; + /** Flattens the NavNode tree to a list of items to appear in the primary navbar menu. */ + function primaryNavBarMenuItems(root) { + // The primary (middle) navbar menu displays the general code navigation hierarchy, similar to the navtree. + // The secondary (right) navbar menu displays the child items of whichever primary item is selected. + // Some less interesting items without their own child navigation items (e.g. a local variable declaration) only show up in the secondary menu. + var primaryNavBarMenuItems = []; function recur(item) { - if (isTopLevel(item)) { - topLevel.push(item); + if (shouldAppearInPrimaryNavBarMenu(item)) { + primaryNavBarMenuItems.push(item); if (item.children) { for (var _i = 0, _a = item.children; _i < _a.length; _i++) { var child = _a[_i]; @@ -107587,28 +109215,28 @@ var ts; } } recur(root); - return topLevel; - function isTopLevel(item) { + return primaryNavBarMenuItems; + /** Determines if a node should appear in the primary navbar menu. */ + function shouldAppearInPrimaryNavBarMenu(item) { + // Items with children should always appear in the primary navbar menu. + if (item.children) { + return true; + } + // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 285 /* SourceFile */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 245 /* EnumDeclaration */: + case 243 /* InterfaceDeclaration */: + case 246 /* ModuleDeclaration */: + case 286 /* SourceFile */: + case 244 /* TypeAliasDeclaration */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: return true; - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 238 /* VariableDeclaration */: - return hasSomeImportantChild(item); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -107618,21 +109246,15 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: + case 247 /* ModuleBlock */: + case 286 /* SourceFile */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: return true; default: - return hasSomeImportantChild(item); + return false; } } - function hasSomeImportantChild(item) { - return ts.some(item.children, function (child) { - var childKind = navigationBarNodeKind(child); - return childKind !== 238 /* VariableDeclaration */ && childKind !== 187 /* BindingElement */; - }); - } } } function convertToTree(n) { @@ -107645,18 +109267,18 @@ var ts; childItems: ts.map(n.children, convertToTree) }; } - function convertToTopLevelItem(n) { + function convertToPrimaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), kindModifiers: getModifiers(n.node), spans: getSpans(n), - childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, + childItems: ts.map(n.children, convertToSecondaryNavBarMenuItem) || emptyChildItemArray, indent: n.indent, bolded: false, grayed: false }; - function convertToChildItem(n) { + function convertToSecondaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), @@ -107687,7 +109309,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 246 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -107701,13 +109323,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 150 /* ComputedPropertyName */; + return !member.name || member.name.kind === 151 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 285 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 286 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 238 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 239 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -107715,11 +109337,11 @@ var ts; function getFunctionOrClassName(node) { var parent = node.parent; if (node.name && ts.getFullWidth(node.name) > 0) { - return ts.declarationNameToString(node.name); + return cleanText(ts.declarationNameToString(node.name)); } // See if it is a var initializer. If so, use the var name. else if (ts.isVariableDeclaration(parent)) { - return ts.declarationNameToString(parent.name); + return cleanText(ts.declarationNameToString(parent.name)); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 60 /* EqualsToken */) { @@ -107739,7 +109361,11 @@ var ts; else if (ts.isCallExpression(parent)) { var name = getCalledExpressionName(parent.expression); if (name !== undefined) { - var args = ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", "); + name = cleanText(name); + if (name.length > maxLength) { + return name + " callback"; + } + var args = cleanText(ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", ")); return name + "(" + args + ") callback"; } } @@ -107760,14 +109386,24 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: + case 199 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 211 /* ClassExpression */: return true; default: return false; } } + function cleanText(text) { + // Truncate to maximum amount of characters as we don't want to do a big replace operation. + text = text.length > maxLength ? text.substring(0, maxLength) + "..." : text; + // Replaces ECMAScript line terminators and removes the trailing `\` from each line: + // \n - Line Feed + // \r - Carriage Return + // \u2028 - Line separator + // \u2029 - Paragraph separator + return text.replace(/\\?(\r?\n|\r|\u2028|\u2029)/g, ""); + } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); /* @internal */ @@ -108227,7 +109863,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 219 /* Block */: + case 220 /* Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -108235,16 +109871,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 224 /* DoStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 275 /* CatchClause */: + case 225 /* DoStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 227 /* ForStatement */: + case 224 /* IfStatement */: + case 226 /* WhileStatement */: + case 233 /* WithStatement */: + case 276 /* CatchClause */: return spanForNode(n.parent); - case 236 /* TryStatement */: + case 237 /* TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { @@ -108259,24 +109895,24 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return spanForNode(n.parent); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 247 /* CaseBlock */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 248 /* CaseBlock */: return spanForNode(n); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 261 /* JsxElement */: + case 262 /* JsxElement */: return spanForJSXElement(n); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return spanForJSXFragment(n); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); } function spanForJSXElement(node) { @@ -108318,7 +109954,7 @@ var ts; ? ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) : ts.findChildOfKind(body, 18 /* OpenBraceToken */, sourceFile); var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 198 /* ArrowFunction */); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 199 /* ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } @@ -109162,7 +110798,7 @@ var ts; return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 150 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 151 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -109251,7 +110887,7 @@ var ts; if (node.getStart(sourceFile) > pos) { break outer; } - if (positionShouldSnapToNode(pos, node, nextNode)) { + 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 // of things that should be considered independently. @@ -109260,7 +110896,7 @@ var ts; // // Dive in without pushing a selection range. if (ts.isBlock(node) - || ts.isTemplateSpan(node) || ts.isTemplateHead(node) + || ts.isTemplateSpan(node) || ts.isTemplateHead(node) || ts.isTemplateTail(node) || prevNode && ts.isTemplateHead(prevNode) || ts.isVariableDeclarationList(node) && ts.isVariableStatement(parentNode) || ts.isSyntaxList(node) && ts.isVariableDeclarationList(parentNode) @@ -109323,12 +110959,11 @@ var ts; * count too, unless that position belongs to the next node. In effect, makes * selections able to snap to preceding tokens when the cursor is on the tail * end of them with only whitespace ahead. + * @param sourceFile The source file containing the nodes. * @param pos The position to check. * @param node The candidate node to snap to. - * @param nextNode The next sibling node in the tree. - * @param sourceFile The source file containing the nodes. */ - function positionShouldSnapToNode(pos, node, nextNode) { + function positionShouldSnapToNode(sourceFile, pos, node) { // Can’t use 'ts.positionBelongsToNode()' here because it cleverly accounts // for missing nodes, which can’t really be considered when deciding what // to select. @@ -109337,9 +110972,8 @@ var ts; return true; } var nodeEnd = node.getEnd(); - var nextNodeStart = nextNode && nextNode.getStart(); if (nodeEnd === pos) { - return pos !== nextNodeStart; + return ts.getTouchingPropertyName(sourceFile, pos).pos < node.end; } return false; } @@ -109381,7 +111015,7 @@ var ts; var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; return kind === 22 /* OpenBracketToken */ || - kind === 151 /* TypeParameter */ || + kind === 152 /* TypeParameter */ || kind === 23 /* CloseBracketToken */; }); return [ @@ -109488,7 +111122,7 @@ var ts; } function createSyntaxList(children) { ts.Debug.assertGreaterThanOrEqual(children.length, 1); - var syntaxList = ts.createNode(313 /* SyntaxList */, children[0].pos, ts.last(children).end); + var syntaxList = ts.createNode(315 /* SyntaxList */, children[0].pos, ts.last(children).end); syntaxList._children = children; return syntaxList; } @@ -109497,14 +111131,14 @@ var ts; return kind === 18 /* OpenBraceToken */ || kind === 22 /* OpenBracketToken */ || kind === 20 /* OpenParenToken */ - || kind === 263 /* JsxOpeningElement */; + || kind === 264 /* JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; return kind === 19 /* CloseBraceToken */ || kind === 23 /* CloseBracketToken */ || kind === 21 /* CloseParenToken */ - || kind === 264 /* JsxClosingElement */; + || kind === 265 /* JsxClosingElement */; } })(SmartSelectionRange = ts.SmartSelectionRange || (ts.SmartSelectionRange = {})); })(ts || (ts = {})); @@ -109709,10 +111343,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 194 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 195 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 207 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 208 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -109779,17 +111413,17 @@ var ts; return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 197 /* ParenthesizedExpression */: + case 158 /* MethodDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* 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 205 /* BinaryExpression */: { + case 206 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; @@ -109860,11 +111494,11 @@ var ts; // not enough to put us in the substitution expression; we should consider ourselves part of // the *next* span's expression by offsetting the index (argIndex = (spanIndex + 1) + 1). // - // tslint:disable no-double-space + /* eslint-disable no-double-space */ // Example: f `# abcd $#{# 1 + 1# }# efghi ${ #"#hello"# } # ` // ^ ^ ^ ^ ^ ^ ^ ^ ^ // Case: 1 1 3 2 1 3 2 2 1 - // tslint:enable no-double-space + /* eslint-enable no-double-space */ ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); if (ts.isTemplateLiteralToken(node)) { if (ts.isInsideTemplateLiteral(node, position, sourceFile)) { @@ -109913,7 +111547,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 === 207 /* TemplateExpression */) { + if (template.kind === 208 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -109978,14 +111612,14 @@ var ts; var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); var tags = symbol.getJsDocTags(); - var prefixDisplayParts = typeSymbolDisplay.concat([ts.punctuationPart(28 /* LessThanToken */)]); + var prefixDisplayParts = __spreadArrays(typeSymbolDisplay, [ts.punctuationPart(28 /* LessThanToken */)]); return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(30 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]; function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) { var _a = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile), isVariadic = _a.isVariadic, parameters = _a.parameters, prefix = _a.prefix, suffix = _a.suffix; - var prefixDisplayParts = callTargetDisplayParts.concat(prefix); - var suffixDisplayParts = suffix.concat(returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker)); + var prefixDisplayParts = __spreadArrays(callTargetDisplayParts, prefix); + var suffixDisplayParts = __spreadArrays(suffix, returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker)); var documentation = candidateSignature.getDocumentationComment(checker); var tags = candidateSignature.getJsDocTags(); return { isVariadic: isVariadic, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; @@ -110009,10 +111643,10 @@ var ts; var parameters = (typeParameters || ts.emptyArray).map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var parameterParts = ts.mapToDisplayParts(function (writer) { var thisParameter = candidateSignature.thisParameter ? [checker.symbolToParameterDeclaration(candidateSignature.thisParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags)] : []; - var params = ts.createNodeArray(thisParameter.concat(checker.getExpandedParameters(candidateSignature).map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); + var params = ts.createNodeArray(__spreadArrays(thisParameter, checker.getExpandedParameters(candidateSignature).map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(28 /* LessThanToken */)], suffix: [ts.punctuationPart(30 /* GreaterThanToken */)].concat(parameterParts) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(28 /* LessThanToken */)], suffix: __spreadArrays([ts.punctuationPart(30 /* GreaterThanToken */)], parameterParts) }; } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { var isVariadic = checker.hasEffectiveRestParameter(candidateSignature); @@ -110024,7 +111658,7 @@ var ts; } }); var parameters = checker.getExpandedParameters(candidateSignature).map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }); - return { isVariadic: isVariadic, parameters: parameters, prefix: typeParameterParts.concat([ts.punctuationPart(20 /* OpenParenToken */)]), suffix: [ts.punctuationPart(21 /* CloseParenToken */)] }; + return { isVariadic: isVariadic, parameters: parameters, prefix: __spreadArrays(typeParameterParts, [ts.punctuationPart(20 /* OpenParenToken */)]), suffix: [ts.punctuationPart(21 /* CloseParenToken */)] }; } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { @@ -110225,7 +111859,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: var decl = ts.getDeclarationOfExpando(node); if (decl) { var symbol_1 = decl.symbol; @@ -110235,7 +111869,7 @@ var ts; } } // falls through if no diagnostic was created - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: var symbol = node.symbol; if (symbol.members && (symbol.members.size > 0)) { diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); @@ -110268,11 +111902,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 222 /* ExpressionStatement */: { + case 223 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -110289,12 +111923,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 252 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 253 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -110352,11 +111986,11 @@ var ts; // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg) { switch (arg.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); - /* falls through */ + // falls through case 97 /* NullKeyword */: case 73 /* Identifier */: // identifier includes undefined return true; @@ -110381,7 +112015,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 211 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -110469,11 +112103,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 263 /* JsxOpeningElement */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: return location.kind === 73 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -110516,7 +112150,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 190 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 191 /* 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)) { @@ -110536,7 +112170,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 193 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 99 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 194 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 99 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -110591,7 +112225,7 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 125 /* ConstructorKeyword */ && location.parent.kind === 158 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 125 /* ConstructorKeyword */ && location.parent.kind === 159 /* 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 @@ -110599,21 +112233,21 @@ var ts; return declaration === (location.kind === 125 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 158 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 159 /* 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 === 158 /* Constructor */) { + if (functionDeclaration_1.kind === 159 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 161 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 162 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -110623,7 +112257,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 211 /* 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 @@ -110667,7 +112301,7 @@ var ts; } if (symbolFlags & 1536 /* Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 245 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 246 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 73 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 132 /* NamespaceKeyword */ : 131 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -110688,7 +112322,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 151 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 152 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -110696,16 +112330,16 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 162 /* ConstructSignature */) { + if (declaration.kind === 163 /* ConstructSignature */) { displayParts.push(ts.keywordPart(96 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 161 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 162 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 243 /* TypeAliasDeclaration */) { + else if (declaration.kind === 244 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path @@ -110722,7 +112356,7 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 279 /* EnumMember */) { + if (declaration.kind === 280 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -110752,17 +112386,17 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(132 /* NamespaceKeyword */)); break; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 60 /* EqualsToken */ : 81 /* DefaultKeyword */)); break; - case 258 /* ExportSpecifier */: + case 259 /* ExportSpecifier */: displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); break; default: @@ -110771,7 +112405,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 249 /* ImportEqualsDeclaration */) { + if (declaration.kind === 250 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -110849,10 +112483,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 === 285 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 286 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 205 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 206 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -110965,16 +112599,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 197 /* FunctionExpression */) { + if (declaration.kind === 198 /* FunctionExpression */) { return true; } - if (declaration.kind !== 238 /* VariableDeclaration */ && declaration.kind !== 240 /* FunctionDeclaration */) { + if (declaration.kind !== 239 /* VariableDeclaration */ && declaration.kind !== 241 /* 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 === 285 /* SourceFile */ || parent.kind === 246 /* ModuleBlock */) { + if (parent.kind === 286 /* SourceFile */ || parent.kind === 247 /* ModuleBlock */) { return false; } } @@ -110997,32 +112631,24 @@ var ts; */ function transpileModule(input, transpileOptions) { var diagnostics = []; - var options = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : ts.getDefaultCompilerOptions(); - options.isolatedModules = true; + var options = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : {}; + // mix in default options + var defaultOptions = ts.getDefaultCompilerOptions(); + for (var key in defaultOptions) { + if (ts.hasProperty(defaultOptions, key) && options[key] === undefined) { + options[key] = defaultOptions[key]; + } + } + for (var _i = 0, transpileOptionValueCompilerOptions_1 = ts.transpileOptionValueCompilerOptions; _i < transpileOptionValueCompilerOptions_1.length; _i++) { + var option = transpileOptionValueCompilerOptions_1[_i]; + options[option.name] = option.transpileOptionValue; + } // transpileModule does not write anything to disk so there is no need to verify that there are no conflicts between input and output paths. options.suppressOutputPathCheck = true; // Filename can be non-ts file. options.allowNonTsExtensions = true; - // We are not returning a sourceFile for lib file when asked by the program, - // so pass --noLib to avoid reporting a file not found error. - options.noLib = true; - // Clear out other settings that would not be used in transpiling this module - options.lib = undefined; - options.types = undefined; - options.noEmit = undefined; - options.noEmitOnError = undefined; - options.paths = undefined; - options.rootDirs = undefined; - options.declaration = undefined; - options.composite = undefined; - options.declarationDir = undefined; - options.out = undefined; - options.outFile = undefined; - // We are not doing a full typecheck, we are not resolving the whole context, - // so pass --noResolve to avoid reporting missing file errors. - options.noResolve = true; // if jsx is specified then treat file as .tsx - var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); + var inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts"); var sourceFile = ts.createSourceFile(inputFileName, input, options.target); // TODO: GH#18217 if (transpileOptions.moduleName) { sourceFile.moduleName = transpileOptions.moduleName; @@ -111279,10 +112905,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 268 /* JsxAttribute */: - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 269 /* JsxAttribute */: + case 264 /* JsxOpeningElement */: + case 265 /* JsxClosingElement */: + case 263 /* 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 === 73 /* Identifier */; } @@ -111306,17 +112932,12 @@ var ts; ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) - ? 1 /* RescanGreaterThanToken */ - : shouldRescanSlashToken(n) - ? 2 /* RescanSlashToken */ - : shouldRescanTemplateToken(n) - ? 3 /* RescanTemplateToken */ - : shouldRescanJsxIdentifier(n) - ? 4 /* RescanJsxIdentifier */ - : shouldRescanJsxText(n) - ? 5 /* RescanJsxText */ - : 0 /* Scan */; + var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : + shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : + shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : + shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : + shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : + 0 /* Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -111459,7 +113080,7 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 148 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 149 /* LastToken */; token++) { allTokens.push(token); } function anyTokenExcept() { @@ -111470,10 +113091,10 @@ var ts; return { tokens: allTokens.filter(function (t) { return !tokens.some(function (t2) { return t2 === t; }); }), isSpecific: false }; } var anyToken = { tokens: allTokens, isSpecific: false }; - var anyTokenIncludingMultilineComments = tokenRangeFrom(allTokens.concat([3 /* MultiLineCommentTrivia */])); - var keywords = tokenRangeFromRange(74 /* FirstKeyword */, 148 /* LastKeyword */); + var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArrays(allTokens, [3 /* MultiLineCommentTrivia */])); + var keywords = tokenRangeFromRange(74 /* FirstKeyword */, 149 /* LastKeyword */); var binaryOperators = tokenRangeFromRange(28 /* FirstBinaryOperator */, 72 /* LastBinaryOperator */); - var binaryKeywordOperators = [94 /* InKeyword */, 95 /* InstanceOfKeyword */, 148 /* OfKeyword */, 120 /* AsKeyword */, 129 /* IsKeyword */]; + var binaryKeywordOperators = [94 /* InKeyword */, 95 /* InstanceOfKeyword */, 149 /* OfKeyword */, 120 /* AsKeyword */, 129 /* IsKeyword */]; var unaryPrefixOperators = [44 /* PlusPlusToken */, 45 /* MinusMinusToken */, 53 /* TildeToken */, 52 /* ExclamationToken */]; var unaryPrefixExpressions = [ 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 73 /* Identifier */, 20 /* OpenParenToken */, @@ -111484,7 +113105,7 @@ var ts; var unaryPredecrementExpressions = [73 /* Identifier */, 20 /* OpenParenToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */]; var unaryPostdecrementExpressions = [73 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 96 /* NewKeyword */]; var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = [73 /* Identifier */].concat(ts.typeKeywords); + var typeNames = __spreadArrays([73 /* Identifier */], ts.typeKeywords); // Place a space before open brace in a function declaration // TypeScript: Function can have return types, which can be made of tons of different token kinds var functionOpenBraceLeftTokenRange = anyTokenIncludingMultilineComments; @@ -111722,7 +113343,7 @@ var ts; // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. rule("SpaceAfterTryFinally", [104 /* TryKeyword */, 89 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), ]; - return highPriorityCommonRules.concat(userConfigurableRules, lowPriorityCommonRules); + return __spreadArrays(highPriorityCommonRules, userConfigurableRules, lowPriorityCommonRules); } formatting.getAllRules = getAllRules; /** @@ -111776,45 +113397,50 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 226 /* ForStatement */; + return context.contextNode.kind === 227 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 176 /* ConditionalType */: - case 213 /* AsExpression */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 164 /* TypePredicate */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 206 /* BinaryExpression */: + case 207 /* ConditionalExpression */: + case 177 /* ConditionalType */: + case 214 /* AsExpression */: + case 259 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 165 /* TypePredicate */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 187 /* BindingElement */: + case 188 /* BindingElement */: // equals in type X = ... - case 243 /* TypeAliasDeclaration */: + // falls through + case 244 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 249 /* ImportEqualsDeclaration */: - // equal in let a = 0; - case 238 /* VariableDeclaration */: - // equal in p = 0; - case 152 /* Parameter */: - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + // falls through + case 250 /* ImportEqualsDeclaration */: + // equal in let a = 0 + // falls through + case 239 /* VariableDeclaration */: + // equal in p = 0 + // falls through + case 153 /* Parameter */: + case 280 /* EnumMember */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 151 /* TypeParameter */: + // falls through + case 152 /* TypeParameter */: return context.currentTokenSpan.kind === 94 /* InKeyword */ || context.nextTokenSpan.kind === 94 /* InKeyword */ || context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 228 /* ForOfStatement */: - return context.currentTokenSpan.kind === 148 /* OfKeyword */ || context.nextTokenSpan.kind === 148 /* OfKeyword */; + case 229 /* ForOfStatement */: + return context.currentTokenSpan.kind === 149 /* OfKeyword */ || context.nextTokenSpan.kind === 149 /* OfKeyword */; } return false; } @@ -111826,22 +113452,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 155 /* PropertyDeclaration */ || - contextKind === 154 /* PropertySignature */ || - contextKind === 152 /* Parameter */ || - contextKind === 238 /* VariableDeclaration */ || + return contextKind === 156 /* PropertyDeclaration */ || + contextKind === 155 /* PropertySignature */ || + contextKind === 153 /* Parameter */ || + contextKind === 239 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 206 /* ConditionalExpression */ || - context.contextNode.kind === 176 /* ConditionalType */; + return context.contextNode.kind === 207 /* ConditionalExpression */ || + context.contextNode.kind === 177 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 185 /* ObjectBindingPattern */ || - context.contextNode.kind === 182 /* MappedType */ || + return context.contextNode.kind === 186 /* ObjectBindingPattern */ || + context.contextNode.kind === 183 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -111867,31 +113493,34 @@ var ts; return true; } switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 189 /* ObjectLiteralExpression */: - case 246 /* ModuleBlock */: + case 220 /* Block */: + case 248 /* CaseBlock */: + case 190 /* ObjectLiteralExpression */: + case 247 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + // falls through + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 161 /* CallSignature */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 198 /* ArrowFunction */: + // falls through + case 162 /* CallSignature */: + case 198 /* FunctionExpression */: + case 159 /* Constructor */: + case 199 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 242 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + // falls through + case 243 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -111900,40 +113529,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 240 /* FunctionDeclaration */ || context.contextNode.kind === 197 /* FunctionExpression */; + return context.contextNode.kind === 241 /* FunctionDeclaration */ || context.contextNode.kind === 198 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 169 /* TypeLiteral */: - case 245 /* ModuleDeclaration */: - case 256 /* ExportDeclaration */: - case 257 /* NamedExports */: - case 250 /* ImportDeclaration */: - case 253 /* NamedImports */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 170 /* TypeLiteral */: + case 246 /* ModuleDeclaration */: + case 257 /* ExportDeclaration */: + case 258 /* NamedExports */: + case 251 /* ImportDeclaration */: + case 254 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 275 /* CatchClause */: - case 246 /* ModuleBlock */: - case 233 /* SwitchStatement */: + case 242 /* ClassDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 276 /* CatchClause */: + case 247 /* ModuleBlock */: + case 234 /* SwitchStatement */: return true; - case 219 /* Block */: { + case 220 /* 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 !== 198 /* ArrowFunction */ && blockParent.kind !== 197 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 199 /* ArrowFunction */ && blockParent.kind !== 198 /* FunctionExpression */) { return true; } } @@ -111942,31 +113571,32 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 232 /* WithStatement */: + case 224 /* IfStatement */: + case 234 /* SwitchStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 226 /* WhileStatement */: + case 237 /* TryStatement */: + case 225 /* DoStatement */: + case 233 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 275 /* CatchClause */: + // falls through + case 276 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 189 /* ObjectLiteralExpression */; + return context.contextNode.kind === 190 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 192 /* CallExpression */; + return context.contextNode.kind === 193 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 193 /* NewExpression */; + return context.contextNode.kind === 194 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -111978,28 +113608,28 @@ var ts; return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 198 /* ArrowFunction */; + return context.contextNode.kind === 199 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 184 /* ImportType */; + return context.contextNode.kind === 185 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 261 /* JsxElement */ && context.contextNode.kind !== 265 /* JsxFragment */; + return context.contextNode.kind !== 262 /* JsxElement */ && context.contextNode.kind !== 266 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 271 /* JsxExpression */ || context.contextNode.kind === 270 /* JsxSpreadAttribute */; + return context.contextNode.kind === 272 /* JsxExpression */ || context.contextNode.kind === 271 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 268 /* JsxAttribute */; + return context.nextTokenParent.kind === 269 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 268 /* JsxAttribute */; + return context.contextNode.kind === 269 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 262 /* JsxSelfClosingElement */; + return context.contextNode.kind === 263 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -112014,45 +113644,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 153 /* Decorator */; + return node.kind === 154 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 239 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 240 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 245 /* ModuleDeclaration */; + return context.contextNode.kind === 246 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 169 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 170 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 162 /* ConstructSignature */; + return context.contextNode.kind === 163 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { if (token.kind !== 28 /* LessThanToken */ && token.kind !== 30 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 165 /* TypeReference */: - case 195 /* TypeAssertionExpression */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: + case 166 /* TypeReference */: + case 196 /* TypeAssertionExpression */: + case 244 /* TypeAliasDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 213 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -112063,16 +113693,16 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 195 /* TypeAssertionExpression */; + return context.contextNode.kind === 196 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 107 /* VoidKeyword */ && context.currentTokenParent.kind === 201 /* VoidExpression */; + return context.currentTokenSpan.kind === 107 /* VoidKeyword */ && context.currentTokenParent.kind === 202 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 208 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 209 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 214 /* NonNullExpression */; + return context.contextNode.kind === 215 /* NonNullExpression */; } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -112123,12 +113753,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 148 /* LastKeyword */ && column <= 148 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 149 /* LastKeyword */ && column <= 149 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 148 /* LastToken */ + 1; + var mapRowLength = 149 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; @@ -112154,11 +113784,11 @@ var ts; // In order to insert a rule to the end of sub-bucket (3), we get the index by adding // the values in the bitmap segments 3rd, 2nd, and 1st. function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) { - var position = rule.action === 1 /* Ignore */ - ? specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny - : rule.context !== formatting.anyContext - ? specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny - : specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; + var position = rule.action === 1 /* Ignore */ ? + specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny : + rule.context !== formatting.anyContext ? + specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny : + specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; var state = constructionState[rulesBucketIndex] || 0; rules.splice(getInsertionIndex(state, position), 0, rule); constructionState[rulesBucketIndex] = increaseInsertionIndex(state, position); @@ -112306,17 +113936,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 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 246 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 285 /* SourceFile */: - case 219 /* Block */: - case 246 /* ModuleBlock */: + return !!body && body.kind === 247 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 286 /* SourceFile */: + case 220 /* Block */: + case 247 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -112541,19 +114171,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 241 /* ClassDeclaration */: return 77 /* ClassKeyword */; - case 242 /* InterfaceDeclaration */: return 111 /* InterfaceKeyword */; - case 240 /* FunctionDeclaration */: return 91 /* FunctionKeyword */; - case 244 /* EnumDeclaration */: return 244 /* EnumDeclaration */; - case 159 /* GetAccessor */: return 127 /* GetKeyword */; - case 160 /* SetAccessor */: return 138 /* SetKeyword */; - case 157 /* MethodDeclaration */: + case 242 /* ClassDeclaration */: return 77 /* ClassKeyword */; + case 243 /* InterfaceDeclaration */: return 111 /* InterfaceKeyword */; + case 241 /* FunctionDeclaration */: return 91 /* FunctionKeyword */; + case 245 /* EnumDeclaration */: return 245 /* EnumDeclaration */; + case 160 /* GetAccessor */: return 127 /* GetKeyword */; + case 161 /* SetAccessor */: return 138 /* SetKeyword */; + case 158 /* MethodDeclaration */: if (node.asteriskToken) { return 40 /* AsteriskToken */; } // falls through - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 153 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -112610,15 +114240,15 @@ var ts; case 42 /* SlashToken */: case 30 /* GreaterThanToken */: switch (container.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 265 /* JsxClosingElement */: + case 263 /* JsxSelfClosingElement */: return false; } break; case 22 /* OpenBracketToken */: case 23 /* CloseBracketToken */: - if (container.kind !== 182 /* MappedType */) { + if (container.kind !== 183 /* MappedType */) { return false; } break; @@ -112710,7 +114340,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 153 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 154 /* 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 */) { @@ -112718,7 +114348,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 188 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 189 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -113101,8 +114731,7 @@ var ts; /** * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. */ - function getRangeOfEnclosingComment(sourceFile, position, precedingToken, // tslint:disable-line:no-null-keyword - tokenAtPosition) { + function getRangeOfEnclosingComment(sourceFile, position, precedingToken, tokenAtPosition) { if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position); } var jsdoc = ts.findAncestor(tokenAtPosition, ts.isJSDoc); if (jsdoc) @@ -113111,6 +114740,7 @@ var ts; if (tokenStart <= position && position < tokenAtPosition.getEnd()) { return undefined; } + // eslint-disable-next-line no-null/no-null precedingToken = precedingToken === null ? undefined : precedingToken === undefined ? ts.findPrecedingToken(position, sourceFile) : precedingToken; // Between two consecutive tokens, all comments are either trailing on the former // or leading on the latter (and none are in both lists). @@ -113136,12 +114766,12 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 198 /* ArrowFunction */: + case 159 /* Constructor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 199 /* ArrowFunction */: if (node.typeParameters === list) { return 28 /* LessThanToken */; } @@ -113149,8 +114779,8 @@ var ts; return 20 /* OpenParenToken */; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: if (node.typeArguments === list) { return 28 /* LessThanToken */; } @@ -113158,12 +114788,12 @@ var ts; return 20 /* OpenParenToken */; } break; - case 165 /* TypeReference */: + case 166 /* TypeReference */: if (node.typeArguments === list) { return 28 /* LessThanToken */; } break; - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return 18 /* OpenBraceToken */; } return 0 /* Unknown */; @@ -113261,7 +114891,8 @@ var ts; return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); - var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); // tslint:disable-line:no-null-keyword + // eslint-disable-next-line no-null/no-null + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } @@ -113280,7 +114911,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 205 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 206 /* 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 */) { @@ -113434,7 +115065,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 === 285 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 286 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -113482,7 +115113,7 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 223 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 224 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 84 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -113517,40 +115148,40 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return getList(node.typeArguments); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return getList(node.properties); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return getList(node.elements); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return getList(node.members); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 159 /* Constructor */: + case 168 /* ConstructorType */: + case 163 /* ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 312 /* JSDocTemplateTag */: return getList(node.typeParameters); - case 193 /* NewExpression */: - case 192 /* CallExpression */: + case 194 /* NewExpression */: + case 193 /* CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return getList(node.declarations); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 254 /* NamedImports */: + case 258 /* NamedExports */: return getList(node.elements); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -113573,7 +115204,7 @@ var ts; return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 239 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 240 /* VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens return -1 /* Unknown */; } @@ -113646,83 +115277,87 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 222 /* ExpressionStatement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 188 /* ArrayLiteralExpression */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 182 /* MappedType */: - case 171 /* TupleType */: - case 247 /* CaseBlock */: - case 273 /* DefaultClause */: - case 272 /* CaseClause */: - case 196 /* ParenthesizedExpression */: - case 190 /* PropertyAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 220 /* VariableStatement */: - case 255 /* ExportAssignment */: - case 231 /* ReturnStatement */: - case 206 /* ConditionalExpression */: - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: - case 262 /* JsxSelfClosingElement */: - case 271 /* JsxExpression */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 152 /* Parameter */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 178 /* ParenthesizedType */: - case 194 /* TaggedTemplateExpression */: - case 202 /* AwaitExpression */: - case 257 /* NamedExports */: - case 253 /* NamedImports */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 155 /* PropertyDeclaration */: + case 223 /* ExpressionStatement */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 189 /* ArrayLiteralExpression */: + case 220 /* Block */: + case 247 /* ModuleBlock */: + case 190 /* ObjectLiteralExpression */: + case 170 /* TypeLiteral */: + case 183 /* MappedType */: + case 172 /* TupleType */: + case 248 /* CaseBlock */: + case 274 /* DefaultClause */: + case 273 /* CaseClause */: + case 197 /* ParenthesizedExpression */: + case 191 /* PropertyAccessExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 221 /* VariableStatement */: + case 256 /* ExportAssignment */: + case 232 /* ReturnStatement */: + case 207 /* ConditionalExpression */: + case 187 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 264 /* JsxOpeningElement */: + case 267 /* JsxOpeningFragment */: + case 263 /* JsxSelfClosingElement */: + case 272 /* JsxExpression */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 153 /* Parameter */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 179 /* ParenthesizedType */: + case 195 /* TaggedTemplateExpression */: + case 203 /* AwaitExpression */: + case 258 /* NamedExports */: + case 254 /* NamedImports */: + case 259 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 156 /* PropertyDeclaration */: return true; - case 238 /* VariableDeclaration */: - case 276 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 189 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 239 /* VariableDeclaration */: + case 277 /* PropertyAssignment */: + case 206 /* BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 190 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - return true; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return childKind !== 219 /* Block */; - case 256 /* ExportDeclaration */: - return childKind !== 257 /* NamedExports */; - case 250 /* ImportDeclaration */: - return childKind !== 251 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 253 /* NamedImports */); - case 261 /* JsxElement */: - return childKind !== 264 /* JsxClosingElement */; - case 265 /* JsxFragment */: - return childKind !== 267 /* JsxClosingFragment */; - case 175 /* IntersectionType */: - case 174 /* UnionType */: - if (childKind === 169 /* TypeLiteral */) { + if (parent.kind !== 206 /* BinaryExpression */) { + return true; + } + break; + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 227 /* ForStatement */: + case 224 /* IfStatement */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 199 /* ArrowFunction */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + return childKind !== 220 /* Block */; + case 257 /* ExportDeclaration */: + return childKind !== 258 /* NamedExports */; + case 251 /* ImportDeclaration */: + return childKind !== 252 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 254 /* NamedImports */); + case 262 /* JsxElement */: + return childKind !== 265 /* JsxClosingElement */; + case 266 /* JsxFragment */: + return childKind !== 268 /* JsxClosingFragment */; + case 176 /* IntersectionType */: + case 175 /* UnionType */: + if (childKind === 170 /* TypeLiteral */) { return false; } // falls through @@ -113733,11 +115368,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: - return parent.kind !== 219 /* Block */; + case 232 /* ReturnStatement */: + case 236 /* ThrowStatement */: + case 230 /* ContinueStatement */: + case 231 /* BreakStatement */: + return parent.kind !== 220 /* Block */; default: return false; } @@ -113879,7 +115514,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 === 189 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 190 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -114044,7 +115679,7 @@ var ts; } } else { - endNode = node.kind !== 238 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 239 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; @@ -114076,7 +115711,7 @@ var ts; ChangeTracker.prototype.insertNodeAtConstructorStart = function (sourceFile, ctr, newStatement) { var firstStatement = ts.firstOrUndefined(ctr.body.statements); if (!firstStatement || !ctr.body.multiLine) { - this.replaceConstructorBody(sourceFile, ctr, [newStatement].concat(ctr.body.statements)); + this.replaceConstructorBody(sourceFile, ctr, __spreadArrays([newStatement], ctr.body.statements)); } else { this.insertNodeBefore(sourceFile, firstStatement, newStatement); @@ -114085,7 +115720,7 @@ var ts; ChangeTracker.prototype.insertNodeAtConstructorEnd = function (sourceFile, ctr, newStatement) { var lastStatement = ts.lastOrUndefined(ctr.body.statements); if (!lastStatement || !ctr.body.multiLine) { - this.replaceConstructorBody(sourceFile, ctr, ctr.body.statements.concat([newStatement])); + this.replaceConstructorBody(sourceFile, ctr, __spreadArrays(ctr.body.statements, [newStatement])); } else { this.insertNodeAfter(sourceFile, lastStatement, newStatement); @@ -114118,7 +115753,7 @@ var ts; if (getMembersOrProperties(cls).length === 0) { if (ts.addToSeen(this.classesWithNodesInsertedAtStart, ts.getNodeId(cls), { node: cls, sourceFile: sourceFile })) { // For `class C {\n}`, don't add the trailing "\n" - var shouldSuffix = ts.positionsAreOnSameLine.apply(void 0, getClassOrObjectBraceEnds(cls, sourceFile).concat([sourceFile])); // TODO: GH#4130 remove 'as any' + var shouldSuffix = ts.positionsAreOnSameLine.apply(void 0, __spreadArrays(getClassOrObjectBraceEnds(cls, sourceFile), [sourceFile])); // TODO: GH#4130 remove 'as any' return { prefix: this.newLineCharacter, suffix: comma + (shouldSuffix ? this.newLineCharacter : "") }; } else { @@ -114157,22 +115792,22 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptions = function (sourceFile, after) { var options = this.getInsertNodeAfterOptionsWorker(after); - return __assign({}, options, { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); + return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 246 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: case 10 /* StringLiteral */: case 73 /* Identifier */: return { prefix: ", " }; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; case 86 /* ExportKeyword */: return { prefix: " " }; - case 152 /* Parameter */: + case 153 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -114181,7 +115816,7 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 198 /* ArrowFunction */) { + if (node.kind === 199 /* ArrowFunction */) { var arrow = ts.findChildOfKind(node, 37 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { @@ -114195,14 +115830,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 219 /* Block */) { + if (node.body.kind !== 220 /* Block */) { // `() => 0` => `function f() { return 0; }` this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(98 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(26 /* SemicolonToken */), ts.createToken(19 /* CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 197 /* FunctionExpression */ ? 91 /* FunctionKeyword */ : 77 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 198 /* FunctionExpression */ ? 91 /* FunctionKeyword */ : 77 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -114475,7 +116110,7 @@ var ts; var omitTrailingSemicolon = !!sourceFile && !ts.probablyUsesSemicolons(sourceFile); var writer = createWriter(newLineCharacter, omitTrailingSemicolon); var newLine = newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; - ts.createPrinter({ newLine: newLine, neverAsciiEscape: true, omitTrailingSemicolon: omitTrailingSemicolon }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + ts.createPrinter({ newLine: newLine, neverAsciiEscape: true }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -114727,14 +116362,14 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 150 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 151 /* 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 152 /* Parameter */: { + case 153 /* Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && @@ -114749,14 +116384,14 @@ var ts; } break; } - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: deleteNode(changes, sourceFile, node, // For first import, leave header comment in place node === sourceFile.imports[0].parent ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined); break; - case 187 /* BindingElement */: + case 188 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 186 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 187 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -114764,13 +116399,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -114779,7 +116414,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; default: @@ -114826,13 +116461,13 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 250 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 251 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 275 /* CatchClause */) { + if (parent.kind === 276 /* 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; @@ -114843,14 +116478,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 228 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); break; - case 226 /* ForStatement */: + case 227 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: deleteNode(changes, sourceFile, gp); break; default: @@ -115011,7 +116646,7 @@ var ts; }); function makeChange(changeTracker, sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); })); + var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); }), "Expected to find an assertion expression"); var replacement = ts.isAsExpression(assertion) ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(144 /* UnknownKeyword */)) : ts.createTypeAssertion(ts.createKeywordTypeNode(144 /* UnknownKeyword */), assertion.expression); @@ -115030,7 +116665,7 @@ var ts; ts.Diagnostics.This_expression_is_not_callable.code, ts.Diagnostics.This_expression_is_not_constructable.code, ]; - var errorCodes = [ + var errorCodes = __spreadArrays([ ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type.code, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type.code, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type.code, @@ -115046,13 +116681,13 @@ var ts; ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator.code, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code, propertyAccessCode - ].concat(callableConstructableErrorCodes); + ], callableConstructableErrorCodes); codefix.registerCodeFix({ fixIds: [fixId], errorCodes: errorCodes, getCodeActions: function (context) { var sourceFile = context.sourceFile, errorCode = context.errorCode, span = context.span, cancellationToken = context.cancellationToken, program = context.program; - var expression = getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program); if (!expression) { return; } @@ -115066,27 +116701,38 @@ var ts; getAllCodeActions: function (context) { var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; var checker = context.program.getTypeChecker(); + var fixedDeclarations = ts.createMap(); return codefix.codeFixAll(context, errorCodes, function (t, diagnostic) { - var expression = getAwaitableExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); if (!expression) { return; } var trackChanges = function (cb) { return (cb(t), []); }; - return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges) - || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges); + return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations) + || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations); }); }, }); - function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges) { - var sourceFile = context.sourceFile; - var awaitableInitializer = findAwaitableInitializer(expression, sourceFile, checker); - if (awaitableInitializer) { - var initializerChanges = trackChanges(function (t) { return makeChange(t, errorCode, sourceFile, checker, awaitableInitializer); }); - return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, [ts.Diagnostics.Add_await_to_initializer_for_0, expression.getText(sourceFile)]); + function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; + var awaitableInitializers = findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker); + if (awaitableInitializers) { + var initializerChanges = trackChanges(function (t) { + ts.forEach(awaitableInitializers.initializers, function (_a) { + var expression = _a.expression; + return makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + }); + if (fixedDeclarations && awaitableInitializers.needsSecondPassForFixAll) { + makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + } + }); + return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, awaitableInitializers.initializers.length === 1 + ? [ts.Diagnostics.Add_await_to_initializer_for_0, awaitableInitializers.initializers[0].declarationSymbol.name] + : ts.Diagnostics.Add_await_to_initializers); } } - function getUseSiteFix(context, expression, errorCode, checker, trackChanges) { - var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression); }); + function getUseSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression, fixedDeclarations); }); return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_await, fixId, ts.Diagnostics.Fix_all_expressions_possibly_missing_await); } function isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) { @@ -115100,7 +116746,7 @@ var ts; ts.some(relatedInformation, function (related) { return related.code === ts.Diagnostics.Did_you_forget_to_use_await.code; }); }); } - function getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program) { + function getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program) { var token = ts.getTokenAtPosition(sourceFile, span.start); // Checker has already done work to determine that await might be possible, and has attached // related info to the node, so start by finding the expression that exactly matches up @@ -115113,64 +116759,146 @@ var ts; }); return expression && isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) - && isInsideAwaitableBody(expression) - ? expression - : undefined; + && isInsideAwaitableBody(expression) ? expression : undefined; } - function findAwaitableInitializer(expression, sourceFile, checker) { - if (!ts.isIdentifier(expression)) { + function findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker) { + var identifiers = getIdentifiersFromErrorSpanExpression(expression, checker); + if (!identifiers) { return; } - var symbol = checker.getSymbolAtLocation(expression); - if (!symbol) { - return; + var isCompleteFix = identifiers.isCompleteFix; + var initializers; + var _loop_11 = 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, 221 /* VariableStatement */); + if (!declaration || !variableStatement || + declaration.type || + !declaration.initializer || + variableStatement.getSourceFile() !== sourceFile || + ts.hasModifier(variableStatement, 1 /* Export */) || + !variableName || + !isInsideAwaitableBody(declaration.initializer)) { + isCompleteFix = false; + return "continue"; + } + var diagnostics = program.getSemanticDiagnostics(sourceFile, cancellationToken); + var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (reference) { + return identifier !== reference && !symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker); + }); + if (isUsedElsewhere) { + isCompleteFix = false; + return "continue"; + } + (initializers || (initializers = [])).push({ + expression: declaration.initializer, + declarationSymbol: symbol, + }); + }; + for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { + var identifier = _a[_i]; + _loop_11(identifier); } - var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); - var variableName = ts.tryCast(declaration && declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 220 /* VariableStatement */); - if (!declaration || !variableStatement || - declaration.type || - !declaration.initializer || - variableStatement.getSourceFile() !== sourceFile || - ts.hasModifier(variableStatement, 1 /* Export */) || - !variableName || - !isInsideAwaitableBody(declaration.initializer)) { - return; + return initializers && { + initializers: initializers, + needsSecondPassForFixAll: !isCompleteFix, + }; + } + function getIdentifiersFromErrorSpanExpression(expression, checker) { + if (ts.isPropertyAccessExpression(expression.parent) && ts.isIdentifier(expression.parent.expression)) { + return { identifiers: [expression.parent.expression], isCompleteFix: true }; } - var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (identifier) { - return identifier !== expression; - }); - if (isUsedElsewhere) { - return; + if (ts.isIdentifier(expression)) { + return { identifiers: [expression], isCompleteFix: true }; + } + if (ts.isBinaryExpression(expression)) { + var sides = void 0; + var isCompleteFix = true; + for (var _i = 0, _a = [expression.left, expression.right]; _i < _a.length; _i++) { + var side = _a[_i]; + var type = checker.getTypeAtLocation(side); + if (checker.getPromisedTypeOfPromise(type)) { + if (!ts.isIdentifier(side)) { + isCompleteFix = false; + continue; + } + (sides || (sides = [])).push(side); + } + } + return sides && { identifiers: sides, isCompleteFix: isCompleteFix }; } - return declaration.initializer; + } + function symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker) { + var errorNode = ts.isPropertyAccessExpression(reference.parent) ? reference.parent.name : + ts.isBinaryExpression(reference.parent) ? reference.parent : + reference; + var diagnostic = ts.find(diagnostics, function (diagnostic) { + return diagnostic.start === errorNode.getStart(sourceFile) && + diagnostic.start + diagnostic.length === errorNode.getEnd(); + }); + return diagnostic && ts.contains(errorCodes, diagnostic.code) || + // A Promise is usually not correct in a binary expression (it’s not valid + // in an arithmetic expression and an equality comparison seems unusual), + // but if the other side of the binary expression has an error, the side + // is typed `any` which will squash the error that would identify this + // Promise as an invalid operand. So if the whole binary expression is + // typed `any` as a result, there is a strong likelihood that this Promise + // is accidentally missing `await`. + checker.getTypeAtLocation(errorNode).flags & 1 /* Any */; } function isInsideAwaitableBody(node) { return node.kind & 16384 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 240 /* FunctionDeclaration */ || - ancestor.parent.kind === 197 /* FunctionExpression */ || - ancestor.parent.kind === 198 /* ArrowFunction */ || - ancestor.parent.kind === 157 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 241 /* FunctionDeclaration */ || + ancestor.parent.kind === 198 /* FunctionExpression */ || + ancestor.parent.kind === 199 /* ArrowFunction */ || + ancestor.parent.kind === 158 /* MethodDeclaration */); }); } - function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite) { + function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { if (ts.isBinaryExpression(insertionSite)) { - var left = insertionSite.left, right = insertionSite.right; - var leftType = checker.getTypeAtLocation(left); - var rightType = checker.getTypeAtLocation(right); - var newLeft = checker.getPromisedTypeOfPromise(leftType) ? ts.createAwait(left) : left; - var newRight = checker.getPromisedTypeOfPromise(rightType) ? ts.createAwait(right) : right; - changeTracker.replaceNode(sourceFile, left, newLeft); - changeTracker.replaceNode(sourceFile, right, newRight); + for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) { + var side = _a[_i]; + if (fixedDeclarations && ts.isIdentifier(side)) { + var symbol = checker.getSymbolAtLocation(side); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + continue; + } + } + var type = checker.getTypeAtLocation(side); + var newNode = checker.getPromisedTypeOfPromise(type) ? ts.createAwait(side) : side; + changeTracker.replaceNode(sourceFile, side, newNode); + } } else if (errorCode === propertyAccessCode && ts.isPropertyAccessExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite.parent.expression)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.expression); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite.parent.expression, ts.createParen(ts.createAwait(insertionSite.parent.expression))); } else if (ts.contains(callableConstructableErrorCodes, errorCode) && ts.isCallOrNewExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite)) { + var symbol = checker.getSymbolAtLocation(insertionSite); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createParen(ts.createAwait(insertionSite))); } else { + if (fixedDeclarations && ts.isVariableDeclaration(insertionSite.parent) && ts.isIdentifier(insertionSite.parent.name)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.name); + if (symbol && !ts.addToSeen(fixedDeclarations, ts.getSymbolId(symbol))) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createAwait(insertionSite)); } } @@ -115239,10 +116967,10 @@ var ts; function isPossiblyPartOfDestructuring(node) { switch (node.kind) { case 73 /* Identifier */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return true; default: return false; @@ -115257,7 +116985,7 @@ var ts; function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { case 73 /* Identifier */: - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: case 27 /* CommaToken */: return true; default: @@ -115398,33 +117126,33 @@ var ts; } } else { - var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl)); // If not defined, shouldn't have been an error to fix - ts.Debug.assert(!decl.type); // If defined, shouldn't have been an error to fix. + var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl), "A JSDocType for this declaration should exist"); // If not defined, shouldn't have been an error to fix + ts.Debug.assert(!decl.type, "The JSDocType decl should have a type"); // If defined, shouldn't have been an error to fix. changes.tryInsertTypeAnnotation(sourceFile, decl, transformJSDocType(jsdocType)); } } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 238 /* VariableDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 239 /* VariableDeclaration */ || + node.kind === 155 /* PropertySignature */ || + node.kind === 156 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 291 /* JSDocAllType */: + case 292 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 294 /* JSDocOptionalType */: + case 295 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 293 /* JSDocNonNullableType */: + case 294 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 292 /* JSDocNullableType */: + case 293 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 296 /* JSDocVariadicType */: + case 297 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); // TODO: GH#18217 @@ -115446,7 +117174,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 296 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 297 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); var dotdotdot = isRest ? ts.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -115678,13 +117406,8 @@ var ts; if (!ts.isIdentifier(parameterDeclaration.name)) { return; } - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - var parameterInferences = InferFromReference.inferTypeForParametersFromReferences(references, containingFunction, program, cancellationToken) || - containingFunction.parameters.map(function (p) { return ({ - declaration: p, - type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() - }); }); - ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length); + var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken); + ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length, "Parameter count and inference count should match"); if (ts.isInJSFile(containingFunction)) { annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } @@ -115703,14 +117426,11 @@ var ts; } } function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - if (!references) { - return; - } - var thisInference = InferFromReference.inferTypeForThisFromReferences(references, program, cancellationToken); - if (!thisInference) { + var references = getFunctionReferences(containingFunction, sourceFile, program, cancellationToken); + if (!references || !references.length) { return; } + var thisInference = inferTypeFromReferences(program, references, cancellationToken).thisParameter(); var typeNode = ts.getTypeNodeIfAccessible(thisInference, containingFunction, program, host); if (!typeNode) { return; @@ -115745,7 +117465,7 @@ var ts; function annotate(changes, sourceFile, declaration, type, program, host) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 154 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 155 /* PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -115785,14 +117505,14 @@ var ts; oldTags[i] = merged; return !!merged; }); }); - var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray((oldTags || ts.emptyArray).concat(unmergedNewTags))); - var jsDocNode = parent.kind === 198 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; + var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray(__spreadArrays((oldTags || ts.emptyArray), unmergedNewTags))); + var jsDocNode = parent.kind === 199 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; jsDocNode.jsDoc = parent.jsDoc; jsDocNode.jsDocCache = parent.jsDocCache; changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag); } function getJsDocNodeForArrowFunction(signature) { - if (signature.parent.kind === 155 /* PropertyDeclaration */) { + if (signature.parent.kind === 156 /* PropertyDeclaration */) { return signature.parent; } return signature.parent.parent; @@ -115802,14 +117522,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 306 /* JSDocParameterTag */: { + case 308 /* JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.createJSDocParamTag(newParam.name, newParam.isBracketed, newParam.typeExpression, oldParam.comment) : undefined; } - case 307 /* JSDocReturnTag */: + case 309 /* JSDocReturnTag */: return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); } } @@ -115821,25 +117541,31 @@ var ts; } function inferTypeForVariableFromUsage(token, program, cancellationToken) { var references = getReferences(token, program, cancellationToken); - var checker = program.getTypeChecker(); - var types = InferFromReference.inferTypesFromReferences(references, checker, cancellationToken); - return InferFromReference.unifyFromContext(types, checker); + return inferTypeFromReferences(program, references, cancellationToken).single(); } - function inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken) { + function inferTypeForParametersFromUsage(func, sourceFile, program, cancellationToken) { + var references = getFunctionReferences(func, sourceFile, program, cancellationToken); + return references && inferTypeFromReferences(program, references, cancellationToken).parameters(func) || + func.parameters.map(function (p) { return ({ + declaration: p, + type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() + }); }); + } + function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: searchToken = ts.findChildOfKind(containingFunction, 125 /* ConstructorKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 198 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: searchToken = containingFunction.name; break; } @@ -115848,54 +117574,51 @@ var ts; } return getReferences(searchToken, program, cancellationToken); } - var InferFromReference; - (function (InferFromReference) { - function inferTypesFromReferences(references, checker, cancellationToken) { - var usageContext = {}; - for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { - var reference = references_2[_i]; - cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); - } - return inferFromContext(usageContext, checker); + function inferTypeFromReferences(program, references, cancellationToken) { + var checker = program.getTypeChecker(); + return { + single: single, + parameters: parameters, + thisParameter: thisParameter, + }; + function single() { + return unifyFromUsage(inferTypesFromReferencesSingle(references)); } - InferFromReference.inferTypesFromReferences = inferTypesFromReferences; - function inferTypeForParametersFromReferences(references, declaration, program, cancellationToken) { - if (references === undefined || references.length === 0 || !declaration.parameters) { + function parameters(declaration) { + if (references.length === 0 || !declaration.parameters) { return undefined; } - var checker = program.getTypeChecker(); - var usageContext = {}; - for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { - var reference = references_3[_i]; + var usage = {}; + for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { + var reference = references_2[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - var callContexts = (usageContext.constructContexts || []).concat(usageContext.callContexts || []); + var calls = __spreadArrays(usage.constructs || [], usage.calls || []); return declaration.parameters.map(function (parameter, parameterIndex) { var types = []; var isRest = ts.isRestParameter(parameter); var isOptional = false; - for (var _i = 0, callContexts_1 = callContexts; _i < callContexts_1.length; _i++) { - var callContext = callContexts_1[_i]; - if (callContext.argumentTypes.length <= parameterIndex) { + for (var _i = 0, calls_1 = calls; _i < calls_1.length; _i++) { + var call = calls_1[_i]; + if (call.argumentTypes.length <= parameterIndex) { isOptional = ts.isInJSFile(declaration); types.push(checker.getUndefinedType()); } else if (isRest) { - for (var i = parameterIndex; i < callContext.argumentTypes.length; i++) { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + for (var i = parameterIndex; i < call.argumentTypes.length; i++) { + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[i])); } } else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex])); } } if (ts.isIdentifier(parameter.name)) { - var inferred = inferTypesFromReferences(getReferences(parameter.name, program, cancellationToken), checker, cancellationToken); + var inferred = inferTypesFromReferencesSingle(getReferences(parameter.name, program, cancellationToken)); types.push.apply(types, (isRest ? ts.mapDefined(inferred, checker.getElementTypeOfArrayType) : inferred)); } - var type = unifyFromContext(types, checker); + var type = unifyFromUsage(types); return { type: isRest ? checker.createArrayType(type) : type, isOptional: isOptional && !isRest, @@ -115903,112 +117626,119 @@ var ts; }; }); } - InferFromReference.inferTypeForParametersFromReferences = inferTypeForParametersFromReferences; - function inferTypeForThisFromReferences(references, program, cancellationToken) { - if (references.length === 0) { - return undefined; + function thisParameter() { + var usage = {}; + for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { + var reference = references_3[_i]; + cancellationToken.throwIfCancellationRequested(); + calculateUsageOfNode(reference, usage); } - var checker = program.getTypeChecker(); - var usageContext = {}; + return unifyFromUsage(usage.candidateThisTypes || ts.emptyArray); + } + function inferTypesFromReferencesSingle(references) { + var usage = {}; for (var _i = 0, references_4 = references; _i < references_4.length; _i++) { var reference = references_4[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - return unifyFromContext(usageContext.candidateThisTypes || ts.emptyArray, checker); + return inferFromUsage(usage); } - InferFromReference.inferTypeForThisFromReferences = inferTypeForThisFromReferences; - function inferTypeFromContext(node, checker, usageContext) { + function calculateUsageOfNode(node, usage) { while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } switch (node.parent.kind) { - case 204 /* PostfixUnaryExpression */: - usageContext.isNumber = true; + case 205 /* PostfixUnaryExpression */: + usage.isNumber = true; break; - case 203 /* PrefixUnaryExpression */: - inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); + case 204 /* PrefixUnaryExpression */: + inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 205 /* BinaryExpression */: - inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); + case 206 /* BinaryExpression */: + inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); + case 273 /* CaseClause */: + case 274 /* DefaultClause */: + inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: if (node.parent.expression === node) { - inferTypeFromCallExpressionContext(node.parent, checker, usageContext); + inferTypeFromCallExpression(node.parent, usage); } else { - inferTypeFromContextualType(node, checker, usageContext); + inferTypeFromContextualType(node, usage); } break; - case 190 /* PropertyAccessExpression */: - inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); + case 191 /* PropertyAccessExpression */: + inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 191 /* ElementAccessExpression */: - inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); + case 192 /* ElementAccessExpression */: + inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - inferTypeFromPropertyAssignment(node.parent, checker, usageContext); + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: + inferTypeFromPropertyAssignment(node.parent, usage); break; - case 155 /* PropertyDeclaration */: - inferTypeFromPropertyDeclaration(node.parent, checker, usageContext); + case 156 /* PropertyDeclaration */: + inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 238 /* VariableDeclaration */: { + case 239 /* 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. - addCandidateType(usageContext, checker.getTypeAtLocation(initializer)); + addCandidateType(usage, checker.getTypeAtLocation(initializer)); } break; } } // falls through default: - return inferTypeFromContextualType(node, checker, usageContext); + return inferTypeFromContextualType(node, usage); } } - function inferTypeFromContextualType(node, checker, usageContext) { + function inferTypeFromContextualType(node, usage) { if (ts.isExpressionNode(node)) { - addCandidateType(usageContext, checker.getContextualType(node)); + addCandidateType(usage, checker.getContextualType(node)); } } - function inferTypeFromPrefixUnaryExpressionContext(node, usageContext) { + function inferTypeFromPrefixUnaryExpression(node, usage) { switch (node.operator) { case 44 /* PlusPlusToken */: case 45 /* MinusMinusToken */: case 39 /* MinusToken */: case 53 /* TildeToken */: - usageContext.isNumber = true; + usage.isNumber = true; break; case 38 /* PlusToken */: - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; break; // case SyntaxKind.ExclamationToken: // no inferences here; } } - function inferTypeFromBinaryExpressionContext(node, parent, checker, usageContext) { + function inferTypeFromBinaryExpression(node, parent, usage) { switch (parent.operatorToken.kind) { // ExponentiationOperator case 41 /* AsteriskAsteriskToken */: // MultiplicativeOperator + // falls through case 40 /* AsteriskToken */: case 42 /* SlashToken */: case 43 /* PercentToken */: // ShiftOperator + // falls through case 46 /* LessThanLessThanToken */: case 47 /* GreaterThanGreaterThanToken */: case 48 /* GreaterThanGreaterThanGreaterThanToken */: // BitwiseOperator + // falls through case 49 /* AmpersandToken */: case 50 /* BarToken */: case 51 /* CaretToken */: // CompoundAssignmentOperator + // falls through case 62 /* MinusEqualsToken */: case 64 /* AsteriskAsteriskEqualsToken */: case 63 /* AsteriskEqualsToken */: @@ -116021,34 +117751,36 @@ var ts; case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: case 68 /* GreaterThanGreaterThanEqualsToken */: // AdditiveOperator + // falls through case 39 /* MinusToken */: // RelationalOperator + // falls through case 28 /* LessThanToken */: case 31 /* LessThanEqualsToken */: case 30 /* GreaterThanToken */: case 32 /* GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (operandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, operandType); + addCandidateType(usage, operandType); } else { - usageContext.isNumber = true; + usage.isNumber = true; } break; case 61 /* PlusEqualsToken */: case 38 /* PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (otherOperandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, otherOperandType); + addCandidateType(usage, otherOperandType); } else if (otherOperandType.flags & 296 /* NumberLike */) { - usageContext.isNumber = true; + usage.isNumber = true; } else if (otherOperandType.flags & 132 /* StringLike */) { - usageContext.isString = true; + usage.isString = true; } else { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; } break; // AssignmentOperators @@ -116057,20 +117789,20 @@ var ts; case 35 /* EqualsEqualsEqualsToken */: case 36 /* ExclamationEqualsEqualsToken */: case 34 /* ExclamationEqualsToken */: - addCandidateType(usageContext, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); + addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; case 94 /* InKeyword */: if (node === parent.left) { - usageContext.isString = true; + usage.isString = true; } break; // LogicalOperator case 55 /* BarBarToken */: if (node === parent.left && - (node.parent.parent.kind === 238 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 239 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType - addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); + addCandidateType(usage, checker.getTypeAtLocation(parent.right)); } break; case 54 /* AmpersandAmpersandToken */: @@ -116080,65 +117812,62 @@ var ts; break; } } - function inferTypeFromSwitchStatementLabelContext(parent, checker, usageContext) { - addCandidateType(usageContext, checker.getTypeAtLocation(parent.parent.parent.expression)); + function inferTypeFromSwitchStatementLabel(parent, usage) { + addCandidateType(usage, checker.getTypeAtLocation(parent.parent.parent.expression)); } - function inferTypeFromCallExpressionContext(parent, checker, usageContext) { - var callContext = { + function inferTypeFromCallExpression(parent, usage) { + var call = { argumentTypes: [], returnType: {} }; if (parent.arguments) { for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { var argument = _a[_i]; - callContext.argumentTypes.push(checker.getTypeAtLocation(argument)); + call.argumentTypes.push(checker.getTypeAtLocation(argument)); } } - inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 192 /* CallExpression */) { - (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); + calculateUsageOfNode(parent, call.returnType); + if (parent.kind === 193 /* CallExpression */) { + (usage.calls || (usage.calls = [])).push(call); } else { - (usageContext.constructContexts || (usageContext.constructContexts = [])).push(callContext); + (usage.constructs || (usage.constructs = [])).push(call); } } - function inferTypeFromPropertyAccessExpressionContext(parent, checker, usageContext) { + function inferTypeFromPropertyAccessExpression(parent, usage) { var name = ts.escapeLeadingUnderscores(parent.name.text); - if (!usageContext.properties) { - usageContext.properties = ts.createUnderscoreEscapedMap(); + if (!usage.properties) { + usage.properties = ts.createUnderscoreEscapedMap(); } - var propertyUsageContext = usageContext.properties.get(name) || {}; - inferTypeFromContext(parent, checker, propertyUsageContext); - usageContext.properties.set(name, propertyUsageContext); + var propertyUsage = usage.properties.get(name) || {}; + calculateUsageOfNode(parent, propertyUsage); + usage.properties.set(name, propertyUsage); } - function inferTypeFromPropertyElementExpressionContext(parent, node, checker, usageContext) { + function inferTypeFromPropertyElementExpression(parent, node, usage) { if (node === parent.argumentExpression) { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; return; } else { var indexType = checker.getTypeAtLocation(parent.argumentExpression); - var indexUsageContext = {}; - inferTypeFromContext(parent, checker, indexUsageContext); + var indexUsage = {}; + calculateUsageOfNode(parent, indexUsage); if (indexType.flags & 296 /* NumberLike */) { - usageContext.numberIndexContext = indexUsageContext; + usage.numberIndex = indexUsage; } else { - usageContext.stringIndexContext = indexUsageContext; + usage.stringIndex = indexUsage; } } } - function inferTypeFromPropertyAssignment(assignment, checker, usageContext) { - var objectLiteral = ts.isShorthandPropertyAssignment(assignment) ? - assignment.parent : - assignment.parent.parent; - var nodeWithRealType = ts.isVariableDeclaration(objectLiteral.parent) ? - objectLiteral.parent : - objectLiteral; - addCandidateThisType(usageContext, checker.getTypeAtLocation(nodeWithRealType)); + function inferTypeFromPropertyAssignment(assignment, usage) { + var nodeWithRealType = ts.isVariableDeclaration(assignment.parent.parent) ? + assignment.parent.parent : + assignment.parent; + addCandidateThisType(usage, checker.getTypeAtLocation(nodeWithRealType)); } - function inferTypeFromPropertyDeclaration(declaration, checker, usageContext) { - addCandidateThisType(usageContext, checker.getTypeAtLocation(declaration.parent)); + function inferTypeFromPropertyDeclaration(declaration, usage) { + addCandidateThisType(usage, checker.getTypeAtLocation(declaration.parent)); } function removeLowPriorityInferences(inferences, priorities) { var toRemove = []; @@ -116147,14 +117876,14 @@ var ts; for (var _a = 0, priorities_1 = priorities; _a < priorities_1.length; _a++) { var _b = priorities_1[_a], high = _b.high, low = _b.low; if (high(i)) { - ts.Debug.assert(!low(i)); + ts.Debug.assert(!low(i), "Priority can't have both low and high"); toRemove.push(low); } } } return inferences.filter(function (i) { return toRemove.every(function (f) { return !f(i); }); }); } - function unifyFromContext(inferences, checker, fallback) { + function unifyFromUsage(inferences, fallback) { if (fallback === void 0) { fallback = checker.getAnyType(); } if (!inferences.length) return fallback; @@ -116180,12 +117909,11 @@ var ts; var anons = good.filter(function (i) { return checker.getObjectFlags(i) & 16 /* Anonymous */; }); if (anons.length) { good = good.filter(function (i) { return !(checker.getObjectFlags(i) & 16 /* Anonymous */); }); - good.push(unifyAnonymousTypes(anons, checker)); + good.push(unifyAnonymousTypes(anons)); } return checker.getWidenedType(checker.getUnionType(good)); } - InferFromReference.unifyFromContext = unifyFromContext; - function unifyAnonymousTypes(anons, checker) { + function unifyAnonymousTypes(anons) { if (anons.length === 1) { return anons[0]; } @@ -116221,74 +117949,74 @@ var ts; }); return checker.createAnonymousType(anons[0].symbol, members, calls, constructs, stringIndices.length ? checker.createIndexInfo(checker.getUnionType(stringIndices), stringIndexReadonly) : undefined, numberIndices.length ? checker.createIndexInfo(checker.getUnionType(numberIndices), numberIndexReadonly) : undefined); } - function inferFromContext(usageContext, checker) { + function inferFromUsage(usage) { var types = []; - if (usageContext.isNumber) { + if (usage.isNumber) { types.push(checker.getNumberType()); } - if (usageContext.isString) { + if (usage.isString) { types.push(checker.getStringType()); } - if (usageContext.isNumberOrString) { + if (usage.isNumberOrString) { types.push(checker.getUnionType([checker.getStringType(), checker.getNumberType()])); } - types.push.apply(types, (usageContext.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); - if (usageContext.properties && hasCallContext(usageContext.properties.get("then"))) { - var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); // TODO: GH#18217 - var types_1 = paramType.getCallSignatures().map(function (c) { return c.getReturnType(); }); + types.push.apply(types, (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); + if (usage.properties && hasCalls(usage.properties.get("then"))) { + var paramType = getParameterTypeFromCalls(0, usage.properties.get("then").calls, /*isRestParameter*/ false); // TODO: GH#18217 + var types_1 = paramType.getCallSignatures().map(function (sig) { return sig.getReturnType(); }); types_1.push(checker.createPromiseType(types_1.length ? checker.getUnionType(types_1, 2 /* Subtype */) : checker.getAnyType())); } - else if (usageContext.properties && hasCallContext(usageContext.properties.get("push"))) { - types.push(checker.createArrayType(getParameterTypeFromCallContexts(0, usageContext.properties.get("push").callContexts, /*isRestParameter*/ false, checker))); + else if (usage.properties && hasCalls(usage.properties.get("push"))) { + types.push(checker.createArrayType(getParameterTypeFromCalls(0, usage.properties.get("push").calls, /*isRestParameter*/ false))); } - if (usageContext.numberIndexContext) { - types.push(checker.createArrayType(recur(usageContext.numberIndexContext))); + if (usage.numberIndex) { + types.push(checker.createArrayType(recur(usage.numberIndex))); } - else if (usageContext.properties || usageContext.callContexts || usageContext.constructContexts || usageContext.stringIndexContext) { + else if (usage.properties || usage.calls || usage.constructs || usage.stringIndex) { var members_1 = ts.createUnderscoreEscapedMap(); var callSignatures = []; var constructSignatures = []; var stringIndexInfo = void 0; - if (usageContext.properties) { - usageContext.properties.forEach(function (context, name) { + if (usage.properties) { + usage.properties.forEach(function (u, name) { var symbol = checker.createSymbol(4 /* Property */, name); - symbol.type = recur(context); + symbol.type = recur(u); members_1.set(name, symbol); }); } - if (usageContext.callContexts) { - for (var _i = 0, _a = usageContext.callContexts; _i < _a.length; _i++) { - var callContext = _a[_i]; - callSignatures.push(getSignatureFromCallContext(callContext, checker)); + if (usage.calls) { + for (var _i = 0, _a = usage.calls; _i < _a.length; _i++) { + var call = _a[_i]; + callSignatures.push(getSignatureFromCall(call)); } } - if (usageContext.constructContexts) { - for (var _b = 0, _c = usageContext.constructContexts; _b < _c.length; _b++) { - var constructContext = _c[_b]; - constructSignatures.push(getSignatureFromCallContext(constructContext, checker)); + if (usage.constructs) { + for (var _b = 0, _c = usage.constructs; _b < _c.length; _b++) { + var construct = _c[_b]; + constructSignatures.push(getSignatureFromCall(construct)); } } - if (usageContext.stringIndexContext) { - stringIndexInfo = checker.createIndexInfo(recur(usageContext.stringIndexContext), /*isReadonly*/ false); + if (usage.stringIndex) { + stringIndexInfo = checker.createIndexInfo(recur(usage.stringIndex), /*isReadonly*/ false); } types.push(checker.createAnonymousType(/*symbol*/ undefined, members_1, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined)); // TODO: GH#18217 } return types; - function recur(innerContext) { - return unifyFromContext(inferFromContext(innerContext, checker), checker); + function recur(innerUsage) { + return unifyFromUsage(inferFromUsage(innerUsage)); } } - function getParameterTypeFromCallContexts(parameterIndex, callContexts, isRestParameter, checker) { + function getParameterTypeFromCalls(parameterIndex, calls, isRestParameter) { var types = []; - if (callContexts) { - for (var _i = 0, callContexts_2 = callContexts; _i < callContexts_2.length; _i++) { - var callContext = callContexts_2[_i]; - if (callContext.argumentTypes.length > parameterIndex) { + if (calls) { + for (var _i = 0, calls_2 = calls; _i < calls_2.length; _i++) { + var call = calls_2[_i]; + if (call.argumentTypes.length > parameterIndex) { if (isRestParameter) { - types = ts.concatenate(types, ts.map(callContext.argumentTypes.slice(parameterIndex), function (a) { return checker.getBaseTypeOfLiteralType(a); })); + types = ts.concatenate(types, ts.map(call.argumentTypes.slice(parameterIndex), function (a) { return checker.getBaseTypeOfLiteralType(a); })); } else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex])); } } } @@ -116299,31 +118027,31 @@ var ts; } return undefined; } - function getSignatureFromCallContext(callContext, checker) { + function getSignatureFromCall(call) { var parameters = []; - for (var i = 0; i < callContext.argumentTypes.length; i++) { + for (var i = 0; i < call.argumentTypes.length; i++) { var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); - symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(call.argumentTypes[i])); parameters.push(symbol); } - var returnType = unifyFromContext(inferFromContext(callContext.returnType, checker), checker, checker.getVoidType()); + var returnType = unifyFromUsage(inferFromUsage(call.returnType), checker.getVoidType()); // TODO: GH#18217 - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, call.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); } - function addCandidateType(context, type) { + function addCandidateType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateTypes || (context.candidateTypes = [])).push(type); + (usage.candidateTypes || (usage.candidateTypes = [])).push(type); } } - function addCandidateThisType(context, type) { + function addCandidateThisType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateThisTypes || (context.candidateThisTypes = [])).push(type); + (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); } } - function hasCallContext(usageContext) { - return !!usageContext && !!usageContext.callContexts; + function hasCalls(usage) { + return !!usage && !!usage.calls; } - })(InferFromReference || (InferFromReference = {})); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -116352,12 +118080,12 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: precedingNode = ctorDeclaration; changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { @@ -116412,7 +118140,7 @@ var ts; return; } // 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 === 222 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 223 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { @@ -116420,7 +118148,7 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 197 /* FunctionExpression */: { + case 198 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 122 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, @@ -116428,12 +118156,12 @@ var ts; ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 198 /* ArrowFunction */: { + case 199 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 219 /* Block */) { + if (arrowFunctionBody.kind === 220 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] @@ -116461,7 +118189,7 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 197 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 198 /* FunctionExpression */) { return undefined; } if (node.name.kind !== 73 /* Identifier */) { @@ -116550,7 +118278,7 @@ var ts; var newNodes = transformExpression(node, transformer, node); changes.replaceNodeWithNodes(sourceFile, nodeToReplace, newNodes); } - var _loop_11 = function (statement) { + var _loop_12 = function (statement) { ts.forEachChild(statement, function visit(node) { if (ts.isCallExpression(node)) { startTransformation(node, statement); @@ -116562,7 +118290,7 @@ var ts; }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var statement = returnStatements_1[_i]; - _loop_11(statement); + _loop_12(statement); } } function getReturnStatementsWithPromiseHandlers(body) { @@ -116881,8 +118609,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: { var funcBody = func.body; // Arrow functions with block bodies { } will enter this control flow if (ts.isBlock(funcBody)) { @@ -116994,6 +118722,7 @@ var ts; name = getMapEntryOrDefault(funcNode); } // return undefined argName when arg is null or undefined + // eslint-disable-next-line no-in-operator if (!name || "identifier" in name && name.identifier.text === "undefined") { return undefined; } @@ -117085,10 +118814,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -117114,7 +118843,7 @@ var ts; forEachExportReference(sourceFile, function (node) { var _a = node.name, text = _a.text, originalKeywordKind = _a.originalKeywordKind; if (!res.has(text) && (originalKeywordKind !== undefined && ts.isNonContextualKeyword(originalKeywordKind) - || checker.resolveName(node.name.text, node, 67220415 /* Value */, /*excludeGlobals*/ true))) { + || checker.resolveName(node.name.text, node, 111551 /* Value */, /*excludeGlobals*/ true))) { // Unconditionally add an underscore in case `text` is a keyword. res.set(text, makeUniqueName("_" + text, identifiers)); } @@ -117141,20 +118870,20 @@ var ts; } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 222 /* ExpressionStatement */: { + case 223 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 192 /* CallExpression */: { + case 193 /* 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 205 /* BinaryExpression */: { + case 206 /* BinaryExpression */: { var operatorToken = expression.operatorToken; return operatorToken.kind === 60 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } @@ -117196,8 +118925,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: { + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -117209,7 +118938,7 @@ var ts; // `const a = require("b").c` --> `import { c as a } from "./b"; return [makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]; default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid syntax form " + name.kind); } } function convertAssignment(sourceFile, checker, assignment, changes, exports) { @@ -117248,18 +118977,19 @@ var ts; function tryChangeModuleExportsObject(object) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 277 /* ShorthandPropertyAssignment */: - case 278 /* SpreadAssignment */: + // falls through + case 278 /* ShorthandPropertyAssignment */: + case 279 /* SpreadAssignment */: return undefined; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(86 /* ExportKeyword */)], prop); default: - ts.Debug.assertNever(prop); + ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); } }); return statements && [statements, false]; @@ -117288,12 +119018,10 @@ var ts; var moduleSpecifier = reExported.text; var moduleSymbol = checker.getSymbolAtLocation(reExported); var exports = moduleSymbol ? moduleSymbol.exports : ts.emptyUnderscoreEscapedMap; - return exports.has("export=") - ? [[reExportDefault(moduleSpecifier)], true] - : !exports.has("default") - ? [[reExportStar(moduleSpecifier)], false] + return exports.has("export=") ? [[reExportDefault(moduleSpecifier)], true] : + !exports.has("default") ? [[reExportStar(moduleSpecifier)], false] : // If there's some non-default export, must include both `export *` and `export default`. - : exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; + exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; } function reExportStar(moduleSpecifier) { return makeExportDeclaration(/*exportClause*/ undefined, moduleSpecifier); @@ -117322,7 +119050,7 @@ var ts; function convertExportsDotXEquals_replaceNode(name, exported) { var modifiers = [ts.createToken(86 /* ExportKeyword */)]; switch (exported.kind) { - case 197 /* FunctionExpression */: { + case 198 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -117330,10 +119058,10 @@ var ts; } } // falls through - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -117351,18 +119079,20 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: { + case 186 /* 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 + // (TODO: GH#18217) + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion : makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text); - }); // tslint:disable-line no-unnecessary-type-assertion (TODO: GH#18217) + }); if (importSpecifiers) { return [ts.makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, quotePreference)]; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 186 /* ArrayBindingPattern */: { + case 187 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -117376,7 +119106,7 @@ var ts; case 73 /* Identifier */: return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, quotePreference); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid name kind " + name.kind); } } /** @@ -117398,7 +119128,7 @@ var ts; var parent = use.parent; if (ts.isPropertyAccessExpression(parent)) { var expression = parent.expression, propertyName = parent.name.text; - ts.Debug.assert(expression === use); // Else shouldn't have been in `collectIdentifiers` + 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); @@ -117445,11 +119175,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return parent.name !== node; - case 187 /* BindingElement */: + case 188 /* BindingElement */: return parent.propertyName !== node; - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -117524,8 +119254,10 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var errorCodes = [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, - ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code]; + var errorCodes = [ + ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, + ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code + ]; var fixId = "fixClassIncorrectlyImplementsInterface"; // TODO: share a group with fixClassDoesntImplementInheritedAbstractMember? codefix.registerCodeFix({ errorCodes: errorCodes, @@ -117552,7 +119284,7 @@ var ts; }, }); function getClass(sourceFile, pos) { - return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos))); + return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); @@ -117650,7 +119382,7 @@ var ts; ts.pushIfUnique(entry.namedImports, symbolName); } else { - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add to Existing) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; } break; @@ -117663,7 +119395,7 @@ var ts; } switch (importKind) { case 1 /* Default */: - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add new) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; break; case 0 /* Named */: @@ -117671,14 +119403,14 @@ var ts; break; case 3 /* Equals */: case 2 /* Namespace */: - ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName); + ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); entry.namespaceLikeImport = { importKind: importKind, name: symbolName }; break; } break; } default: - ts.Debug.assertNever(fix); + ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); } }); return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { @@ -117715,10 +119447,11 @@ var ts; ImportKind[ImportKind["Default"] = 1] = "Default"; ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; ImportKind[ImportKind["Equals"] = 3] = "Equals"; + ImportKind[ImportKind["ConstEquals"] = 4] = "ConstEquals"; })(ImportKind || (ImportKind = {})); function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) { - var exportInfos = getAllReExportingModules(exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles()); - ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; })); + var exportInfos = getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles()); + 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 for completions. var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, position, exportInfos, host, preferences)).moduleSpecifier; var fix = ts.first(getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences)); @@ -117729,14 +119462,14 @@ var ts; var description = _a.description, changes = _a.changes, commands = _a.commands; return { description: description, changes: changes, commands: commands }; } - function getAllReExportingModules(exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, compilerOptions, checker, allSourceFiles) { + function getAllReExportingModules(importingFile, exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, compilerOptions, checker, allSourceFiles) { var result = []; forEachExternalModule(checker, allSourceFiles, function (moduleSymbol, moduleFile) { // Don't import from a re-export when looking "up" like to `./index` or `../index`. if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(sourceFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) { return; } - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + var defaultInfo = getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions); if (defaultInfo && defaultInfo.name === symbolName && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol) { result.push({ moduleSymbol: moduleSymbol, importKind: defaultInfo.kind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker) }); } @@ -117750,7 +119483,7 @@ var ts; return result; } function isTypeOnlySymbol(s, checker) { - return !(ts.skipAlias(s, checker).flags & 67220415 /* Value */); + return !(ts.skipAlias(s, checker).flags & 111551 /* Value */); } function getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences) { var checker = program.getTypeChecker(); @@ -117759,7 +119492,7 @@ var ts; var addToExisting = tryAddToExistingImport(existingImports); // Don't bother providing an action to add a new import if we can add to an existing one. var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences); - return (useNamespace ? [useNamespace] : ts.emptyArray).concat(addImport); + return __spreadArrays((useNamespace ? [useNamespace] : ts.emptyArray), addImport); } function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) { // It is possible that multiple import statements with the same specifier exist in the file. @@ -117788,21 +119521,21 @@ var ts; function tryAddToExistingImport(existingImports) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind !== 250 /* ImportDeclaration */) + if (declaration.kind !== 251 /* ImportDeclaration */) return undefined; var importClause = declaration.importClause; if (!importClause) return undefined; var name = importClause.name, namedBindings = importClause.namedBindings; - return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 253 /* NamedImports */) + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 254 /* NamedImports */) ? { kind: 2 /* AddToExisting */, importClause: importClause, importKind: importKind } : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 250 /* ImportDeclaration */) { + if (declaration.kind === 251 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 252 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 253 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -117813,7 +119546,7 @@ var ts; // Can't use an es6 import for a type in JS. return exportedSymbolIsTypeOnly && ts.isSourceFileJS(sourceFile) ? ts.emptyArray : ts.mapDefined(sourceFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 250 /* ImportDeclaration */ || i.kind === 249 /* ImportEqualsDeclaration */) + return (i.kind === 251 /* ImportDeclaration */ || i.kind === 250 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } @@ -117824,7 +119557,7 @@ var ts; return ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences, program.redirectTargetsMap) .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.assertDefined(position) } : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; + return exportedSymbolIsTypeOnly && isJs ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position, "position should be defined") } : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; }); }); // Sort to keep the shortest paths first @@ -117836,9 +119569,9 @@ var ts; } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 250 /* ImportDeclaration */ + var expression = declaration.kind === 251 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 260 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 261 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; return expression && ts.isStringLiteral(expression) ? { kind: 3 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; @@ -117848,7 +119581,7 @@ 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) : undefined; - return info && __assign({}, info, { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); + return info && __assign(__assign({}, info), { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); } function getFixesInfoForUMDImport(_a, token) { var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences; @@ -117858,7 +119591,7 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; + var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(sourceFile, program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; var fixes = getFixForImport(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, program, sourceFile, host, preferences); return { fixes: fixes, symbolName: symbolName }; } @@ -117870,10 +119603,10 @@ var ts; // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. var parent = token.parent; return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) - ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 67220415 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } - function getUmdImportKind(compilerOptions) { + function getUmdImportKind(importingFile, compilerOptions) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { return 1 /* Default */; @@ -117884,6 +119617,9 @@ var ts; case ts.ModuleKind.AMD: case ts.ModuleKind.CommonJS: case ts.ModuleKind.UMD: + if (ts.isInJSFile(importingFile)) { + return ts.isExternalModule(importingFile) ? 2 /* Namespace */ : 4 /* ConstEquals */; + } return 3 /* Equals */; case ts.ModuleKind.System: case ts.ModuleKind.ES2015: @@ -117892,7 +119628,7 @@ var ts; // Fall back to the `import * as ns` style import. return 2 /* Namespace */; default: - return ts.Debug.assertNever(moduleKind); + return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind); } } function getFixesInfoForNonUMDImport(_a, symbolToken) { @@ -117905,7 +119641,7 @@ var ts; ? checker.getJsxNamespace(sourceFile) : symbolToken.text; // "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 */); + ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here"); var fixes = ts.arrayFrom(ts.flatMapIterator(getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), program, sourceFile, host, preferences); @@ -117922,7 +119658,7 @@ var ts; } forEachExternalModuleToImportFrom(checker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { cancellationToken.throwIfCancellationRequested(); - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, program.getCompilerOptions()); + var defaultInfo = getDefaultLikeExportInfo(sourceFile, moduleSymbol, checker, program.getCompilerOptions()); if (defaultInfo && defaultInfo.name === symbolName && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { addSymbol(moduleSymbol, defaultInfo.symbol, defaultInfo.kind); } @@ -117934,20 +119670,41 @@ var ts; }); return originalSymbolToExportInfos; } - function getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions) { - var exported = getDefaultLikeExportWorker(moduleSymbol, checker); + function getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions) { + var exported = getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions); if (!exported) return undefined; var symbol = exported.symbol, kind = exported.kind; var info = getDefaultExportInfoWorker(symbol, moduleSymbol, checker, compilerOptions); return info && __assign({ symbol: symbol, kind: kind }, info); } - function getDefaultLikeExportWorker(moduleSymbol, checker) { + function getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions) { 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: 3 /* Equals */ }; + return exportEquals === moduleSymbol ? undefined : { symbol: exportEquals, kind: getExportEqualsImportKind(importingFile, compilerOptions, checker) }; + } + function getExportEqualsImportKind(importingFile, compilerOptions, checker) { + if (ts.getAllowSyntheticDefaultImports(compilerOptions) && ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { + return 1 /* Default */; + } + if (ts.isInJSFile(importingFile)) { + return ts.isExternalModule(importingFile) ? 1 /* Default */ : 4 /* ConstEquals */; + } + for (var _i = 0, _a = importingFile.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (ts.isImportEqualsDeclaration(statement)) { + return 3 /* Equals */; + } + if (ts.isImportDeclaration(statement) && statement.importClause && statement.importClause.name) { + var moduleSymbol = checker.getImmediateAliasedSymbol(statement.importClause.symbol); + if (moduleSymbol && moduleSymbol.name !== "default" /* Default */) { + return 1 /* Default */; + } + } + } + return 3 /* Equals */; } function getDefaultExportInfoWorker(defaultExport, moduleSymbol, checker, compilerOptions) { var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); @@ -117958,7 +119715,7 @@ var ts; return { symbolForMeaning: defaultExport, name: name }; if (defaultExport.flags & 2097152 /* Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); - return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent), checker, compilerOptions); + return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent, "Alias targets of default exports must have a parent"), checker, compilerOptions); } if (defaultExport.escapedName !== "default" /* Default */ && defaultExport.escapedName !== "export=" /* ExportEquals */) { @@ -117974,7 +119731,7 @@ var ts; } } else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.text === "default" /* Default */); + ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); return declaration.propertyName && declaration.propertyName.text; } }); @@ -118008,12 +119765,12 @@ var ts; return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; } default: - return ts.Debug.assertNever(fix); + return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind); } } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports) { if (defaultImport) { - ts.Debug.assert(!clause.name); + ts.Debug.assert(!clause.name, "Default imports can't have names"); changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), ts.createIdentifier(defaultImport), { suffix: ", " }); } if (namedImports.length) { @@ -118031,7 +119788,7 @@ var ts; changes.replaceNode(sourceFile, clause.namedBindings, namedImports_1); } else { - changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name), namedImports_1); + changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name, "Named import specifiers must have names"), namedImports_1); } } } @@ -118056,11 +119813,17 @@ var ts; ts.insertImport(changes, sourceFile, ts.makeImport(defaultImport === undefined ? undefined : ts.createIdentifier(defaultImport), namedImports.map(function (n) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(n)); }), moduleSpecifier, quotePreference)); } if (namespaceLikeImport) { - ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ - ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) - : ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); + ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) : + namespaceLikeImport.importKind === 4 /* ConstEquals */ ? createConstEqualsRequireDeclaration(namespaceLikeImport.name, quotedModuleSpecifier) : + ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); } } + function createConstEqualsRequireDeclaration(name, quotedModuleSpecifier) { + return ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.createIdentifier(name), + /*type*/ undefined, ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, [quotedModuleSpecifier])) + ], 2 /* Const */)); + } function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); @@ -118168,12 +119931,12 @@ var ts; var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 73 /* Identifier */); + ts.Debug.assert(node.kind === 73 /* Identifier */, "Expected an identifier for spelling (property access)"); var containingType = checker.getTypeAtLocation(node.parent.expression); suggestion = checker.getSuggestionForNonexistentProperty(node, containingType); } else if (ts.isImportSpecifier(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 73 /* Identifier */); + ts.Debug.assert(node.kind === 73 /* Identifier */, "Expected an identifier for spelling (import)"); var importDeclaration = ts.findAncestor(node, ts.isImportDeclaration); var resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration); if (resolvedSourceFile && resolvedSourceFile.symbol) { @@ -118202,10 +119965,10 @@ var ts; flags |= 1920 /* Namespace */; } if (meaning & 2 /* Type */) { - flags |= 67897832 /* Type */; + flags |= 788968 /* Type */; } if (meaning & 1 /* Value */) { - flags |= 67220415 /* Value */; + flags |= 111551 /* Value */; } return flags; } @@ -118276,7 +120039,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, classDeclaration) { var supers = getAllSupers(classDeclaration, checker); - var _loop_12 = function (info) { + var _loop_13 = function (info) { // If some superclass added this property, don't add it again. if (supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -118303,7 +120066,7 @@ var ts; }; for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { var info = infos_1[_i]; - _loop_12(info); + _loop_13(info); } }); })); @@ -118364,7 +120127,7 @@ var ts; } function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 210 /* ClassExpression */) { + if (classDeclaration.kind === 211 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -118390,7 +120153,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 205 /* BinaryExpression */) { + if (token.parent.parent.kind === 206 /* 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))); @@ -118453,7 +120216,7 @@ var ts; } function addMethodDeclaration(context, changeTracker, declSourceFile, typeDecl, token, callExpression, makeStatic, inJs, preferences) { var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences, typeDecl); - var containingMethodDeclaration = ts.getAncestor(callExpression, 157 /* MethodDeclaration */); + var containingMethodDeclaration = ts.getAncestor(callExpression, 158 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === typeDecl) { changeTracker.insertNodeAfter(declSourceFile, containingMethodDeclaration, methodDeclaration); } @@ -118700,7 +120463,7 @@ var ts; }); function getNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 125 /* ConstructorKeyword */); + ts.Debug.assert(token.kind === 125 /* ConstructorKeyword */, "token should be at the constructor keyword"); return token.parent; } function doChange(changes, sourceFile, ctr) { @@ -118744,6 +120507,43 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixID = "fixEnableJsxFlag"; + var errorCodes = [ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) { + return doChange(changeTracker, configFile); + }); + return [ + codefix.createCodeFixActionNoFixId(fixID, changes, ts.Diagnostics.Enable_the_jsx_flag_in_your_configuration_file) + ]; + }, + fixIds: [fixID], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + doChange(changes, configFile); + }); + } + }); + function doChange(changeTracker, configFile) { + codefix.setJsonCompilerOptionValue(changeTracker, configFile, "jsx", ts.createStringLiteral("react")); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -118953,7 +120753,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); } function deleteTypeParameters(changes, sourceFile, token) { - changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters)); + changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. function tryGetFullImport(token) { @@ -118963,7 +120763,7 @@ var ts; if (token.kind !== 18 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; var decl = token.parent.parent; - if (decl.kind === 152 /* Parameter */) { + if (decl.kind === 153 /* Parameter */) { tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); } else { @@ -118974,7 +120774,7 @@ var ts; function tryDeleteFullVariableStatement(sourceFile, token, changes) { var declarationList = ts.tryCast(token.parent, ts.isVariableDeclarationList); if (declarationList && declarationList.getChildren(sourceFile)[0] === token) { - changes.delete(sourceFile, declarationList.parent.kind === 220 /* VariableStatement */ ? declarationList.parent : declarationList); + changes.delete(sourceFile, declarationList.parent.kind === 221 /* VariableStatement */ ? declarationList.parent : declarationList); return true; } return false; @@ -118992,14 +120792,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 152 /* Parameter */: - case 151 /* TypeParameter */: + case 153 /* Parameter */: + case 152 /* TypeParameter */: return true; - case 238 /* VariableDeclaration */: { + case 239 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 228 /* ForInStatement */: return true; } } @@ -119046,26 +120846,26 @@ var ts; function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: // Don't remove a parameter if this overrides something. var symbol = checker.getSymbolAtLocation(parent.name); if (ts.isMemberSymbolInBaseType(symbol, checker)) return false; // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: + case 159 /* Constructor */: + case 241 /* FunctionDeclaration */: return true; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 198 /* FunctionExpression */: + case 199 /* 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. var parameters = parent.parameters; var index = parameters.indexOf(p); - ts.Debug.assert(index !== -1); + ts.Debug.assert(index !== -1, "The parameter should already be in the list"); return isFixAll ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 73 /* Identifier */ && !p.symbol.isReferenced; }) : index === parameters.length - 1; } - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -119101,11 +120901,11 @@ var ts; function doChange(changes, sourceFile, start, length) { var token = ts.getTokenAtPosition(sourceFile, start); var statement = ts.findAncestor(token, ts.isStatement); - ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); + ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile), "token and statement should start at the same point"); 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 223 /* IfStatement */: + case 224 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -119116,15 +120916,15 @@ var ts; return; } // falls through - case 225 /* WhileStatement */: - case 226 /* ForStatement */: + case 226 /* WhileStatement */: + case 227 /* ForStatement */: changes.delete(sourceFile, container); return; } } if (ts.isBlock(statement.parent)) { var end_3 = start + length; - var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; })); + var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; }), "Some statement should be last"); changes.deleteNodeRange(sourceFile, statement, lastStatement); } else { @@ -119190,7 +120990,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 === 292 /* JSDocNullableType */) { + if (typeNode.kind === 293 /* 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)); @@ -119210,7 +121010,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 292 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 293 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -119227,22 +121027,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 213 /* AsExpression */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 240 /* FunctionDeclaration */: - case 159 /* GetAccessor */: - case 163 /* IndexSignature */: - case 182 /* MappedType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 195 /* TypeAssertionExpression */: - case 238 /* VariableDeclaration */: + case 214 /* AsExpression */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 241 /* FunctionDeclaration */: + case 160 /* GetAccessor */: + case 164 /* IndexSignature */: + case 183 /* MappedType */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 153 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 161 /* SetAccessor */: + case 244 /* TypeAliasDeclaration */: + case 196 /* TypeAssertionExpression */: + case 239 /* VariableDeclaration */: return true; default: return false; @@ -119271,12 +121071,15 @@ var ts; return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_async_modifier_to_containing_function, fixId, ts.Diagnostics.Add_all_missing_async_modifiers)]; }, fixIds: [fixId], - getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var nodes = getNodes(diag.file, diag.start); - if (!nodes) - return; - doChange(changes, context.sourceFile, nodes); - }); }, + getAllCodeActions: function (context) { + var seen = ts.createMap(); + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var nodes = getNodes(diag.file, diag.start); + if (!nodes || !ts.addToSeen(seen, ts.getNodeId(nodes.insertBefore))) + return; + doChange(changes, context.sourceFile, nodes); + }); + }, }); function getReturnType(expr) { if (expr.type) { @@ -119296,14 +121099,14 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: insertBefore = ts.findChildOfKind(containingFunction, 91 /* FunctionKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -119430,18 +121233,40 @@ var ts; var modifiers = visibilityModifier ? ts.createNodeArray([visibilityModifier]) : undefined; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var optional = !!(symbol.flags & 16777216 /* Optional */); + var ambient = !!(enclosingDeclaration.flags & 4194304 /* Ambient */); switch (declaration.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 154 /* PropertySignature */: - case 155 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 156 /* PropertyDeclaration */: var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); out(ts.createProperty( /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 156 /* MethodSignature */: - case 157 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: { + var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); + var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); + var orderedAccessors = allAccessors.secondAccessor + ? [allAccessors.firstAccessor, allAccessors.secondAccessor] + : [allAccessors.firstAccessor]; + for (var _i = 0, orderedAccessors_1 = orderedAccessors; _i < orderedAccessors_1.length; _i++) { + var accessor = orderedAccessors_1[_i]; + if (ts.isGetAccessorDeclaration(accessor)) { + out(ts.createGetAccessor( + /*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : createStubbedMethodBody(preferences))); + } + else { + ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter"); + var parameter = ts.getSetAccessorValueParameter(accessor); + var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined; + out(ts.createSetAccessor( + /*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : createStubbedMethodBody(preferences))); + } + } + break; + } + case 157 /* MethodSignature */: + case 158 /* 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 @@ -119454,23 +121279,25 @@ var ts; break; } if (declarations.length === 1) { - ts.Debug.assert(signatures.length === 1); + ts.Debug.assert(signatures.length === 1, "One declaration implies one signature"); var signature = signatures[0]; - outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); + outputMethod(signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(preferences)); break; } - for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { - var signature = signatures_1[_i]; + for (var _a = 0, signatures_1 = signatures; _a < signatures_1.length; _a++) { + var signature = signatures_1[_a]; // Need to ensure nodes are fresh each time so they can have different positions. outputMethod(signature, ts.getSynthesizedDeepClones(modifiers, /*includeTrivia*/ false), ts.getSynthesizedDeepClone(name, /*includeTrivia*/ false)); } - if (declarations.length > signatures.length) { - var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); - outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); - } - else { - ts.Debug.assert(declarations.length === signatures.length); - out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); + if (!ambient) { + if (declarations.length > signatures.length) { + var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); + outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); + } + else { + ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); + out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); + } } break; } @@ -119482,7 +121309,7 @@ var ts; } function signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body) { var program = context.program; - var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 157 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); + var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 158 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } @@ -119503,8 +121330,7 @@ var ts; return checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, /*flags*/ undefined, tracker); }); var names = ts.map(args, function (arg) { - return ts.isIdentifier(arg) ? arg.text : - ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; + return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; }); var contextualType = checker.getContextualType(call); var returnType = (inJs || !contextualType) ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); @@ -119658,7 +121484,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 192 /* CallExpression */ : 193 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 193 /* CallExpression */ : 194 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -119898,6 +121724,39 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "useBigintLiteral"; + var errorCodes = [ + ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span); }); + if (changes.length > 0) { + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_to_a_bigint_numeric_literal, fixId, ts.Diagnostics.Convert_all_to_bigint_numeric_literals)]; + } + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag); }); + }, + }); + function makeChange(changeTracker, sourceFile, span) { + var numericLiteral = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), ts.isNumericLiteral); + if (!numericLiteral) { + return; + } + // We use .getText to overcome parser inaccuracies: https://github.com/microsoft/TypeScript/issues/33298 + var newText = numericLiteral.getText(sourceFile) + "n"; + changeTracker.replaceNode(sourceFile, numericLiteral, ts.createBigIntLiteral(newText)); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -119919,8 +121778,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 93 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 184 /* ImportType */); + ts.Debug.assert(token.kind === 93 /* ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 185 /* ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -119973,7 +121832,7 @@ var ts; var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(134 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); - var intersectionType = ts.createIntersectionTypeNode(ts.getAllSuperTypeNodes(container).concat([ + var intersectionType = ts.createIntersectionTypeNode(__spreadArrays(ts.getAllSuperTypeNodes(container), [ mappedIntersectionType ], (otherMembers.length ? [ts.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); changes.replaceNode(sourceFile, container, createTypeAliasFromInterface(container, intersectionType)); @@ -120025,6 +121884,40 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "fixConvertConstToLet"; + var errorCodes = [ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, span = context.span, program = context.program; + var variableStatement = getVariableStatement(sourceFile, span.start, program); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, variableStatement); }); + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_const_to_let, fixId, ts.Diagnostics.Convert_const_to_let)]; + }, + fixIds: [fixId] + }); + function getVariableStatement(sourceFile, pos, program) { + var token = ts.getTokenAtPosition(sourceFile, pos); + var checker = program.getTypeChecker(); + var symbol = checker.getSymbolAtLocation(token); + if (symbol) { + return symbol.valueDeclaration.parent.parent; + } + } + function doChange(changes, sourceFile, variableStatement) { + if (!variableStatement) { + return; + } + var start = variableStatement.getStart(); + changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 5 }, "let"); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var refactor; (function (refactor) { @@ -120041,8 +121934,8 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context)), t, context.cancellationToken); }); + ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context), "context must have info"), t, context.cancellationToken); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; }, }); @@ -120062,16 +121955,16 @@ var ts; return undefined; } switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: { + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 246 /* ModuleDeclaration */: { var node = exportNode; return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } - case 220 /* VariableStatement */: { + case 221 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -120080,7 +121973,7 @@ var ts; var decl = ts.first(vs.declarationList.declarations); if (!decl.initializer) return undefined; - ts.Debug.assert(!wasDefault); + 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; } default: @@ -120094,40 +121987,40 @@ 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.assertDefined(ts.findModifier(exportNode, 81 /* DefaultKeyword */))); + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 81 /* DefaultKeyword */), "Should find a default keyword in modifier list")); } else { - var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 86 /* ExportKeyword */)); + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 86 /* ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(81 /* DefaultKeyword */)); break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: // If 'x' isn't used in this file, `export const x = 0;` --> `export default 0;` if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile)) { // We checked in `getInfo` that an initializer exists. - changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer))); + changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer, "Initializer was previously known to be present"))); break; } // falls through - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 246 /* ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.createExportDefault(ts.createIdentifier(exportName.text))); break; default: - ts.Debug.assertNever(exportNode); + ts.Debug.assertNever(exportNode, "Unexpected exportNode kind " + exportNode.kind); } } } function changeImports(program, _a, changes, cancellationToken) { var wasDefault = _a.wasDefault, exportName = _a.exportName, exportingModuleSymbol = _a.exportingModuleSymbol; var checker = program.getTypeChecker(); - var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName)); + var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName), "Export name should resolve to a symbol"); ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) { var importingSourceFile = ref.getSourceFile(); if (wasDefault) { @@ -120141,27 +122034,27 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: { + case 255 /* ImportSpecifier */: + case 259 /* 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 251 /* ImportClause */: { + case 252 /* ImportClause */: { var clause = parent; - ts.Debug.assert(clause.name === ref); + ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); var namedBindings = clause.namedBindings; if (!namedBindings) { // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); } - else if (namedBindings.kind === 252 /* NamespaceImport */) { + else if (namedBindings.kind === 253 /* 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 */; @@ -120182,11 +122075,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); break; - case 254 /* ImportSpecifier */: { + case 255 /* ImportSpecifier */: { // `import { foo } from "./a";` --> `import foo from "./a";` // `import { foo as bar } from "./a";` --> `import bar from "./a";` var defaultImport = ts.createIdentifier(parent.name.text); @@ -120199,7 +122092,7 @@ var ts; } break; } - case 258 /* ExportSpecifier */: { + case 259 /* 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";` @@ -120208,7 +122101,7 @@ var ts; break; } default: - ts.Debug.assertNever(parent); + ts.Debug.assertNever(parent, "Unexpected parent kind " + parent.kind); } } function makeImportSpecifier(propertyName, name) { @@ -120232,13 +122125,13 @@ var ts; var i = getImportToConvert(context); if (!i) return ts.emptyArray; - var description = i.kind === 252 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; - var actionName = i.kind === 252 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + var description = i.kind === 253 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 253 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); + ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context), "Context must provide an import to convert")); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; } }); @@ -120255,7 +122148,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 252 /* NamespaceImport */) { + if (toConvert.kind === 253 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -120276,7 +122169,7 @@ var ts; if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { conflictingNames.set(exportName, true); } - ts.Debug.assert(parent.expression === id); + ts.Debug.assert(parent.expression === id, "Parent expression should match id"); nodesToReplace.push(parent); } }); @@ -120315,7 +122208,7 @@ var ts; }); var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; var neededNamedImports = []; - var _loop_13 = function (element) { + var _loop_14 = function (element) { var propertyName = (element.propertyName || element.name).text; ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); @@ -120334,7 +122227,7 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_13(element); + _loop_14(element); } changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); if (neededNamedImports.length) { @@ -120455,6 +122348,7 @@ var ts; Messages.cannotExtractRange = createMessage("Cannot extract range."); Messages.cannotExtractImport = createMessage("Cannot extract import statement."); Messages.cannotExtractSuper = createMessage("Cannot extract super call."); + Messages.cannotExtractJSDoc = createMessage("Cannot extract JSDoc."); Messages.cannotExtractEmpty = createMessage("Cannot extract empty range."); Messages.expressionExpected = createMessage("expression expected."); Messages.uselessConstantType = createMessage("No reason to extract constant of type."); @@ -120546,6 +122440,9 @@ 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)] }; @@ -120598,20 +122495,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 155 /* PropertyDeclaration */) { + if (current.kind === 156 /* PropertyDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 152 /* Parameter */) { + else if (current.kind === 153 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 158 /* Constructor */) { + if (ctorOrMethod.kind === 159 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 157 /* MethodDeclaration */) { + else if (current.kind === 158 /* MethodDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -120629,9 +122526,9 @@ var ts; PermittedJumps[PermittedJumps["Return"] = 4] = "Return"; })(PermittedJumps || (PermittedJumps = {})); // We believe it's true because the node is from the (unmodified) tree. - ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (1)"); // For understanding how skipTrivia functioned: - ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (2)"); if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck))) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)]; } @@ -120654,7 +122551,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 238 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 239 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasModifier(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`! @@ -120666,13 +122563,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; case 99 /* 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 === 192 /* CallExpression */) { + if (node.parent.kind === 193 /* 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)) { @@ -120687,8 +122584,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -120700,20 +122597,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 223 /* IfStatement */: + case 224 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 236 /* TryStatement */: + case 237 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 219 /* Block */: - if (node.parent && node.parent.kind === 236 /* TryStatement */ && node.parent.finallyBlock === node) { + case 220 /* Block */: + if (node.parent && node.parent.kind === 237 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 272 /* CaseClause */: + case 273 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -120725,19 +122622,19 @@ var ts; break; } switch (node.kind) { - case 179 /* ThisType */: + case 180 /* ThisType */: case 101 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 234 /* LabeledStatement */: { + case 235 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: { + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -120746,20 +122643,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 230 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 231 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -120813,7 +122710,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 === 152 /* Parameter */) { + if (current.kind === 153 /* 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; } @@ -120824,7 +122721,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 285 /* SourceFile */) { + if (current.kind === 286 /* SourceFile */) { return scopes; } } @@ -120914,32 +122811,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: return "constructor"; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return "arrow function"; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return "method '" + scope.name.getText() + "'"; - case 159 /* GetAccessor */: + case 160 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: - throw ts.Debug.assertNever(scope); + throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 241 /* ClassDeclaration */ + return scope.kind === 242 /* 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 === 246 /* ModuleBlock */ + return scope.kind === 247 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -121043,8 +122940,8 @@ var ts; if (exposedVariableDeclarations.length && !writes) { // No need to mix declarations and writes. // How could any variables be exposed if there's a return statement? - ts.Debug.assert(!returnValueProperty); - ts.Debug.assert(!(range.facts & RangeFacts.HasReturn)); + ts.Debug.assert(!returnValueProperty, "Expected no returnValueProperty"); + ts.Debug.assert(!(range.facts & RangeFacts.HasReturn), "Expected RangeFacts.HasReturn flag to be unset"); if (exposedVariableDeclarations.length === 1) { // Declaring exactly one variable: let x = newFunction(); var variableDeclaration = exposedVariableDeclarations[0]; @@ -121112,7 +123009,7 @@ var ts; if (assignments.length === 1) { // We would only have introduced a return value property if there had been // other assignments to make. - ts.Debug.assert(!returnValueProperty); + ts.Debug.assert(!returnValueProperty, "Shouldn't have returnValueProperty here"); newNodes.push(ts.createStatement(ts.createAssignment(assignments[0].name, call))); if (range.facts & RangeFacts.HasReturn) { newNodes.push(ts.createReturn()); @@ -121169,6 +123066,7 @@ var ts; * Stores either a list of changes that should be applied to extract a range or a list of errors */ function extractConstantInScope(node, scope, _a, rangeFacts, context) { + var _b; var substitutions = _a.substitutions; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable @@ -121179,10 +123077,11 @@ var ts; ? undefined : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(node, substitutions); + (_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer); ts.suppressLeadingAndTrailingTrivia(initializer); var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); if (ts.isClassLike(scope)) { - ts.Debug.assert(!isJS); // See CannotExtractToJSClass + ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass var modifiers = []; modifiers.push(ts.createToken(114 /* PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { @@ -121217,7 +123116,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 222 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 223 /* 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.createVariableStatement( @@ -121236,7 +123135,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 222 /* ExpressionStatement */) { + if (node.parent.kind === 223 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -121250,6 +123149,63 @@ var ts; var renameFilename = node.getSourceFile().fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, localNameText, /*isDeclaredBeforeUse*/ true); return { renameFilename: renameFilename, renameLocation: renameLocation, edits: edits }; + function transformFunctionInitializerAndType(variableType, initializer) { + // If no contextual type exists there is nothing to transfer to the function signature + if (variableType === undefined) + return { variableType: variableType, initializer: initializer }; + // Only do this for function expressions and arrow functions that are not generic + if (!ts.isFunctionExpression(initializer) && !ts.isArrowFunction(initializer) || !!initializer.typeParameters) + return { variableType: variableType, initializer: initializer }; + var functionType = checker.getTypeAtLocation(node); + var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* Call */)); + // If no function signature, maybe there was an error, do nothing + if (!functionSignature) + return { variableType: variableType, initializer: initializer }; + // If the function signature has generic type parameters we don't attempt to move the parameters + if (!!functionSignature.getTypeParameters()) + return { variableType: variableType, initializer: initializer }; + // We add parameter types if needed + var parameters = []; + var hasAny = false; + for (var _i = 0, _a = initializer.parameters; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.type) { + parameters.push(p); + } + else { + var paramType = checker.getTypeAtLocation(p); + if (paramType === checker.getAnyType()) + hasAny = true; + parameters.push(ts.updateParameter(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NoTruncation */), p.initializer)); + } + } + // If a parameter was inferred as any we skip adding function parameters at all. + // Turning an implicit any (which under common settings is a error) to an explicit + // is probably actually a worse refactor outcome. + if (hasAny) + return { variableType: variableType, initializer: initializer }; + variableType = undefined; + if (ts.isArrowFunction(initializer)) { + initializer = ts.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); + } + else { + if (functionSignature && !!functionSignature.thisParameter) { + var firstParameter = ts.firstOrUndefined(parameters); + // If the function signature has a this parameter and if the first defined parameter is not the this parameter, we must add it + // Note: If this parameter was already there, it would have been previously updated with the type if not type was present + if ((!firstParameter || (ts.isIdentifier(firstParameter.name) && firstParameter.name.escapedText !== "this"))) { + var thisType = checker.getTypeOfSymbolAtLocation(functionSignature.thisParameter, node); + parameters.splice(0, 0, ts.createParameter( + /* decorators */ undefined, + /* modifiers */ undefined, + /* dotDotDotToken */ undefined, "this", + /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NoTruncation */))); + } + } + initializer = ts.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.body); + } + return { variableType: variableType, initializer: initializer }; + } } function getContainingVariableDeclarationIfInList(node, scope) { var prevNode; @@ -121323,7 +123279,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 231 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 232 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -121386,7 +123342,7 @@ var ts; } function getNodeToInsertPropertyBefore(maxPos, scope) { var members = scope.members; - ts.Debug.assert(members.length > 0); // There must be at least one child, since we extracted from one. + ts.Debug.assert(members.length > 0, "Found no members"); // There must be at least one child, since we extracted from one. var prevMember; var allProperties = true; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { @@ -121428,11 +123384,11 @@ var ts; } if (!prevStatement && ts.isCaseClause(curr)) { // We must have been in the expression of the case clause. - ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent)); + ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent), "Grandparent isn't a switch statement"); return curr.parent.parent; } // There must be at least one statement since we started in one. - return ts.Debug.assertDefined(prevStatement); + return ts.Debug.assertDefined(prevStatement, "prevStatement failed to get set"); } ts.Debug.assert(curr !== scope, "Didn't encounter a block-like before encountering scope"); } @@ -121501,7 +123457,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 240 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 241 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -121554,7 +123510,7 @@ var ts; // If we didn't get through all the scopes, then there were some that weren't in our // parent chain (impossible at time of writing). A conservative solution would be to // copy allTypeParameterUsages into all remaining scopes. - ts.Debug.assert(i_1 === scopes.length); + ts.Debug.assert(i_1 === scopes.length, "Should have iterated all scopes"); } // If there are any declarations in the extracted block that are used in the same enclosing // lexical scope, we can't move the extraction "up" as those declarations will become unreachable @@ -121564,7 +123520,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_14 = function (i) { + var _loop_15 = 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 @@ -121586,7 +123542,7 @@ var ts; } }); // If an expression was extracted, then there shouldn't have been any variable declarations. - ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0); + ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0, "No variable declarations expected if something was extracted"); if (hasWrite && !isReadonlyArray(targetRange.range)) { var diag = ts.createDiagnosticForNode(targetRange.range, Messages.cannotWriteInExpression); functionErrorsPerScope[i].push(diag); @@ -121604,7 +123560,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_14(i); + _loop_15(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -121817,30 +123773,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 279 /* EnumMember */: + case 280 /* EnumMember */: return false; } switch (node.kind) { case 10 /* StringLiteral */: - return parent.kind !== 250 /* ImportDeclaration */ && - parent.kind !== 254 /* ImportSpecifier */; - case 209 /* SpreadElement */: - case 185 /* ObjectBindingPattern */: - case 187 /* BindingElement */: + return parent.kind !== 251 /* ImportDeclaration */ && + parent.kind !== 255 /* ImportSpecifier */; + case 210 /* SpreadElement */: + case 186 /* ObjectBindingPattern */: + case 188 /* BindingElement */: return false; case 73 /* Identifier */: - return parent.kind !== 187 /* BindingElement */ && - parent.kind !== 254 /* ImportSpecifier */ && - parent.kind !== 258 /* ExportSpecifier */; + return parent.kind !== 188 /* BindingElement */ && + parent.kind !== 255 /* ImportSpecifier */ && + parent.kind !== 259 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 219 /* Block */: - case 285 /* SourceFile */: - case 246 /* ModuleBlock */: - case 272 /* CaseClause */: + case 220 /* Block */: + case 286 /* SourceFile */: + case 247 /* ModuleBlock */: + case 273 /* CaseClause */: return true; default: return false; @@ -121856,6 +123812,7 @@ var ts; (function (refactor) { var refactorName = "Extract type"; var extractToTypeAlias = "Extract to type alias"; + var extractToInterface = "Extract to interface"; var extractToTypeDef = "Extract to typedef"; refactor.registerRefactor(refactorName, { getAvailableActions: function (context) { @@ -121865,22 +123822,34 @@ var ts; return [{ name: refactorName, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_type), - actions: [info.isJS ? { + actions: info.isJS ? [{ name: extractToTypeDef, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_typedef) - } : { + }] : ts.append([{ name: extractToTypeAlias, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_type_alias) - }] + }], info.typeElements && { + name: extractToInterface, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_interface) + }) }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === extractToTypeAlias || actionName === extractToTypeDef); var file = context.file; - var info = ts.Debug.assertDefined(getRangeToExtract(context)); - ts.Debug.assert(actionName === extractToTypeAlias && !info.isJS || actionName === extractToTypeDef && info.isJS); + var info = ts.Debug.assertDefined(getRangeToExtract(context), "Expected to find a range to extract"); var name = ts.getUniqueName("NewType", file); - var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { return info.isJS ? - doTypedefChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters) : - doTypeAliasChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters); }); + var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { + switch (actionName) { + case extractToTypeAlias: + ts.Debug.assert(!info.isJS, "Invalid actionName/JS combo"); + return doTypeAliasChange(changes, file, name, info); + case extractToTypeDef: + ts.Debug.assert(info.isJS, "Invalid actionName/JS combo"); + return doTypedefChange(changes, file, name, info); + case extractToInterface: + ts.Debug.assert(!info.isJS && !!info.typeElements, "Invalid actionName/JS combo"); + return doInterfaceChange(changes, file, name, info); + default: + ts.Debug.fail("Unexpected action name"); + } + }); var renameFilename = file.fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, name, /*preferLastLocation*/ false); return { edits: edits, renameFilename: renameFilename, renameLocation: renameLocation }; @@ -121895,11 +123864,36 @@ var ts; if (!selection || !ts.isTypeNode(selection)) return undefined; var checker = context.program.getTypeChecker(); - var firstStatement = ts.Debug.assertDefined(isJS ? ts.findAncestor(selection, isStatementAndHasJSDoc) : ts.findAncestor(selection, ts.isStatement)); + var firstStatement = ts.Debug.assertDefined(isJS ? ts.findAncestor(selection, isStatementAndHasJSDoc) : ts.findAncestor(selection, ts.isStatement), "Should find a statement"); var typeParameters = collectTypeParameters(checker, selection, firstStatement, file); if (!typeParameters) return undefined; - return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters }; + var typeElements = flattenTypeLiteralNodeReference(checker, selection); + return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters, typeElements: typeElements }; + } + function flattenTypeLiteralNodeReference(checker, node) { + if (!node) + return undefined; + if (ts.isIntersectionTypeNode(node)) { + var result = []; + var seen_1 = ts.createMap(); + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var type = _a[_i]; + var flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type); + if (!flattenedTypeMembers || !flattenedTypeMembers.every(function (type) { return type.name && ts.addToSeen(seen_1, ts.getNameFromPropertyName(type.name)); })) { + return undefined; + } + ts.addRange(result, flattenedTypeMembers); + } + return result; + } + else if (ts.isParenthesizedTypeNode(node)) { + return flattenTypeLiteralNodeReference(checker, node.type); + } + else if (ts.isTypeLiteralNode(node)) { + return node.members; + } + return undefined; } function isStatementAndHasJSDoc(n) { return ts.isStatement(n) && ts.hasJSDocNodes(n); @@ -121936,7 +123930,7 @@ var ts; } else if (ts.isTypeQueryNode(node)) { if (ts.isIdentifier(node.exprName)) { - var symbol = checker.resolveName(node.exprName.text, node.exprName, 67220415 /* Value */, /* excludeGlobals */ false); + 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)) { return true; } @@ -121950,15 +123944,26 @@ var ts; return ts.forEachChild(node, visitor); } } - function doTypeAliasChange(changes, file, name, firstStatement, selection, typeParameters) { + function doTypeAliasChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; var newTypeNode = ts.createTypeAliasDeclaration( /* decorators */ undefined, /* modifiers */ undefined, name, typeParameters.map(function (id) { return ts.updateTypeParameterDeclaration(id, id.name, id.constraint, /* defaultType */ undefined); }), selection); changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); } - function doTypedefChange(changes, file, name, firstStatement, selection, typeParameters) { - var node = ts.createNode(311 /* JSDocTypedefTag */); + function doInterfaceChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters, typeElements = info.typeElements; + var newTypeNode = ts.createInterfaceDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, name, typeParameters, + /* heritageClauses */ undefined, typeElements); + changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); + changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); + } + function doTypedefChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; + var node = ts.createNode(313 /* JSDocTypedefTag */); node.tagName = ts.createIdentifier("typedef"); // TODO: jsdoc factory https://github.com/Microsoft/TypeScript/pull/29539 node.fullName = ts.createIdentifier(name); node.name = node.fullName; @@ -121966,10 +123971,10 @@ var ts; var templates = []; ts.forEach(typeParameters, function (typeParameter) { var constraint = ts.getEffectiveConstraintOfTypeParameter(typeParameter); - var template = ts.createNode(310 /* JSDocTemplateTag */); + var template = ts.createNode(312 /* JSDocTemplateTag */); template.tagName = ts.createIdentifier("template"); template.constraint = constraint && ts.cast(constraint, ts.isJSDocTypeExpression); - var parameter = ts.createNode(151 /* TypeParameter */); + var parameter = ts.createNode(152 /* TypeParameter */); parameter.name = typeParameter.name; template.typeParameters = ts.createNodeArray([parameter]); templates.push(template); @@ -122050,7 +124055,7 @@ var ts; return ts.isIdentifier(name) || ts.isStringLiteral(name); } function isAcceptedDeclaration(node) { - return ts.isParameterPropertyDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); + return ts.isParameterPropertyDeclaration(node, node.parent) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); } function createPropertyName(name, originalName) { return ts.isIdentifier(originalName) ? ts.createIdentifier(name) : ts.createLiteral(name); @@ -122083,7 +124088,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasReadonlyModifier(declaration), type: ts.getTypeAnnotationNode(declaration), - container: declaration.kind === 152 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 153 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -122129,11 +124134,9 @@ var ts; } } function insertAccessor(changeTracker, file, accessor, declaration, container) { - ts.isParameterPropertyDeclaration(declaration) - ? changeTracker.insertNodeAtClassStart(file, container, accessor) - : ts.isPropertyAssignment(declaration) - ? changeTracker.insertNodeAfterComma(file, declaration, accessor) - : changeTracker.insertNodeAfter(file, declaration, accessor); + ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.insertNodeAtClassStart(file, container, accessor) : + ts.isPropertyAssignment(declaration) ? changeTracker.insertNodeAfterComma(file, declaration, accessor) : + changeTracker.insertNodeAfter(file, declaration, accessor); } function updateReadonlyPropertyInitializerStatementConstructor(changeTracker, file, constructor, fieldName, originalName) { if (!constructor.body) @@ -122171,7 +124174,7 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Wrong refactor invoked"); var statements = ts.Debug.assertDefined(getStatementsToMove(context)); var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; @@ -122228,11 +124231,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return true; - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -122267,7 +124270,7 @@ var ts; deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker); deleteMovedStatements(oldFile, toMove.ranges, changes); updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName); - return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference).concat(addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); + return __spreadArrays(getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference), addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); } function deleteMovedStatements(sourceFile, moved, changes) { for (var _i = 0, moved_1 = moved; _i < moved_1.length; _i++) { @@ -122285,10 +124288,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_15 = function (sourceFile) { + var _loop_16 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_16 = function (statement) { + var _loop_17 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -122310,25 +124313,25 @@ var ts; }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_16(statement); + _loop_17(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_15(sourceFile); + _loop_16(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 252 /* NamespaceImport */ ? + case 251 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 253 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return node.name; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { @@ -122356,20 +124359,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function moduleSpecifierFromImport(i) { - return (i.kind === 250 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 249 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 251 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 250 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -122411,7 +124414,7 @@ var ts; return ts.makeImportIfNecessary(defaultImport, specifiers, path, quotePreference); } else { - ts.Debug.assert(!defaultImport); // If there's a default export, it should have been an es6 module. + ts.Debug.assert(!defaultImport, "No default import should exist"); // If there's a default export, it should have been an es6 module. var bindingElements = imports.map(function (i) { return ts.createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, i); }); return bindingElements.length ? makeVariableStatement(ts.createObjectBindingPattern(bindingElements), /*type*/ undefined, createRequireCall(ts.createLiteral(path))) @@ -122439,19 +124442,19 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: - ts.Debug.assertNever(importDecl); + ts.Debug.assertNever(importDecl, "Unexpected import decl kind " + importDecl.kind); } } function deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused) { @@ -122460,7 +124463,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 252 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 253 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -122470,9 +124473,9 @@ var ts; } if (namedBindings) { if (namedBindingsUnused) { - changes.delete(sourceFile, namedBindings); + changes.replaceNode(sourceFile, importDecl.importClause, ts.updateImportClause(importDecl.importClause, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 253 /* NamedImports */) { + else if (namedBindings.kind === 254 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -122490,9 +124493,9 @@ var ts; changes.delete(sourceFile, name); } break; - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: break; - case 185 /* ObjectBindingPattern */: + case 186 /* 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); } @@ -122566,7 +124569,7 @@ var ts; for (var _i = 0, toMove_1 = toMove; _i < toMove_1.length; _i++) { var statement = toMove_1[_i]; forEachTopLevelDeclaration(statement, function (decl) { - movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol)); + movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol, "Need a symbol here")); }); } for (var _a = 0, toMove_2 = toMove; _a < toMove_2.length; _a++) { @@ -122619,13 +124622,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: + case 250 /* ImportEqualsDeclaration */: + case 255 /* ImportSpecifier */: + case 252 /* ImportClause */: return true; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -122637,7 +124640,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 250 /* ImportDeclaration */: { + case 251 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -122647,18 +124650,18 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 238 /* VariableDeclaration */: { + case 239 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } default: - return ts.Debug.assertNever(i); + return ts.Debug.assertNever(i, "Unexpected import kind " + i.kind); } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 253 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -122670,9 +124673,9 @@ var ts; switch (name.kind) { case 73 /* Identifier */: return keep(name) ? name : undefined; - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: return name; - case 185 /* ObjectBindingPattern */: { + case 186 /* 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.createObjectBindingPattern(newElements) : undefined; @@ -122724,18 +124727,18 @@ var ts; return ts.isVariableDeclaration(node) ? node.parent.parent.parent : node.parent; } function isTopLevelDeclarationStatement(node) { - ts.Debug.assert(ts.isSourceFile(node.parent)); + ts.Debug.assert(ts.isSourceFile(node.parent), "Node parent should be a SourceFile"); return isNonVariableTopLevelDeclaration(node) || ts.isVariableStatement(node); } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 250 /* ImportEqualsDeclaration */: return true; default: return false; @@ -122743,17 +124746,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 250 /* ImportEqualsDeclaration */: return cb(statement); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 222 /* ExpressionStatement */: { + case 223 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -122765,11 +124768,11 @@ var ts; switch (name.kind) { case 73 /* Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); } } function nameOfTopLevelDeclaration(d) { @@ -122777,9 +124780,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return d.parent.parent; - case 187 /* BindingElement */: + case 188 /* BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -122812,48 +124815,48 @@ var ts; function addEs6Export(d) { var modifiers = ts.concatenate([ts.createModifier(86 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(d); + return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); } } function addCommonjsExport(decl) { - return [decl].concat(getNamesToExportInCommonJS(decl).map(createExportAssignment)); + return __spreadArrays([decl], getNamesToExportInCommonJS(decl).map(createExportAssignment)); } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 250 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 222 /* ExpressionStatement */: - return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` + case 223 /* 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); + return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); } } /** Creates `exports.x = x;` */ @@ -122981,7 +124984,7 @@ var ts; }]; } function getEditsForAction(context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Unexpected action name"); var file = context.file, startPosition = context.startPosition, program = context.program, cancellationToken = context.cancellationToken, host = context.host; var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker()); if (!functionDeclaration || !cancellationToken) @@ -123013,7 +125016,7 @@ var ts; function getGroupedReferences(functionDeclaration, program, cancellationToken) { var functionNames = getFunctionNames(functionDeclaration); var classNames = ts.isConstructorDeclaration(functionDeclaration) ? getClassNames(functionDeclaration) : []; - var names = ts.deduplicate(functionNames.concat(classNames), ts.equateValues); + var names = ts.deduplicate(__spreadArrays(functionNames, classNames), ts.equateValues); var checker = program.getTypeChecker(); var references = ts.flatMap(names, /*mapfn*/ function (/*mapfn*/ name) { return ts.FindAllReferences.getReferenceEntriesForNode(-1, name, program, program.getSourceFiles(), cancellationToken); }); var groupedReferences = groupReferences(references); @@ -123120,15 +125123,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -123138,7 +125141,7 @@ var ts; } break; // x["foo"](...) - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -123157,14 +125160,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -123206,11 +125209,11 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return isSingleImplementation(functionDeclaration, checker); - case 158 /* Constructor */: + case 159 /* Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -123218,8 +125221,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -123390,7 +125393,7 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; @@ -123398,7 +125401,7 @@ var ts; // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 81 /* DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -123409,30 +125412,30 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* 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.assertDefined(ts.findModifier(functionDeclaration, 81 /* DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return [functionDeclaration.name]; - case 158 /* Constructor */: + case 159 /* Constructor */: var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 125 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 210 /* ClassExpression */) { + if (functionDeclaration.parent.kind === 211 /* ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return [functionDeclaration.parent.name]; - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; default: - return ts.Debug.assertNever(functionDeclaration); + return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind " + functionDeclaration.kind); } } })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); @@ -123461,7 +125464,7 @@ var ts; this.kind = kind; } NodeObject.prototype.assertHasRealPosition = function (message) { - // tslint:disable-next-line:debug-assert + // eslint-disable-next-line debug-assert ts.Debug.assert(!ts.positionIsSynthesized(this.pos) && !ts.positionIsSynthesized(this.end), message || "Node must have a real position for this operation"); }; NodeObject.prototype.getSourceFile = function () { @@ -123518,8 +125521,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 289 /* FirstJSDocNode */ || kid.kind > 312 /* LastJSDocNode */; }); - return child.kind < 149 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 290 /* FirstJSDocNode */ || kid.kind > 314 /* LastJSDocNode */; }); + return child.kind < 150 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -123530,7 +125533,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 149 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 150 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -123588,7 +125591,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(313 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(315 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { @@ -123923,10 +125926,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -123946,31 +125949,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 169 /* TypeLiteral */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 245 /* EnumDeclaration */: + case 246 /* ModuleDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 259 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 252 /* ImportClause */: + case 253 /* NamespaceImport */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 170 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 152 /* Parameter */: + case 153 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // falls through - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: { + case 239 /* VariableDeclaration */: + case 188 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -123981,19 +125984,19 @@ var ts; } } // falls through - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 280 /* EnumMember */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: addDeclaration(node); break; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -124005,7 +126008,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 253 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -124014,7 +126017,7 @@ var ts; } } break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -124211,7 +126214,7 @@ var ts; return sourceFile; } ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; - ts.disableIncrementalParsing = false; + ts.disableIncrementalParsing = false; // eslint-disable-line prefer-const function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { // If we were given a text change range, and our version or open-ness changed, then // incrementally parse this file. @@ -124340,7 +126343,11 @@ var ts; function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { - throw new Error("Could not find sourceFile: '" + fileName + "' in " + (program && JSON.stringify(program.getSourceFiles().map(function (f) { return f.fileName; }))) + "."); + var error = new Error("Could not find source file: '" + fileName + "'."); + // We've been having trouble debugging this, so attach sidecar data for the tsserver log. + // See https://github.com/microsoft/TypeScript/issues/30180. + error.ProgramFiles = program.getSourceFiles().map(function (f) { return f.fileName; }); + throw error; } return sourceFile; } @@ -124409,11 +126416,21 @@ var ts; compilerHost.trace = function (message) { return host.trace(message); }; } if (host.resolveModuleNames) { - compilerHost.resolveModuleNames = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }; + compilerHost.resolveModuleNames = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveModuleNames.apply(host, args); + }; } if (host.resolveTypeReferenceDirectives) { - compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { - return host.resolveTypeReferenceDirectives(typeReferenceDirectiveNames, containingFile, redirectedReference); + compilerHost.resolveTypeReferenceDirectives = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveTypeReferenceDirectives.apply(host, args); }; } var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); @@ -124551,7 +126568,7 @@ var ts; } // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); - return semanticDiagnostics.concat(declarationDiagnostics); + return __spreadArrays(semanticDiagnostics, declarationDiagnostics); } function getSuggestionDiagnostics(fileName) { synchronizeHostData(); @@ -124559,12 +126576,12 @@ var ts; } function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); + return __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken)); } function getCompletionsAtPosition(fileName, position, options) { if (options === void 0) { options = ts.emptyOptions; } // Convert from deprecated options names to new names - var fullPreferences = __assign({}, ts.identity(options), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); + var fullPreferences = __assign(__assign({}, ts.identity(options)), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); synchronizeHostData(); return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter); } @@ -124622,12 +126639,12 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node); - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 191 /* PropertyAccessExpression */: + case 150 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); case 101 /* ThisKeyword */: - case 179 /* ThisType */: + case 180 /* ThisType */: case 99 /* SuperKeyword */: return true; default: @@ -124654,13 +126671,13 @@ var ts; } /// References and Occurrences function getOccurrencesAtPosition(fileName, position) { - return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */, isDefinition: false }, highlightSpan.isInString && { isInString: true }, highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); + return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */, isDefinition: false }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); } function getDocumentHighlights(fileName, position, filesToSearch) { var normalizedFileName = ts.normalizePath(fileName); ts.Debug.assert(filesToSearch.some(function (f) { return ts.normalizePath(f) === normalizedFileName; })); synchronizeHostData(); - var sourceFilesToSearch = filesToSearch.map(getValidSourceFile); + var sourceFilesToSearch = ts.mapDefined(filesToSearch, function (fileName) { return program.getSourceFile(fileName); }); var sourceFile = getValidSourceFile(fileName); return ts.DocumentHighlights.getDocumentHighlights(program, cancellationToken, sourceFile, position, sourceFilesToSearch); } @@ -124730,15 +126747,15 @@ var ts; return undefined; } switch (node.kind) { - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 191 /* PropertyAccessExpression */: + case 150 /* QualifiedName */: case 10 /* StringLiteral */: case 88 /* FalseKeyword */: case 103 /* TrueKeyword */: case 97 /* NullKeyword */: case 99 /* SuperKeyword */: case 101 /* ThisKeyword */: - case 179 /* ThisType */: + case 180 /* ThisType */: case 73 /* Identifier */: break; // Cant create the text span @@ -124755,7 +126772,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 === 245 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 246 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -125207,7 +127224,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 260 /* ExternalModuleReference */ || + node.parent.kind === 261 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -125224,13 +127241,13 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 150 /* ComputedPropertyName */) { + if (node.parent.kind === 151 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through case 73 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 189 /* ObjectLiteralExpression */ || node.parent.parent.kind === 269 /* JsxAttributes */) && + (node.parent.parent.kind === 190 /* ObjectLiteralExpression */ || node.parent.parent.kind === 270 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -125272,7 +127289,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 191 /* ElementAccessExpression */ && + node.parent.kind === 192 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -125352,114 +127369,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 239 /* VariableDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return spanInVariableDeclaration(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return spanInParameterDeclaration(node); - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 159 /* Constructor */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 219 /* Block */: + case 220 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return spanInBlock(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return spanInBlock(node.block); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 224 /* DoStatement */: + case 225 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 237 /* DebuggerStatement */: + case 238 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 223 /* IfStatement */: + case 224 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return spanInForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 236 /* TryStatement */: + case 237 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 187 /* BindingElement */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 188 /* BindingElement */: // span on complete node return textSpan(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 153 /* Decorator */: + case 154 /* Decorator */: return spanInNodeArray(parent.decorators); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: return undefined; // Tokens: case 26 /* SemicolonToken */: @@ -125489,7 +127506,7 @@ var ts; case 76 /* CatchKeyword */: case 89 /* FinallyKeyword */: return spanInNextNode(node); - case 148 /* OfKeyword */: + case 149 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -125502,13 +127519,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 === 73 /* Identifier */ || - node.kind === 209 /* SpreadElement */ || - node.kind === 276 /* PropertyAssignment */ || - node.kind === 277 /* ShorthandPropertyAssignment */) && + node.kind === 210 /* SpreadElement */ || + node.kind === 277 /* PropertyAssignment */ || + node.kind === 278 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 205 /* BinaryExpression */) { + if (node.kind === 206 /* 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 @@ -125530,22 +127547,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 224 /* DoStatement */: + case 225 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 153 /* Decorator */: + case 154 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 227 /* ForStatement */: + case 229 /* ForOfStatement */: return textSpan(node); - case 205 /* BinaryExpression */: + case 206 /* 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 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -125554,21 +127571,21 @@ var ts; } } switch (node.parent.kind) { - case 276 /* PropertyAssignment */: + case 277 /* 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 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: { + case 239 /* VariableDeclaration */: + case 153 /* 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)) { @@ -125576,7 +127593,7 @@ var ts; } break; } - case 205 /* BinaryExpression */: { + case 206 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -125606,7 +127623,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 227 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 228 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -125618,7 +127635,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 228 /* ForOfStatement */) { + parent.parent.kind === 229 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -125659,7 +127676,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 241 /* ClassDeclaration */ && functionDeclaration.kind !== 158 /* Constructor */); + (functionDeclaration.parent.kind === 242 /* ClassDeclaration */ && functionDeclaration.kind !== 159 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -125682,26 +127699,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } - // falls through // Set on parent if on same line otherwise on first statement - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 227 /* ForInStatement */: + // falls through + case 226 /* WhileStatement */: + case 224 /* IfStatement */: + case 228 /* 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 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 227 /* ForStatement */: + case 229 /* 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 === 239 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 240 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -125726,21 +127743,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 212 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 187 /* BindingElement */) { + if (bindingPattern.parent.kind === 188 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 186 /* ArrayBindingPattern */ && node.kind !== 185 /* ObjectBindingPattern */); - var elements = node.kind === 188 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 187 /* ArrayBindingPattern */ && node.kind !== 186 /* ObjectBindingPattern */); + var elements = node.kind === 189 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 212 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -125748,18 +127765,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 === 205 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 206 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -125767,25 +127784,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 246 /* ModuleBlock */: + case 247 /* 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 244 /* EnumDeclaration */: - case 241 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 242 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 219 /* Block */: + case 220 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 275 /* CatchClause */: + case 276 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -125793,7 +127810,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 185 /* ObjectBindingPattern */: + case 186 /* 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); @@ -125809,7 +127826,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 186 /* ArrayBindingPattern */: + case 187 /* 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); @@ -125824,12 +127841,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 224 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 192 /* CallExpression */ || - node.parent.kind === 193 /* NewExpression */) { + if (node.parent.kind === 225 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 193 /* CallExpression */ || + node.parent.kind === 194 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 196 /* ParenthesizedExpression */) { + if (node.parent.kind === 197 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -125838,21 +127855,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 196 /* ParenthesizedExpression */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 159 /* Constructor */: + case 226 /* WhileStatement */: + case 225 /* DoStatement */: + case 227 /* ForStatement */: + case 229 /* ForOfStatement */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 197 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -125862,20 +127879,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ || - node.parent.kind === 152 /* Parameter */) { + node.parent.kind === 277 /* PropertyAssignment */ || + node.parent.kind === 153 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 195 /* TypeAssertionExpression */) { + if (node.parent.kind === 196 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 224 /* DoStatement */) { + if (node.parent.kind === 225 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -125883,7 +127900,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.kind === 229 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -125928,10 +127945,9 @@ var ts; // limitations under the License. // /* @internal */ -var debugObjectHost = (function () { return this; })(); +var debugObjectHost = (function () { return this; })(); // eslint-disable-line prefer-const // We need to use 'null' to interface with the managed side. -/* tslint:disable:no-null-keyword */ -/* tslint:disable:no-in-operator */ +/* eslint-disable no-in-operator */ /* @internal */ var ts; (function (ts) { @@ -125953,9 +127969,11 @@ var ts; ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + /* eslint-disable no-null/no-null */ if (encoded === null) { return null; // TODO: GH#18217 } + /* eslint-enable no-null/no-null */ var decoded = JSON.parse(encoded); // TODO: GH#18217 return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); }; @@ -126026,6 +128044,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); + // eslint-disable-next-line no-null/no-null if (settingsJson === null || settingsJson === "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } @@ -126054,6 +128073,7 @@ var ts; return this.shimHost.getScriptVersion(fileName); }; LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { + /* eslint-disable no-null/no-null */ var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); if (diagnosticMessagesJson === null || diagnosticMessagesJson === "") { return null; @@ -126065,6 +128085,7 @@ var ts; this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); return null; } + /* eslint-enable no-null/no-null */ }; LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { var hostCancellationToken = this.shimHost.getCancellationToken(); @@ -126208,13 +128229,13 @@ var ts; LanguageServiceShimObject.prototype.dispose = function (dummy) { this.logger.log("dispose()"); this.languageService.dispose(); - this.languageService = null; + this.languageService = null; // eslint-disable-line no-null/no-null // force a GC if (debugObjectHost && debugObjectHost.CollectGarbage) { debugObjectHost.CollectGarbage(); this.logger.log("CollectGarbage()"); } - this.logger = null; + this.logger = null; // eslint-disable-line no-null/no-null _super.prototype.dispose.call(this, dummy); }; /// REFRESH @@ -126222,13 +128243,14 @@ var ts; * Update the list of scripts known to the compiler */ LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); + this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; } // eslint-disable-line no-null/no-null + ); }; LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { var _this = this; this.forwardJSONCall("cleanupSemanticCache()", function () { _this.languageService.cleanupSemanticCache(); - return null; + return null; // eslint-disable-line no-null/no-null }); }; LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { @@ -126599,7 +128621,7 @@ var ts; typeAcquisition: configFile.typeAcquisition, files: configFile.fileNames, raw: configFile.raw, - errors: realizeDiagnostics(result.parseDiagnostics.concat(configFile.errors), "\r\n") + errors: realizeDiagnostics(__spreadArrays(result.parseDiagnostics, configFile.errors), "\r\n") }; }); }; @@ -126686,8 +128708,7 @@ var ts; module.exports = ts; } })(ts || (ts = {})); -/* tslint:enable:no-in-operator */ -/* tslint:enable:no-null */ +/* eslint-enable no-in-operator */ /// TODO: this is used by VS, clean this up on both sides of the interface /* @internal */ var TypeScript; @@ -126706,7 +128727,6 @@ var ts; (function (ts) { var server; (function (server) { - // tslint:disable variable-name server.ActionSet = "action::set"; server.ActionInvalidate = "action::invalidate"; server.ActionPackageInstalled = "action::packageInstalled"; @@ -127187,11 +129207,13 @@ var ts; } }; ThrottledOperations.run = function (self, operationId, cb) { + ts.perfLogger.logStartScheduledOperation(operationId); self.pendingTimeouts.delete(operationId); if (self.logger) { self.logger.info("Running: " + operationId); } cb(); + ts.perfLogger.logStopScheduledOperation(); }; return ThrottledOperations; }()); @@ -127211,6 +129233,7 @@ var ts; }; GcTimer.run = function (self) { self.timerId = undefined; + ts.perfLogger.logStartScheduledOperation("GC collect"); var log = self.logger.hasLevel(server.LogLevel.requestTime); var before = log && self.host.getMemoryUsage(); // TODO: GH#18217 self.host.gc(); // TODO: GH#18217 @@ -127218,6 +129241,7 @@ var ts; var after = self.host.getMemoryUsage(); // TODO: GH#18217 self.logger.perftrc("GC::before " + before + ", after " + after); } + ts.perfLogger.logStopScheduledOperation(); }; return GcTimer; }()); @@ -127266,7 +129290,7 @@ var ts; WatchType["MissingGeneratedFile"] = "Missing generated file"; })(WatchType = ts.WatchType || (ts.WatchType = {})); })(ts || (ts = {})); -// tslint:disable no-unnecessary-qualifier +/* eslint-disable @typescript-eslint/no-unnecessary-qualifier */ /** * Declaration module describing the TypeScript Server protocol */ @@ -127869,14 +129893,14 @@ var ts; ts.assign(this.formatSettings, formatSettings); } else { - this.formatSettings = __assign({}, this.formatSettings, formatSettings); + this.formatSettings = __assign(__assign({}, this.formatSettings), formatSettings); } } if (preferences) { if (!this.preferences) { this.preferences = ts.emptyOptions; } - this.preferences = __assign({}, this.preferences, preferences); + this.preferences = __assign(__assign({}, this.preferences), preferences); } }; ScriptInfo.prototype.getLatestVersion = function () { @@ -128254,7 +130278,7 @@ var ts; return this.typingsCache.isKnownTypesPackageName(name); }; Project.prototype.installPackage = function (options) { - return this.typingsCache.installPackage(__assign({}, options, { projectName: this.projectName, projectRootPath: this.toPath(this.currentDirectory) })); + return this.typingsCache.installPackage(__assign(__assign({}, options), { projectName: this.projectName, projectRootPath: this.toPath(this.currentDirectory) })); }; Object.defineProperty(Project.prototype, "typingsCache", { get: function () { @@ -128500,7 +130524,7 @@ var ts; // Nothing to filter out, so just return as-is return newTypeAcquisition; } - return __assign({}, newTypeAcquisition, { include: this.removeExistingTypings(newTypeAcquisition.include) }); + return __assign(__assign({}, newTypeAcquisition), { include: this.removeExistingTypings(newTypeAcquisition.include) }); }; Project.prototype.getExternalFiles = function () { var _this = this; @@ -128738,6 +130762,7 @@ var ts; * @returns: true if set of files in the project stays the same and false - otherwise. */ Project.prototype.updateGraph = function () { + ts.perfLogger.logStartUpdateGraph(); this.resolutionCache.startRecordingFilesWithChangedResolutions(); var hasNewProgram = this.updateGraphWorker(); var hasAddedorRemovedFiles = this.hasAddedorRemovedFiles; @@ -128768,6 +130793,7 @@ var ts; if (hasNewProgram) { this.projectProgramVersion++; } + ts.perfLogger.logStopUpdateGraph(); return !hasNewProgram; }; /*@internal*/ @@ -128868,9 +130894,12 @@ var ts; }, function (removed) { return _this.detachScriptInfoFromProject(removed); }); var elapsed = ts.timestamp() - start; this.writeLog("Finishing updateGraphWorker: Project: " + this.getProjectName() + " Version: " + this.getProjectVersion() + " structureChanged: " + hasNewProgram + " Elapsed: " + elapsed + "ms"); - if (this.program !== oldProgram) { + if (this.hasAddedorRemovedFiles) { this.print(); } + else if (this.program !== oldProgram) { + this.writeLog("Different program with same set of files:: oldProgram.structureIsReused:: " + (oldProgram && oldProgram.structureIsReused)); + } return hasNewProgram; }; Project.prototype.detachScriptInfoFromProject = function (uncheckedFileName, noRemoveResolution) { @@ -129057,7 +131086,7 @@ var ts; } // Search our peer node_modules, then any globally-specified probe paths // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/ - var searchPaths = [ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")].concat(this.projectService.pluginProbeLocations); + var searchPaths = __spreadArrays([ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")], this.projectService.pluginProbeLocations); if (this.projectService.globalPlugins) { var _loop_1 = function (globalPluginName) { // Skip empty names from odd commandline parses @@ -129105,7 +131134,7 @@ var ts; Project.prototype.enableProxy = function (pluginModuleFactory, configEntry) { try { if (typeof pluginModuleFactory !== "function") { - this.projectService.logger.info("Skipped loading plugin " + configEntry.name + " because it did expose a proper factory function"); + this.projectService.logger.info("Skipped loading plugin " + configEntry.name + " because it did not expose a proper factory function"); return; } var info = { @@ -129119,6 +131148,7 @@ var ts; var newLS = pluginModule.create(info); for (var _i = 0, _a = Object.keys(this.languageService); _i < _a.length; _i++) { var k = _a[_i]; + // eslint-disable-next-line no-in-operator if (!(k in newLS)) { this.projectService.logger.info("Plugin activation warning: Missing proxied method " + k + " in created LS. Patching."); newLS[k] = this.languageService[k]; @@ -129339,7 +131369,7 @@ var ts; } // Search our peer node_modules, then any globally-specified probe paths // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/ - var searchPaths = [ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")].concat(this.projectService.pluginProbeLocations); + var searchPaths = __spreadArrays([ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")], this.projectService.pluginProbeLocations); if (this.projectService.allowLocalPluginLoads) { var local = ts.getDirectoryPath(this.canonicalConfigFilePath); this.projectService.logger.info("Local plugin loading enabled; adding " + local + " to search paths"); @@ -129490,7 +131520,6 @@ var ts; server.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; /*@internal*/ server.maxFileSize = 4 * 1024 * 1024; - // tslint:disable variable-name server.ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground"; server.ProjectLoadingStartEvent = "projectLoadingStart"; server.ProjectLoadingFinishEvent = "projectLoadingFinish"; @@ -130060,7 +132089,7 @@ var ts; }; ProjectService.prototype.getPreferences = function (file) { var info = this.getScriptInfoForNormalizedPath(file); - return __assign({}, this.hostConfiguration.preferences, info && info.getPreferences()); + return __assign(__assign({}, this.hostConfiguration.preferences), info && info.getPreferences()); }; ProjectService.prototype.getHostFormatCodeOptions = function () { return this.hostConfiguration.formatCodeOptions; @@ -130824,7 +132853,7 @@ var ts; } project.enablePluginsWithOptions(compilerOptions, this.currentPluginConfigOverrides); var filesToAdd = parsedCommandLine.fileNames.concat(project.getExternalFiles()); - this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave); // TODO: GH#18217 + this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave); }; ProjectService.prototype.updateNonInferredProjectFiles = function (project, files, propertyReader) { var projectRootFilesMap = project.getRootFilesMap(); @@ -131375,12 +133404,12 @@ var ts; this.logger.info("Host information " + args.hostInfo); } if (args.formatOptions) { - this.hostConfiguration.formatCodeOptions = __assign({}, this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); + this.hostConfiguration.formatCodeOptions = __assign(__assign({}, this.hostConfiguration.formatCodeOptions), convertFormatOptions(args.formatOptions)); this.logger.info("Format host information updated"); } if (args.preferences) { var lazyConfiguredProjectsFromExternalProject = this.hostConfiguration.preferences.lazyConfiguredProjectsFromExternalProject; - this.hostConfiguration.preferences = __assign({}, this.hostConfiguration.preferences, args.preferences); + this.hostConfiguration.preferences = __assign(__assign({}, this.hostConfiguration.preferences), args.preferences); if (lazyConfiguredProjectsFromExternalProject && !this.hostConfiguration.preferences.lazyConfiguredProjectsFromExternalProject) { // Load configured projects for external projects that are pending reload this.configuredProjects.forEach(function (project) { @@ -131582,6 +133611,7 @@ var ts; var configFileName; var configFileErrors; var project = this.findExternalProjectContainingOpenScriptInfo(info); + var defaultConfigProject; if (!project && !this.syntaxOnly) { // Checking syntaxOnly is an optimization configFileName = this.getConfigFileNameForFile(info); if (configFileName) { @@ -131602,6 +133632,7 @@ var ts; // Ensure project is ready to check if it contains opened script info updateProjectIfDirty(project); } + defaultConfigProject = project; } } // Project we have at this point is going to be updated since its either found through @@ -131618,12 +133649,12 @@ var ts; this.assignOrphanScriptInfoToInferredProject(info, this.openFiles.get(info.path)); } ts.Debug.assert(!info.isOrphan()); - return { configFileName: configFileName, configFileErrors: configFileErrors }; + return { configFileName: configFileName, configFileErrors: configFileErrors, defaultConfigProject: defaultConfigProject }; }; - ProjectService.prototype.cleanupAfterOpeningFile = function () { + ProjectService.prototype.cleanupAfterOpeningFile = function (toRetainConfigProjects) { // This was postponed from closeOpenFile to after opening next file, // so that we can reuse the project if we need to right away - this.removeOrphanConfiguredProjects(); + this.removeOrphanConfiguredProjects(toRetainConfigProjects); // Remove orphan inferred projects now that we have reused projects // We need to create a duplicate because we cant guarantee order after removal for (var _i = 0, _a = this.inferredProjects.slice(); _i < _a.length; _i++) { @@ -131637,25 +133668,33 @@ var ts; // It was then postponed to cleanup these script infos so that they can be reused if // the file from that old project is reopened because of opening file from here. this.removeOrphanScriptInfos(); - this.printProjects(); }; ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent, projectRootPath) { var info = this.getOrCreateOpenScriptInfo(fileName, fileContent, scriptKind, hasMixedContent, projectRootPath); - var result = this.assignProjectToOpenedScriptInfo(info); - this.cleanupAfterOpeningFile(); + var _a = this.assignProjectToOpenedScriptInfo(info), defaultConfigProject = _a.defaultConfigProject, result = __rest(_a, ["defaultConfigProject"]); + this.cleanupAfterOpeningFile(defaultConfigProject); this.telemetryOnOpenFile(info); + this.printProjects(); return result; }; - ProjectService.prototype.removeOrphanConfiguredProjects = function () { + ProjectService.prototype.removeOrphanConfiguredProjects = function (toRetainConfiguredProjects) { var _this = this; var toRemoveConfiguredProjects = ts.cloneMap(this.configuredProjects); + if (toRetainConfiguredProjects) { + if (ts.isArray(toRetainConfiguredProjects)) { + toRetainConfiguredProjects.forEach(retainConfiguredProject); + } + else { + retainConfiguredProject(toRetainConfiguredProjects); + } + } // Do not remove configured projects that are used as original projects of other this.inferredProjects.forEach(markOriginalProjectsAsUsed); this.externalProjects.forEach(markOriginalProjectsAsUsed); this.configuredProjects.forEach(function (project) { // If project has open ref (there are more than zero references from external project/open file), keep it alive as well as any project it references if (project.hasOpenRef()) { - toRemoveConfiguredProjects.delete(project.canonicalConfigFilePath); + retainConfiguredProject(project); markOriginalProjectsAsUsed(project); } else { @@ -131664,7 +133703,7 @@ var ts; if (ref) { var refProject = _this.configuredProjects.get(ref.sourceFile.path); if (refProject && refProject.hasOpenRef()) { - toRemoveConfiguredProjects.delete(project.canonicalConfigFilePath); + retainConfiguredProject(project); } } }); @@ -131677,6 +133716,9 @@ var ts; project.originalConfiguredProjects.forEach(function (_value, configuredProjectPath) { return toRemoveConfiguredProjects.delete(configuredProjectPath); }); } } + function retainConfiguredProject(project) { + toRemoveConfiguredProjects.delete(project.canonicalConfigFilePath); + } }; ProjectService.prototype.removeOrphanScriptInfos = function () { var _this = this; @@ -131804,18 +133846,24 @@ var ts; } } // All the script infos now exist, so ok to go update projects for open files + var defaultConfigProjects; if (openScriptInfos) { - openScriptInfos.forEach(function (info) { return _this.assignProjectToOpenedScriptInfo(info); }); + defaultConfigProjects = ts.mapDefined(openScriptInfos, function (info) { return _this.assignProjectToOpenedScriptInfo(info).defaultConfigProject; }); } // While closing files there could be open files that needed assigning new inferred projects, do it now if (assignOrphanScriptInfosToInferredProject) { this.assignOrphanScriptInfosToInferredProject(); } - // Cleanup projects - this.cleanupAfterOpeningFile(); - // Telemetry - ts.forEach(openScriptInfos, function (info) { return _this.telemetryOnOpenFile(info); }); - this.printProjects(); + if (openScriptInfos) { + // Cleanup projects + this.cleanupAfterOpeningFile(defaultConfigProjects); + // Telemetry + openScriptInfos.forEach(function (info) { return _this.telemetryOnOpenFile(info); }); + this.printProjects(); + } + else if (ts.length(closedFiles)) { + this.printProjects(); + } }; /* @internal */ ProjectService.prototype.applyChangesToFile = function (scriptInfo, changes) { @@ -132187,6 +134235,9 @@ var ts; } return false; } + function dtsChangeCanAffectEmit(compilationSettings) { + return ts.getEmitDeclarations(compilationSettings) || !!compilationSettings.emitDecoratorMetadata; + } function formatDiag(fileName, project, diag) { var scriptInfo = project.getScriptInfoForNormalizedPath(fileName); // TODO: GH#18217 return { @@ -132239,12 +134290,12 @@ var ts; relatedInformation: ts.map(diag.relatedInformation, formatRelatedInformation), }; return includeFileName - ? __assign({}, common, { fileName: diag.file && diag.file.fileName }) : common; + ? __assign(__assign({}, common), { fileName: diag.file && diag.file.fileName }) : common; } function allEditsBeforePos(edits, pos) { return edits.every(function (edit) { return ts.textSpanEnd(edit.span) < pos; }); } - server.CommandNames = server.protocol.CommandTypes; // tslint:disable-line variable-name + server.CommandNames = server.protocol.CommandTypes; function formatMessage(msg, logger, byteLength, newLine) { var verboseLogging = logger.hasLevel(server.LogLevel.verbose); var json = JSON.stringify(msg); @@ -132403,7 +134454,7 @@ var ts; var _loop_8 = function (outputReferencedSymbol) { var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(outputReferencedSymbol.definition)); var definition = mappedDefinitionFile === undefined ? - outputReferencedSymbol.definition : __assign({}, outputReferencedSymbol.definition, { textSpan: ts.createTextSpan(mappedDefinitionFile.pos, outputReferencedSymbol.definition.textSpan.length), fileName: mappedDefinitionFile.fileName, contextSpan: getMappedContextSpan(outputReferencedSymbol.definition, project) }); + outputReferencedSymbol.definition : __assign(__assign({}, outputReferencedSymbol.definition), { textSpan: ts.createTextSpan(mappedDefinitionFile.pos, outputReferencedSymbol.definition.textSpan.length), fileName: mappedDefinitionFile.fileName, contextSpan: getMappedContextSpan(outputReferencedSymbol.definition, project) }); var symbolToAddTo = ts.find(outputs, function (o) { return ts.documentSpansEqual(o.definition, definition); }); if (!symbolToAddTo) { symbolToAddTo = { definition: definition, references: [] }; @@ -132533,8 +134584,8 @@ var ts; } var Session = /** @class */ (function () { function Session(opts) { - var _this = this; var _a; + var _this = this; this.changeSeq = 0; this.handlers = ts.createMapFromTemplate((_a = {}, _a[server.CommandNames.Status] = function () { @@ -133001,9 +135052,10 @@ var ts; msg += "\n\nFile text of " + fileRequest.file + ":" + server.indent(text) + "\n"; } } - catch (_b) { } // tslint:disable-line no-empty + catch (_b) { } // eslint-disable-line no-empty } - if (err.message && err.message.indexOf("Could not find sourceFile:") !== -1) { + if (err.ProgramFiles) { + msg += "\n\nProgram files: " + JSON.stringify(err.ProgramFiles) + "\n"; msg += "\n\nProjects::\n"; var counter_1 = 0; var addProjectInfo = function (project) { @@ -133026,7 +135078,9 @@ var ts; } return; } - this.host.write(formatMessage(msg, this.logger, this.byteLength, this.host.newLine)); + var msgText = formatMessage(msg, this.logger, this.byteLength, this.host.newLine); + ts.perfLogger.logEvent("Response message size: " + msgText.length); + this.host.write(msgText); }; Session.prototype.event = function (body, eventName) { this.send(toEvent(eventName, body)); @@ -133245,7 +135299,7 @@ var ts; Session.prototype.mapDefinitionInfoLocations = function (definitions, project) { return definitions.map(function (info) { var newDocumentSpan = getMappedDocumentSpan(info, project); - return !newDocumentSpan ? info : __assign({}, newDocumentSpan, { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }); + return !newDocumentSpan ? info : __assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }); }); }; Session.prototype.getDefinitionAndBoundSpan = function (args, simplifiedResult) { @@ -133290,7 +135344,7 @@ var ts; Session.mapToOriginalLocation = function (def) { if (def.originalFileName) { ts.Debug.assert(def.originalTextSpan !== undefined, "originalTextSpan should be present if originalFileName is"); - return __assign({}, def, { fileName: def.originalFileName, textSpan: def.originalTextSpan, targetFileName: def.fileName, targetTextSpan: def.textSpan, contextSpan: def.originalContextSpan, targetContextSpan: def.contextSpan }); + return __assign(__assign({}, def), { fileName: def.originalFileName, textSpan: def.originalTextSpan, targetFileName: def.fileName, targetTextSpan: def.textSpan, contextSpan: def.originalContextSpan, targetContextSpan: def.contextSpan }); } return def; }; @@ -133307,7 +135361,7 @@ var ts; Session.prototype.toFileSpanWithContext = function (fileName, textSpan, contextSpan, project) { var fileSpan = this.toFileSpan(fileName, textSpan, project); var context = contextSpan && this.toFileSpan(fileName, contextSpan, project); - return context ? __assign({}, fileSpan, { contextStart: context.start, contextEnd: context.end }) : + return context ? __assign(__assign({}, fileSpan), { contextStart: context.start, contextEnd: context.end }) : fileSpan; }; Session.prototype.getTypeDefinition = function (args) { @@ -133319,7 +135373,7 @@ var ts; Session.prototype.mapImplementationLocations = function (implementations, project) { return implementations.map(function (info) { var newDocumentSpan = getMappedDocumentSpan(info, project); - return !newDocumentSpan ? info : __assign({}, newDocumentSpan, { kind: info.kind, displayParts: info.displayParts }); + return !newDocumentSpan ? info : __assign(__assign({}, newDocumentSpan), { kind: info.kind, displayParts: info.displayParts }); }); }; Session.prototype.getImplementation = function (args, simplifiedResult) { @@ -133342,7 +135396,7 @@ var ts; occurrences.map(function (occurrence) { var fileName = occurrence.fileName, isWriteAccess = occurrence.isWriteAccess, textSpan = occurrence.textSpan, isInString = occurrence.isInString, contextSpan = occurrence.contextSpan; var scriptInfo = project.getScriptInfo(fileName); - return __assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo), { file: fileName, isWriteAccess: isWriteAccess }, (isInString ? { isInString: isInString } : undefined)); + return __assign(__assign(__assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo)), { file: fileName, isWriteAccess: isWriteAccess }), (isInString ? { isInString: isInString } : undefined)); }) : server.emptyArray; }; @@ -133391,7 +135445,7 @@ var ts; file: fileName, highlightSpans: highlightSpans.map(function (_a) { var textSpan = _a.textSpan, kind = _a.kind, contextSpan = _a.contextSpan; - return (__assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo), { kind: kind })); + return (__assign(__assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo)), { kind: kind })); }) }; }); @@ -133486,7 +135540,7 @@ var ts; if (!group_1) map.set(fileName, group_1 = { file: fileName, locs: [] }); var scriptInfo = ts.Debug.assertDefined(this.projectService.getScriptInfo(fileName)); - group_1.locs.push(__assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo), prefixSuffixText)); + group_1.locs.push(__assign(__assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo)), prefixSuffixText)); } return ts.arrayFrom(map.values()); }; @@ -133512,7 +135566,7 @@ var ts; var span = toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo); var lineSpan = scriptInfo.lineToTextSpan(span.start.line - 1); var lineText = scriptInfo.getSnapshot().getText(lineSpan.start, ts.textSpanEnd(lineSpan)).replace(/\r|\n/g, ""); - return __assign({ file: fileName }, span, { lineText: lineText, + return __assign(__assign({ file: fileName }, span), { lineText: lineText, isWriteAccess: isWriteAccess, isDefinition: isDefinition }); }); @@ -133714,7 +135768,7 @@ var ts; var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; var scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file); var position = this.getPosition(args, scriptInfo); - var completions = project.getLanguageService().getCompletionsAtPosition(file, position, __assign({}, server.convertUserPreferences(this.getPreferences(file)), { triggerCharacter: args.triggerCharacter, includeExternalModuleExports: args.includeExternalModuleExports, includeInsertTextCompletions: args.includeInsertTextCompletions })); + var completions = project.getLanguageService().getCompletionsAtPosition(file, position, __assign(__assign({}, server.convertUserPreferences(this.getPreferences(file))), { triggerCharacter: args.triggerCharacter, includeExternalModuleExports: args.includeExternalModuleExports, includeInsertTextCompletions: args.includeInsertTextCompletions })); if (completions === undefined) return undefined; if (kind === "completions-full" /* CompletionsFull */) @@ -133733,7 +135787,7 @@ var ts; entries.metadata = completions.metadata; return entries; } - var res = __assign({}, completions, { entries: entries }); + var res = __assign(__assign({}, completions), { entries: entries }); return res; }; Session.prototype.getCompletionEntryDetails = function (args, simplifiedResult) { @@ -133747,7 +135801,7 @@ var ts; return project.getLanguageService().getCompletionEntryDetails(file, position, name, formattingOptions, source, _this.getPreferences(file)); }); return simplifiedResult - ? result.map(function (details) { return (__assign({}, details, { codeActions: ts.map(details.codeActions, function (action) { return _this.mapCodeAction(action); }) })); }) + ? result.map(function (details) { return (__assign(__assign({}, details), { codeActions: ts.map(details.codeActions, function (action) { return _this.mapCodeAction(action); }) })); }) : result; }; Session.prototype.getCompileOnSaveAffectedFileList = function (args) { @@ -133758,15 +135812,19 @@ var ts; return server.emptyArray; } return combineProjectOutput(info, function (path) { return _this.projectService.getScriptInfoForPath(path); }, projects, function (project, info) { - var result; - if (project.compileOnSaveEnabled && project.languageServiceEnabled && !project.isOrphan() && !project.getCompilationSettings().noEmit) { - result = { - projectFileName: project.getProjectName(), - fileNames: project.getCompileOnSaveAffectedFileList(info), - projectUsesOutFile: !!project.getCompilationSettings().outFile || !!project.getCompilationSettings().out - }; + if (!project.compileOnSaveEnabled || !project.languageServiceEnabled || project.isOrphan()) { + return undefined; } - return result; + var compilationSettings = project.getCompilationSettings(); + if (!!compilationSettings.noEmit || ts.fileExtensionIs(info.fileName, ".d.ts" /* Dts */) && !dtsChangeCanAffectEmit(compilationSettings)) { + // avoid triggering emit when a change is made in a .d.ts when declaration emit and decorator metadata emit are disabled + return undefined; + } + return { + projectFileName: project.getProjectName(), + fileNames: project.getCompileOnSaveAffectedFileList(info), + projectUsesOutFile: !!compilationSettings.outFile || !!compilationSettings.out + }; }); }; Session.prototype.emitFile = function (args) { @@ -134157,7 +136215,7 @@ var ts; } } } - var sortedFiles = highPriorityFiles.concat(mediumPriorityFiles, lowPriorityFiles, veryLowPriorityFiles); + var sortedFiles = __spreadArrays(highPriorityFiles, mediumPriorityFiles, lowPriorityFiles, veryLowPriorityFiles); var checkList = sortedFiles.map(function (fileName) { return ({ fileName: fileName, project: project }); }); // Project level error analysis runs on background files too, therefore // doesn't require the file to be opened @@ -134247,6 +136305,7 @@ var ts; try { request = JSON.parse(message); relevantFile = request.arguments && request.arguments.file ? request.arguments : undefined; + ts.perfLogger.logStartCommand("" + request.command, message.substring(0, 100)); var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired; if (this.logger.hasLevel(server.LogLevel.requestTime)) { var elapsedTime = hrTimeToMilliseconds(this.hrtime(start)).toFixed(4); @@ -134257,6 +136316,8 @@ var ts; this.logger.perftrc(request.seq + "::" + request.command + ": async elapsed time (in milliseconds) " + elapsedTime); } } + // Note: Log before writing the response, else the editor can complete its activity before the server does + ts.perfLogger.logStopCommand("" + request.command, "Success"); if (response) { this.doOutput(response, request.command, request.seq, /*success*/ true); } @@ -134267,10 +136328,12 @@ var ts; catch (err) { if (err instanceof ts.OperationCanceledException) { // Handle cancellation exceptions + ts.perfLogger.logStopCommand("" + (request && request.command), "Canceled: " + err); this.doOutput({ canceled: true }, request.command, request.seq, /*success*/ true); return; } this.logErrorWorker(err, message, relevantFile); + ts.perfLogger.logStopCommand("" + (request && request.command), "Error: " + err); this.doOutput( /*info*/ undefined, request ? request.command : server.CommandNames.Unknown, request ? request.seq : 0, /*success*/ false, "Error processing request. " + err.message + "\n" + err.stack); @@ -134300,7 +136363,7 @@ var ts; function toProtocolTextSpanWithContext(span, contextSpan, scriptInfo) { var textSpan = toProcolTextSpan(span, scriptInfo); var contextTextSpan = contextSpan && toProcolTextSpan(contextSpan, scriptInfo); - return contextTextSpan ? __assign({}, textSpan, { contextStart: contextTextSpan.start, contextEnd: contextTextSpan.end }) : + return contextTextSpan ? __assign(__assign({}, textSpan), { contextStart: contextTextSpan.start, contextEnd: contextTextSpan.end }) : textSpan; } function convertTextChangeToCodeEdit(change, scriptInfo) { @@ -135101,7 +137164,6 @@ var ts; }()); })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); -// tslint:disable no-unnecessary-type-assertion (TODO: tslint can't find node types) var ts; (function (ts) { var server; @@ -135206,6 +137268,17 @@ var ts; }; Logger.prototype.msg = function (s, type) { if (type === void 0) { type = server.Msg.Err; } + switch (type) { + case server.Msg.Info: + ts.perfLogger.logInfoEvent(s); + break; + case server.Msg.Perf: + ts.perfLogger.logPerfEvent(s); + break; + default: // Msg.Err + ts.perfLogger.logErrEvent(s); + break; + } if (!this.canWrite) return; s = "[" + server.nowString() + "] " + s + "\n"; @@ -135228,7 +137301,7 @@ var ts; Logger.prototype.write = function (s) { if (this.fd >= 0) { var buf = sys.bufferFrom(s); - // tslint:disable-next-line no-null-keyword + // eslint-disable-next-line no-null/no-null fs.writeSync(this.fd, buf, 0, buf.length, /*position*/ null); // TODO: GH#18217 } if (this.traceToConsole) { @@ -135474,6 +137547,7 @@ var ts; // so we defer until the next tick. // // Construction should finish before the next tick fires, so we do not need to do this recursively. + // eslint-disable-next-line no-restricted-globals setImmediate(function () { return _this.event(body, eventName); }); } }; @@ -135667,7 +137741,7 @@ var ts; // stat due to inconsistencies of fs.watch // and efficiency of stat on modern filesystems function startWatchTimer() { - // tslint:disable-next-line:ban + // eslint-disable-next-line no-restricted-globals setInterval(function () { var count = 0; var nextToCheck = nextFileToCheck; @@ -135836,10 +137910,12 @@ var ts; close: function () { return pollingWatchedFileSet.removeFile(watchedFile); } }; }; + /* eslint-disable no-restricted-globals */ sys.setTimeout = setTimeout; sys.clearTimeout = clearTimeout; sys.setImmediate = setImmediate; sys.clearImmediate = clearImmediate; + /* eslint-enable no-restricted-globals */ if (typeof global !== "undefined" && global.gc) { sys.gc = function () { return global.gc(); }; } @@ -135859,14 +137935,11 @@ var ts; catch (e) { cancellationToken = server.nullCancellationToken; } - var eventPort; - { - var str = server.findArgument("--eventPort"); - var v = str === undefined ? undefined : parseInt(str); - if (v !== undefined && !isNaN(v)) { - eventPort = v; - } + function parseEventPort(eventPortStr) { + var eventPort = eventPortStr === undefined ? undefined : parseInt(eventPortStr); + return eventPort !== undefined && !isNaN(eventPort) ? eventPort : undefined; } + var eventPort = parseEventPort(server.findArgument("--eventPort")); var localeStr = server.findArgument("--locale"); if (localeStr) { ts.validateLocaleAndSetLanguage(localeStr, sys); @@ -135902,7 +137975,6 @@ var ts; ioSession.logError(err, "unknown"); }); // See https://github.com/Microsoft/TypeScript/issues/11348 - // tslint:disable-next-line no-unnecessary-type-assertion-2 process.noAsar = true; // Start listening ioSession.listen(); @@ -135912,6 +137984,31 @@ var ts; if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) { ts.sys.tryEnableSourceMapsForHost(); } + // Overwrites the current console messages to instead write to + // the log. This is so that language service plugins which use + // console.log don't break the message passing between tsserver + // and the client + console.log = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return logger.msg(args.length === 1 ? args[0] : args.join(", "), server.Msg.Info); + }; + console.warn = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return logger.msg(args.length === 1 ? args[0] : args.join(", "), server.Msg.Err); + }; + console.error = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return logger.msg(args.length === 1 ? args[0] : args.join(", "), server.Msg.Err); + }; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); //# sourceMappingURL=tsserver.js.map \ No newline at end of file diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index c2bad61505ba7..c484e3ac730a2 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "3.6"; + const versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ const version: string; } @@ -65,17 +65,17 @@ declare namespace ts { } } declare namespace ts { - type Path = string & { + export type Path = string & { __pathBrand: any; }; - interface TextRange { + export interface TextRange { pos: number; end: number; } - type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; - type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | 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.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | 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 | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; - type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; - enum SyntaxKind { + export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; + export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | 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.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | 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 | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.TagKeyword | SyntaxKind.OfKeyword; + export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; + export enum SyntaxKind { Unknown = 0, EndOfFileToken = 1, SingleLineCommentTrivia = 2, @@ -225,178 +225,180 @@ declare namespace ts { FromKeyword = 145, GlobalKeyword = 146, BigIntKeyword = 147, - OfKeyword = 148, - QualifiedName = 149, - ComputedPropertyName = 150, - TypeParameter = 151, - Parameter = 152, - Decorator = 153, - PropertySignature = 154, - PropertyDeclaration = 155, - MethodSignature = 156, - MethodDeclaration = 157, - Constructor = 158, - GetAccessor = 159, - SetAccessor = 160, - CallSignature = 161, - ConstructSignature = 162, - IndexSignature = 163, - TypePredicate = 164, - TypeReference = 165, - FunctionType = 166, - ConstructorType = 167, - TypeQuery = 168, - TypeLiteral = 169, - ArrayType = 170, - TupleType = 171, - OptionalType = 172, - RestType = 173, - UnionType = 174, - IntersectionType = 175, - ConditionalType = 176, - InferType = 177, - ParenthesizedType = 178, - ThisType = 179, - TypeOperator = 180, - IndexedAccessType = 181, - MappedType = 182, - LiteralType = 183, - ImportType = 184, - ObjectBindingPattern = 185, - ArrayBindingPattern = 186, - BindingElement = 187, - ArrayLiteralExpression = 188, - ObjectLiteralExpression = 189, - PropertyAccessExpression = 190, - ElementAccessExpression = 191, - CallExpression = 192, - NewExpression = 193, - TaggedTemplateExpression = 194, - TypeAssertionExpression = 195, - ParenthesizedExpression = 196, - FunctionExpression = 197, - ArrowFunction = 198, - DeleteExpression = 199, - TypeOfExpression = 200, - VoidExpression = 201, - AwaitExpression = 202, - PrefixUnaryExpression = 203, - PostfixUnaryExpression = 204, - BinaryExpression = 205, - ConditionalExpression = 206, - TemplateExpression = 207, - YieldExpression = 208, - SpreadElement = 209, - ClassExpression = 210, - OmittedExpression = 211, - ExpressionWithTypeArguments = 212, - AsExpression = 213, - NonNullExpression = 214, - MetaProperty = 215, - SyntheticExpression = 216, - TemplateSpan = 217, - SemicolonClassElement = 218, - Block = 219, - VariableStatement = 220, - EmptyStatement = 221, - ExpressionStatement = 222, - IfStatement = 223, - DoStatement = 224, - WhileStatement = 225, - ForStatement = 226, - ForInStatement = 227, - ForOfStatement = 228, - ContinueStatement = 229, - BreakStatement = 230, - ReturnStatement = 231, - WithStatement = 232, - SwitchStatement = 233, - LabeledStatement = 234, - ThrowStatement = 235, - TryStatement = 236, - DebuggerStatement = 237, - VariableDeclaration = 238, - VariableDeclarationList = 239, - FunctionDeclaration = 240, - ClassDeclaration = 241, - InterfaceDeclaration = 242, - TypeAliasDeclaration = 243, - EnumDeclaration = 244, - ModuleDeclaration = 245, - ModuleBlock = 246, - CaseBlock = 247, - NamespaceExportDeclaration = 248, - ImportEqualsDeclaration = 249, - ImportDeclaration = 250, - ImportClause = 251, - NamespaceImport = 252, - NamedImports = 253, - ImportSpecifier = 254, - ExportAssignment = 255, - ExportDeclaration = 256, - NamedExports = 257, - ExportSpecifier = 258, - MissingDeclaration = 259, - ExternalModuleReference = 260, - JsxElement = 261, - JsxSelfClosingElement = 262, - JsxOpeningElement = 263, - JsxClosingElement = 264, - JsxFragment = 265, - JsxOpeningFragment = 266, - JsxClosingFragment = 267, - JsxAttribute = 268, - JsxAttributes = 269, - JsxSpreadAttribute = 270, - JsxExpression = 271, - CaseClause = 272, - DefaultClause = 273, - HeritageClause = 274, - CatchClause = 275, - PropertyAssignment = 276, - ShorthandPropertyAssignment = 277, - SpreadAssignment = 278, - EnumMember = 279, - UnparsedPrologue = 280, - UnparsedPrepend = 281, - UnparsedText = 282, - UnparsedInternalText = 283, - UnparsedSyntheticReference = 284, - SourceFile = 285, - Bundle = 286, - UnparsedSource = 287, - InputFiles = 288, - JSDocTypeExpression = 289, - JSDocAllType = 290, - JSDocUnknownType = 291, - JSDocNullableType = 292, - JSDocNonNullableType = 293, - JSDocOptionalType = 294, - JSDocFunctionType = 295, - JSDocVariadicType = 296, - JSDocComment = 297, - JSDocTypeLiteral = 298, - JSDocSignature = 299, - JSDocTag = 300, - JSDocAugmentsTag = 301, - JSDocAuthorTag = 302, - JSDocClassTag = 303, - JSDocCallbackTag = 304, - JSDocEnumTag = 305, - JSDocParameterTag = 306, - JSDocReturnTag = 307, - JSDocThisTag = 308, - JSDocTypeTag = 309, - JSDocTemplateTag = 310, - JSDocTypedefTag = 311, - JSDocPropertyTag = 312, - SyntaxList = 313, - NotEmittedStatement = 314, - PartiallyEmittedExpression = 315, - CommaListExpression = 316, - MergeDeclarationMarker = 317, - EndOfDeclarationMarker = 318, - Count = 319, + TagKeyword = 148, + OfKeyword = 149, + QualifiedName = 150, + ComputedPropertyName = 151, + TypeParameter = 152, + Parameter = 153, + Decorator = 154, + PropertySignature = 155, + PropertyDeclaration = 156, + MethodSignature = 157, + MethodDeclaration = 158, + Constructor = 159, + GetAccessor = 160, + SetAccessor = 161, + CallSignature = 162, + ConstructSignature = 163, + IndexSignature = 164, + TypePredicate = 165, + TypeReference = 166, + FunctionType = 167, + ConstructorType = 168, + TypeQuery = 169, + TypeLiteral = 170, + ArrayType = 171, + TupleType = 172, + OptionalType = 173, + RestType = 174, + UnionType = 175, + IntersectionType = 176, + ConditionalType = 177, + InferType = 178, + ParenthesizedType = 179, + ThisType = 180, + TypeOperator = 181, + IndexedAccessType = 182, + MappedType = 183, + LiteralType = 184, + ImportType = 185, + ObjectBindingPattern = 186, + ArrayBindingPattern = 187, + BindingElement = 188, + ArrayLiteralExpression = 189, + ObjectLiteralExpression = 190, + PropertyAccessExpression = 191, + ElementAccessExpression = 192, + CallExpression = 193, + NewExpression = 194, + TaggedTemplateExpression = 195, + TypeAssertionExpression = 196, + ParenthesizedExpression = 197, + FunctionExpression = 198, + ArrowFunction = 199, + DeleteExpression = 200, + TypeOfExpression = 201, + VoidExpression = 202, + AwaitExpression = 203, + PrefixUnaryExpression = 204, + PostfixUnaryExpression = 205, + BinaryExpression = 206, + ConditionalExpression = 207, + TemplateExpression = 208, + YieldExpression = 209, + SpreadElement = 210, + ClassExpression = 211, + OmittedExpression = 212, + ExpressionWithTypeArguments = 213, + AsExpression = 214, + NonNullExpression = 215, + MetaProperty = 216, + SyntheticExpression = 217, + TemplateSpan = 218, + SemicolonClassElement = 219, + Block = 220, + VariableStatement = 221, + EmptyStatement = 222, + ExpressionStatement = 223, + IfStatement = 224, + DoStatement = 225, + WhileStatement = 226, + ForStatement = 227, + ForInStatement = 228, + ForOfStatement = 229, + ContinueStatement = 230, + BreakStatement = 231, + ReturnStatement = 232, + WithStatement = 233, + SwitchStatement = 234, + LabeledStatement = 235, + ThrowStatement = 236, + TryStatement = 237, + DebuggerStatement = 238, + VariableDeclaration = 239, + VariableDeclarationList = 240, + FunctionDeclaration = 241, + ClassDeclaration = 242, + InterfaceDeclaration = 243, + TypeAliasDeclaration = 244, + EnumDeclaration = 245, + ModuleDeclaration = 246, + ModuleBlock = 247, + CaseBlock = 248, + NamespaceExportDeclaration = 249, + ImportEqualsDeclaration = 250, + ImportDeclaration = 251, + ImportClause = 252, + NamespaceImport = 253, + NamedImports = 254, + ImportSpecifier = 255, + ExportAssignment = 256, + ExportDeclaration = 257, + NamedExports = 258, + ExportSpecifier = 259, + MissingDeclaration = 260, + ExternalModuleReference = 261, + JsxElement = 262, + JsxSelfClosingElement = 263, + JsxOpeningElement = 264, + JsxClosingElement = 265, + JsxFragment = 266, + JsxOpeningFragment = 267, + JsxClosingFragment = 268, + JsxAttribute = 269, + JsxAttributes = 270, + JsxSpreadAttribute = 271, + JsxExpression = 272, + CaseClause = 273, + DefaultClause = 274, + HeritageClause = 275, + CatchClause = 276, + PropertyAssignment = 277, + ShorthandPropertyAssignment = 278, + SpreadAssignment = 279, + EnumMember = 280, + UnparsedPrologue = 281, + UnparsedPrepend = 282, + UnparsedText = 283, + UnparsedInternalText = 284, + UnparsedSyntheticReference = 285, + SourceFile = 286, + Bundle = 287, + UnparsedSource = 288, + InputFiles = 289, + JSDocTypeExpression = 290, + JSDocAllType = 291, + JSDocUnknownType = 292, + JSDocNullableType = 293, + JSDocNonNullableType = 294, + JSDocOptionalType = 295, + JSDocFunctionType = 296, + JSDocVariadicType = 297, + JSDocNamepathType = 298, + JSDocComment = 299, + JSDocTypeLiteral = 300, + JSDocSignature = 301, + JSDocTag = 302, + JSDocAugmentsTag = 303, + JSDocAuthorTag = 304, + JSDocClassTag = 305, + JSDocCallbackTag = 306, + JSDocEnumTag = 307, + JSDocParameterTag = 308, + JSDocReturnTag = 309, + JSDocThisTag = 310, + JSDocTypeTag = 311, + JSDocTemplateTag = 312, + JSDocTypedefTag = 313, + JSDocPropertyTag = 314, + SyntaxList = 315, + NotEmittedStatement = 316, + PartiallyEmittedExpression = 317, + CommaListExpression = 318, + MergeDeclarationMarker = 319, + EndOfDeclarationMarker = 320, + Count = 321, FirstAssignment = 60, LastAssignment = 72, FirstCompoundAssignment = 61, @@ -404,15 +406,15 @@ declare namespace ts { FirstReservedWord = 74, LastReservedWord = 109, FirstKeyword = 74, - LastKeyword = 148, + LastKeyword = 149, FirstFutureReservedWord = 110, LastFutureReservedWord = 118, - FirstTypeNode = 164, - LastTypeNode = 184, + FirstTypeNode = 165, + LastTypeNode = 185, FirstPunctuation = 18, LastPunctuation = 72, FirstToken = 0, - LastToken = 148, + LastToken = 149, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -421,13 +423,13 @@ declare namespace ts { LastTemplateToken = 17, FirstBinaryOperator = 28, LastBinaryOperator = 72, - FirstNode = 149, - FirstJSDocNode = 289, - LastJSDocNode = 312, - FirstJSDocTagNode = 300, - LastJSDocTagNode = 312, + FirstNode = 150, + FirstJSDocNode = 290, + LastJSDocNode = 314, + FirstJSDocTagNode = 302, + LastJSDocTagNode = 314, } - enum NodeFlags { + export enum NodeFlags { None = 0, Let = 1, Const = 2, @@ -456,7 +458,7 @@ declare namespace ts { ContextFlags = 12679168, TypeExcludesFlags = 20480, } - enum ModifierFlags { + export enum ModifierFlags { None = 0, Export = 1, Ambient = 2, @@ -477,7 +479,7 @@ declare namespace ts { ExportDefault = 513, All = 3071 } - enum JsxFlags { + export enum JsxFlags { None = 0, /** An element from a named property of the JSX.IntrinsicElements interface */ IntrinsicNamedElement = 1, @@ -485,40 +487,40 @@ declare namespace ts { IntrinsicIndexedElement = 2, IntrinsicElement = 3 } - interface Node extends TextRange { + export interface Node extends TextRange { kind: SyntaxKind; flags: NodeFlags; decorators?: NodeArray; modifiers?: ModifiersArray; parent: Node; } - interface JSDocContainer { + export interface JSDocContainer { } - 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 | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | EndOfFileToken; - type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; - type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; - type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertySignature | PropertyDeclaration | PropertyAssignment | EnumMember; - interface NodeArray extends ReadonlyArray, TextRange { + 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 | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | EndOfFileToken; + export type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; + export type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; + export type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertySignature | PropertyDeclaration | PropertyAssignment | EnumMember; + export interface NodeArray extends ReadonlyArray, TextRange { hasTrailingComma?: boolean; } - interface Token extends Node { + export interface Token extends Node { kind: TKind; } - type DotDotDotToken = Token; - type QuestionToken = Token; - type ExclamationToken = Token; - type ColonToken = Token; - type EqualsToken = Token; - type AsteriskToken = Token; - type EqualsGreaterThanToken = Token; - type EndOfFileToken = Token & JSDocContainer; - type ReadonlyToken = Token; - type AwaitKeywordToken = Token; - type PlusToken = Token; - type MinusToken = Token; - type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; - type ModifiersArray = NodeArray; - interface Identifier extends PrimaryExpression, Declaration { + export type DotDotDotToken = Token; + export type QuestionToken = Token; + export type ExclamationToken = Token; + export type ColonToken = Token; + export type EqualsToken = Token; + export type AsteriskToken = Token; + export type EqualsGreaterThanToken = Token; + export type EndOfFileToken = Token & JSDocContainer; + export type ReadonlyToken = Token; + export type AwaitKeywordToken = Token; + export type PlusToken = Token; + export type MinusToken = Token; + export type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; + export type ModifiersArray = NodeArray; + export interface Identifier extends PrimaryExpression, Declaration { kind: SyntaxKind.Identifier; /** * Prefer to use `id.unescapedText`. (Note: This is available only in services, not internally to the TypeScript compiler.) @@ -528,37 +530,37 @@ declare namespace ts { originalKeywordKind?: SyntaxKind; isInJSDocNamespace?: boolean; } - interface TransientIdentifier extends Identifier { + export interface TransientIdentifier extends Identifier { resolvedSymbol: Symbol; } - interface QualifiedName extends Node { + export interface QualifiedName extends Node { kind: SyntaxKind.QualifiedName; left: EntityName; right: Identifier; } - type EntityName = Identifier | QualifiedName; - type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName; - type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | BindingPattern; - interface Declaration extends Node { + export type EntityName = Identifier | QualifiedName; + export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName; + export type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | BindingPattern; + export interface Declaration extends Node { _declarationBrand: any; } - interface NamedDeclaration extends Declaration { + export interface NamedDeclaration extends Declaration { name?: DeclarationName; } - interface DeclarationStatement extends NamedDeclaration, Statement { + export interface DeclarationStatement extends NamedDeclaration, Statement { name?: Identifier | StringLiteral | NumericLiteral; } - interface ComputedPropertyName extends Node { + export interface ComputedPropertyName extends Node { parent: Declaration; kind: SyntaxKind.ComputedPropertyName; expression: Expression; } - interface Decorator extends Node { + export interface Decorator extends Node { kind: SyntaxKind.Decorator; parent: NamedDeclaration; expression: LeftHandSideExpression; } - interface TypeParameterDeclaration extends NamedDeclaration { + export interface TypeParameterDeclaration extends NamedDeclaration { kind: SyntaxKind.TypeParameter; parent: DeclarationWithTypeParameterChildren | InferTypeNode; name: Identifier; @@ -567,22 +569,22 @@ declare namespace ts { default?: TypeNode; expression?: Expression; } - interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { + export interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SignatureDeclaration["kind"]; name?: PropertyName; typeParameters?: NodeArray; parameters: NodeArray; type?: TypeNode; } - type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; - interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { + export type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; + export interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.CallSignature; } - interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement { + export interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.ConstructSignature; } - type BindingName = Identifier | BindingPattern; - interface VariableDeclaration extends NamedDeclaration { + export type BindingName = Identifier | BindingPattern; + export interface VariableDeclaration extends NamedDeclaration { kind: SyntaxKind.VariableDeclaration; parent: VariableDeclarationList | CatchClause; name: BindingName; @@ -590,12 +592,12 @@ declare namespace ts { type?: TypeNode; initializer?: Expression; } - interface VariableDeclarationList extends Node { + export interface VariableDeclarationList extends Node { kind: SyntaxKind.VariableDeclarationList; parent: VariableStatement | ForStatement | ForOfStatement | ForInStatement; declarations: NodeArray; } - interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { + export interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.Parameter; parent: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; @@ -604,7 +606,7 @@ declare namespace ts { type?: TypeNode; initializer?: Expression; } - interface BindingElement extends NamedDeclaration { + export interface BindingElement extends NamedDeclaration { kind: SyntaxKind.BindingElement; parent: BindingPattern; propertyName?: PropertyName; @@ -612,14 +614,14 @@ declare namespace ts { name: BindingName; initializer?: Expression; } - interface PropertySignature extends TypeElement, JSDocContainer { + export interface PropertySignature extends TypeElement, JSDocContainer { kind: SyntaxKind.PropertySignature; name: PropertyName; questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } - interface PropertyDeclaration extends ClassElement, JSDocContainer { + export interface PropertyDeclaration extends ClassElement, JSDocContainer { kind: SyntaxKind.PropertyDeclaration; parent: ClassLikeDeclaration; name: PropertyName; @@ -628,20 +630,20 @@ declare namespace ts { type?: TypeNode; initializer?: Expression; } - interface ObjectLiteralElement extends NamedDeclaration { + export interface ObjectLiteralElement extends NamedDeclaration { _objectLiteralBrand: any; name?: PropertyName; } /** Unlike ObjectLiteralElement, excludes JSXAttribute and JSXSpreadAttribute. */ - type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration; - interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer { + export type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration; + export interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.PropertyAssignment; name: PropertyName; questionToken?: QuestionToken; initializer: Expression; } - interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { + export interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.ShorthandPropertyAssignment; name: Identifier; @@ -650,27 +652,27 @@ declare namespace ts { equalsToken?: Token; objectAssignmentInitializer?: Expression; } - interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer { + export interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.SpreadAssignment; expression: Expression; } - type VariableLikeDeclaration = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertyAssignment | PropertySignature | JsxAttribute | ShorthandPropertyAssignment | EnumMember | JSDocPropertyTag | JSDocParameterTag; - interface PropertyLikeDeclaration extends NamedDeclaration { + export type VariableLikeDeclaration = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertyAssignment | PropertySignature | JsxAttribute | ShorthandPropertyAssignment | EnumMember | JSDocPropertyTag | JSDocParameterTag; + export interface PropertyLikeDeclaration extends NamedDeclaration { name: PropertyName; } - interface ObjectBindingPattern extends Node { + export interface ObjectBindingPattern extends Node { kind: SyntaxKind.ObjectBindingPattern; parent: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } - interface ArrayBindingPattern extends Node { + export interface ArrayBindingPattern extends Node { kind: SyntaxKind.ArrayBindingPattern; parent: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } - type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; - type ArrayBindingElement = BindingElement | OmittedExpression; + export type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; + export type ArrayBindingElement = BindingElement | OmittedExpression; /** * Several node kinds share function-like features such as a signature, * a name, and a body. These nodes should extend FunctionLikeDeclarationBase. @@ -679,298 +681,298 @@ declare namespace ts { * - MethodDeclaration * - AccessorDeclaration */ - interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { + export interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { _functionLikeDeclarationBrand: any; asteriskToken?: AsteriskToken; questionToken?: QuestionToken; exclamationToken?: ExclamationToken; body?: Block | Expression; } - type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction; + export type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction; /** @deprecated Use SignatureDeclaration */ - type FunctionLike = SignatureDeclaration; - interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement { + export type FunctionLike = SignatureDeclaration; + export interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.FunctionDeclaration; name?: Identifier; body?: FunctionBody; } - interface MethodSignature extends SignatureDeclarationBase, TypeElement { + export interface MethodSignature extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.MethodSignature; parent: ObjectTypeDeclaration; name: PropertyName; } - interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.MethodDeclaration; parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } - interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { + export interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { kind: SyntaxKind.Constructor; parent: ClassLikeDeclaration; body?: FunctionBody; } /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */ - interface SemicolonClassElement extends ClassElement { + export interface SemicolonClassElement extends ClassElement { kind: SyntaxKind.SemicolonClassElement; parent: ClassLikeDeclaration; } - interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.GetAccessor; parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } - interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.SetAccessor; parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } - type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; - interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { + export type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; + export interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; parent: ObjectTypeDeclaration; } - interface TypeNode extends Node { + export interface TypeNode extends Node { _typeNodeBrand: any; } - interface KeywordTypeNode extends TypeNode { + export interface KeywordTypeNode extends TypeNode { kind: SyntaxKind.AnyKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.NumberKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; } - interface ImportTypeNode extends NodeWithTypeArguments { + export interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportType; isTypeOf?: boolean; argument: TypeNode; qualifier?: EntityName; } - interface ThisTypeNode extends TypeNode { + export interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; } - type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; - interface FunctionOrConstructorTypeNodeBase extends TypeNode, SignatureDeclarationBase { + export type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; + export interface FunctionOrConstructorTypeNodeBase extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType; type: TypeNode; } - interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase { + export interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase { kind: SyntaxKind.FunctionType; } - interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase { + export interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase { kind: SyntaxKind.ConstructorType; } - interface NodeWithTypeArguments extends TypeNode { + export interface NodeWithTypeArguments extends TypeNode { typeArguments?: NodeArray; } - type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments; - interface TypeReferenceNode extends NodeWithTypeArguments { + export type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments; + export interface TypeReferenceNode extends NodeWithTypeArguments { kind: SyntaxKind.TypeReference; typeName: EntityName; } - interface TypePredicateNode extends TypeNode { + export interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; parent: SignatureDeclaration | JSDocTypeExpression; parameterName: Identifier | ThisTypeNode; type: TypeNode; } - interface TypeQueryNode extends TypeNode { + export interface TypeQueryNode extends TypeNode { kind: SyntaxKind.TypeQuery; exprName: EntityName; } - interface TypeLiteralNode extends TypeNode, Declaration { + export interface TypeLiteralNode extends TypeNode, Declaration { kind: SyntaxKind.TypeLiteral; members: NodeArray; } - interface ArrayTypeNode extends TypeNode { + export interface ArrayTypeNode extends TypeNode { kind: SyntaxKind.ArrayType; elementType: TypeNode; } - interface TupleTypeNode extends TypeNode { + export interface TupleTypeNode extends TypeNode { kind: SyntaxKind.TupleType; elementTypes: NodeArray; } - interface OptionalTypeNode extends TypeNode { + export interface OptionalTypeNode extends TypeNode { kind: SyntaxKind.OptionalType; type: TypeNode; } - interface RestTypeNode extends TypeNode { + export interface RestTypeNode extends TypeNode { kind: SyntaxKind.RestType; type: TypeNode; } - type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; - interface UnionTypeNode extends TypeNode { + export type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; + export interface UnionTypeNode extends TypeNode { kind: SyntaxKind.UnionType; types: NodeArray; } - interface IntersectionTypeNode extends TypeNode { + export interface IntersectionTypeNode extends TypeNode { kind: SyntaxKind.IntersectionType; types: NodeArray; } - interface ConditionalTypeNode extends TypeNode { + export interface ConditionalTypeNode extends TypeNode { kind: SyntaxKind.ConditionalType; checkType: TypeNode; extendsType: TypeNode; trueType: TypeNode; falseType: TypeNode; } - interface InferTypeNode extends TypeNode { + export interface InferTypeNode extends TypeNode { kind: SyntaxKind.InferType; typeParameter: TypeParameterDeclaration; } - interface ParenthesizedTypeNode extends TypeNode { + export interface ParenthesizedTypeNode extends TypeNode { kind: SyntaxKind.ParenthesizedType; type: TypeNode; } - interface TypeOperatorNode extends TypeNode { + export interface TypeOperatorNode extends TypeNode { kind: SyntaxKind.TypeOperator; - operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword; + operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.TagKeyword; type: TypeNode; } - interface IndexedAccessTypeNode extends TypeNode { + export interface IndexedAccessTypeNode extends TypeNode { kind: SyntaxKind.IndexedAccessType; objectType: TypeNode; indexType: TypeNode; } - interface MappedTypeNode extends TypeNode, Declaration { + export interface MappedTypeNode extends TypeNode, Declaration { kind: SyntaxKind.MappedType; readonlyToken?: ReadonlyToken | PlusToken | MinusToken; typeParameter: TypeParameterDeclaration; questionToken?: QuestionToken | PlusToken | MinusToken; type?: TypeNode; } - interface LiteralTypeNode extends TypeNode { + export interface LiteralTypeNode extends TypeNode { kind: SyntaxKind.LiteralType; literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } - interface StringLiteral extends LiteralExpression { + export interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; } - type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; - interface Expression extends Node { + export type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; + export interface Expression extends Node { _expressionBrand: any; } - interface OmittedExpression extends Expression { + export interface OmittedExpression extends Expression { kind: SyntaxKind.OmittedExpression; } - interface PartiallyEmittedExpression extends LeftHandSideExpression { + export interface PartiallyEmittedExpression extends LeftHandSideExpression { kind: SyntaxKind.PartiallyEmittedExpression; expression: Expression; } - interface UnaryExpression extends Expression { + export interface UnaryExpression extends Expression { _unaryExpressionBrand: any; } /** Deprecated, please use UpdateExpression */ - type IncrementExpression = UpdateExpression; - interface UpdateExpression extends UnaryExpression { + export type IncrementExpression = UpdateExpression; + export interface UpdateExpression extends UnaryExpression { _updateExpressionBrand: any; } - type PrefixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.TildeToken | SyntaxKind.ExclamationToken; - interface PrefixUnaryExpression extends UpdateExpression { + export type PrefixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.TildeToken | SyntaxKind.ExclamationToken; + export interface PrefixUnaryExpression extends UpdateExpression { kind: SyntaxKind.PrefixUnaryExpression; operator: PrefixUnaryOperator; operand: UnaryExpression; } - type PostfixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken; - interface PostfixUnaryExpression extends UpdateExpression { + export type PostfixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken; + export interface PostfixUnaryExpression extends UpdateExpression { kind: SyntaxKind.PostfixUnaryExpression; operand: LeftHandSideExpression; operator: PostfixUnaryOperator; } - interface LeftHandSideExpression extends UpdateExpression { + export interface LeftHandSideExpression extends UpdateExpression { _leftHandSideExpressionBrand: any; } - interface MemberExpression extends LeftHandSideExpression { + export interface MemberExpression extends LeftHandSideExpression { _memberExpressionBrand: any; } - interface PrimaryExpression extends MemberExpression { + export interface PrimaryExpression extends MemberExpression { _primaryExpressionBrand: any; } - interface NullLiteral extends PrimaryExpression, TypeNode { + export interface NullLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.NullKeyword; } - interface BooleanLiteral extends PrimaryExpression, TypeNode { + export interface BooleanLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword; } - interface ThisExpression extends PrimaryExpression, KeywordTypeNode { + export interface ThisExpression extends PrimaryExpression, KeywordTypeNode { kind: SyntaxKind.ThisKeyword; } - interface SuperExpression extends PrimaryExpression { + export interface SuperExpression extends PrimaryExpression { kind: SyntaxKind.SuperKeyword; } - interface ImportExpression extends PrimaryExpression { + export interface ImportExpression extends PrimaryExpression { kind: SyntaxKind.ImportKeyword; } - interface DeleteExpression extends UnaryExpression { + export interface DeleteExpression extends UnaryExpression { kind: SyntaxKind.DeleteExpression; expression: UnaryExpression; } - interface TypeOfExpression extends UnaryExpression { + export interface TypeOfExpression extends UnaryExpression { kind: SyntaxKind.TypeOfExpression; expression: UnaryExpression; } - interface VoidExpression extends UnaryExpression { + export interface VoidExpression extends UnaryExpression { kind: SyntaxKind.VoidExpression; expression: UnaryExpression; } - interface AwaitExpression extends UnaryExpression { + export interface AwaitExpression extends UnaryExpression { kind: SyntaxKind.AwaitExpression; expression: UnaryExpression; } - interface YieldExpression extends Expression { + export interface YieldExpression extends Expression { kind: SyntaxKind.YieldExpression; asteriskToken?: AsteriskToken; expression?: Expression; } - interface SyntheticExpression extends Expression { + export interface SyntheticExpression extends Expression { kind: SyntaxKind.SyntheticExpression; isSpread: boolean; type: Type; } - type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; - type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; - type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; - type AdditiveOperator = SyntaxKind.PlusToken | SyntaxKind.MinusToken; - type AdditiveOperatorOrHigher = MultiplicativeOperatorOrHigher | AdditiveOperator; - type ShiftOperator = SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken; - type ShiftOperatorOrHigher = AdditiveOperatorOrHigher | ShiftOperator; - type RelationalOperator = SyntaxKind.LessThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.InstanceOfKeyword | SyntaxKind.InKeyword; - type RelationalOperatorOrHigher = ShiftOperatorOrHigher | RelationalOperator; - type EqualityOperator = SyntaxKind.EqualsEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.ExclamationEqualsToken; - type EqualityOperatorOrHigher = RelationalOperatorOrHigher | EqualityOperator; - type BitwiseOperator = SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken; - type BitwiseOperatorOrHigher = EqualityOperatorOrHigher | BitwiseOperator; - type LogicalOperator = SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken; - type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; - type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken; - type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; - type AssignmentOperatorOrHigher = LogicalOperatorOrHigher | AssignmentOperator; - type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; - type BinaryOperatorToken = Token; - interface BinaryExpression extends Expression, Declaration { + export type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; + export type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; + export type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; + export type AdditiveOperator = SyntaxKind.PlusToken | SyntaxKind.MinusToken; + export type AdditiveOperatorOrHigher = MultiplicativeOperatorOrHigher | AdditiveOperator; + export type ShiftOperator = SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken; + export type ShiftOperatorOrHigher = AdditiveOperatorOrHigher | ShiftOperator; + export type RelationalOperator = SyntaxKind.LessThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.InstanceOfKeyword | SyntaxKind.InKeyword; + export type RelationalOperatorOrHigher = ShiftOperatorOrHigher | RelationalOperator; + export type EqualityOperator = SyntaxKind.EqualsEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.ExclamationEqualsToken; + export type EqualityOperatorOrHigher = RelationalOperatorOrHigher | EqualityOperator; + export type BitwiseOperator = SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken; + export type BitwiseOperatorOrHigher = EqualityOperatorOrHigher | BitwiseOperator; + export type LogicalOperator = SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken; + export type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; + export type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken; + export type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; + export type AssignmentOperatorOrHigher = LogicalOperatorOrHigher | AssignmentOperator; + export type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; + export type BinaryOperatorToken = Token; + export interface BinaryExpression extends Expression, Declaration { kind: SyntaxKind.BinaryExpression; left: Expression; operatorToken: BinaryOperatorToken; right: Expression; } - type AssignmentOperatorToken = Token; - interface AssignmentExpression extends BinaryExpression { + export type AssignmentOperatorToken = Token; + export interface AssignmentExpression extends BinaryExpression { left: LeftHandSideExpression; operatorToken: TOperator; } - interface ObjectDestructuringAssignment extends AssignmentExpression { + export interface ObjectDestructuringAssignment extends AssignmentExpression { left: ObjectLiteralExpression; } - interface ArrayDestructuringAssignment extends AssignmentExpression { + export interface ArrayDestructuringAssignment extends AssignmentExpression { left: ArrayLiteralExpression; } - type DestructuringAssignment = ObjectDestructuringAssignment | ArrayDestructuringAssignment; - type BindingOrAssignmentElement = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | OmittedExpression | SpreadElement | ArrayLiteralExpression | ObjectLiteralExpression | AssignmentExpression | Identifier | PropertyAccessExpression | ElementAccessExpression; - type BindingOrAssignmentElementRestIndicator = DotDotDotToken | SpreadElement | SpreadAssignment; - type BindingOrAssignmentElementTarget = BindingOrAssignmentPattern | Identifier | PropertyAccessExpression | ElementAccessExpression | OmittedExpression; - type ObjectBindingOrAssignmentPattern = ObjectBindingPattern | ObjectLiteralExpression; - type ArrayBindingOrAssignmentPattern = ArrayBindingPattern | ArrayLiteralExpression; - type AssignmentPattern = ObjectLiteralExpression | ArrayLiteralExpression; - type BindingOrAssignmentPattern = ObjectBindingOrAssignmentPattern | ArrayBindingOrAssignmentPattern; - interface ConditionalExpression extends Expression { + export type DestructuringAssignment = ObjectDestructuringAssignment | ArrayDestructuringAssignment; + export type BindingOrAssignmentElement = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | OmittedExpression | SpreadElement | ArrayLiteralExpression | ObjectLiteralExpression | AssignmentExpression | Identifier | PropertyAccessExpression | ElementAccessExpression; + export type BindingOrAssignmentElementRestIndicator = DotDotDotToken | SpreadElement | SpreadAssignment; + export type BindingOrAssignmentElementTarget = BindingOrAssignmentPattern | Identifier | PropertyAccessExpression | ElementAccessExpression | OmittedExpression; + export type ObjectBindingOrAssignmentPattern = ObjectBindingPattern | ObjectLiteralExpression; + export type ArrayBindingOrAssignmentPattern = ArrayBindingPattern | ArrayLiteralExpression; + export type AssignmentPattern = ObjectLiteralExpression | ArrayLiteralExpression; + export type BindingOrAssignmentPattern = ObjectBindingOrAssignmentPattern | ArrayBindingOrAssignmentPattern; + export interface ConditionalExpression extends Expression { kind: SyntaxKind.ConditionalExpression; condition: Expression; questionToken: QuestionToken; @@ -978,34 +980,37 @@ declare namespace ts { colonToken: ColonToken; whenFalse: Expression; } - type FunctionBody = Block; - type ConciseBody = FunctionBody | Expression; - interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { + export type FunctionBody = Block; + export type ConciseBody = FunctionBody | Expression; + export interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.FunctionExpression; name?: Identifier; body: FunctionBody; } - interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { + export interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.ArrowFunction; equalsGreaterThanToken: EqualsGreaterThanToken; body: ConciseBody; name: never; } - interface LiteralLikeNode extends Node { + export interface LiteralLikeNode extends Node { text: string; isUnterminated?: boolean; hasExtendedUnicodeEscape?: boolean; } - interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { + export interface TemplateLiteralLikeNode extends LiteralLikeNode { + rawText?: string; + } + export interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { _literalExpressionBrand: any; } - interface RegularExpressionLiteral extends LiteralExpression { + export interface RegularExpressionLiteral extends LiteralExpression { kind: SyntaxKind.RegularExpressionLiteral; } - interface NoSubstitutionTemplateLiteral extends LiteralExpression { + export interface NoSubstitutionTemplateLiteral extends LiteralExpression, TemplateLiteralLikeNode { kind: SyntaxKind.NoSubstitutionTemplateLiteral; } - enum TokenFlags { + export enum TokenFlags { None = 0, Scientific = 16, Octal = 32, @@ -1013,45 +1018,45 @@ declare namespace ts { BinarySpecifier = 128, OctalSpecifier = 256, } - interface NumericLiteral extends LiteralExpression { + export interface NumericLiteral extends LiteralExpression { kind: SyntaxKind.NumericLiteral; } - interface BigIntLiteral extends LiteralExpression { + export interface BigIntLiteral extends LiteralExpression { kind: SyntaxKind.BigIntLiteral; } - interface TemplateHead extends LiteralLikeNode { + export interface TemplateHead extends TemplateLiteralLikeNode { kind: SyntaxKind.TemplateHead; parent: TemplateExpression; } - interface TemplateMiddle extends LiteralLikeNode { + export interface TemplateMiddle extends TemplateLiteralLikeNode { kind: SyntaxKind.TemplateMiddle; parent: TemplateSpan; } - interface TemplateTail extends LiteralLikeNode { + export interface TemplateTail extends TemplateLiteralLikeNode { kind: SyntaxKind.TemplateTail; parent: TemplateSpan; } - type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; - interface TemplateExpression extends PrimaryExpression { + export type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; + export interface TemplateExpression extends PrimaryExpression { kind: SyntaxKind.TemplateExpression; head: TemplateHead; templateSpans: NodeArray; } - interface TemplateSpan extends Node { + export interface TemplateSpan extends Node { kind: SyntaxKind.TemplateSpan; parent: TemplateExpression; expression: Expression; literal: TemplateMiddle | TemplateTail; } - interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer { + export interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer { kind: SyntaxKind.ParenthesizedExpression; expression: Expression; } - interface ArrayLiteralExpression extends PrimaryExpression { + export interface ArrayLiteralExpression extends PrimaryExpression { kind: SyntaxKind.ArrayLiteralExpression; elements: NodeArray; } - interface SpreadElement extends Expression { + export interface SpreadElement extends Expression { kind: SyntaxKind.SpreadElement; parent: ArrayLiteralExpression | CallExpression | NewExpression; expression: Expression; @@ -1062,413 +1067,413 @@ declare namespace ts { * JSXAttribute or JSXSpreadAttribute. ObjectLiteralExpression, on the other hand, can only have properties of type * ObjectLiteralElement (e.g. PropertyAssignment, ShorthandPropertyAssignment etc.) */ - interface ObjectLiteralExpressionBase extends PrimaryExpression, Declaration { + export interface ObjectLiteralExpressionBase extends PrimaryExpression, Declaration { properties: NodeArray; } - interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { + export interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { kind: SyntaxKind.ObjectLiteralExpression; } - type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; - type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; - interface PropertyAccessExpression extends MemberExpression, NamedDeclaration { + export type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; + export type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; + export interface PropertyAccessExpression extends MemberExpression, NamedDeclaration { kind: SyntaxKind.PropertyAccessExpression; expression: LeftHandSideExpression; name: Identifier; } - interface SuperPropertyAccessExpression extends PropertyAccessExpression { + export interface SuperPropertyAccessExpression extends PropertyAccessExpression { expression: SuperExpression; } /** Brand for a PropertyAccessExpression which, like a QualifiedName, consists of a sequence of identifiers separated by dots. */ - interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { + export interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { _propertyAccessExpressionLikeQualifiedNameBrand?: any; expression: EntityNameExpression; } - interface ElementAccessExpression extends MemberExpression { + export interface ElementAccessExpression extends MemberExpression { kind: SyntaxKind.ElementAccessExpression; expression: LeftHandSideExpression; argumentExpression: Expression; } - interface SuperElementAccessExpression extends ElementAccessExpression { + export interface SuperElementAccessExpression extends ElementAccessExpression { expression: SuperExpression; } - type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; - interface CallExpression extends LeftHandSideExpression, Declaration { + export type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; + export interface CallExpression extends LeftHandSideExpression, Declaration { kind: SyntaxKind.CallExpression; expression: LeftHandSideExpression; typeArguments?: NodeArray; arguments: NodeArray; } - interface SuperCall extends CallExpression { + export interface SuperCall extends CallExpression { expression: SuperExpression; } - interface ImportCall extends CallExpression { + export interface ImportCall extends CallExpression { expression: ImportExpression; } - interface ExpressionWithTypeArguments extends NodeWithTypeArguments { + export interface ExpressionWithTypeArguments extends NodeWithTypeArguments { kind: SyntaxKind.ExpressionWithTypeArguments; parent: HeritageClause | JSDocAugmentsTag; expression: LeftHandSideExpression; } - interface NewExpression extends PrimaryExpression, Declaration { + export interface NewExpression extends PrimaryExpression, Declaration { kind: SyntaxKind.NewExpression; expression: LeftHandSideExpression; typeArguments?: NodeArray; arguments?: NodeArray; } - interface TaggedTemplateExpression extends MemberExpression { + export interface TaggedTemplateExpression extends MemberExpression { kind: SyntaxKind.TaggedTemplateExpression; tag: LeftHandSideExpression; typeArguments?: NodeArray; template: TemplateLiteral; } - type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; - interface AsExpression extends Expression { + export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; + export interface AsExpression extends Expression { kind: SyntaxKind.AsExpression; expression: Expression; type: TypeNode; } - interface TypeAssertion extends UnaryExpression { + export interface TypeAssertion extends UnaryExpression { kind: SyntaxKind.TypeAssertionExpression; type: TypeNode; expression: UnaryExpression; } - type AssertionExpression = TypeAssertion | AsExpression; - interface NonNullExpression extends LeftHandSideExpression { + export type AssertionExpression = TypeAssertion | AsExpression; + export interface NonNullExpression extends LeftHandSideExpression { kind: SyntaxKind.NonNullExpression; expression: Expression; } - interface MetaProperty extends PrimaryExpression { + export interface MetaProperty extends PrimaryExpression { kind: SyntaxKind.MetaProperty; keywordToken: SyntaxKind.NewKeyword | SyntaxKind.ImportKeyword; name: Identifier; } - interface JsxElement extends PrimaryExpression { + export interface JsxElement extends PrimaryExpression { kind: SyntaxKind.JsxElement; openingElement: JsxOpeningElement; children: NodeArray; closingElement: JsxClosingElement; } - type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; - type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; - interface JsxTagNamePropertyAccess extends PropertyAccessExpression { + export type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; + export type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; + export type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; + export interface JsxTagNamePropertyAccess extends PropertyAccessExpression { expression: JsxTagNameExpression; } - interface JsxAttributes extends ObjectLiteralExpressionBase { + export interface JsxAttributes extends ObjectLiteralExpressionBase { kind: SyntaxKind.JsxAttributes; parent: JsxOpeningLikeElement; } - interface JsxOpeningElement extends Expression { + export interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; parent: JsxElement; tagName: JsxTagNameExpression; typeArguments?: NodeArray; attributes: JsxAttributes; } - interface JsxSelfClosingElement extends PrimaryExpression { + export interface JsxSelfClosingElement extends PrimaryExpression { kind: SyntaxKind.JsxSelfClosingElement; tagName: JsxTagNameExpression; typeArguments?: NodeArray; attributes: JsxAttributes; } - interface JsxFragment extends PrimaryExpression { + export interface JsxFragment extends PrimaryExpression { kind: SyntaxKind.JsxFragment; openingFragment: JsxOpeningFragment; children: NodeArray; closingFragment: JsxClosingFragment; } - interface JsxOpeningFragment extends Expression { + export interface JsxOpeningFragment extends Expression { kind: SyntaxKind.JsxOpeningFragment; parent: JsxFragment; } - interface JsxClosingFragment extends Expression { + export interface JsxClosingFragment extends Expression { kind: SyntaxKind.JsxClosingFragment; parent: JsxFragment; } - interface JsxAttribute extends ObjectLiteralElement { + export interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; parent: JsxAttributes; name: Identifier; initializer?: StringLiteral | JsxExpression; } - interface JsxSpreadAttribute extends ObjectLiteralElement { + export interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; parent: JsxAttributes; expression: Expression; } - interface JsxClosingElement extends Node { + export interface JsxClosingElement extends Node { kind: SyntaxKind.JsxClosingElement; parent: JsxElement; tagName: JsxTagNameExpression; } - interface JsxExpression extends Expression { + export interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; parent: JsxElement | JsxAttributeLike; dotDotDotToken?: Token; expression?: Expression; } - interface JsxText extends LiteralLikeNode { + export interface JsxText extends LiteralLikeNode { kind: SyntaxKind.JsxText; containsOnlyTriviaWhiteSpaces: boolean; parent: JsxElement; } - type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; - interface Statement extends Node { + export type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; + export interface Statement extends Node { _statementBrand: any; } - interface NotEmittedStatement extends Statement { + export interface NotEmittedStatement extends Statement { kind: SyntaxKind.NotEmittedStatement; } /** * A list of comma-separated expressions. This node is only created by transformations. */ - interface CommaListExpression extends Expression { + export interface CommaListExpression extends Expression { kind: SyntaxKind.CommaListExpression; elements: NodeArray; } - interface EmptyStatement extends Statement { + export interface EmptyStatement extends Statement { kind: SyntaxKind.EmptyStatement; } - interface DebuggerStatement extends Statement { + export interface DebuggerStatement extends Statement { kind: SyntaxKind.DebuggerStatement; } - interface MissingDeclaration extends DeclarationStatement { + export interface MissingDeclaration extends DeclarationStatement { kind: SyntaxKind.MissingDeclaration; name?: Identifier; } - type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; - interface Block extends Statement { + export type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; + export interface Block extends Statement { kind: SyntaxKind.Block; statements: NodeArray; } - interface VariableStatement extends Statement, JSDocContainer { + export interface VariableStatement extends Statement, JSDocContainer { kind: SyntaxKind.VariableStatement; declarationList: VariableDeclarationList; } - interface ExpressionStatement extends Statement, JSDocContainer { + export interface ExpressionStatement extends Statement, JSDocContainer { kind: SyntaxKind.ExpressionStatement; expression: Expression; } - interface IfStatement extends Statement { + export interface IfStatement extends Statement { kind: SyntaxKind.IfStatement; expression: Expression; thenStatement: Statement; elseStatement?: Statement; } - interface IterationStatement extends Statement { + export interface IterationStatement extends Statement { statement: Statement; } - interface DoStatement extends IterationStatement { + export interface DoStatement extends IterationStatement { kind: SyntaxKind.DoStatement; expression: Expression; } - interface WhileStatement extends IterationStatement { + export interface WhileStatement extends IterationStatement { kind: SyntaxKind.WhileStatement; expression: Expression; } - type ForInitializer = VariableDeclarationList | Expression; - interface ForStatement extends IterationStatement { + export type ForInitializer = VariableDeclarationList | Expression; + export interface ForStatement extends IterationStatement { kind: SyntaxKind.ForStatement; initializer?: ForInitializer; condition?: Expression; incrementor?: Expression; } - type ForInOrOfStatement = ForInStatement | ForOfStatement; - interface ForInStatement extends IterationStatement { + export type ForInOrOfStatement = ForInStatement | ForOfStatement; + export interface ForInStatement extends IterationStatement { kind: SyntaxKind.ForInStatement; initializer: ForInitializer; expression: Expression; } - interface ForOfStatement extends IterationStatement { + export interface ForOfStatement extends IterationStatement { kind: SyntaxKind.ForOfStatement; awaitModifier?: AwaitKeywordToken; initializer: ForInitializer; expression: Expression; } - interface BreakStatement extends Statement { + export interface BreakStatement extends Statement { kind: SyntaxKind.BreakStatement; label?: Identifier; } - interface ContinueStatement extends Statement { + export interface ContinueStatement extends Statement { kind: SyntaxKind.ContinueStatement; label?: Identifier; } - type BreakOrContinueStatement = BreakStatement | ContinueStatement; - interface ReturnStatement extends Statement { + export type BreakOrContinueStatement = BreakStatement | ContinueStatement; + export interface ReturnStatement extends Statement { kind: SyntaxKind.ReturnStatement; expression?: Expression; } - interface WithStatement extends Statement { + export interface WithStatement extends Statement { kind: SyntaxKind.WithStatement; expression: Expression; statement: Statement; } - interface SwitchStatement extends Statement { + export interface SwitchStatement extends Statement { kind: SyntaxKind.SwitchStatement; expression: Expression; caseBlock: CaseBlock; possiblyExhaustive?: boolean; } - interface CaseBlock extends Node { + export interface CaseBlock extends Node { kind: SyntaxKind.CaseBlock; parent: SwitchStatement; clauses: NodeArray; } - interface CaseClause extends Node { + export interface CaseClause extends Node { kind: SyntaxKind.CaseClause; parent: CaseBlock; expression: Expression; statements: NodeArray; } - interface DefaultClause extends Node { + export interface DefaultClause extends Node { kind: SyntaxKind.DefaultClause; parent: CaseBlock; statements: NodeArray; } - type CaseOrDefaultClause = CaseClause | DefaultClause; - interface LabeledStatement extends Statement, JSDocContainer { + export type CaseOrDefaultClause = CaseClause | DefaultClause; + export interface LabeledStatement extends Statement, JSDocContainer { kind: SyntaxKind.LabeledStatement; label: Identifier; statement: Statement; } - interface ThrowStatement extends Statement { + export interface ThrowStatement extends Statement { kind: SyntaxKind.ThrowStatement; expression?: Expression; } - interface TryStatement extends Statement { + export interface TryStatement extends Statement { kind: SyntaxKind.TryStatement; tryBlock: Block; catchClause?: CatchClause; finallyBlock?: Block; } - interface CatchClause extends Node { + export interface CatchClause extends Node { kind: SyntaxKind.CatchClause; parent: TryStatement; variableDeclaration?: VariableDeclaration; block: Block; } - type ObjectTypeDeclaration = ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode; - type DeclarationWithTypeParameters = DeclarationWithTypeParameterChildren | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature; - type DeclarationWithTypeParameterChildren = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; - interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { + export type ObjectTypeDeclaration = ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode; + export type DeclarationWithTypeParameters = DeclarationWithTypeParameterChildren | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature; + export type DeclarationWithTypeParameterChildren = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; + export interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression; name?: Identifier; typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; } - interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { + export interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.ClassDeclaration; /** May be undefined in `export default class { ... }`. */ name?: Identifier; } - interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { + export interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { kind: SyntaxKind.ClassExpression; } - type ClassLikeDeclaration = ClassDeclaration | ClassExpression; - interface ClassElement extends NamedDeclaration { + export type ClassLikeDeclaration = ClassDeclaration | ClassExpression; + export interface ClassElement extends NamedDeclaration { _classElementBrand: any; name?: PropertyName; } - interface TypeElement extends NamedDeclaration { + export interface TypeElement extends NamedDeclaration { _typeElementBrand: any; name?: PropertyName; questionToken?: QuestionToken; } - interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { + export interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.InterfaceDeclaration; name: Identifier; typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; } - interface HeritageClause extends Node { + export interface HeritageClause extends Node { kind: SyntaxKind.HeritageClause; parent: InterfaceDeclaration | ClassLikeDeclaration; token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword; types: NodeArray; } - interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { + export interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.TypeAliasDeclaration; name: Identifier; typeParameters?: NodeArray; type: TypeNode; } - interface EnumMember extends NamedDeclaration, JSDocContainer { + export interface EnumMember extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.EnumMember; parent: EnumDeclaration; name: PropertyName; initializer?: Expression; } - interface EnumDeclaration extends DeclarationStatement, JSDocContainer { + export interface EnumDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.EnumDeclaration; name: Identifier; members: NodeArray; } - type ModuleName = Identifier | StringLiteral; - type ModuleBody = NamespaceBody | JSDocNamespaceBody; - interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { + export type ModuleName = Identifier | StringLiteral; + export type ModuleBody = NamespaceBody | JSDocNamespaceBody; + export interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ModuleDeclaration; parent: ModuleBody | SourceFile; name: ModuleName; body?: ModuleBody | JSDocNamespaceDeclaration; } - type NamespaceBody = ModuleBlock | NamespaceDeclaration; - interface NamespaceDeclaration extends ModuleDeclaration { + export type NamespaceBody = ModuleBlock | NamespaceDeclaration; + export interface NamespaceDeclaration extends ModuleDeclaration { name: Identifier; body: NamespaceBody; } - type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; - interface JSDocNamespaceDeclaration extends ModuleDeclaration { + export type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; + export interface JSDocNamespaceDeclaration extends ModuleDeclaration { name: Identifier; body?: JSDocNamespaceBody; } - interface ModuleBlock extends Node, Statement { + export interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; parent: ModuleDeclaration; statements: NodeArray; } - type ModuleReference = EntityName | ExternalModuleReference; + export type ModuleReference = EntityName | ExternalModuleReference; /** * One of: * - import x = require("mod"); * - import x = M.x; */ - interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { + export interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ImportEqualsDeclaration; parent: SourceFile | ModuleBlock; name: Identifier; moduleReference: ModuleReference; } - interface ExternalModuleReference extends Node { + export interface ExternalModuleReference extends Node { kind: SyntaxKind.ExternalModuleReference; parent: ImportEqualsDeclaration; expression: Expression; } - interface ImportDeclaration extends Statement { + export interface ImportDeclaration extends Statement { kind: SyntaxKind.ImportDeclaration; parent: SourceFile | ModuleBlock; importClause?: ImportClause; /** If this is not a StringLiteral it will be a grammar error. */ moduleSpecifier: Expression; } - type NamedImportBindings = NamespaceImport | NamedImports; - interface ImportClause extends NamedDeclaration { + export type NamedImportBindings = NamespaceImport | NamedImports; + export interface ImportClause extends NamedDeclaration { kind: SyntaxKind.ImportClause; parent: ImportDeclaration; name?: Identifier; namedBindings?: NamedImportBindings; } - interface NamespaceImport extends NamedDeclaration { + export interface NamespaceImport extends NamedDeclaration { kind: SyntaxKind.NamespaceImport; parent: ImportClause; name: Identifier; } - interface NamespaceExportDeclaration extends DeclarationStatement { + export interface NamespaceExportDeclaration extends DeclarationStatement { kind: SyntaxKind.NamespaceExportDeclaration; name: Identifier; } - interface ExportDeclaration extends DeclarationStatement, JSDocContainer { + export interface ExportDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ExportDeclaration; parent: SourceFile | ModuleBlock; /** Will not be assigned in the case of `export * from "foo";` */ @@ -1476,161 +1481,166 @@ declare namespace ts { /** If this is not a StringLiteral it will be a grammar error. */ moduleSpecifier?: Expression; } - interface NamedImports extends Node { + export interface NamedImports extends Node { kind: SyntaxKind.NamedImports; parent: ImportClause; elements: NodeArray; } - interface NamedExports extends Node { + export interface NamedExports extends Node { kind: SyntaxKind.NamedExports; parent: ExportDeclaration; elements: NodeArray; } - type NamedImportsOrExports = NamedImports | NamedExports; - interface ImportSpecifier extends NamedDeclaration { + export type NamedImportsOrExports = NamedImports | NamedExports; + export interface ImportSpecifier extends NamedDeclaration { kind: SyntaxKind.ImportSpecifier; parent: NamedImports; propertyName?: Identifier; name: Identifier; } - interface ExportSpecifier extends NamedDeclaration { + export interface ExportSpecifier extends NamedDeclaration { kind: SyntaxKind.ExportSpecifier; parent: NamedExports; propertyName?: Identifier; name: Identifier; } - type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; + export type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; /** * This is either an `export =` or an `export default` declaration. * Unless `isExportEquals` is set, this node was parsed as an `export default`. */ - interface ExportAssignment extends DeclarationStatement { + export interface ExportAssignment extends DeclarationStatement { kind: SyntaxKind.ExportAssignment; parent: SourceFile; isExportEquals?: boolean; expression: Expression; } - interface FileReference extends TextRange { + export interface FileReference extends TextRange { fileName: string; } - interface CheckJsDirective extends TextRange { + export interface CheckJsDirective extends TextRange { enabled: boolean; } - type CommentKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia; - interface CommentRange extends TextRange { + export type CommentKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia; + export interface CommentRange extends TextRange { hasTrailingNewLine?: boolean; kind: CommentKind; } - interface SynthesizedComment extends CommentRange { + export interface SynthesizedComment extends CommentRange { text: string; pos: -1; end: -1; } - interface JSDocTypeExpression extends TypeNode { + export interface JSDocTypeExpression extends TypeNode { kind: SyntaxKind.JSDocTypeExpression; type: TypeNode; } - interface JSDocType extends TypeNode { + export interface JSDocType extends TypeNode { _jsDocTypeBrand: any; } - interface JSDocAllType extends JSDocType { + export interface JSDocAllType extends JSDocType { kind: SyntaxKind.JSDocAllType; } - interface JSDocUnknownType extends JSDocType { + export interface JSDocUnknownType extends JSDocType { kind: SyntaxKind.JSDocUnknownType; } - interface JSDocNonNullableType extends JSDocType { + export interface JSDocNonNullableType extends JSDocType { kind: SyntaxKind.JSDocNonNullableType; type: TypeNode; } - interface JSDocNullableType extends JSDocType { + export interface JSDocNullableType extends JSDocType { kind: SyntaxKind.JSDocNullableType; type: TypeNode; } - interface JSDocOptionalType extends JSDocType { + export interface JSDocOptionalType extends JSDocType { kind: SyntaxKind.JSDocOptionalType; type: TypeNode; } - interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase { + export interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase { kind: SyntaxKind.JSDocFunctionType; } - interface JSDocVariadicType extends JSDocType { + export interface JSDocVariadicType extends JSDocType { kind: SyntaxKind.JSDocVariadicType; type: TypeNode; } - type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; - interface JSDoc extends Node { + export interface JSDocNamepathType extends JSDocType { + kind: SyntaxKind.JSDocNamepathType; + type: TypeNode; + } + export type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; + export interface JSDoc extends Node { kind: SyntaxKind.JSDocComment; parent: HasJSDoc; tags?: NodeArray; comment?: string; } - interface JSDocTag extends Node { + export interface JSDocTag extends Node { parent: JSDoc | JSDocTypeLiteral; tagName: Identifier; comment?: string; } - interface JSDocUnknownTag extends JSDocTag { + export interface JSDocUnknownTag extends JSDocTag { kind: SyntaxKind.JSDocTag; } /** * Note that `@extends` is a synonym of `@augments`. * Both tags are represented by this interface. */ - interface JSDocAugmentsTag extends JSDocTag { + export interface JSDocAugmentsTag extends JSDocTag { kind: SyntaxKind.JSDocAugmentsTag; class: ExpressionWithTypeArguments & { expression: Identifier | PropertyAccessEntityNameExpression; }; } - interface JSDocAuthorTag extends JSDocTag { + export interface JSDocAuthorTag extends JSDocTag { kind: SyntaxKind.JSDocAuthorTag; } - interface JSDocClassTag extends JSDocTag { + export interface JSDocClassTag extends JSDocTag { kind: SyntaxKind.JSDocClassTag; } - interface JSDocEnumTag extends JSDocTag { + export interface JSDocEnumTag extends JSDocTag, Declaration { + parent: JSDoc; kind: SyntaxKind.JSDocEnumTag; typeExpression?: JSDocTypeExpression; } - interface JSDocThisTag extends JSDocTag { + export interface JSDocThisTag extends JSDocTag { kind: SyntaxKind.JSDocThisTag; typeExpression?: JSDocTypeExpression; } - interface JSDocTemplateTag extends JSDocTag { + export interface JSDocTemplateTag extends JSDocTag { kind: SyntaxKind.JSDocTemplateTag; constraint: JSDocTypeExpression | undefined; typeParameters: NodeArray; } - interface JSDocReturnTag extends JSDocTag { + export interface JSDocReturnTag extends JSDocTag { kind: SyntaxKind.JSDocReturnTag; typeExpression?: JSDocTypeExpression; } - interface JSDocTypeTag extends JSDocTag { + export interface JSDocTypeTag extends JSDocTag { kind: SyntaxKind.JSDocTypeTag; typeExpression: JSDocTypeExpression; } - interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { + export interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { parent: JSDoc; kind: SyntaxKind.JSDocTypedefTag; fullName?: JSDocNamespaceDeclaration | Identifier; name?: Identifier; typeExpression?: JSDocTypeExpression | JSDocTypeLiteral; } - interface JSDocCallbackTag extends JSDocTag, NamedDeclaration { + export interface JSDocCallbackTag extends JSDocTag, NamedDeclaration { parent: JSDoc; kind: SyntaxKind.JSDocCallbackTag; fullName?: JSDocNamespaceDeclaration | Identifier; name?: Identifier; typeExpression: JSDocSignature; } - interface JSDocSignature extends JSDocType, Declaration { + export interface JSDocSignature extends JSDocType, Declaration { kind: SyntaxKind.JSDocSignature; - typeParameters?: ReadonlyArray; - parameters: ReadonlyArray; + typeParameters?: readonly JSDocTemplateTag[]; + parameters: readonly JSDocParameterTag[]; type: JSDocReturnTag | undefined; } - interface JSDocPropertyLikeTag extends JSDocTag, Declaration { + export interface JSDocPropertyLikeTag extends JSDocTag, Declaration { parent: JSDoc; name: EntityName; typeExpression?: JSDocTypeExpression; @@ -1638,19 +1648,19 @@ declare namespace ts { isNameFirst: boolean; isBracketed: boolean; } - interface JSDocPropertyTag extends JSDocPropertyLikeTag { + export interface JSDocPropertyTag extends JSDocPropertyLikeTag { kind: SyntaxKind.JSDocPropertyTag; } - interface JSDocParameterTag extends JSDocPropertyLikeTag { + export interface JSDocParameterTag extends JSDocPropertyLikeTag { kind: SyntaxKind.JSDocParameterTag; } - interface JSDocTypeLiteral extends JSDocType { + export interface JSDocTypeLiteral extends JSDocType { kind: SyntaxKind.JSDocTypeLiteral; - jsDocPropertyTags?: ReadonlyArray; + jsDocPropertyTags?: readonly JSDocPropertyLikeTag[]; /** If true, then this type literal represents an *array* of its type. */ isArrayType?: boolean; } - enum FlowFlags { + export enum FlowFlags { Unreachable = 1, Start = 2, BranchLabel = 4, @@ -1667,65 +1677,65 @@ declare namespace ts { Label = 12, Condition = 96 } - interface FlowLock { + export interface FlowLock { locked?: boolean; } - interface AfterFinallyFlow extends FlowNodeBase, FlowLock { + export interface AfterFinallyFlow extends FlowNodeBase, FlowLock { antecedent: FlowNode; } - interface PreFinallyFlow extends FlowNodeBase { + export interface PreFinallyFlow extends FlowNodeBase { antecedent: FlowNode; lock: FlowLock; } - type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation; - interface FlowNodeBase { + export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation; + export interface FlowNodeBase { flags: FlowFlags; id?: number; } - interface FlowStart extends FlowNodeBase { + export interface FlowStart extends FlowNodeBase { container?: FunctionExpression | ArrowFunction | MethodDeclaration; } - interface FlowLabel extends FlowNodeBase { + export interface FlowLabel extends FlowNodeBase { antecedents: FlowNode[] | undefined; } - interface FlowAssignment extends FlowNodeBase { + export interface FlowAssignment extends FlowNodeBase { node: Expression | VariableDeclaration | BindingElement; antecedent: FlowNode; } - interface FlowCondition extends FlowNodeBase { + export interface FlowCondition extends FlowNodeBase { expression: Expression; antecedent: FlowNode; } - interface FlowSwitchClause extends FlowNodeBase { + export interface FlowSwitchClause extends FlowNodeBase { switchStatement: SwitchStatement; clauseStart: number; clauseEnd: number; antecedent: FlowNode; } - interface FlowArrayMutation extends FlowNodeBase { + export interface FlowArrayMutation extends FlowNodeBase { node: CallExpression | BinaryExpression; antecedent: FlowNode; } - type FlowType = Type | IncompleteType; - interface IncompleteType { + export type FlowType = Type | IncompleteType; + export interface IncompleteType { flags: TypeFlags; type: Type; } - interface AmdDependency { + export interface AmdDependency { path: string; name?: string; } - interface SourceFile extends Declaration { + export interface SourceFile extends Declaration { kind: SyntaxKind.SourceFile; statements: NodeArray; endOfFileToken: Token; fileName: string; text: string; - amdDependencies: ReadonlyArray; + amdDependencies: readonly AmdDependency[]; moduleName?: string; - referencedFiles: ReadonlyArray; - typeReferenceDirectives: ReadonlyArray; - libReferenceDirectives: ReadonlyArray; + referencedFiles: readonly FileReference[]; + typeReferenceDirectives: readonly FileReference[]; + libReferenceDirectives: readonly FileReference[]; languageVariant: LanguageVariant; isDeclarationFile: boolean; /** @@ -1739,12 +1749,12 @@ declare namespace ts { hasNoDefaultLib: boolean; languageVersion: ScriptTarget; } - interface Bundle extends Node { + export interface Bundle extends Node { kind: SyntaxKind.Bundle; - prepends: ReadonlyArray; - sourceFiles: ReadonlyArray; + prepends: readonly (InputFiles | UnparsedSource)[]; + sourceFiles: readonly SourceFile[]; } - interface InputFiles extends Node { + export interface InputFiles extends Node { kind: SyntaxKind.InputFiles; javascriptPath?: string; javascriptText: string; @@ -1755,70 +1765,70 @@ declare namespace ts { declarationMapPath?: string; declarationMapText?: string; } - interface UnparsedSource extends Node { + export interface UnparsedSource extends Node { kind: SyntaxKind.UnparsedSource; fileName: string; text: string; - prologues: ReadonlyArray; - helpers: ReadonlyArray | undefined; - referencedFiles: ReadonlyArray; - typeReferenceDirectives: ReadonlyArray | undefined; - libReferenceDirectives: ReadonlyArray; + prologues: readonly UnparsedPrologue[]; + helpers: readonly UnscopedEmitHelper[] | undefined; + referencedFiles: readonly FileReference[]; + typeReferenceDirectives: readonly string[] | undefined; + libReferenceDirectives: readonly FileReference[]; hasNoDefaultLib?: boolean; sourceMapPath?: string; sourceMapText?: string; - syntheticReferences?: ReadonlyArray; - texts: ReadonlyArray; + syntheticReferences?: readonly UnparsedSyntheticReference[]; + texts: readonly UnparsedSourceText[]; } - type UnparsedSourceText = UnparsedPrepend | UnparsedTextLike; - type UnparsedNode = UnparsedPrologue | UnparsedSourceText | UnparsedSyntheticReference; - interface UnparsedSection extends Node { + export type UnparsedSourceText = UnparsedPrepend | UnparsedTextLike; + export type UnparsedNode = UnparsedPrologue | UnparsedSourceText | UnparsedSyntheticReference; + export interface UnparsedSection extends Node { kind: SyntaxKind; data?: string; parent: UnparsedSource; } - interface UnparsedPrologue extends UnparsedSection { + export interface UnparsedPrologue extends UnparsedSection { kind: SyntaxKind.UnparsedPrologue; data: string; parent: UnparsedSource; } - interface UnparsedPrepend extends UnparsedSection { + export interface UnparsedPrepend extends UnparsedSection { kind: SyntaxKind.UnparsedPrepend; data: string; parent: UnparsedSource; - texts: ReadonlyArray; + texts: readonly UnparsedTextLike[]; } - interface UnparsedTextLike extends UnparsedSection { + export interface UnparsedTextLike extends UnparsedSection { kind: SyntaxKind.UnparsedText | SyntaxKind.UnparsedInternalText; parent: UnparsedSource; } - interface UnparsedSyntheticReference extends UnparsedSection { + export interface UnparsedSyntheticReference extends UnparsedSection { kind: SyntaxKind.UnparsedSyntheticReference; parent: UnparsedSource; } - interface JsonSourceFile extends SourceFile { + export interface JsonSourceFile extends SourceFile { statements: NodeArray; } - interface TsConfigSourceFile extends JsonSourceFile { + export interface TsConfigSourceFile extends JsonSourceFile { extendedSourceFiles?: string[]; } - interface JsonMinusNumericLiteral extends PrefixUnaryExpression { + export interface JsonMinusNumericLiteral extends PrefixUnaryExpression { kind: SyntaxKind.PrefixUnaryExpression; operator: SyntaxKind.MinusToken; operand: NumericLiteral; } - interface JsonObjectExpressionStatement extends ExpressionStatement { + export interface JsonObjectExpressionStatement extends ExpressionStatement { expression: ObjectLiteralExpression | ArrayLiteralExpression | JsonMinusNumericLiteral | NumericLiteral | StringLiteral | BooleanLiteral | NullLiteral; } - interface ScriptReferenceHost { + export interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; getSourceFile(fileName: string): SourceFile | undefined; getSourceFileByPath(path: Path): SourceFile | undefined; getCurrentDirectory(): string; } - interface ParseConfigHost { + export interface ParseConfigHost { useCaseSensitiveFileNames: boolean; - readDirectory(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): ReadonlyArray; + readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): readonly string[]; /** * Gets a value indicating whether the specified path exists and is a file. * @param path The path to test. @@ -1832,26 +1842,26 @@ declare namespace ts { * specified like "./blah" to an absolute path to an actual * tsconfig file, e.g. "/root/blah/tsconfig.json" */ - type ResolvedConfigFileName = string & { + export type ResolvedConfigFileName = string & { _isResolvedConfigFileName: never; }; - type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: ReadonlyArray) => void; - class OperationCanceledException { + export type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[]) => void; + export class OperationCanceledException { } - interface CancellationToken { + export interface CancellationToken { isCancellationRequested(): boolean; /** @throws OperationCanceledException if isCancellationRequested is true */ throwIfCancellationRequested(): void; } - interface Program extends ScriptReferenceHost { + export interface Program extends ScriptReferenceHost { /** * Get a list of root file names that were passed to a 'createProgram' */ - getRootFileNames(): ReadonlyArray; + getRootFileNames(): readonly string[]; /** * Get a list of files in the program */ - getSourceFiles(): ReadonlyArray; + getSourceFiles(): readonly SourceFile[]; /** * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then * the JavaScript and declaration files will be produced for all the files in this program. @@ -1863,33 +1873,42 @@ declare namespace ts { * will be invoked when writing the JavaScript and declaration files. */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; /** The first time this is called, it will return global diagnostics (no location). */ - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getConfigFileParsingDiagnostics(): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; /** * Gets a type checker that can be used to semantically analyze source files in the program. */ getTypeChecker(): TypeChecker; + getNodeCount(): number; + getIdentifierCount(): number; + getSymbolCount(): number; + getTypeCount(): number; + getRelationCacheSizes(): { + assignable: number; + identity: number; + subtype: number; + }; isSourceFileFromExternalLibrary(file: SourceFile): boolean; isSourceFileDefaultLibrary(file: SourceFile): boolean; - getProjectReferences(): ReadonlyArray | undefined; - getResolvedProjectReferences(): ReadonlyArray | undefined; + getProjectReferences(): readonly ProjectReference[] | undefined; + getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined; } - interface ResolvedProjectReference { + export interface ResolvedProjectReference { commandLine: ParsedCommandLine; sourceFile: SourceFile; - references?: ReadonlyArray; + references?: readonly (ResolvedProjectReference | undefined)[]; } - type CustomTransformerFactory = (context: TransformationContext) => CustomTransformer; - interface CustomTransformer { + export type CustomTransformerFactory = (context: TransformationContext) => CustomTransformer; + export interface CustomTransformer { transformSourceFile(node: SourceFile): SourceFile; transformBundle(node: Bundle): Bundle; } - interface CustomTransformers { + export interface CustomTransformers { /** Custom transformers to evaluate before built-in .js transformations. */ before?: (TransformerFactory | CustomTransformerFactory)[]; /** Custom transformers to evaluate after built-in .js transformations. */ @@ -1897,7 +1916,7 @@ declare namespace ts { /** Custom transformers to evaluate after built-in .d.ts transformations. */ afterDeclarations?: (TransformerFactory | CustomTransformerFactory)[]; } - interface SourceMapSpan { + export interface SourceMapSpan { /** Line number in the .js file. */ emittedLine: number; /** Column number in the .js file. */ @@ -1912,25 +1931,26 @@ declare namespace ts { sourceIndex: number; } /** Return code used by getEmitOutput function to indicate status of the function */ - enum ExitStatus { + export enum ExitStatus { Success = 0, DiagnosticsPresent_OutputsSkipped = 1, DiagnosticsPresent_OutputsGenerated = 2, - InvalidProject_OutputsSkipped = 3 + InvalidProject_OutputsSkipped = 3, + ProjectReferenceCycle_OutputsSkupped = 4 } - interface EmitResult { + export interface EmitResult { emitSkipped: boolean; /** Contains declaration emit diagnostics */ - diagnostics: ReadonlyArray; + diagnostics: readonly Diagnostic[]; emittedFiles?: string[]; } - interface TypeChecker { + export interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; getDeclaredTypeOfSymbol(symbol: Symbol): Type; getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol | undefined; getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined; - getSignaturesOfType(type: Type, kind: SignatureKind): ReadonlyArray; + getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined; getBaseTypes(type: InterfaceType): BaseType[]; getBaseTypeOfLiteralType(type: Type): Type; @@ -1984,7 +2004,7 @@ declare namespace ts { typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; - getRootSymbols(symbol: Symbol): ReadonlyArray; + getRootSymbols(symbol: Symbol): readonly Symbol[]; getContextualType(node: Expression): Type | undefined; /** * returns unknownSignature in the case of an error. @@ -2016,7 +2036,7 @@ declare namespace ts { */ runWithCancellationToken(token: CancellationToken, cb: (checker: TypeChecker) => T): T; } - enum NodeBuilderFlags { + export enum NodeBuilderFlags { None = 0, NoTruncation = 1, WriteArrayAsGenericType = 2, @@ -2047,7 +2067,7 @@ declare namespace ts { InInitialEntityName = 16777216, InReverseMappedType = 33554432 } - enum TypeFormatFlags { + export enum TypeFormatFlags { None = 0, NoTruncation = 1, WriteArrayAsGenericType = 2, @@ -2070,31 +2090,31 @@ declare namespace ts { /** @deprecated */ WriteOwnNameForAnyLike = 0, NodeBuilderFlagsMask = 9469291 } - enum SymbolFormatFlags { + export enum SymbolFormatFlags { None = 0, WriteTypeParametersOrArguments = 1, UseOnlyExternalAliasing = 2, AllowAnyNodeKind = 4, UseAliasDefinedOutsideCurrentScope = 8, } - enum TypePredicateKind { + export enum TypePredicateKind { This = 0, Identifier = 1 } - interface TypePredicateBase { + export interface TypePredicateBase { kind: TypePredicateKind; type: Type; } - interface ThisTypePredicate extends TypePredicateBase { + export interface ThisTypePredicate extends TypePredicateBase { kind: TypePredicateKind.This; } - interface IdentifierTypePredicate extends TypePredicateBase { + export interface IdentifierTypePredicate extends TypePredicateBase { kind: TypePredicateKind.Identifier; parameterName: string; parameterIndex: number; } - type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; - enum SymbolFlags { + export type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; + export enum SymbolFlags { None = 0, FunctionScopedVariable = 1, BlockScopedVariable = 2, @@ -2126,28 +2146,28 @@ declare namespace ts { ModuleExports = 134217728, Enum = 384, Variable = 3, - Value = 67220415, - Type = 67897832, + Value = 111551, + Type = 788968, Namespace = 1920, Module = 1536, Accessor = 98304, - FunctionScopedVariableExcludes = 67220414, - BlockScopedVariableExcludes = 67220415, - ParameterExcludes = 67220415, + FunctionScopedVariableExcludes = 111550, + BlockScopedVariableExcludes = 111551, + ParameterExcludes = 111551, PropertyExcludes = 0, - EnumMemberExcludes = 68008959, - FunctionExcludes = 67219887, - ClassExcludes = 68008383, - InterfaceExcludes = 67897736, - RegularEnumExcludes = 68008191, - ConstEnumExcludes = 68008831, + EnumMemberExcludes = 900095, + FunctionExcludes = 110991, + ClassExcludes = 899503, + InterfaceExcludes = 788872, + RegularEnumExcludes = 899327, + ConstEnumExcludes = 899967, ValueModuleExcludes = 110735, NamespaceModuleExcludes = 0, - MethodExcludes = 67212223, - GetAccessorExcludes = 67154879, - SetAccessorExcludes = 67187647, - TypeParameterExcludes = 67635688, - TypeAliasExcludes = 67897832, + MethodExcludes = 103359, + GetAccessorExcludes = 46015, + SetAccessorExcludes = 78783, + TypeParameterExcludes = 526824, + TypeAliasExcludes = 788968, AliasExcludes = 2097152, ModuleMember = 2623475, ExportHasLocal = 944, @@ -2155,7 +2175,7 @@ declare namespace ts { PropertyOrAccessor = 98308, ClassMember = 106500, } - interface Symbol { + export interface Symbol { flags: SymbolFlags; escapedName: __String; declarations: Declaration[]; @@ -2164,7 +2184,7 @@ declare namespace ts { exports?: SymbolTable; globalExports?: SymbolTable; } - enum InternalSymbolName { + export enum InternalSymbolName { Call = "__call", Constructor = "__constructor", New = "__new", @@ -2191,13 +2211,13 @@ declare namespace ts { * with a normal string (which is good, it cannot be misused on assignment or on usage), * while still being comparable with a normal string via === (also good) and castable from a string. */ - type __String = (string & { + export type __String = (string & { __escapedIdentifier: void; }) | (void & { __escapedIdentifier: void; }) | InternalSymbolName; /** ReadonlyMap where keys are `__String`s. */ - interface ReadonlyUnderscoreEscapedMap { + export interface ReadonlyUnderscoreEscapedMap { get(key: __String): T | undefined; has(key: __String): boolean; forEach(action: (value: T, key: __String) => void): void; @@ -2207,14 +2227,14 @@ declare namespace ts { entries(): Iterator<[__String, T]>; } /** Map where keys are `__String`s. */ - interface UnderscoreEscapedMap extends ReadonlyUnderscoreEscapedMap { + export interface UnderscoreEscapedMap extends ReadonlyUnderscoreEscapedMap { set(key: __String, value: T): this; delete(key: __String): boolean; clear(): void; } /** SymbolTable based on ES6 Map interface. */ - type SymbolTable = UnderscoreEscapedMap; - enum TypeFlags { + export type SymbolTable = UnderscoreEscapedMap; + export enum TypeFlags { Any = 1, Unknown = 2, String = 4, @@ -2242,6 +2262,7 @@ declare namespace ts { Conditional = 16777216, Substitution = 33554432, NonPrimitive = 67108864, + StructuralTag = 134217728, Literal = 2944, Unit = 109440, StringOrNumberLiteral = 384, @@ -2254,44 +2275,44 @@ declare namespace ts { ESSymbolLike = 12288, VoidLike = 49152, UnionOrIntersection = 3145728, - StructuredType = 3670016, + StructuredType = 137887744, TypeVariable = 8650752, InstantiableNonPrimitive = 58982400, InstantiablePrimitive = 4194304, Instantiable = 63176704, - StructuredOrInstantiable = 66846720, - Narrowable = 133970943, + StructuredOrInstantiable = 201064448, + Narrowable = 268188671, NotUnionOrUnit = 67637251, } - type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; - interface Type { + export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; + export interface Type { flags: TypeFlags; symbol: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; - aliasTypeArguments?: ReadonlyArray; + aliasTypeArguments?: readonly Type[]; } - interface LiteralType extends Type { + export interface LiteralType extends Type { value: string | number | PseudoBigInt; freshType: LiteralType; regularType: LiteralType; } - interface UniqueESSymbolType extends Type { + export interface UniqueESSymbolType extends Type { symbol: Symbol; escapedName: __String; } - interface StringLiteralType extends LiteralType { + export interface StringLiteralType extends LiteralType { value: string; } - interface NumberLiteralType extends LiteralType { + export interface NumberLiteralType extends LiteralType { value: number; } - interface BigIntLiteralType extends LiteralType { + export interface BigIntLiteralType extends LiteralType { value: PseudoBigInt; } - interface EnumType extends Type { + export interface EnumType extends Type { } - enum ObjectFlags { + export enum ObjectFlags { Class = 1, Interface = 2, Reference = 4, @@ -2311,18 +2332,18 @@ declare namespace ts { ArrayLiteral = 65536, ClassOrInterface = 3, } - interface ObjectType extends Type { + export interface ObjectType extends Type { objectFlags: ObjectFlags; } /** Class and interface types (ObjectFlags.Class and ObjectFlags.Interface). */ - interface InterfaceType extends ObjectType { + export interface InterfaceType extends ObjectType { typeParameters: TypeParameter[] | undefined; outerTypeParameters: TypeParameter[] | undefined; localTypeParameters: TypeParameter[] | undefined; thisType: TypeParameter | undefined; } - type BaseType = ObjectType | IntersectionType; - interface InterfaceTypeWithDeclaredMembers extends InterfaceType { + export type BaseType = ObjectType | IntersectionType; + export interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; declaredConstructSignatures: Signature[]; @@ -2339,49 +2360,49 @@ declare namespace ts { * if the class or interface has no type parameters and the reference isn't specifying an * explicit "this" argument. */ - interface TypeReference extends ObjectType { + export interface TypeReference extends ObjectType { target: GenericType; - typeArguments?: ReadonlyArray; + typeArguments?: readonly Type[]; } - interface GenericType extends InterfaceType, TypeReference { + export interface GenericType extends InterfaceType, TypeReference { } - interface TupleType extends GenericType { + export interface TupleType extends GenericType { minLength: number; hasRestElement: boolean; readonly: boolean; associatedNames?: __String[]; } - interface TupleTypeReference extends TypeReference { + export interface TupleTypeReference extends TypeReference { target: TupleType; } - interface UnionOrIntersectionType extends Type { + export interface UnionOrIntersectionType extends Type { types: Type[]; } - interface UnionType extends UnionOrIntersectionType { + export interface UnionType extends UnionOrIntersectionType { } - interface IntersectionType extends UnionOrIntersectionType { + export interface IntersectionType extends UnionOrIntersectionType { } - type StructuredType = ObjectType | UnionType | IntersectionType; - interface EvolvingArrayType extends ObjectType { + export type StructuredType = ObjectType | UnionType | IntersectionType | StructuralTagType; + export interface EvolvingArrayType extends ObjectType { elementType: Type; finalArrayType?: Type; } - interface InstantiableType extends Type { + export interface InstantiableType extends Type { } - interface TypeParameter extends InstantiableType { + export interface TypeParameter extends InstantiableType { } - interface IndexedAccessType extends InstantiableType { + export interface IndexedAccessType extends InstantiableType { objectType: Type; indexType: Type; constraint?: Type; simplifiedForReading?: Type; simplifiedForWriting?: Type; } - type TypeVariable = TypeParameter | IndexedAccessType; - interface IndexType extends InstantiableType { + export type TypeVariable = TypeParameter | IndexedAccessType; + export interface IndexType extends InstantiableType { type: InstantiableType | UnionOrIntersectionType; } - interface ConditionalRoot { + export interface ConditionalRoot { node: ConditionalTypeNode; checkType: Type; extendsType: Type; @@ -2394,36 +2415,39 @@ declare namespace ts { aliasSymbol?: Symbol; aliasTypeArguments?: Type[]; } - interface ConditionalType extends InstantiableType { + export interface ConditionalType extends InstantiableType { root: ConditionalRoot; checkType: Type; extendsType: Type; resolvedTrueType: Type; resolvedFalseType: Type; } - interface SubstitutionType extends InstantiableType { + export interface SubstitutionType extends InstantiableType { typeVariable: TypeVariable; substitute: Type; } - enum SignatureKind { + export interface StructuralTagType extends Type { + type: Type; + } + export enum SignatureKind { Call = 0, Construct = 1 } - interface Signature { + export interface Signature { declaration?: SignatureDeclaration | JSDocSignature; - typeParameters?: ReadonlyArray; - parameters: ReadonlyArray; + typeParameters?: readonly TypeParameter[]; + parameters: readonly Symbol[]; } - enum IndexKind { + export enum IndexKind { String = 0, Number = 1 } - interface IndexInfo { + export interface IndexInfo { type: Type; isReadonly: boolean; declaration?: IndexSignatureDeclaration; } - enum InferencePriority { + export enum InferencePriority { NakedTypeVariable = 1, HomomorphicMappedType = 2, PartialHomomorphicMappedType = 4, @@ -2432,16 +2456,18 @@ declare namespace ts { LiteralKeyof = 32, NoConstraints = 64, AlwaysStrict = 128, - PriorityImpliesCombination = 56 + MaxValue = 256, + PriorityImpliesCombination = 56, + Circularity = -1 } /** @deprecated Use FileExtensionInfo instead. */ - type JsFileExtensionInfo = FileExtensionInfo; - interface FileExtensionInfo { + export type JsFileExtensionInfo = FileExtensionInfo; + export interface FileExtensionInfo { extension: string; isMixedContent: boolean; scriptKind?: ScriptKind; } - interface DiagnosticMessage { + export interface DiagnosticMessage { key: string; category: DiagnosticCategory; code: number; @@ -2454,19 +2480,19 @@ declare namespace ts { * While it seems that DiagnosticMessageChain is structurally similar to DiagnosticMessage, * the difference is that messages are all preformatted in DMC. */ - interface DiagnosticMessageChain { + export interface DiagnosticMessageChain { messageText: string; category: DiagnosticCategory; code: number; next?: DiagnosticMessageChain[]; } - interface Diagnostic extends DiagnosticRelatedInformation { + export interface Diagnostic extends DiagnosticRelatedInformation { /** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */ reportsUnnecessary?: {}; source?: string; relatedInformation?: DiagnosticRelatedInformation[]; } - interface DiagnosticRelatedInformation { + export interface DiagnosticRelatedInformation { category: DiagnosticCategory; code: number; file: SourceFile | undefined; @@ -2474,25 +2500,25 @@ declare namespace ts { length: number | undefined; messageText: string | DiagnosticMessageChain; } - interface DiagnosticWithLocation extends Diagnostic { + export interface DiagnosticWithLocation extends Diagnostic { file: SourceFile; start: number; length: number; } - enum DiagnosticCategory { + export enum DiagnosticCategory { Warning = 0, Error = 1, Suggestion = 2, Message = 3 } - enum ModuleResolutionKind { + export enum ModuleResolutionKind { Classic = 1, NodeJs = 2 } - interface PluginImport { + export interface PluginImport { name: string; } - interface ProjectReference { + export interface ProjectReference { /** A normalized path on disk */ path: string; /** The path as the user originally wrote it */ @@ -2502,8 +2528,8 @@ declare namespace ts { /** True if it is intended that this reference form a circularity */ circular?: boolean; } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; - interface CompilerOptions { + export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; + export interface CompilerOptions { allowJs?: boolean; allowSyntheticDefaultImports?: boolean; allowUmdGlobalAccess?: boolean; @@ -2586,14 +2612,14 @@ declare namespace ts { esModuleInterop?: boolean; [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } - interface TypeAcquisition { + export interface TypeAcquisition { enableAutoDiscovery?: boolean; enable?: boolean; include?: string[]; exclude?: string[]; [option: string]: string[] | boolean | undefined; } - enum ModuleKind { + export enum ModuleKind { None = 0, CommonJS = 1, AMD = 2, @@ -2602,22 +2628,22 @@ declare namespace ts { ES2015 = 5, ESNext = 99 } - enum JsxEmit { + export enum JsxEmit { None = 0, Preserve = 1, React = 2, ReactNative = 3 } - enum NewLineKind { + export enum NewLineKind { CarriageReturnLineFeed = 0, LineFeed = 1 } - interface LineAndCharacter { + export interface LineAndCharacter { /** 0-based. */ line: number; character: number; } - enum ScriptKind { + export enum ScriptKind { Unknown = 0, JS = 1, JSX = 2, @@ -2631,7 +2657,7 @@ declare namespace ts { */ Deferred = 7 } - enum ScriptTarget { + export enum ScriptTarget { ES3 = 0, ES5 = 1, ES2015 = 2, @@ -2644,38 +2670,38 @@ declare namespace ts { JSON = 100, Latest = 99 } - enum LanguageVariant { + export enum LanguageVariant { Standard = 0, JSX = 1 } /** Either a parsed command line or a parsed tsconfig.json */ - interface ParsedCommandLine { + export interface ParsedCommandLine { options: CompilerOptions; typeAcquisition?: TypeAcquisition; fileNames: string[]; - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; raw?: any; errors: Diagnostic[]; wildcardDirectories?: MapLike; compileOnSave?: boolean; } - enum WatchDirectoryFlags { + export enum WatchDirectoryFlags { None = 0, Recursive = 1 } - interface ExpandResult { + export interface ExpandResult { fileNames: string[]; wildcardDirectories: MapLike; } - interface CreateProgramOptions { - rootNames: ReadonlyArray; + export interface CreateProgramOptions { + rootNames: readonly string[]; options: CompilerOptions; - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; host?: CompilerHost; oldProgram?: Program; - configFileParsingDiagnostics?: ReadonlyArray; + configFileParsingDiagnostics?: readonly Diagnostic[]; } - interface ModuleResolutionHost { + export interface ModuleResolutionHost { fileExists(fileName: string): boolean; readFile(fileName: string): string | undefined; trace?(s: string): void; @@ -2695,7 +2721,7 @@ declare namespace ts { * * Prefer to return a `ResolvedModuleFull` so that the file type does not have to be inferred. */ - interface ResolvedModule { + export interface ResolvedModule { /** Path of the file the module was resolved to. */ resolvedFileName: string; /** True if `resolvedFileName` comes from `node_modules`. */ @@ -2706,7 +2732,7 @@ declare namespace ts { * Prefer this over `ResolvedModule`. * If changing this, remember to change `moduleResolutionIsEqualTo`. */ - interface ResolvedModuleFull extends ResolvedModule { + export interface ResolvedModuleFull extends ResolvedModule { /** * Extension of resolvedFileName. This must match what's at the end of resolvedFileName. * This is optional for backwards-compatibility, but will be added if not provided. @@ -2718,7 +2744,7 @@ declare namespace ts { * Unique identifier with a package name and version. * If changing this, remember to change `packageIdIsEqual`. */ - interface PackageId { + export interface PackageId { /** * Name of the package. * Should not include `@types`. @@ -2733,7 +2759,7 @@ declare namespace ts { /** Version of the package, e.g. "1.2.3" */ version: string; } - enum Extension { + export enum Extension { Ts = ".ts", Tsx = ".tsx", Dts = ".d.ts", @@ -2742,21 +2768,21 @@ declare namespace ts { Json = ".json", TsBuildInfo = ".tsbuildinfo" } - interface ResolvedModuleWithFailedLookupLocations { + export interface ResolvedModuleWithFailedLookupLocations { readonly resolvedModule: ResolvedModuleFull | undefined; } - interface ResolvedTypeReferenceDirective { + export interface ResolvedTypeReferenceDirective { primary: boolean; resolvedFileName: string | undefined; packageId?: PackageId; /** True if `resolvedFileName` comes from `node_modules`. */ isExternalLibraryImport?: boolean; } - interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { + export interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; - readonly failedLookupLocations: ReadonlyArray; + readonly failedLookupLocations: readonly string[]; } - interface CompilerHost extends ModuleResolutionHost { + export interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; getCancellationToken?(): CancellationToken; @@ -2767,25 +2793,25 @@ declare namespace ts { getCanonicalFileName(fileName: string): string; useCaseSensitiveFileNames(): boolean; getNewLine(): string; - readDirectory?(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): string[]; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; + readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; /** * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[]; getEnvironmentVariable?(name: string): string | undefined; createHash?(data: string): string; getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; } - interface SourceMapRange extends TextRange { + export interface SourceMapRange extends TextRange { source?: SourceMapSource; } - interface SourceMapSource { + export interface SourceMapSource { fileName: string; text: string; skipTrivia?: (pos: number) => number; } - enum EmitFlags { + export enum EmitFlags { None = 0, SingleLine = 1, AdviseOnEmitNode = 2, @@ -2816,18 +2842,18 @@ declare namespace ts { Iterator = 8388608, NoAsciiEscaping = 16777216, } - interface EmitHelper { + export interface EmitHelper { readonly name: string; readonly scoped: boolean; readonly text: string | ((node: EmitHelperUniqueNameCallback) => string); readonly priority?: number; } - interface UnscopedEmitHelper extends EmitHelper { + export interface UnscopedEmitHelper extends EmitHelper { readonly scoped: false; readonly text: string; } - type EmitHelperUniqueNameCallback = (name: string) => string; - enum EmitHint { + export type EmitHelperUniqueNameCallback = (name: string) => string; + export enum EmitHint { SourceFile = 0, Expression = 1, IdentifierName = 2, @@ -2835,7 +2861,7 @@ declare namespace ts { Unspecified = 4, EmbeddedStatement = 5 } - interface TransformationContext { + export interface TransformationContext { /** Gets the compiler options supplied to the transformer. */ getCompilerOptions(): CompilerOptions; /** Starts a new lexical environment. */ @@ -2885,7 +2911,7 @@ declare namespace ts { */ onEmitNode: (hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) => void; } - interface TransformationResult { + export interface TransformationResult { /** Gets the transformed source files. */ transformed: T[]; /** Gets diagnostics for the transformation. */ @@ -2914,17 +2940,17 @@ declare namespace ts { * A function that is used to initialize and return a `Transformer` callback, which in turn * will be used to transform one or more nodes. */ - type TransformerFactory = (context: TransformationContext) => Transformer; + export type TransformerFactory = (context: TransformationContext) => Transformer; /** * A function that transforms a node. */ - type Transformer = (node: T) => T; + export type Transformer = (node: T) => T; /** * A function that accepts and possibly transforms a node. */ - type Visitor = (node: Node) => VisitResult; - type VisitResult = T | T[] | undefined; - interface Printer { + export type Visitor = (node: Node) => VisitResult; + export type VisitResult = T | T[] | undefined; + export interface Printer { /** * Print a node and its subtree as-is, without any emit transformations. * @param hint A value indicating the purpose of a node. This is primarily used to @@ -2952,7 +2978,7 @@ declare namespace ts { */ printBundle(bundle: Bundle): string; } - interface PrintHandlers { + export interface PrintHandlers { /** * A hook used by the Printer when generating unique names to avoid collisions with * globally defined names that exist outside of the current source file. @@ -2995,28 +3021,28 @@ declare namespace ts { */ substituteNode?(hint: EmitHint, node: Node): Node; } - interface PrinterOptions { + export interface PrinterOptions { removeComments?: boolean; newLine?: NewLineKind; omitTrailingSemicolon?: boolean; noEmitHelpers?: boolean; } - interface GetEffectiveTypeRootsHost { + export interface GetEffectiveTypeRootsHost { directoryExists?(directoryName: string): boolean; getCurrentDirectory?(): string; } - interface TextSpan { + export interface TextSpan { start: number; length: number; } - interface TextChangeRange { + export interface TextChangeRange { span: TextSpan; newLength: number; } - interface SyntaxList extends Node { + export interface SyntaxList extends Node { _children: Node[]; } - enum ListFormat { + export enum ListFormat { None = 0, SingleLine = 0, MultiLine = 1, @@ -3083,7 +3109,7 @@ declare namespace ts { IndexSignatureParameters = 8848, JSDocComment = 33 } - interface UserPreferences { + export interface UserPreferences { readonly disableSuggestions?: boolean; readonly quotePreference?: "auto" | "double" | "single"; readonly includeCompletionsForModuleExports?: boolean; @@ -3095,22 +3121,23 @@ declare namespace ts { readonly providePrefixAndSuffixTextForRename?: boolean; } /** Represents a bigint literal value without requiring bigint support */ - interface PseudoBigInt { + export interface PseudoBigInt { negative: boolean; base10Value: string; } + export {}; } declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; declare namespace ts { - enum FileWatcherEventKind { + export enum FileWatcherEventKind { Created = 0, Changed = 1, Deleted = 2 } - type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind) => void; - type DirectoryWatcherCallback = (fileName: string) => void; - interface System { + export type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind) => void; + export type DirectoryWatcherCallback = (fileName: string) => void; + export interface System { args: string[]; newLine: string; useCaseSensitiveFileNames: boolean; @@ -3132,7 +3159,7 @@ declare namespace ts { getExecutingFilePath(): string; getCurrentDirectory(): string; getDirectories(path: string): string[]; - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; getModifiedTime?(path: string): Date | undefined; setModifiedTime?(path: string, time: Date): void; deleteFile?(path: string): void; @@ -3151,11 +3178,12 @@ declare namespace ts { base64decode?(input: string): string; base64encode?(input: string): string; } - interface FileWatcher { + export interface FileWatcher { close(): void; } - function getNodeMajorVersion(): number | undefined; - let sys: System; + export function getNodeMajorVersion(): number | undefined; + export let sys: System; + export {}; } declare namespace ts { type ErrorCallback = (message: DiagnosticMessage, length: number) => void; @@ -3166,6 +3194,7 @@ declare namespace ts { getTokenPos(): number; getTokenText(): string; getTokenValue(): string; + hasUnicodeEscape(): boolean; hasExtendedUnicodeEscape(): boolean; hasPrecedingLineBreak(): boolean; isIdentifier(): boolean; @@ -3215,7 +3244,7 @@ declare namespace ts { } declare namespace ts { function isExternalModuleNameRelative(moduleName: string): boolean; - function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): SortedReadonlyArray; + function sortAndDeduplicateDiagnostics(diagnostics: readonly T[]): SortedReadonlyArray; } declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -3244,13 +3273,13 @@ declare namespace ts { * This function will then merge those changes into a single change range valid between V1 and * Vn. */ - function collapseTextChangeRangesAcrossMultipleVersions(changes: ReadonlyArray): TextChangeRange; + function collapseTextChangeRangesAcrossMultipleVersions(changes: readonly TextChangeRange[]): TextChangeRange; function getTypeParameterOwner(d: Declaration): Declaration | undefined; type ParameterPropertyDeclaration = ParameterDeclaration & { parent: ConstructorDeclaration; name: Identifier; }; - function isParameterPropertyDeclaration(node: Node): node is ParameterPropertyDeclaration; + function isParameterPropertyDeclaration(node: Node, parent: Node): node is ParameterPropertyDeclaration; function isEmptyBindingPattern(node: BindingName): node is BindingPattern; function isEmptyBindingElement(node: BindingElement): boolean; function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; @@ -3316,7 +3345,7 @@ declare namespace ts { * * For binding patterns, parameter tags are matched by position. */ - function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray; + function getJSDocParameterTags(param: ParameterDeclaration): readonly JSDocParameterTag[]; /** * Gets the JSDoc type parameter tags for the node if present. * @@ -3327,7 +3356,7 @@ declare namespace ts { * node are returned first, so in the previous example, the template * tag on the containing function expression would be first. */ - function getJSDocTypeParameterTags(param: TypeParameterDeclaration): ReadonlyArray; + function getJSDocTypeParameterTags(param: TypeParameterDeclaration): readonly JSDocTemplateTag[]; /** * Return true if the node has JSDoc parameter tags. * @@ -3369,14 +3398,14 @@ declare namespace ts { */ function getJSDocReturnType(node: Node): TypeNode | undefined; /** Get all JSDoc tags related to a node, including those on parent nodes. */ - function getJSDocTags(node: Node): ReadonlyArray; + function getJSDocTags(node: Node): readonly JSDocTag[]; /** Gets all JSDoc tags of a specified kind, or undefined if not present. */ - function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): ReadonlyArray; + function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): readonly JSDocTag[]; /** * 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): ReadonlyArray; + function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[]; function getEffectiveConstraintOfTypeParameter(node: TypeParameterDeclaration): TypeNode | undefined; } declare namespace ts { @@ -3601,7 +3630,7 @@ declare namespace ts { function isStringLiteralLike(node: Node): node is StringLiteralLike; } declare namespace ts { - function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; + export function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; /** * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes * stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise, @@ -3615,25 +3644,26 @@ declare namespace ts { * @remarks `forEachChild` must visit the children of a node in the order * that they appear in the source code. The language service depends on this property to locate nodes by position. */ - function forEachChild(node: Node, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray) => T | undefined): T | undefined; - function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; - function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName | undefined; + export function forEachChild(node: Node, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray) => T | undefined): T | undefined; + export function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; + export function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName | undefined; /** * Parse json text into SyntaxTree and return node and parse errors if any * @param fileName * @param sourceText */ - function parseJsonText(fileName: string, sourceText: string): JsonSourceFile; - function isExternalModule(file: SourceFile): boolean; - function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + export function parseJsonText(fileName: string, sourceText: string): JsonSourceFile; + export function isExternalModule(file: SourceFile): boolean; + export function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + export {}; } declare namespace ts { - function parseCommandLine(commandLine: ReadonlyArray, readFile?: (path: string) => string | undefined): ParsedCommandLine; - type DiagnosticReporter = (diagnostic: Diagnostic) => void; + export function parseCommandLine(commandLine: readonly string[], readFile?: (path: string) => string | undefined): ParsedCommandLine; + export type DiagnosticReporter = (diagnostic: Diagnostic) => void; /** * Reports config file diagnostics */ - interface ConfigFileDiagnosticsReporter { + export interface ConfigFileDiagnosticsReporter { /** * Reports unrecoverable error when parsing config file */ @@ -3642,18 +3672,18 @@ declare namespace ts { /** * Interface extending ParseConfigHost to support ParseConfigFile that reads config file and reports errors */ - interface ParseConfigFileHost extends ParseConfigHost, ConfigFileDiagnosticsReporter { + export interface ParseConfigFileHost extends ParseConfigHost, ConfigFileDiagnosticsReporter { getCurrentDirectory(): string; } /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ - function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map): ParsedCommandLine | undefined; + export function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map): ParsedCommandLine | undefined; /** * Read tsconfig.json file * @param fileName The path to the config file */ - function readConfigFile(fileName: string, readFile: (path: string) => string | undefined): { + export function readConfigFile(fileName: string, readFile: (path: string) => string | undefined): { config?: any; error?: Diagnostic; }; @@ -3662,7 +3692,7 @@ declare namespace ts { * @param fileName The path to the config file * @param jsonText The text of the config file */ - function parseConfigFileTextToJson(fileName: string, jsonText: string): { + export function parseConfigFileTextToJson(fileName: string, jsonText: string): { config?: any; error?: Diagnostic; }; @@ -3670,11 +3700,11 @@ declare namespace ts { * Read tsconfig.json file * @param fileName The path to the config file */ - function readJsonConfigFile(fileName: string, readFile: (path: string) => string | undefined): TsConfigSourceFile; + export function readJsonConfigFile(fileName: string, readFile: (path: string) => string | undefined): TsConfigSourceFile; /** * Convert the json syntax tree into the json value */ - function convertToObject(sourceFile: JsonSourceFile, errors: Push): any; + export function convertToObject(sourceFile: JsonSourceFile, errors: Push): any; /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse @@ -3682,7 +3712,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; + export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map): ParsedCommandLine; /** * Parse the contents of a config file (tsconfig.json). * @param jsonNode The contents of the config file to parse @@ -3690,8 +3720,8 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; - interface ParsedTsconfig { + export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map): ParsedCommandLine; + export interface ParsedTsconfig { raw: any; options?: CompilerOptions; typeAcquisition?: TypeAcquisition; @@ -3700,18 +3730,19 @@ declare namespace ts { */ extendedConfigPath?: string; } - interface ExtendedConfigCacheEntry { + export interface ExtendedConfigCacheEntry { extendedResult: TsConfigSourceFile; extendedConfig: ParsedTsconfig | undefined; } - function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { + export function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; }; - function convertTypeAcquisitionFromJson(jsonOptions: any, basePath: string, configFileName?: string): { + export function convertTypeAcquisitionFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: TypeAcquisition; errors: Diagnostic[]; }; + export {}; } declare namespace ts { function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined; @@ -3755,7 +3786,7 @@ declare namespace ts { function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; } declare namespace ts { - function createNodeArray(elements?: ReadonlyArray, hasTrailingComma?: boolean): NodeArray; + function createNodeArray(elements?: readonly T[], hasTrailingComma?: boolean): NodeArray; /** If a node is passed, creates a string literal whose source text is read from a source node during emit. */ function createLiteral(value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier): StringLiteral; function createLiteral(value: number | PseudoBigInt): NumericLiteral; @@ -3793,67 +3824,67 @@ declare namespace ts { function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; function createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration; function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; - function createParameter(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; - function updateParameter(node: ParameterDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; + function createParameter(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + function updateParameter(node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; function createDecorator(expression: Expression): Decorator; function updateDecorator(node: Decorator, expression: Expression): Decorator; - function createPropertySignature(modifiers: ReadonlyArray | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; - function updatePropertySignature(node: PropertySignature, modifiers: ReadonlyArray | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; - function createProperty(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; - function updateProperty(node: PropertyDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; - function createMethodSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature; + function createPropertySignature(modifiers: readonly Modifier[] | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function updatePropertySignature(node: PropertySignature, modifiers: readonly Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function createProperty(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + function updateProperty(node: PropertyDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + function createMethodSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature; function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined): MethodSignature; - function createMethod(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - function updateMethod(node: MethodDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - function createConstructor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, body: Block | undefined): ConstructorDeclaration; - function updateConstructor(node: ConstructorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, body: Block | undefined): ConstructorDeclaration; - function createGetAccessor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - function updateGetAccessor(node: GetAccessorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: PropertyName, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - function createSetAccessor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, parameters: ReadonlyArray, body: Block | undefined): SetAccessorDeclaration; - function updateSetAccessor(node: SetAccessorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: PropertyName, parameters: ReadonlyArray, body: Block | undefined): SetAccessorDeclaration; - function createCallSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): CallSignatureDeclaration; + function createMethod(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function updateMethod(node: MethodDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function createConstructor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function updateConstructor(node: ConstructorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function createGetAccessor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function updateGetAccessor(node: GetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function createSetAccessor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + function updateSetAccessor(node: SetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + function createCallSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration; function updateCallSignature(node: CallSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): CallSignatureDeclaration; - function createConstructSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): ConstructSignatureDeclaration; + function createConstructSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration; function updateConstructSignature(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructSignatureDeclaration; - function createIndexSignature(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode): IndexSignatureDeclaration; - function updateIndexSignature(node: IndexSignatureDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode): IndexSignatureDeclaration; + function createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + function updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode; function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode; function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode; - function createTypeReferenceNode(typeName: string | EntityName, typeArguments: ReadonlyArray | undefined): TypeReferenceNode; + function createTypeReferenceNode(typeName: string | EntityName, typeArguments: readonly TypeNode[] | undefined): TypeReferenceNode; function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray | undefined): TypeReferenceNode; - function createFunctionTypeNode(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): FunctionTypeNode; + function createFunctionTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode; function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): FunctionTypeNode; - function createConstructorTypeNode(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): ConstructorTypeNode; + function createConstructorTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructorTypeNode; function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructorTypeNode; function createTypeQueryNode(exprName: EntityName): TypeQueryNode; function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode; - function createTypeLiteralNode(members: ReadonlyArray | undefined): TypeLiteralNode; + function createTypeLiteralNode(members: readonly TypeElement[] | undefined): TypeLiteralNode; function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray): TypeLiteralNode; function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; - function createTupleTypeNode(elementTypes: ReadonlyArray): TupleTypeNode; - function updateTupleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray): TupleTypeNode; + function createTupleTypeNode(elementTypes: readonly TypeNode[]): TupleTypeNode; + function updateTupleTypeNode(node: TupleTypeNode, elementTypes: readonly TypeNode[]): TupleTypeNode; function createOptionalTypeNode(type: TypeNode): OptionalTypeNode; function updateOptionalTypeNode(node: OptionalTypeNode, type: TypeNode): OptionalTypeNode; function createRestTypeNode(type: TypeNode): RestTypeNode; function updateRestTypeNode(node: RestTypeNode, type: TypeNode): RestTypeNode; - function createUnionTypeNode(types: ReadonlyArray): UnionTypeNode; + function createUnionTypeNode(types: readonly TypeNode[]): UnionTypeNode; function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray): UnionTypeNode; - function createIntersectionTypeNode(types: ReadonlyArray): IntersectionTypeNode; + function createIntersectionTypeNode(types: readonly TypeNode[]): IntersectionTypeNode; function updateIntersectionTypeNode(node: IntersectionTypeNode, types: NodeArray): IntersectionTypeNode; - function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: ReadonlyArray): UnionOrIntersectionTypeNode; + function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: readonly TypeNode[]): UnionOrIntersectionTypeNode; function createConditionalTypeNode(checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function updateConditionalTypeNode(node: ConditionalTypeNode, checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function createInferTypeNode(typeParameter: TypeParameterDeclaration): InferTypeNode; function updateInferTypeNode(node: InferTypeNode, typeParameter: TypeParameterDeclaration): InferTypeNode; - function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; - function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; + function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; + function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode; function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; function createThisTypeNode(): ThisTypeNode; function createTypeOperatorNode(type: TypeNode): TypeOperatorNode; - function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword, type: TypeNode): TypeOperatorNode; + function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.TagKeyword, type: TypeNode): TypeOperatorNode; function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode; function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; @@ -3861,36 +3892,36 @@ declare namespace ts { function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode; function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; - function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; - function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray): ObjectBindingPattern; - function createArrayBindingPattern(elements: ReadonlyArray): ArrayBindingPattern; - function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ReadonlyArray): ArrayBindingPattern; + function createObjectBindingPattern(elements: readonly BindingElement[]): ObjectBindingPattern; + function updateObjectBindingPattern(node: ObjectBindingPattern, elements: readonly BindingElement[]): ObjectBindingPattern; + function createArrayBindingPattern(elements: readonly ArrayBindingElement[]): ArrayBindingPattern; + function updateArrayBindingPattern(node: ArrayBindingPattern, elements: readonly ArrayBindingElement[]): ArrayBindingPattern; function createBindingElement(dotDotDotToken: DotDotDotToken | undefined, propertyName: string | PropertyName | undefined, name: string | BindingName, initializer?: Expression): BindingElement; function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken | undefined, propertyName: PropertyName | undefined, name: BindingName, initializer: Expression | undefined): BindingElement; - function createArrayLiteral(elements?: ReadonlyArray, multiLine?: boolean): ArrayLiteralExpression; - function updateArrayLiteral(node: ArrayLiteralExpression, elements: ReadonlyArray): ArrayLiteralExpression; - function createObjectLiteral(properties?: ReadonlyArray, multiLine?: boolean): ObjectLiteralExpression; - function updateObjectLiteral(node: ObjectLiteralExpression, properties: ReadonlyArray): ObjectLiteralExpression; + function createArrayLiteral(elements?: readonly Expression[], multiLine?: boolean): ArrayLiteralExpression; + function updateArrayLiteral(node: ArrayLiteralExpression, elements: readonly Expression[]): ArrayLiteralExpression; + function createObjectLiteral(properties?: readonly ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; + function updateObjectLiteral(node: ObjectLiteralExpression, properties: readonly ObjectLiteralElementLike[]): ObjectLiteralExpression; function createPropertyAccess(expression: Expression, name: string | Identifier): PropertyAccessExpression; function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression; function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; - function createCall(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): CallExpression; - function updateCall(node: CallExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray): CallExpression; - function createNew(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; - function updateNew(node: NewExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; + function createCall(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): CallExpression; + function updateCall(node: CallExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[]): CallExpression; + function createNew(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression; + function updateNew(node: NewExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression; /** @deprecated */ function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function createTaggedTemplate(tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; + function createTaggedTemplate(tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; /** @deprecated */ function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; + function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; function createParen(expression: Expression): ParenthesizedExpression; function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; - function createFunctionExpression(modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; - function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; - function createArrowFunction(modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; - function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; + function createFunctionExpression(modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[] | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; + function updateFunctionExpression(node: FunctionExpression, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block): FunctionExpression; + function createArrowFunction(modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; + function updateArrowFunction(node: ArrowFunction, modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; function createTypeOf(expression: Expression): TypeOfExpression; @@ -3908,22 +3939,22 @@ declare namespace ts { /** @deprecated */ function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token, whenTrue: Expression, colonToken: Token, whenFalse: Expression): ConditionalExpression; - function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; - function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; - function createTemplateHead(text: string): TemplateHead; - function createTemplateMiddle(text: string): TemplateMiddle; - function createTemplateTail(text: string): TemplateTail; - function createNoSubstitutionTemplateLiteral(text: string): NoSubstitutionTemplateLiteral; + function createTemplateExpression(head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression; + function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression; + function createTemplateHead(text: string, rawText?: string): TemplateHead; + function createTemplateMiddle(text: string, rawText?: string): TemplateMiddle; + function createTemplateTail(text: string, rawText?: string): TemplateTail; + function createNoSubstitutionTemplateLiteral(text: string, rawText?: string): NoSubstitutionTemplateLiteral; function createYield(expression?: Expression): YieldExpression; function createYield(asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function createSpread(expression: Expression): SpreadElement; function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; - function createClassExpression(modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; - function updateClassExpression(node: ClassExpression, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; + function createClassExpression(modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; + function updateClassExpression(node: ClassExpression, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; function createOmittedExpression(): OmittedExpression; - function createExpressionWithTypeArguments(typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; - function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; + function createExpressionWithTypeArguments(typeArguments: readonly TypeNode[] | undefined, expression: Expression): ExpressionWithTypeArguments; + function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: readonly TypeNode[] | undefined, expression: Expression): ExpressionWithTypeArguments; function createAsExpression(expression: Expression, type: TypeNode): AsExpression; function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression; function createNonNullExpression(expression: Expression): NonNullExpression; @@ -3933,10 +3964,10 @@ declare namespace ts { function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function createSemicolonClassElement(): SemicolonClassElement; - function createBlock(statements: ReadonlyArray, multiLine?: boolean): Block; - function updateBlock(node: Block, statements: ReadonlyArray): Block; - function createVariableStatement(modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList | ReadonlyArray): VariableStatement; - function updateVariableStatement(node: VariableStatement, modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList): VariableStatement; + function createBlock(statements: readonly Statement[], multiLine?: boolean): Block; + function updateBlock(node: Block, statements: readonly Statement[]): Block; + function createVariableStatement(modifiers: readonly Modifier[] | undefined, declarationList: VariableDeclarationList | readonly VariableDeclaration[]): VariableStatement; + function updateVariableStatement(node: VariableStatement, modifiers: readonly Modifier[] | undefined, declarationList: VariableDeclarationList): VariableStatement; function createEmptyStatement(): EmptyStatement; function createExpressionStatement(expression: Expression): ExpressionStatement; function updateExpressionStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; @@ -3975,76 +4006,76 @@ declare namespace ts { function createDebuggerStatement(): DebuggerStatement; function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration; function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; - function createVariableDeclarationList(declarations: ReadonlyArray, flags?: NodeFlags): VariableDeclarationList; - function updateVariableDeclarationList(node: VariableDeclarationList, declarations: ReadonlyArray): VariableDeclarationList; - function createFunctionDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - function updateFunctionDeclaration(node: FunctionDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - function createClassDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; - function updateClassDeclaration(node: ClassDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; - function createInterfaceDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; - function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; - function createTypeAliasDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, type: TypeNode): TypeAliasDeclaration; - function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, typeParameters: ReadonlyArray | undefined, type: TypeNode): TypeAliasDeclaration; - function createEnumDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, members: ReadonlyArray): EnumDeclaration; - function updateEnumDeclaration(node: EnumDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, members: ReadonlyArray): EnumDeclaration; - function createModuleDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; - function updateModuleDeclaration(node: ModuleDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; - function createModuleBlock(statements: ReadonlyArray): ModuleBlock; - function updateModuleBlock(node: ModuleBlock, statements: ReadonlyArray): ModuleBlock; - function createCaseBlock(clauses: ReadonlyArray): CaseBlock; - function updateCaseBlock(node: CaseBlock, clauses: ReadonlyArray): CaseBlock; + function createVariableDeclarationList(declarations: readonly VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; + function updateVariableDeclarationList(node: VariableDeclarationList, declarations: readonly VariableDeclaration[]): VariableDeclarationList; + function createFunctionDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function updateFunctionDeclaration(node: FunctionDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function createClassDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + function updateClassDeclaration(node: ClassDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + function createInterfaceDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + function createTypeAliasDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + function createEnumDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; + function updateEnumDeclaration(node: EnumDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; + function createModuleDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; + function updateModuleDeclaration(node: ModuleDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; + function createModuleBlock(statements: readonly Statement[]): ModuleBlock; + function updateModuleBlock(node: ModuleBlock, statements: readonly Statement[]): ModuleBlock; + function createCaseBlock(clauses: readonly CaseOrDefaultClause[]): CaseBlock; + function updateCaseBlock(node: CaseBlock, clauses: readonly CaseOrDefaultClause[]): CaseBlock; function createNamespaceExportDeclaration(name: string | Identifier): NamespaceExportDeclaration; function updateNamespaceExportDeclaration(node: NamespaceExportDeclaration, name: Identifier): NamespaceExportDeclaration; - function createImportEqualsDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function createImportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; - function updateImportDeclaration(node: ImportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; + function createImportEqualsDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function createImportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; + function updateImportDeclaration(node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; function createImportClause(name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function updateImportClause(node: ImportClause, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function createNamespaceImport(name: Identifier): NamespaceImport; function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; - function createNamedImports(elements: ReadonlyArray): NamedImports; - function updateNamedImports(node: NamedImports, elements: ReadonlyArray): NamedImports; + function createNamedImports(elements: readonly ImportSpecifier[]): NamedImports; + function updateNamedImports(node: NamedImports, elements: readonly ImportSpecifier[]): NamedImports; function createImportSpecifier(propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; - function createExportAssignment(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; - function updateExportAssignment(node: ExportAssignment, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, expression: Expression): ExportAssignment; - function createExportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; - function updateExportDeclaration(node: ExportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; - function createNamedExports(elements: ReadonlyArray): NamedExports; - function updateNamedExports(node: NamedExports, elements: ReadonlyArray): NamedExports; + function createExportAssignment(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; + function updateExportAssignment(node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; + function createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; + function updateExportDeclaration(node: ExportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; + function createNamedExports(elements: readonly ExportSpecifier[]): NamedExports; + function updateNamedExports(node: NamedExports, elements: readonly ExportSpecifier[]): NamedExports; function createExportSpecifier(propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier; function updateExportSpecifier(node: ExportSpecifier, propertyName: Identifier | undefined, name: Identifier): ExportSpecifier; function createExternalModuleReference(expression: Expression): ExternalModuleReference; function updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference; - function createJsxElement(openingElement: JsxOpeningElement, children: ReadonlyArray, closingElement: JsxClosingElement): JsxElement; - function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: ReadonlyArray, closingElement: JsxClosingElement): JsxElement; - function createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxSelfClosingElement; - function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxSelfClosingElement; - function createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxOpeningElement; - function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxOpeningElement; + function createJsxElement(openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; + function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; + function createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; + function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; + function createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement; + function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement; function createJsxClosingElement(tagName: JsxTagNameExpression): JsxClosingElement; function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement; - function createJsxFragment(openingFragment: JsxOpeningFragment, children: ReadonlyArray, closingFragment: JsxClosingFragment): JsxFragment; + function createJsxFragment(openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; function createJsxText(text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText; function updateJsxText(node: JsxText, text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText; function createJsxOpeningFragment(): JsxOpeningFragment; function createJsxJsxClosingFragment(): JsxClosingFragment; - function updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: ReadonlyArray, closingFragment: JsxClosingFragment): JsxFragment; + function updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; - function createJsxAttributes(properties: ReadonlyArray): JsxAttributes; - function updateJsxAttributes(node: JsxAttributes, properties: ReadonlyArray): JsxAttributes; + function createJsxAttributes(properties: readonly JsxAttributeLike[]): JsxAttributes; + function updateJsxAttributes(node: JsxAttributes, properties: readonly JsxAttributeLike[]): JsxAttributes; function createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; function createJsxExpression(dotDotDotToken: DotDotDotToken | undefined, expression: Expression | undefined): JsxExpression; function updateJsxExpression(node: JsxExpression, expression: Expression | undefined): JsxExpression; - function createCaseClause(expression: Expression, statements: ReadonlyArray): CaseClause; - function updateCaseClause(node: CaseClause, expression: Expression, statements: ReadonlyArray): CaseClause; - function createDefaultClause(statements: ReadonlyArray): DefaultClause; - function updateDefaultClause(node: DefaultClause, statements: ReadonlyArray): DefaultClause; - function createHeritageClause(token: HeritageClause["token"], types: ReadonlyArray): HeritageClause; - function updateHeritageClause(node: HeritageClause, types: ReadonlyArray): HeritageClause; + function createCaseClause(expression: Expression, statements: readonly Statement[]): CaseClause; + function updateCaseClause(node: CaseClause, expression: Expression, statements: readonly Statement[]): CaseClause; + function createDefaultClause(statements: readonly Statement[]): DefaultClause; + function updateDefaultClause(node: DefaultClause, statements: readonly Statement[]): DefaultClause; + function createHeritageClause(token: HeritageClause["token"], types: readonly ExpressionWithTypeArguments[]): HeritageClause; + function updateHeritageClause(node: HeritageClause, types: readonly ExpressionWithTypeArguments[]): HeritageClause; function createCatchClause(variableDeclaration: string | VariableDeclaration | undefined, block: Block): CatchClause; function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration | undefined, block: Block): CatchClause; function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; @@ -4055,7 +4086,7 @@ declare namespace ts { function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember; function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember; - function updateSourceFileNode(node: SourceFile, statements: ReadonlyArray, isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean, libReferences?: SourceFile["libReferenceDirectives"]): SourceFile; + function updateSourceFileNode(node: SourceFile, statements: readonly Statement[], isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean, libReferences?: SourceFile["libReferenceDirectives"]): SourceFile; /** * Creates a shallow, memberwise clone of a node for mutation. */ @@ -4077,20 +4108,20 @@ declare namespace ts { */ function createPartiallyEmittedExpression(expression: Expression, original?: Node): PartiallyEmittedExpression; function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; - function createCommaList(elements: ReadonlyArray): CommaListExpression; - function updateCommaList(node: CommaListExpression, elements: ReadonlyArray): CommaListExpression; - function createBundle(sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; + function createCommaList(elements: readonly Expression[]): CommaListExpression; + function updateCommaList(node: CommaListExpression, elements: readonly Expression[]): CommaListExpression; + function createBundle(sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle; function createUnparsedSourceFile(text: string): UnparsedSource; function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts", stripInternal?: boolean): UnparsedSource; function createUnparsedSourceFile(text: string, mapPath: string | undefined, map: string | undefined): UnparsedSource; function createInputFiles(javascriptText: string, declarationText: string): InputFiles; function createInputFiles(readFileText: (path: string) => string | undefined, javascriptPath: string, javascriptMapPath: string | undefined, declarationPath: string, declarationMapPath: string | undefined, buildInfoPath: string | undefined): InputFiles; function createInputFiles(javascriptText: string, declarationText: string, javascriptMapPath: string | undefined, javascriptMapText: string | undefined, declarationMapPath: string | undefined, declarationMapText: string | undefined): InputFiles; - function updateBundle(node: Bundle, sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; - function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray): CallExpression; - function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; - function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray): CallExpression; - function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; + function updateBundle(node: Bundle, sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle; + function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[]): CallExpression; + function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; function createComma(left: Expression, right: Expression): Expression; function createLessThan(left: Expression, right: Expression): Expression; function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment; @@ -4266,20 +4297,20 @@ declare namespace ts { function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; } declare namespace ts { - function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string | undefined; - function resolveTripleslashReference(moduleName: string, containingFile: string): string; - function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; - function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - interface FormatDiagnosticsHost { + export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string | undefined; + export function resolveTripleslashReference(moduleName: string, containingFile: string): string; + export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; + export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + export interface FormatDiagnosticsHost { getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; getNewLine(): string; } - function formatDiagnostics(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; - function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string; - function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; - function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string; - function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): ReadonlyArray; + export function formatDiagnostics(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string; + export function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string; + export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string; + export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string; + export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[]; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' * that represent a compilation unit. @@ -4290,7 +4321,7 @@ declare namespace ts { * @param createProgramOptions - The options for creating a program. * @returns A 'Program' object. */ - function createProgram(createProgramOptions: CreateProgramOptions): Program; + export function createProgram(createProgramOptions: CreateProgramOptions): Program; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' * that represent a compilation unit. @@ -4305,16 +4336,17 @@ declare namespace ts { * @param configFileParsingDiagnostics - error during config file parsing * @returns A 'Program' object. */ - function createProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: ReadonlyArray): Program; - /** @deprecated */ interface ResolveProjectReferencePathHost { + export function createProgram(rootNames: readonly string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: readonly Diagnostic[]): Program; + /** @deprecated */ export interface ResolveProjectReferencePathHost { fileExists(fileName: string): boolean; } /** * Returns the target config filename of a project reference. * Note: The file might not exist. */ - function resolveProjectReferencePath(ref: ProjectReference): ResolvedConfigFileName; - /** @deprecated */ function resolveProjectReferencePath(host: ResolveProjectReferencePathHost, ref: ProjectReference): ResolvedConfigFileName; + export function resolveProjectReferencePath(ref: ProjectReference): ResolvedConfigFileName; + /** @deprecated */ export function resolveProjectReferencePath(host: ResolveProjectReferencePathHost, ref: ProjectReference): ResolvedConfigFileName; + export {}; } declare namespace ts { interface EmitOutput { @@ -4366,31 +4398,31 @@ declare namespace ts { /** * Get a list of files in the program */ - getSourceFiles(): ReadonlyArray; + getSourceFiles(): readonly SourceFile[]; /** * Get the diagnostics for compiler options */ - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the diagnostics that dont belong to any file */ - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the diagnostics from config file parsing */ - getConfigFileParsingDiagnostics(): ReadonlyArray; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; /** * Get the syntax diagnostics, for all source files if source file is not supplied */ - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the declaration diagnostics, for all source files if source file is not supplied */ - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; /** * Get all the dependencies of the file */ - getAllDependencies(sourceFile: SourceFile): ReadonlyArray; + getAllDependencies(sourceFile: SourceFile): readonly string[]; /** * Gets the semantic diagnostics from the program corresponding to this state of file (if provided) or whole program * The semantic diagnostics are cached and managed here @@ -4399,7 +4431,7 @@ declare namespace ts { * In case of SemanticDiagnosticsBuilderProgram if the source file is not provided, * it will iterate through all the affected files, to ensure that cache stays valid and yet provide a way to get all semantic diagnostics */ - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Emits the JavaScript and declaration files. * When targetSource file is specified, emits the files corresponding to that source file, @@ -4425,7 +4457,7 @@ declare namespace ts { * Gets the semantic diagnostics from the program for the next affected file and caches it * Returns undefined if the iteration is complete */ - getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult>; + getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult; } /** * The builder that can handle the changes in program and iterate through changed file to emit the files @@ -4442,19 +4474,19 @@ declare namespace ts { /** * Create the builder to manage semantic diagnostics and cache them */ - function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; - function createSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; + function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): SemanticDiagnosticsBuilderProgram; + function createSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): SemanticDiagnosticsBuilderProgram; /** * Create the builder that can handle the changes in program and iterate through changed files * to emit the those files and manage semantic diagnostics cache as well */ - function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; - function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; + function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): EmitAndSemanticDiagnosticsBuilderProgram; + function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): EmitAndSemanticDiagnosticsBuilderProgram; /** * Creates a builder thats just abstraction over program and can be used with watch */ - function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderProgram; - function createAbstractBuilder(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): BuilderProgram; + function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): BuilderProgram; + function createAbstractBuilder(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): BuilderProgram; } declare namespace ts { interface ReadBuildProgramHost { @@ -4465,21 +4497,21 @@ declare namespace ts { function readBuilderProgram(compilerOptions: CompilerOptions, host: ReadBuildProgramHost): EmitAndSemanticDiagnosticsBuilderProgram | undefined; function createIncrementalCompilerHost(options: CompilerOptions, system?: System): CompilerHost; interface IncrementalProgramOptions { - rootNames: ReadonlyArray; + rootNames: readonly string[]; options: CompilerOptions; - configFileParsingDiagnostics?: ReadonlyArray; - projectReferences?: ReadonlyArray; + configFileParsingDiagnostics?: readonly Diagnostic[]; + projectReferences?: readonly ProjectReference[]; host?: CompilerHost; createProgram?: CreateProgram; } function createIncrementalProgram({ rootNames, options, configFileParsingDiagnostics, projectReferences, host, createProgram }: IncrementalProgramOptions): T; - type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions) => void; + type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions, errorCount?: number) => void; /** Create the program with rootNames and options, if they are undefined, oldProgram and new configFile diagnostics create new program */ - type CreateProgram = (rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: T, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray | undefined) => T; + type CreateProgram = (rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: T, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[] | undefined) => T; /** Host that has watch functionality used in --watch mode */ interface WatchHost { /** If provided, called with Diagnostic message that informs about change in watch status */ - onWatchStatusChange?(diagnostic: Diagnostic, newLine: string, options: CompilerOptions): void; + onWatchStatusChange?(diagnostic: Diagnostic, newLine: string, options: CompilerOptions, errorCount?: number): void; /** Used to watch changes in source files, missing files needed to update the program or config file */ watchFile(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher; /** Used to watch resolved module's failed lookup locations, config file specs, type roots where auto type reference directives are added */ @@ -4515,7 +4547,7 @@ declare namespace ts { /** If provided, used in resolutions as well as handling directory structure */ getDirectories?(path: string): string[]; /** If provided, used to cache and handle directory structure modifications */ - readDirectory?(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; /** Symbol links resolution */ realpath?(path: string): string; /** If provided would be used to write log about compilation */ @@ -4523,9 +4555,9 @@ declare namespace ts { /** If provided is used to get the environment variable */ getEnvironmentVariable?(name: string): string | undefined; /** If provided, used to resolve the module names, otherwise typescript's default module resolution */ - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[]; } interface WatchCompilerHost extends ProgramHost, WatchHost { /** If provided, callback to invoke after every new program creation */ @@ -4540,7 +4572,7 @@ declare namespace ts { /** Compiler options */ options: CompilerOptions; /** Project References */ - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; } /** * Host to create watch with config file @@ -4554,7 +4586,7 @@ declare namespace ts { * Used to generate source file names from the config file and its include, exclude, files rules * and also to cache the directory stucture */ - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; } interface Watch { /** Synchronize with host and get updated program */ @@ -4578,7 +4610,7 @@ declare namespace ts { * Create the watch compiler host for either configFile or fileNames and its options */ function createWatchCompilerHost(configFileName: string, optionsToExtend: CompilerOptions | undefined, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): WatchCompilerHostOfConfigFile; - function createWatchCompilerHost(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: ReadonlyArray): WatchCompilerHostOfFilesAndCompilerOptions; + function createWatchCompilerHost(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: readonly ProjectReference[]): WatchCompilerHostOfFilesAndCompilerOptions; /** * Creates the watch from the host for root files and compiler options */ @@ -4631,8 +4663,8 @@ declare namespace ts { function createBuilderStatusReporter(system: System, pretty?: boolean): DiagnosticReporter; function createSolutionBuilderHost(system?: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportErrorSummary?: ReportEmitErrorSummary): SolutionBuilderHost; function createSolutionBuilderWithWatchHost(system?: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): SolutionBuilderWithWatchHost; - function createSolutionBuilder(host: SolutionBuilderHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilder; - function createSolutionBuilderWithWatch(host: SolutionBuilderWithWatchHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilder; + function createSolutionBuilder(host: SolutionBuilderHost, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder; + function createSolutionBuilderWithWatch(host: SolutionBuilderWithWatchHost, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder; enum InvalidatedProjectKind { Build = 0, UpdateBundle = 1, @@ -4657,14 +4689,14 @@ declare namespace ts { getBuilderProgram(): T | undefined; getProgram(): Program | undefined; getSourceFile(fileName: string): SourceFile | undefined; - getSourceFiles(): ReadonlyArray; - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getConfigFileParsingDiagnostics(): ReadonlyArray; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getAllDependencies(sourceFile: SourceFile): ReadonlyArray; - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult>; + getSourceFiles(): readonly SourceFile[]; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getAllDependencies(sourceFile: SourceFile): readonly string[]; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult; emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult | undefined; } interface UpdateBundleProject extends InvalidatedProjectBase { @@ -4727,7 +4759,7 @@ declare namespace ts.server { readonly kind: EventBeginInstallTypes | EventEndInstallTypes; readonly eventId: number; readonly typingsInstallerVersion: string; - readonly packagesToInstall: ReadonlyArray; + readonly packagesToInstall: readonly string[]; } interface BeginInstallTypes extends InstallTypes { readonly kind: EventBeginInstallTypes; @@ -4780,8 +4812,8 @@ declare namespace ts { getProperties(): Symbol[]; getProperty(propertyName: string): Symbol | undefined; getApparentProperties(): Symbol[]; - getCallSignatures(): ReadonlyArray; - getConstructSignatures(): ReadonlyArray; + getCallSignatures(): readonly Signature[]; + getConstructSignatures(): readonly Signature[]; getStringIndexType(): Type | undefined; getNumberIndexType(): Type | undefined; getBaseTypes(): BaseType[] | undefined; @@ -4809,7 +4841,7 @@ declare namespace ts { interface SourceFile { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineEndOfPosition(pos: number): number; - getLineStarts(): ReadonlyArray; + getLineStarts(): readonly number[]; getPositionOfLineAndCharacter(line: number, character: number): number; update(newText: string, textChangeRange: TextChangeRange): SourceFile; } @@ -4866,7 +4898,7 @@ declare namespace ts { getScriptKind?(fileName: string): ScriptKind; getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): IScriptSnapshot | undefined; - getProjectReferences?(): ReadonlyArray | undefined; + getProjectReferences?(): readonly ProjectReference[] | undefined; getLocalizedDiagnosticMessages?(): any; getCancellationToken?(): HostCancellationToken; getCurrentDirectory(): string; @@ -4875,14 +4907,14 @@ declare namespace ts { trace?(s: string): void; error?(s: string): void; useCaseSensitiveFileNames?(): boolean; - readDirectory?(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; readFile?(path: string, encoding?: string): string | undefined; realpath?(path: string): string; fileExists?(path: string): boolean; getTypeRootsVersion?(): number; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined; - resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[]; getDirectories?(directoryName: string): string[]; /** * Gets a set of custom transformers to use during emit. @@ -4920,17 +4952,17 @@ declare namespace ts { getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): ReadonlyArray | undefined; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): readonly RenameLocation[] | undefined; getSmartSelectionRange(fileName: string, position: number): SelectionRange; - getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; - getTypeDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; - getImplementationAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getTypeDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; + getImplementationAtPosition(fileName: string, position: number): readonly ImplementationLocation[] | undefined; getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] | undefined; findReferences(fileName: string, position: number): ReferencedSymbol[] | undefined; getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] | undefined; /** @deprecated */ - getOccurrencesAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getOccurrencesAtPosition(fileName: string, position: number): readonly ReferenceEntry[] | undefined; getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; getNavigationTree(fileName: string): NavigationTree; @@ -4950,7 +4982,7 @@ declare namespace ts { getJsxClosingTagAtPosition(fileName: string, position: number): JsxClosingTagInfo | undefined; getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan | undefined; toLineColumnOffset?(fileName: string, position: number): LineAndCharacter; - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray, formatOptions: FormatCodeSettings, preferences: UserPreferences): ReadonlyArray; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: readonly number[], formatOptions: FormatCodeSettings, preferences: UserPreferences): readonly CodeFixAction[]; getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings, preferences: UserPreferences): CombinedCodeActions; applyCodeActionCommand(action: CodeActionCommand, formatSettings?: FormatCodeSettings): Promise; applyCodeActionCommand(action: CodeActionCommand[], formatSettings?: FormatCodeSettings): Promise; @@ -4963,8 +4995,8 @@ declare namespace ts { applyCodeActionCommand(fileName: string, action: CodeActionCommand | CodeActionCommand[]): Promise; getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined): 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): ReadonlyArray; - getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): ReadonlyArray; + organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; + getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; getProgram(): Program | undefined; dispose(): void; @@ -5113,8 +5145,8 @@ declare namespace ts { fixAllDescription?: string; } interface CombinedCodeActions { - changes: ReadonlyArray; - commands?: ReadonlyArray; + changes: readonly FileTextChanges[]; + commands?: readonly CodeActionCommand[]; } type CodeActionCommand = InstallPackageAction; interface InstallPackageAction { @@ -5296,7 +5328,7 @@ declare namespace ts { containerName: string; } interface DefinitionInfoAndBoundSpan { - definitions?: ReadonlyArray; + definitions?: readonly DefinitionInfo[]; textSpan: TextSpan; } interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { @@ -5665,6 +5697,7 @@ declare namespace ts { } } declare namespace ts { + /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier(): Classifier; } declare namespace ts { @@ -6328,7 +6361,7 @@ declare namespace ts.server.protocol { scope: OrganizeImportsScope; } interface OrganizeImportsResponse extends Response { - body: ReadonlyArray; + body: readonly FileCodeEdits[]; } interface GetEditsForFileRenameRequest extends Request { command: CommandTypes.GetEditsForFileRename; @@ -6340,7 +6373,7 @@ declare namespace ts.server.protocol { readonly newFilePath: string; } interface GetEditsForFileRenameResponse extends Response { - body: ReadonlyArray; + body: readonly FileCodeEdits[]; } /** * Request for the available codefixes at a specific position. @@ -6387,7 +6420,7 @@ declare namespace ts.server.protocol { /** * Errorcodes we want to get the fixes for. */ - errorCodes: ReadonlyArray; + errorCodes: readonly number[]; } interface GetCombinedCodeFixRequestArgs { scope: GetCombinedCodeFixScope; @@ -6504,7 +6537,7 @@ declare namespace ts.server.protocol { interface FileSpanWithContext extends FileSpan, TextSpanWithContext { } interface DefinitionInfoAndBoundSpan { - definitions: ReadonlyArray; + definitions: readonly FileSpanWithContext[]; textSpan: TextSpan; } /** @@ -6642,7 +6675,7 @@ declare namespace ts.server.protocol { /** * The file locations referencing the symbol. */ - refs: ReadonlyArray; + refs: readonly ReferencesResponseItem[]; /** * The name of the symbol. */ @@ -6746,7 +6779,7 @@ declare namespace ts.server.protocol { /** * An array of span groups (one per file) that refer to the item to be renamed. */ - locs: ReadonlyArray; + locs: readonly SpanGroup[]; } /** * Rename response message. @@ -7225,8 +7258,8 @@ declare namespace ts.server.protocol { commands?: {}[]; } interface CombinedCodeActions { - changes: ReadonlyArray; - commands?: ReadonlyArray<{}>; + changes: readonly FileCodeEdits[]; + commands?: readonly {}[]; } interface CodeFixAction extends CodeAction { /** Short name to identify the fix, for use by telemetry. */ @@ -7433,7 +7466,7 @@ declare namespace ts.server.protocol { readonly isGlobalCompletion: boolean; readonly isMemberCompletion: boolean; readonly isNewIdentifierLocation: boolean; - readonly entries: ReadonlyArray; + readonly entries: readonly CompletionEntry[]; } interface CompletionDetailsResponse extends Response { body?: CompletionEntryDetails[]; @@ -8112,7 +8145,7 @@ declare namespace ts.server.protocol { /** * list of packages to install */ - packages: ReadonlyArray; + packages: readonly string[]; } interface BeginInstallTypesEventBody extends InstallTypesEventBody { } @@ -8441,7 +8474,7 @@ declare namespace ts.server { getCompilerOptions(): CompilerOptions; getNewLine(): string; getProjectVersion(): string; - getProjectReferences(): ReadonlyArray | undefined; + getProjectReferences(): readonly ProjectReference[] | undefined; getScriptFileNames(): string[]; private getOrCreateScriptInfoAndAttachToProject; getScriptKind(fileName: string): ScriptKind; @@ -8451,7 +8484,7 @@ declare namespace ts.server { getCurrentDirectory(): string; getDefaultLibFileName(): string; useCaseSensitiveFileNames(): boolean; - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; readFile(fileName: string): string | undefined; writeFile(fileName: string, content: string): void; fileExists(file: string): boolean; @@ -8466,8 +8499,8 @@ declare namespace ts.server { /** * Get the errors that dont have any file name associated */ - getGlobalProjectErrors(): ReadonlyArray; - getAllProjectErrors(): ReadonlyArray; + getGlobalProjectErrors(): readonly Diagnostic[]; + getAllProjectErrors(): readonly Diagnostic[]; getLanguageService(ensureSynchronized?: boolean): LanguageService; private shouldEmitFile; getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[]; @@ -8489,7 +8522,7 @@ declare namespace ts.server { getRootFiles(): NormalizedPath[]; getRootScriptInfos(): ScriptInfo[]; getScriptInfos(): ScriptInfo[]; - getExcludedFiles(): ReadonlyArray; + getExcludedFiles(): readonly NormalizedPath[]; getFileNames(excludeFilesFromExternalLibraries?: boolean, excludeConfigFiles?: boolean): NormalizedPath[]; hasConfigFile(configFilePath: NormalizedPath): boolean; containsScriptInfo(info: ScriptInfo): boolean; @@ -8561,16 +8594,16 @@ declare namespace ts.server { */ updateGraph(): boolean; getConfigFilePath(): NormalizedPath; - getProjectReferences(): ReadonlyArray | undefined; - updateReferences(refs: ReadonlyArray | undefined): void; + getProjectReferences(): readonly ProjectReference[] | undefined; + updateReferences(refs: readonly ProjectReference[] | undefined): void; /** * Get the errors that dont have any file name associated */ - getGlobalProjectErrors(): ReadonlyArray; + getGlobalProjectErrors(): readonly Diagnostic[]; /** * Get all the project errors */ - getAllProjectErrors(): ReadonlyArray; + getAllProjectErrors(): readonly Diagnostic[]; setProjectErrors(projectErrors: Diagnostic[]): void; setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; getTypeAcquisition(): TypeAcquisition; @@ -8584,7 +8617,7 @@ declare namespace ts.server { class ExternalProject extends Project { externalProjectName: string; compileOnSaveEnabled: boolean; - excludedFiles: ReadonlyArray; + excludedFiles: readonly NormalizedPath[]; private typeAcquisition; updateGraph(): boolean; getExcludedFiles(): readonly NormalizedPath[]; @@ -8593,35 +8626,35 @@ declare namespace ts.server { } } declare namespace ts.server { - const maxProgramSizeForNonTsFiles: number; - const ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground"; - const ProjectLoadingStartEvent = "projectLoadingStart"; - const ProjectLoadingFinishEvent = "projectLoadingFinish"; - const LargeFileReferencedEvent = "largeFileReferenced"; - const ConfigFileDiagEvent = "configFileDiag"; - const ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; - const ProjectInfoTelemetryEvent = "projectInfo"; - const OpenFileInfoTelemetryEvent = "openFileInfo"; - interface ProjectsUpdatedInBackgroundEvent { + export const maxProgramSizeForNonTsFiles: number; + export const ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground"; + export const ProjectLoadingStartEvent = "projectLoadingStart"; + export const ProjectLoadingFinishEvent = "projectLoadingFinish"; + export const LargeFileReferencedEvent = "largeFileReferenced"; + export const ConfigFileDiagEvent = "configFileDiag"; + export const ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; + export const ProjectInfoTelemetryEvent = "projectInfo"; + export const OpenFileInfoTelemetryEvent = "openFileInfo"; + export interface ProjectsUpdatedInBackgroundEvent { eventName: typeof ProjectsUpdatedInBackgroundEvent; data: { openFiles: string[]; }; } - interface ProjectLoadingStartEvent { + export interface ProjectLoadingStartEvent { eventName: typeof ProjectLoadingStartEvent; data: { project: Project; reason: string; }; } - interface ProjectLoadingFinishEvent { + export interface ProjectLoadingFinishEvent { eventName: typeof ProjectLoadingFinishEvent; data: { project: Project; }; } - interface LargeFileReferencedEvent { + export interface LargeFileReferencedEvent { eventName: typeof LargeFileReferencedEvent; data: { file: string; @@ -8629,15 +8662,15 @@ declare namespace ts.server { maxFileSize: number; }; } - interface ConfigFileDiagEvent { + export interface ConfigFileDiagEvent { eventName: typeof ConfigFileDiagEvent; data: { triggerFile: string; configFileName: string; - diagnostics: ReadonlyArray; + diagnostics: readonly Diagnostic[]; }; } - interface ProjectLanguageServiceStateEvent { + export interface ProjectLanguageServiceStateEvent { eventName: typeof ProjectLanguageServiceStateEvent; data: { project: Project; @@ -8645,11 +8678,11 @@ declare namespace ts.server { }; } /** This will be converted to the payload of a protocol.TelemetryEvent in session.defaultEventHandler. */ - interface ProjectInfoTelemetryEvent { + export interface ProjectInfoTelemetryEvent { readonly eventName: typeof ProjectInfoTelemetryEvent; readonly data: ProjectInfoTelemetryEventData; } - interface ProjectInfoTelemetryEventData { + export interface ProjectInfoTelemetryEventData { /** Cryptographically secure hash of project file location. */ readonly projectId: string; /** Count of file extensions seen in the project. */ @@ -8676,19 +8709,19 @@ declare namespace ts.server { * Info about a file will only be sent once per session, even if the file changes in ways that might affect the info. * Currently this is only sent for '.js' files. */ - interface OpenFileInfoTelemetryEvent { + export interface OpenFileInfoTelemetryEvent { readonly eventName: typeof OpenFileInfoTelemetryEvent; readonly data: OpenFileInfoTelemetryEventData; } - interface OpenFileInfoTelemetryEventData { + export interface OpenFileInfoTelemetryEventData { readonly info: OpenFileInfo; } - interface ProjectInfoTypeAcquisitionData { + export interface ProjectInfoTypeAcquisitionData { readonly enable: boolean | undefined; readonly include: boolean; readonly exclude: boolean; } - interface FileStats { + export interface FileStats { readonly js: number; readonly jsSize?: number; readonly jsx: number; @@ -8702,39 +8735,39 @@ declare namespace ts.server { readonly deferred: number; readonly deferredSize?: number; } - interface OpenFileInfo { + export interface OpenFileInfo { readonly checkJs: boolean; } - type ProjectServiceEvent = LargeFileReferencedEvent | ProjectsUpdatedInBackgroundEvent | ProjectLoadingStartEvent | ProjectLoadingFinishEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent | OpenFileInfoTelemetryEvent; - type ProjectServiceEventHandler = (event: ProjectServiceEvent) => void; - interface SafeList { + export type ProjectServiceEvent = LargeFileReferencedEvent | ProjectsUpdatedInBackgroundEvent | ProjectLoadingStartEvent | ProjectLoadingFinishEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent | OpenFileInfoTelemetryEvent; + export type ProjectServiceEventHandler = (event: ProjectServiceEvent) => void; + export interface SafeList { [name: string]: { match: RegExp; exclude?: (string | number)[][]; types?: string[]; }; } - interface TypesMapFile { + export interface TypesMapFile { typesMap: SafeList; simpleMap: { [libName: string]: string; }; } - function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings; - function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin; - function tryConvertScriptKindName(scriptKindName: protocol.ScriptKindName | ScriptKind): ScriptKind; - function convertScriptKindName(scriptKindName: protocol.ScriptKindName): ScriptKind.Unknown | ScriptKind.JS | ScriptKind.JSX | ScriptKind.TS | ScriptKind.TSX; - interface HostConfiguration { + export function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings; + export function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin; + export function tryConvertScriptKindName(scriptKindName: protocol.ScriptKindName | ScriptKind): ScriptKind; + export function convertScriptKindName(scriptKindName: protocol.ScriptKindName): ScriptKind.Unknown | ScriptKind.JS | ScriptKind.JSX | ScriptKind.TS | ScriptKind.TSX; + export interface HostConfiguration { formatCodeOptions: FormatCodeSettings; preferences: protocol.UserPreferences; hostInfo: string; extraFileExtensions?: FileExtensionInfo[]; } - interface OpenConfiguredProjectResult { + export interface OpenConfiguredProjectResult { configFileName?: NormalizedPath; - configFileErrors?: ReadonlyArray; + configFileErrors?: readonly Diagnostic[]; } - interface ProjectServiceOptions { + export interface ProjectServiceOptions { host: ServerHost; logger: Logger; cancellationToken: HostCancellationToken; @@ -8744,13 +8777,13 @@ declare namespace ts.server { eventHandler?: ProjectServiceEventHandler; suppressDiagnosticEvents?: boolean; throttleWaitMilliseconds?: number; - globalPlugins?: ReadonlyArray; - pluginProbeLocations?: ReadonlyArray; + globalPlugins?: readonly string[]; + pluginProbeLocations?: readonly string[]; allowLocalPluginLoads?: boolean; typesMapLocation?: string; syntaxOnly?: boolean; } - class ProjectService { + export class ProjectService { private readonly scriptInfoInNodeModulesWatchers; /** * Contains all the deleted script info's version information so that @@ -8814,8 +8847,8 @@ declare namespace ts.server { readonly throttleWaitMilliseconds?: number; private readonly eventHandler?; private readonly suppressDiagnosticEvents?; - readonly globalPlugins: ReadonlyArray; - readonly pluginProbeLocations: ReadonlyArray; + readonly globalPlugins: readonly string[]; + readonly pluginProbeLocations: readonly string[]; readonly allowLocalPluginLoads: boolean; private currentPluginConfigOverrides; readonly typesMapLocation: string | undefined; @@ -9003,6 +9036,7 @@ declare namespace ts.server { hasDeferredExtension(): boolean; configurePlugin(args: protocol.ConfigurePluginRequestArguments): void; } + export {}; } declare namespace ts.server { interface ServerCancellationToken extends HostCancellationToken { @@ -9040,8 +9074,8 @@ declare namespace ts.server { syntaxOnly?: boolean; throttleWaitMilliseconds?: number; noGetErrOnBackgroundUpdate?: boolean; - globalPlugins?: ReadonlyArray; - pluginProbeLocations?: ReadonlyArray; + globalPlugins?: readonly string[]; + pluginProbeLocations?: readonly string[]; allowLocalPluginLoads?: boolean; typesMapLocation?: string; } diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index c1f065ea5d23d..62c4138c9430e 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -14,6 +14,13 @@ and limitations under the License. ***************************************************************************** */ "use strict"; +var __spreadArrays = (this && this.__spreadArrays) || function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +}; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { @@ -74,15 +81,17 @@ var __rest = (this && this.__rest) || function (s, e) { for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) - t[p[i]] = s[p[i]]; + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } return t; }; var ts; (function (ts) { // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configureNightly` too. - ts.versionMajorMinor = "3.6"; + ts.versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ ts.version = ts.versionMajorMinor + ".0-dev"; })(ts || (ts = {})); @@ -100,7 +109,7 @@ var ts; ts.emptyArray = []; /** Create a MapLike with good performance. */ function createDictionaryObject() { - var map = Object.create(/*prototype*/ null); // tslint:disable-line:no-null-keyword + var map = Object.create(/*prototype*/ null); // eslint-disable-line no-null/no-null // Using 'delete' on an object causes V8 to put the object in dictionary mode. // This disables creation of hidden classes, which are expensive when an object is // constantly changing shape. @@ -135,7 +144,7 @@ var ts; } ts.createMapFromTemplate = createMapFromTemplate; // Internet Explorer's Map doesn't support iteration, so don't use it. - // tslint:disable-next-line no-in-operator variable-name + // eslint-disable-next-line no-in-operator ts.MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); // Keep the class inside a function so it doesn't get compiled if it's not used. function shimMap() { @@ -199,7 +208,7 @@ var ts; return this; }; class_1.prototype.has = function (key) { - // tslint:disable-next-line:no-in-operator + // eslint-disable-next-line no-in-operator return key in this.data; }; class_1.prototype.delete = function (key) { @@ -792,7 +801,7 @@ var ts; return array1; if (!some(array1)) return array2; - return array1.concat(array2); + return __spreadArrays(array1, array2); } ts.concatenate = concatenate; function deduplicateRelational(array, equalityComparer, comparer) { @@ -849,6 +858,7 @@ var ts; // equality comparison case true: // relational comparison + // falls through case 0 /* EqualTo */: continue; case -1 /* LessThan */: @@ -1239,6 +1249,18 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; + function getAllKeys(obj) { + var result = []; + do { + var names = Object.getOwnPropertyNames(obj); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name = names_1[_i]; + pushIfUnique(result, name); + } + } while (obj = Object.getPrototypeOf(obj)); + return result; + } + ts.getAllKeys = getAllKeys; function getOwnValues(sparseArray) { var values = []; for (var key in sparseArray) { @@ -1436,7 +1458,7 @@ var ts; } ts.cast = cast; /** Does nothing. */ - function noop(_) { } // tslint:disable-line no-empty + function noop(_) { } ts.noop = noop; /** Do nothing and return false */ function returnFalse() { return false; } @@ -1948,7 +1970,7 @@ var ts; return function (arg) { return f(arg) || g(arg); }; } ts.or = or; - function assertType(_) { } // tslint:disable-line no-empty + function assertType(_) { } ts.assertType = assertType; function singleElementArray(t) { return t === undefined ? undefined : [t]; @@ -2025,8 +2047,10 @@ var ts; (function (ts) { var Debug; (function (Debug) { + /* eslint-disable prefer-const */ Debug.currentAssertionLevel = 0 /* None */; Debug.isDebugging = false; + /* eslint-enable prefer-const */ function shouldAssert(level) { return Debug.currentAssertionLevel >= level; } @@ -2075,6 +2099,7 @@ var ts; } Debug.fail = fail; function assertDefined(value, message) { + // eslint-disable-next-line no-null/no-null if (value === undefined || value === null) return fail(message); return value; @@ -2090,7 +2115,7 @@ var ts; Debug.assertEachDefined = assertEachDefined; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } - var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); + var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); return fail(message + " " + detail, stackCrawlMark || assertNever); } Debug.assertNever = assertNever; @@ -2378,6 +2403,47 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var nullLogger = { + logEvent: ts.noop, + logErrEvent: ts.noop, + logPerfEvent: ts.noop, + logInfoEvent: ts.noop, + logStartCommand: ts.noop, + logStopCommand: ts.noop, + logStartUpdateProgram: ts.noop, + logStopUpdateProgram: ts.noop, + logStartUpdateGraph: ts.noop, + logStopUpdateGraph: ts.noop, + logStartResolveModule: ts.noop, + logStopResolveModule: ts.noop, + logStartParseSourceFile: ts.noop, + logStopParseSourceFile: ts.noop, + logStartReadFile: ts.noop, + logStopReadFile: ts.noop, + logStartBindFile: ts.noop, + logStopBindFile: ts.noop, + logStartScheduledOperation: ts.noop, + logStopScheduledOperation: ts.noop, + }; + // Load optional module to enable Event Tracing for Windows + // See https://github.com/microsoft/typescript-etw for more information + var etwModule; + try { + // require() will throw an exception if the module is not installed + // It may also return undefined if not installed properly + etwModule = require("@microsoft/typescript-etw"); + } + catch (e) { + etwModule = undefined; + } + /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ + ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; + var args = typeof process === "undefined" ? [] : process.argv; + ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify(args)); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { // https://semver.org/#spec-item-2 // > A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative @@ -2902,200 +2968,203 @@ var ts; SyntaxKind[SyntaxKind["FromKeyword"] = 145] = "FromKeyword"; SyntaxKind[SyntaxKind["GlobalKeyword"] = 146] = "GlobalKeyword"; SyntaxKind[SyntaxKind["BigIntKeyword"] = 147] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 148] = "OfKeyword"; + SyntaxKind[SyntaxKind["TagKeyword"] = 148] = "TagKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 149] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 149] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 150] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 150] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 151] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 151] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 152] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 153] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 152] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 153] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 154] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 154] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 155] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 156] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 157] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 158] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 159] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 160] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 161] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 162] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 163] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 155] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 156] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 157] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 158] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 159] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 160] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 161] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 162] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 163] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 164] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 164] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 165] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 166] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 167] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 168] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 169] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 170] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 171] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 172] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 173] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 174] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 175] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 176] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 177] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 178] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 179] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 180] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 181] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 182] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 183] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 184] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 165] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 166] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 167] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 168] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 169] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 170] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 171] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 172] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 173] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 174] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 175] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 176] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 177] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 178] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 179] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 180] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 181] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 182] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 183] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 184] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 185] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 185] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 186] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 187] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 186] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 187] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 188] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 188] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 189] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 190] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 191] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 192] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 193] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 194] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 195] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 196] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 197] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 198] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 199] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 200] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 201] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 202] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 203] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 204] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 205] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 206] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 207] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 208] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 209] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 210] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 211] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 212] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 213] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 214] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 215] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 216] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 189] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 190] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 191] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 192] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 193] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 194] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 195] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 196] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 197] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 198] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 199] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 200] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 201] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 202] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 203] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 204] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 205] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 206] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 207] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 208] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 209] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 210] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 211] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 212] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 213] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 214] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 215] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 216] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 217] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 217] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 218] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 218] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 219] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 219] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 220] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 221] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 222] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 223] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 224] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 225] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 226] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 227] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 228] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 229] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 230] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 231] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 232] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 233] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 234] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 235] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 236] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 237] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 238] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 239] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 240] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 241] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 242] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 243] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 244] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 245] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 246] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 247] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 248] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 249] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 250] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 251] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 252] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 253] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 254] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 255] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 256] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 257] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 258] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 259] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 220] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 221] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 222] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 223] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 224] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 225] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 226] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 227] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 228] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 229] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 230] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 231] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 232] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 233] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 234] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 235] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 236] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 237] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 238] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 239] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 240] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 241] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 242] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 243] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 244] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 245] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 246] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 247] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 248] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 249] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 250] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 251] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 252] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 253] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 254] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 255] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 256] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 257] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 258] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 259] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 260] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 260] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 261] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 261] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 262] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 263] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 264] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 265] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 266] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 267] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 268] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 269] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 270] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 271] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 262] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 263] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 264] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 265] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 266] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 267] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 268] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 269] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 270] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 271] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 272] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 272] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 273] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 274] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 275] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 273] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 274] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 275] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 276] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 276] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 277] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 278] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 277] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 278] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 279] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 279] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 280] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 280] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 281] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 282] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 283] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 284] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 281] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 282] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 283] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 284] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 285] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 285] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 286] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 287] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 288] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 286] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 287] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 288] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 289] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 289] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 290] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 290] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 291] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 291] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 292] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 293] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 294] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 295] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 296] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 297] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 298] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 299] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 300] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 301] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 302] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 303] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 304] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 305] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 306] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 307] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 308] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 309] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 310] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 311] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 312] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 292] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 293] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 294] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 295] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 296] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 297] = "JSDocVariadicType"; + // https://jsdoc.app/about-namepaths.html + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 298] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 299] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 300] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 301] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 302] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 303] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 304] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 305] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 306] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 307] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 308] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 309] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 310] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 311] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 312] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 313] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 314] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 313] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 315] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 314] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 315] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 316] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 317] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 318] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 316] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 317] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 318] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 319] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 320] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 319] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 321] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 60] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 72] = "LastAssignment"; @@ -3104,15 +3173,15 @@ var ts; SyntaxKind[SyntaxKind["FirstReservedWord"] = 74] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 109] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 74] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 148] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 149] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 110] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 118] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 164] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 184] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 165] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 185] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 72] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 148] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 149] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -3121,13 +3190,13 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 72] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 149] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 289] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 312] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 300] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 312] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 150] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 290] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 314] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 302] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 314] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 119] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 148] = "LastContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 149] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -3251,6 +3320,8 @@ var ts; /* @internal */ TokenFlags[TokenFlags["ContainsSeparator"] = 512] = "ContainsSeparator"; /* @internal */ + TokenFlags[TokenFlags["UnicodeEscape"] = 1024] = "UnicodeEscape"; + /* @internal */ TokenFlags[TokenFlags["BinaryOrOctalSpecifier"] = 384] = "BinaryOrOctalSpecifier"; /* @internal */ TokenFlags[TokenFlags["NumericLiteralFlags"] = 1008] = "NumericLiteralFlags"; @@ -3281,6 +3352,13 @@ var ts; return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + /*@internal*/ + var RefFileKind; + (function (RefFileKind) { + RefFileKind[RefFileKind["Import"] = 0] = "Import"; + RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile"; + RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective"; + })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {})); /* @internal */ var StructureIsReused; (function (StructureIsReused) { @@ -3301,6 +3379,8 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; // When build skipped because passed in project is invalid ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped"; + // When build is skipped because project references form cycle + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); /* @internal */ var UnionReduction; @@ -3366,7 +3446,6 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 4096] = "UseTypeOfFunction"; TypeFormatFlags[TypeFormatFlags["OmitParameterModifiers"] = 8192] = "OmitParameterModifiers"; TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; - // even though `T` can't be accessed in the current scope. // Error Handling TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; // TypeFormatFlags exclusive @@ -3421,22 +3500,33 @@ var ts; /* @internal */ var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { + // The TypeReferenceNode could not be resolved. + // The type name should be emitted using a safe fallback. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; - // should be emitted using a safe fallback. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a type with a constructor // function that can be reached at runtime (e.g. a `class` // declaration or a `var` declaration for the static side // of a type, such as the global `Promise` type in lib.d.ts). + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a Void-like, Nullable, or Never type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType"; + // The TypeReferenceNode resolves to a Number-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + // The TypeReferenceNode resolves to a BigInt-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType"; + // The TypeReferenceNode resolves to a String-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType"; + // The TypeReferenceNode resolves to a Boolean-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType"; + // The TypeReferenceNode resolves to an Array-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType"; + // The TypeReferenceNode resolves to the ESSymbol type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType"; + // The TypeReferenceNode resolved to the global Promise constructor symbol. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise"; + // The TypeReferenceNode resolves to a Function type or a type with call signatures. TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature"; - // with call signatures. + // The TypeReferenceNode resolves to any other type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var SymbolFlags; @@ -3474,32 +3564,32 @@ var ts; SymbolFlags[SymbolFlags["All"] = 67108863] = "All"; SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; - SymbolFlags[SymbolFlags["Value"] = 67220415] = "Value"; - SymbolFlags[SymbolFlags["Type"] = 67897832] = "Type"; + SymbolFlags[SymbolFlags["Value"] = 111551] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 788968] = "Type"; SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; // Variables can be redeclared, but can not redeclare a block-scoped declaration with the // same name, or any other value that is not a variable, e.g. ValueModule or Class - SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 67220414] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 111550] = "FunctionScopedVariableExcludes"; // Block-scoped declarations are not allowed to be re-declared // they can not merge with anything in the value space - SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 67220415] = "BlockScopedVariableExcludes"; - SymbolFlags[SymbolFlags["ParameterExcludes"] = 67220415] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 111551] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 111551] = "ParameterExcludes"; SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; - SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 68008959] = "EnumMemberExcludes"; - SymbolFlags[SymbolFlags["FunctionExcludes"] = 67219887] = "FunctionExcludes"; - SymbolFlags[SymbolFlags["ClassExcludes"] = 68008383] = "ClassExcludes"; - SymbolFlags[SymbolFlags["InterfaceExcludes"] = 67897736] = "InterfaceExcludes"; - SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 68008191] = "RegularEnumExcludes"; - SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 68008831] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 110991] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899503] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 788872] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 110735] = "ValueModuleExcludes"; SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; - SymbolFlags[SymbolFlags["MethodExcludes"] = 67212223] = "MethodExcludes"; - SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 67154879] = "GetAccessorExcludes"; - SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 67187647] = "SetAccessorExcludes"; - SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 67635688] = "TypeParameterExcludes"; - SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 67897832] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 103359] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 46015] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 78783] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 526824] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 788968] = "TypeAliasExcludes"; SymbolFlags[SymbolFlags["AliasExcludes"] = 2097152] = "AliasExcludes"; SymbolFlags[SymbolFlags["ModuleMember"] = 2623475] = "ModuleMember"; SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; @@ -3618,6 +3708,7 @@ var ts; TypeFlags[TypeFlags["Conditional"] = 16777216] = "Conditional"; TypeFlags[TypeFlags["Substitution"] = 33554432] = "Substitution"; TypeFlags[TypeFlags["NonPrimitive"] = 67108864] = "NonPrimitive"; + TypeFlags[TypeFlags["StructuralTag"] = 134217728] = "StructuralTag"; /* @internal */ TypeFlags[TypeFlags["AnyOrUnknown"] = 3] = "AnyOrUnknown"; /* @internal */ @@ -3644,22 +3735,22 @@ var ts; /* @internal */ TypeFlags[TypeFlags["DisjointDomains"] = 67238908] = "DisjointDomains"; TypeFlags[TypeFlags["UnionOrIntersection"] = 3145728] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 3670016] = "StructuredType"; + TypeFlags[TypeFlags["StructuredType"] = 137887744] = "StructuredType"; TypeFlags[TypeFlags["TypeVariable"] = 8650752] = "TypeVariable"; TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 58982400] = "InstantiableNonPrimitive"; TypeFlags[TypeFlags["InstantiablePrimitive"] = 4194304] = "InstantiablePrimitive"; TypeFlags[TypeFlags["Instantiable"] = 63176704] = "Instantiable"; - TypeFlags[TypeFlags["StructuredOrInstantiable"] = 66846720] = "StructuredOrInstantiable"; + TypeFlags[TypeFlags["StructuredOrInstantiable"] = 201064448] = "StructuredOrInstantiable"; /* @internal */ TypeFlags[TypeFlags["ObjectFlagsType"] = 3899392] = "ObjectFlagsType"; /* @internal */ TypeFlags[TypeFlags["Simplifiable"] = 25165824] = "Simplifiable"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - TypeFlags[TypeFlags["Narrowable"] = 133970943] = "Narrowable"; + TypeFlags[TypeFlags["Narrowable"] = 268188671] = "Narrowable"; TypeFlags[TypeFlags["NotUnionOrUnit"] = 67637251] = "NotUnionOrUnit"; /* @internal */ - TypeFlags[TypeFlags["NotPrimitiveUnion"] = 66994211] = "NotPrimitiveUnion"; + TypeFlags[TypeFlags["NotPrimitiveUnion"] = 201211939] = "NotPrimitiveUnion"; // The following flags are aggregated during union and intersection type construction /* @internal */ TypeFlags[TypeFlags["IncludesMask"] = 68943871] = "IncludesMask"; @@ -3749,7 +3840,9 @@ var ts; InferencePriority[InferencePriority["LiteralKeyof"] = 32] = "LiteralKeyof"; InferencePriority[InferencePriority["NoConstraints"] = 64] = "NoConstraints"; InferencePriority[InferencePriority["AlwaysStrict"] = 128] = "AlwaysStrict"; + InferencePriority[InferencePriority["MaxValue"] = 256] = "MaxValue"; InferencePriority[InferencePriority["PriorityImpliesCombination"] = 56] = "PriorityImpliesCombination"; + InferencePriority[InferencePriority["Circularity"] = -1] = "Circularity"; })(InferencePriority = ts.InferencePriority || (ts.InferencePriority = {})); /* @internal */ var InferenceFlags; @@ -3827,6 +3920,9 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; + // NOTE: ES module kinds should be contiguous to more easily check whether a module kind is *any* ES module kind. + // Non-ES module kinds should not come between ES2015 (the earliest ES module kind) and ESNext (the last ES + // module kind). ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); @@ -4411,7 +4507,7 @@ var ts; function getCustomPollingBasedLevels(baseVariable, defaultLevels) { var customLevels = getCustomLevels(baseVariable); return (pollingIntervalChanged || customLevels) && - createPollingIntervalBasedLevels(customLevels ? __assign({}, defaultLevels, customLevels) : defaultLevels); + createPollingIntervalBasedLevels(customLevels ? __assign(__assign({}, defaultLevels), customLevels) : defaultLevels); } } ts.setCustomPollingValues = setCustomPollingValues; @@ -4565,6 +4661,38 @@ var ts; } } ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile; + /* @internal */ + function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) { + var cache = ts.createMap(); + var callbacksCache = ts.createMultiMap(); + var toCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); + return function (fileName, callback, pollingInterval) { + var path = toCanonicalFileName(fileName); + var existing = cache.get(path); + if (existing) { + existing.refCount++; + } + else { + cache.set(path, { + watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval), + refCount: 1 + }); + } + callbacksCache.add(path, callback); + return { + close: function () { + var watcher = ts.Debug.assertDefined(cache.get(path)); + callbacksCache.remove(path, callback); + watcher.refCount--; + if (watcher.refCount) + return; + cache.delete(path); + ts.closeFileWatcherOf(watcher); + } + }; + }; + } + ts.createSingleFileWatcherPerName = createSingleFileWatcherPerName; /** * Returns true if file status changed */ @@ -4591,6 +4719,8 @@ var ts; ts.getFileWatcherEventKind = getFileWatcherEventKind; /*@internal*/ ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"]; + /*@internal*/ + ts.sysLog = ts.noop; // eslint-disable-line prefer-const /** * Watch the directory recursively using host provided method to watch child directories * that means if this is recursive watcher, watch the children directories as well @@ -4711,6 +4841,7 @@ var ts; } ts.getNodeMajorVersion = getNodeMajorVersion; // TODO: GH#18217 this is used as if it's certainly defined in many places. + // eslint-disable-next-line prefer-const ts.sys = (function () { // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual // byte order mark from the specified encoding. Using any other byte order mark does @@ -4731,6 +4862,7 @@ var ts; 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 FileSystemEntryKind; @@ -4741,6 +4873,7 @@ var ts; var useNonPollingWatchers = process.env.TSC_NONPOLLING_WATCHER; var tscWatchFile = process.env.TSC_WATCHFILE; var tscWatchDirectory = process.env.TSC_WATCHDIRECTORY; + var fsWatchFile = createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames); var dynamicPollingWatchFile; var nodeSystem = { args: process.argv.slice(2), @@ -4877,7 +5010,7 @@ var ts; return useNonPollingWatchers ? createNonPollingWatchFile() : // Default to do not use polling interval as it is before this experiment branch - function (fileName, callback) { return fsWatchFile(fileName, callback); }; + function (fileName, callback) { return fsWatchFile(fileName, callback, /*pollingInterval*/ undefined); }; } function getWatchDirectory() { // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows @@ -4951,7 +5084,7 @@ var ts; return watcher; } } - function fsWatchFile(fileName, callback, pollingInterval) { + function fsWatchFileWorker(fileName, callback, pollingInterval) { _fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged); var eventKind; return { @@ -5009,6 +5142,12 @@ var ts; } function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingWatchFile, pollingInterval) { var options; + var lastDirectoryPartWithDirectorySeparator; + var lastDirectoryPart; + if (isLinuxOrMacOs) { + lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator)); + lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length); + } /** Watcher for the file system entry depending on whether it is missing or present */ var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry() : @@ -5025,6 +5164,7 @@ var ts; * @param createWatcher */ function invokeCallbackAndUpdateWatcher(createWatcher) { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); // Call the callback for current directory callback("rename", ""); // If watcher is not closed, update it @@ -5049,7 +5189,9 @@ var ts; } } try { - var presentWatcher = _fs.watch(fileOrDirectory, options, callback); + var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ? + callbackChangingToMissingFileSystemEntry : + callback); // Watch the missing file or directory or error presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); }); return presentWatcher; @@ -5061,11 +5203,23 @@ var ts; return watchPresentFileSystemEntryWithFsWatchFile(); } } + function callbackChangingToMissingFileSystemEntry(event, relativeName) { + // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations + // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path + return event === "rename" && + (!relativeName || + relativeName === lastDirectoryPart || + relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) && + !fileSystemEntryExists(fileOrDirectory, entryKind) ? + invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) : + callback(event, relativeName); + } /** * Watch the file or directory using fs.watchFile since fs.watch threw exception * Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point */ function watchPresentFileSystemEntryWithFsWatchFile() { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile"); return fallbackPollingWatchFile(fileOrDirectory, createFileWatcherCallback(callback), pollingInterval); } /** @@ -5098,7 +5252,7 @@ var ts; function createWatchDirectoryUsing(fsWatchFile) { return function (directoryName, callback) { return fsWatchFile(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium); }; } - function readFile(fileName, _encoding) { + function readFileWorker(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -5126,7 +5280,14 @@ var ts; // Default is UTF-8 with no byte order mark return buffer.toString("utf8"); } + function readFile(fileName, _encoding) { + ts.perfLogger.logStartReadFile(fileName); + var file = readFileWorker(fileName, _encoding); + ts.perfLogger.logStopReadFile(); + return file; + } function writeFile(fileName, data, writeByteOrderMark) { + ts.perfLogger.logEvent("WriteFile: " + fileName); // If a BOM is required, emit one if (writeByteOrderMark) { data = byteOrderMarkIndicator + data; @@ -5143,6 +5304,7 @@ var ts; } } function getAccessibleFileSystemEntries(path) { + ts.perfLogger.logEvent("ReadDir: " + (path || ".")); try { var entries = _fs.readdirSync(path || ".").sort(); var files = []; @@ -5198,6 +5360,7 @@ var ts; return fileSystemEntryExists(path, 1 /* Directory */); } function getDirectories(path) { + ts.perfLogger.logEvent("ReadDir: " + path); return ts.filter(_fs.readdirSync(path), function (dir) { return fileSystemEntryExists(ts.combinePaths(path, dir), 1 /* Directory */); }); } function realpath(path) { @@ -5325,7 +5488,6 @@ var ts; function diag(code, category, key, message, reportsUnnecessary) { return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary }; } - // tslint:disable-next-line variable-name ts.Diagnostics = { Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), @@ -5388,7 +5550,6 @@ var ts; A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), - An_accessor_cannot_be_declared_in_an_ambient_context: diag(1086, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_declared_in_an_ambient_context_1086", "An accessor cannot be declared in an ambient context."), _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), @@ -5443,7 +5604,6 @@ var ts; Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: diag(1150, ts.DiagnosticCategory.Error, "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", "'new T[]' cannot be used to create an array. Use 'new Array()' instead."), const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), @@ -5541,6 +5701,7 @@ var ts; 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."), Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), 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."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -5573,7 +5734,7 @@ var ts; Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), - The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), @@ -5587,6 +5748,7 @@ var ts; readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), + An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), @@ -6367,6 +6529,8 @@ var ts; Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2: diag(6381, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381", "Project '{0}' is out of date because output for it was generated with version '{1}' that differs with current version '{2}'"), + Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), + Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), 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."), @@ -6482,6 +6646,7 @@ var ts; require_call_may_be_converted_to_an_import: diag(80005, ts.DiagnosticCategory.Suggestion, "require_call_may_be_converted_to_an_import_80005", "'require' call may be converted to an import."), This_may_be_converted_to_an_async_function: diag(80006, ts.DiagnosticCategory.Suggestion, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."), await_has_no_effect_on_the_type_of_this_expression: diag(80007, ts.DiagnosticCategory.Suggestion, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."), + Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, ts.DiagnosticCategory.Suggestion, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."), Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"), Make_super_call_the_first_statement_in_the_constructor: diag(90002, ts.DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"), Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"), @@ -6599,6 +6764,12 @@ var ts; Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"), Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"), Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"), + Enable_the_jsx_flag_in_your_configuration_file: diag(95088, ts.DiagnosticCategory.Message, "Enable_the_jsx_flag_in_your_configuration_file_95088", "Enable the '--jsx' flag in your configuration file"), + Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"), + Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"), + Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"), + Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"), + Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"), 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?"), @@ -6693,10 +6864,11 @@ var ts; _a.yield = 118 /* YieldKeyword */, _a.async = 122 /* AsyncKeyword */, _a.await = 123 /* AwaitKeyword */, - _a.of = 148 /* OfKeyword */, + _a.of = 149 /* OfKeyword */, + _a.tag = 148 /* TagKeyword */, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 28 /* LessThanToken */, ">": 30 /* GreaterThanToken */, "<=": 31 /* LessThanEqualsToken */, ">=": 32 /* GreaterThanEqualsToken */, "==": 33 /* EqualsEqualsToken */, "!=": 34 /* ExclamationEqualsToken */, "===": 35 /* EqualsEqualsEqualsToken */, "!==": 36 /* ExclamationEqualsEqualsToken */, "=>": 37 /* EqualsGreaterThanToken */, "+": 38 /* PlusToken */, "-": 39 /* MinusToken */, "**": 41 /* AsteriskAsteriskToken */, "*": 40 /* AsteriskToken */, "/": 42 /* SlashToken */, "%": 43 /* PercentToken */, "++": 44 /* PlusPlusToken */, "--": 45 /* MinusMinusToken */, "<<": 46 /* LessThanLessThanToken */, ">": 47 /* GreaterThanGreaterThanToken */, ">>>": 48 /* GreaterThanGreaterThanGreaterThanToken */, "&": 49 /* AmpersandToken */, "|": 50 /* BarToken */, "^": 51 /* CaretToken */, "!": 52 /* ExclamationToken */, "~": 53 /* TildeToken */, "&&": 54 /* AmpersandAmpersandToken */, "||": 55 /* BarBarToken */, "?": 56 /* QuestionToken */, ":": 57 /* ColonToken */, "=": 60 /* EqualsToken */, "+=": 61 /* PlusEqualsToken */, "-=": 62 /* MinusEqualsToken */, "*=": 63 /* AsteriskEqualsToken */, "**=": 64 /* AsteriskAsteriskEqualsToken */, "/=": 65 /* SlashEqualsToken */, "%=": 66 /* PercentEqualsToken */, "<<=": 67 /* LessThanLessThanEqualsToken */, ">>=": 68 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 70 /* AmpersandEqualsToken */, "|=": 71 /* BarEqualsToken */, "^=": 72 /* CaretEqualsToken */, "@": 58 /* AtToken */, "`": 59 /* BacktickToken */ })); + var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 28 /* LessThanToken */, ">": 30 /* GreaterThanToken */, "<=": 31 /* LessThanEqualsToken */, ">=": 32 /* GreaterThanEqualsToken */, "==": 33 /* EqualsEqualsToken */, "!=": 34 /* ExclamationEqualsToken */, "===": 35 /* EqualsEqualsEqualsToken */, "!==": 36 /* ExclamationEqualsEqualsToken */, "=>": 37 /* EqualsGreaterThanToken */, "+": 38 /* PlusToken */, "-": 39 /* MinusToken */, "**": 41 /* AsteriskAsteriskToken */, "*": 40 /* AsteriskToken */, "/": 42 /* SlashToken */, "%": 43 /* PercentToken */, "++": 44 /* PlusPlusToken */, "--": 45 /* MinusMinusToken */, "<<": 46 /* LessThanLessThanToken */, ">": 47 /* GreaterThanGreaterThanToken */, ">>>": 48 /* GreaterThanGreaterThanGreaterThanToken */, "&": 49 /* AmpersandToken */, "|": 50 /* BarToken */, "^": 51 /* CaretToken */, "!": 52 /* ExclamationToken */, "~": 53 /* TildeToken */, "&&": 54 /* AmpersandAmpersandToken */, "||": 55 /* BarBarToken */, "?": 56 /* QuestionToken */, ":": 57 /* ColonToken */, "=": 60 /* EqualsToken */, "+=": 61 /* PlusEqualsToken */, "-=": 62 /* MinusEqualsToken */, "*=": 63 /* AsteriskEqualsToken */, "**=": 64 /* AsteriskAsteriskEqualsToken */, "/=": 65 /* SlashEqualsToken */, "%=": 66 /* PercentEqualsToken */, "<<=": 67 /* LessThanLessThanEqualsToken */, ">>=": 68 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 70 /* AmpersandEqualsToken */, "|=": 71 /* BarEqualsToken */, "^=": 72 /* CaretEqualsToken */, "@": 58 /* AtToken */, "`": 59 /* BacktickToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -6743,6 +6915,14 @@ var ts; */ var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + /** + * Generated by scripts/regenerate-unicode-identifier-parts.js on node v12.4.0 with unicode 12.1 + * based on http://www.unicode.org/reports/tr31/ and https://www.ecma-international.org/ecma-262/6.0/#sec-names-and-keywords + * unicodeESNextIdentifierStart corresponds to the ID_Start and Other_ID_Start property, and + * unicodeESNextIdentifierPart corresponds to ID_Continue, Other_ID_Continue, plus ID_Start and Other_ID_Start + */ + var unicodeESNextIdentifierStart = [65, 90, 97, 122, 170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2809, 2809, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101]; + var unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2208, 2228, 2230, 2237, 2259, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3328, 3331, 3333, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7673, 7675, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43047, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69376, 69404, 69415, 69415, 69424, 69456, 69600, 69622, 69632, 69702, 69734, 69743, 69759, 69818, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69958, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70096, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70206, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70751, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71680, 71738, 71840, 71913, 71935, 71935, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123584, 123641, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101, 917760, 917999]; function lookupInUnicodeMap(code, map) { // Bail out quickly if it couldn't possibly be in the map. if (code < map[0]) { @@ -6769,15 +6949,17 @@ var ts; return false; } /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierStart) : - lookupInUnicodeMap(code, unicodeES3IdentifierStart); + return languageVersion >= 2 /* ES2015 */ ? + lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : + languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierPart) : - lookupInUnicodeMap(code, unicodeES3IdentifierPart); + return languageVersion >= 2 /* ES2015 */ ? + lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : + languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { var result = []; @@ -6950,6 +7132,7 @@ var ts; case 32 /* space */: case 47 /* slash */: // starts of normal trivia + // falls through case 60 /* lessThan */: case 124 /* bar */: case 61 /* equals */: @@ -7273,11 +7456,12 @@ var ts; ts.isIdentifierPart = isIdentifierPart; /* @internal */ function isIdentifierText(name, languageVersion) { - if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { + var ch = codePointAt(name, 0); + if (!isIdentifierStart(ch, languageVersion)) { return false; } - for (var i = 1; i < name.length; i++) { - if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { + for (var i = charSize(ch); i < name.length; i += charSize(ch)) { + if (!isIdentifierPart(ch = codePointAt(name, i), languageVersion)) { return false; } } @@ -7301,13 +7485,14 @@ var ts; var tokenFlags; var inJSDocType = 0; setText(text, start, length); - return { + var scanner = { getStartPos: function () { return startPos; }, getTextPos: function () { return pos; }, getToken: function () { return token; }, getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, isIdentifier: function () { return token === 73 /* Identifier */ || token > 109 /* LastReservedWord */; }, @@ -7335,6 +7520,15 @@ var ts; lookAhead: lookAhead, scanRange: scanRange, }; + if (ts.Debug.isDebugging) { + Object.defineProperty(scanner, "__debugShowCurrentPositionInText", { + get: function () { + var text = scanner.getText(); + return text.slice(0, scanner.getStartPos()) + "║" + text.slice(scanner.getStartPos()); + }, + }); + } + return scanner; function error(message, errPos, length) { if (errPos === void 0) { errPos = pos; } if (onError) { @@ -7434,7 +7628,7 @@ var ts; } } function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) { - if (!isIdentifierStart(text.charCodeAt(pos), languageVersion)) { + if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) { return; } var identifierStart = pos; @@ -7642,6 +7836,7 @@ var ts; pos++; return scanExtendedUnicodeEscape(); } + tokenFlags |= 1024 /* UnicodeEscape */; // '\uDDDD' return scanHexadecimalEscape(/*numDigits*/ 4); case 120 /* x */: @@ -7724,21 +7919,41 @@ var ts; } return -1; } + function peekExtendedUnicodeEscape() { + if (languageVersion >= 2 /* ES2015 */ && codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) { + var start_2 = pos; + pos += 3; + var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); + var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; + pos = start_2; + return escapedValue; + } + return -1; + } function scanIdentifierParts() { var result = ""; var start = pos; while (pos < end) { - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); if (isIdentifierPart(ch, languageVersion)) { - pos++; + pos += charSize(ch); } else if (ch === 92 /* backslash */) { + ch = peekExtendedUnicodeEscape(); + if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + result += scanExtendedUnicodeEscape(); + start = pos; + continue; + } ch = peekUnicodeEscape(); if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } + tokenFlags |= 1024 /* UnicodeEscape */; result += text.substring(start, pos); - result += String.fromCharCode(ch); + result += utf16EncodeAsString(ch); // Valid Unicode escape is always six characters pos += 6; start = pos; @@ -7826,14 +8041,14 @@ var ts; function scan() { var _a; startPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; var asteriskSeen = false; while (true) { tokenPos = pos; if (pos >= end) { return token = 1 /* EndOfFileToken */; } - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); // Special handling for shebang if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); @@ -8198,9 +8413,17 @@ var ts; pos++; return token = 58 /* AtToken */; case 92 /* backslash */: + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; + tokenFlags |= 1024 /* UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } @@ -8209,9 +8432,9 @@ var ts; return token = 0 /* Unknown */; default: if (isIdentifierStart(ch, languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; + pos += charSize(ch); + while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) + pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); if (ch === 92 /* backslash */) { tokenValue += scanIdentifierParts(); @@ -8219,16 +8442,16 @@ var ts; return token = getIdentifierToken(); } else if (isWhiteSpaceSingleLine(ch)) { - pos++; + pos += charSize(ch); continue; } else if (isLineBreak(ch)) { tokenFlags |= 1 /* PrecedingLineBreak */; - pos++; + pos += charSize(ch); continue; } error(ts.Diagnostics.Invalid_character); - pos++; + pos += charSize(ch); return token = 0 /* Unknown */; } } @@ -8345,7 +8568,7 @@ var ts; // First non-whitespace character on this line. var firstNonWhitespace = 0; // These initial values are special because the first line is: - // firstNonWhitespace = 0 to indicate that we want leading whitspace, + // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { char = text.charCodeAt(pos); if (char === 123 /* openBrace */) { @@ -8379,17 +8602,22 @@ var ts; // they allow dashes function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { - var firstCharPosition = pos; + // An identifier or keyword has already been parsed - check for a `-` and then append it and everything after it to the token + // Do note that this means that `scanJsxIdentifier` effectively _mutates_ the visible token without advancing to a new token + // Any caller should be expecting this behavior and should only read the pos or token value after calling it. while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { + if (ch === 45 /* minus */) { + tokenValue += "-"; pos++; + continue; } - else { + var oldPos = pos; + tokenValue += scanIdentifierParts(); // reuse `scanIdentifierParts` so unicode escapes are handled + if (pos === oldPos) { break; } } - tokenValue += text.substring(firstCharPosition, pos); } return token; } @@ -8407,12 +8635,12 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; if (pos >= end) { return token = 1 /* EndOfFileToken */; } - var ch = text.charCodeAt(pos); - pos++; + var ch = codePointAt(text, pos); + pos += charSize(ch); switch (ch) { case 9 /* tab */: case 11 /* verticalTab */: @@ -8450,12 +8678,33 @@ var ts; return token = 24 /* DotToken */; case 96 /* backtick */: return token = 59 /* BacktickToken */; - } - if (isIdentifierStart(ch, 99 /* Latest */)) { - while (isIdentifierPart(text.charCodeAt(pos), 99 /* Latest */) && pos < end) { + case 92 /* backslash */: + pos--; + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } + var cookedChar = peekUnicodeEscape(); + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + pos += 6; + tokenFlags |= 1024 /* UnicodeEscape */; + tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); + return token = getIdentifierToken(); + } pos++; - } + return token = 0 /* Unknown */; + } + if (isIdentifierStart(ch, languageVersion)) { + var char = ch; + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) + pos += charSize(char); tokenValue = text.substring(tokenPos, pos); + if (char === 92 /* backslash */) { + tokenValue += scanIdentifierParts(); + } return token = getIdentifierToken(); } else { @@ -8531,13 +8780,40 @@ var ts; tokenPos = textPos; token = 0 /* Unknown */; tokenValue = undefined; - tokenFlags = 0; + tokenFlags = 0 /* None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; } } ts.createScanner = createScanner; + /* @internal */ + var codePointAt = String.prototype.codePointAt ? function (s, i) { return s.codePointAt(i); } : function codePointAt(str, i) { + // from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt + var size = str.length; + // Account for out-of-bounds indices: + if (i < 0 || i >= size) { + return undefined; // String.codePointAt returns `undefined` for OOB indexes + } + // Get the first code unit + var first = str.charCodeAt(i); + // check if it’s the start of a surrogate pair + if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) { // high surrogate and there is a next code unit + var second = str.charCodeAt(i + 1); + if (second >= 0xDC00 && second <= 0xDFFF) { // low surrogate + // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + } + } + return first; + }; + /* @internal */ + function charSize(ch) { + if (ch >= 0x10000) { + return 2; + } + return 1; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -8704,7 +8980,7 @@ var ts; } ts.copyEntries = copyEntries; function arrayToSet(array, makeKey) { - return ts.arrayToMap(array, makeKey || (function (s) { return s; }), function () { return true; }); + return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue); } ts.arrayToSet = arrayToSet; function cloneMap(map) { @@ -8813,7 +9089,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 285 /* SourceFile */) { + while (node && node.kind !== 286 /* SourceFile */) { node = node.parent; } return node; @@ -8821,11 +9097,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 220 /* Block */: + case 248 /* CaseBlock */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: return true; } return false; @@ -8910,7 +9186,7 @@ var ts; break; } } - to.splice.apply(to, [statementIndex, 0].concat(from)); + to.splice.apply(to, __spreadArrays([statementIndex, 0], from)); return to; } function insertStatementAfterPrologue(to, statement, isPrologueDirective) { @@ -8993,7 +9269,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 313 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 315 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -9012,7 +9288,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 289 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 290 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -9058,6 +9334,8 @@ var ts; ts.isBigIntLiteral(node))) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } + // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text + // had to include a backslash: `not \${a} substitution`. var escapeText = neverAsciiEscape || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; // If we can't reach the original source text, use the canonical form if it's a number, // or a (possibly escaped) quoted form of the original text if it's string-like. @@ -9070,15 +9348,21 @@ var ts; return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; } case 14 /* NoSubstitutionTemplateLiteral */: - return "`" + escapeText(node.text, 96 /* backtick */) + "`"; case 15 /* TemplateHead */: - // tslint:disable-next-line no-invalid-template-strings - return "`" + escapeText(node.text, 96 /* backtick */) + "${"; case 16 /* TemplateMiddle */: - // tslint:disable-next-line no-invalid-template-strings - return "}" + escapeText(node.text, 96 /* backtick */) + "${"; case 17 /* TemplateTail */: - return "}" + escapeText(node.text, 96 /* backtick */) + "`"; + var rawText = node.rawText || escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); + switch (node.kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + return "`" + rawText + "`"; + case 15 /* TemplateHead */: + return "`" + rawText + "${"; + case 16 /* TemplateMiddle */: + return "}" + rawText + "${"; + case 17 /* TemplateTail */: + return "}" + rawText + "`"; + } + break; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 13 /* RegularExpressionLiteral */: @@ -9104,7 +9388,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 238 /* VariableDeclaration */ && node.parent.kind === 275 /* CatchClause */; + return node.kind === 239 /* VariableDeclaration */ && node.parent.kind === 276 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -9136,11 +9420,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 === 245 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 246 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 285 /* SourceFile */ || - node.kind === 245 /* ModuleDeclaration */ || + return node.kind === 286 /* SourceFile */ || + node.kind === 246 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -9157,9 +9441,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: return ts.isExternalModule(node.parent); - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -9173,24 +9457,61 @@ var ts; return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS) && !!node.commonJsModuleIndicator); } ts.isEffectiveExternalModule = isEffectiveExternalModule; + /** + * Returns whether the source file will be treated as if it were in strict mode at runtime. + */ + function isEffectiveStrictModeSourceFile(node, compilerOptions) { + // We can only verify strict mode for JS/TS files + switch (node.scriptKind) { + case 1 /* JS */: + case 3 /* TS */: + case 2 /* JSX */: + case 4 /* TSX */: + break; + default: + return false; + } + // Strict mode does not matter for declaration files. + if (node.isDeclarationFile) { + return false; + } + // If `alwaysStrict` is set, then treat the file as strict. + if (ts.getStrictOptionValue(compilerOptions, "alwaysStrict")) { + return true; + } + // Starting with a "use strict" directive indicates the file is strict. + if (ts.startsWithUseStrict(node.statements)) { + return true; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + // ECMAScript Modules are always strict. + if (ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { + return true; + } + // Other modules are strict unless otherwise specified. + return !compilerOptions.noImplicitUseStrict; + } + return false; + } + ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 275 /* CatchClause */: - case 245 /* ModuleDeclaration */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 286 /* SourceFile */: + case 248 /* CaseBlock */: + case 276 /* CatchClause */: + case 246 /* ModuleDeclaration */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return true; - case 219 /* Block */: + case 220 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -9200,9 +9521,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: - case 299 /* JSDocSignature */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 301 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -9212,25 +9533,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 157 /* MethodSignature */: + case 164 /* IndexSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 296 /* JSDocFunctionType */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 312 /* JSDocTemplateTag */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -9240,8 +9561,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: return true; default: return false; @@ -9250,15 +9571,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 220 /* VariableStatement */: - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 221 /* VariableStatement */: + case 242 /* ClassDeclaration */: + case 241 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: return true; default: return false; @@ -9294,7 +9615,7 @@ var ts; case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 151 /* 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"); @@ -9307,9 +9628,9 @@ var ts; switch (name.kind) { case 73 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -9354,7 +9675,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 219 /* Block */) { + if (node.body && node.body.kind === 220 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -9368,7 +9689,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 285 /* SourceFile */: + case 286 /* 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 @@ -9377,25 +9698,25 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 239 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 244 /* TypeAliasDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: errorNode = node.name; break; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -9403,6 +9724,7 @@ var ts; // construct. return getSpanOfTokenAtPosition(sourceFile, node.pos); } + ts.Debug.assert(!ts.isJSDoc(errorNode)); var isMissing = nodeIsMissing(errorNode); var pos = isMissing || ts.isJsxText(node) ? errorNode.pos @@ -9432,7 +9754,7 @@ var ts; } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { @@ -9444,19 +9766,25 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 99 /* SuperKeyword */; + return n.kind === 193 /* CallExpression */ && n.expression.kind === 99 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 93 /* ImportKeyword */; + return n.kind === 193 /* CallExpression */ && n.expression.kind === 93 /* ImportKeyword */; } ts.isImportCall = isImportCall; + function isImportMeta(n) { + return ts.isMetaProperty(n) + && n.keywordToken === 93 /* ImportKeyword */ + && n.name.escapedText === "meta"; + } + ts.isImportMeta = isImportMeta; function isLiteralImportTypeNode(n) { return ts.isImportTypeNode(n) && ts.isLiteralTypeNode(n.argument) && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 222 /* ExpressionStatement */ + return node.kind === 223 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -9465,11 +9793,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 152 /* Parameter */ || - node.kind === 151 /* TypeParameter */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 198 /* ArrowFunction */ || - node.kind === 196 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 153 /* Parameter */ || + node.kind === 152 /* TypeParameter */ || + node.kind === 198 /* FunctionExpression */ || + node.kind === 199 /* ArrowFunction */ || + node.kind === 197 /* ParenthesizedExpression */) ? 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 '/**/' @@ -9485,7 +9813,7 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (164 /* FirstTypeNode */ <= node.kind && node.kind <= 184 /* LastTypeNode */) { + if (165 /* FirstTypeNode */ <= node.kind && node.kind <= 185 /* LastTypeNode */) { return true; } switch (node.kind) { @@ -9501,32 +9829,32 @@ var ts; case 133 /* NeverKeyword */: return true; case 107 /* VoidKeyword */: - return node.parent.kind !== 201 /* VoidExpression */; - case 212 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 202 /* VoidExpression */; + case 213 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 151 /* TypeParameter */: - return node.parent.kind === 182 /* MappedType */ || node.parent.kind === 177 /* InferType */; + case 152 /* TypeParameter */: + return node.parent.kind === 183 /* MappedType */ || node.parent.kind === 178 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 73 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 150 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 191 /* 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 === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */ || node.kind === 190 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 73 /* Identifier */ || node.kind === 150 /* QualifiedName */ || node.kind === 191 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 149 /* QualifiedName */: - case 190 /* PropertyAccessExpression */: + case 150 /* QualifiedName */: + case 191 /* PropertyAccessExpression */: case 101 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 168 /* TypeQuery */) { + if (parent.kind === 169 /* TypeQuery */) { return false; } - if (parent.kind === 184 /* ImportType */) { + if (parent.kind === 185 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -9535,40 +9863,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 (164 /* FirstTypeNode */ <= parent.kind && parent.kind <= 184 /* LastTypeNode */) { + if (165 /* FirstTypeNode */ <= parent.kind && parent.kind <= 185 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return node === parent.constraint; - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return node === parent.constraint; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 153 /* Parameter */: + case 239 /* VariableDeclaration */: return node === parent.type; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return node === parent.type; - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: return node === parent.type; - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: return node === parent.type; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -9593,23 +9921,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitor(node); - case 247 /* CaseBlock */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 248 /* CaseBlock */: + case 220 /* Block */: + case 224 /* IfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 233 /* WithStatement */: + case 234 /* SwitchStatement */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: + case 235 /* LabeledStatement */: + case 237 /* TryStatement */: + case 276 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -9619,26 +9947,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 245 /* EnumDeclaration */: + case 243 /* InterfaceDeclaration */: + case 246 /* ModuleDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 151 /* 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); @@ -9661,10 +9989,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 170 /* ArrayType */) { + if (node && node.kind === 171 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 165 /* TypeReference */) { + else if (node && node.kind === 166 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9674,12 +10002,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 169 /* TypeLiteral */: + case 243 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 170 /* TypeLiteral */: return node.members; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return node.properties; } } @@ -9687,14 +10015,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 187 /* BindingElement */: - case 279 /* EnumMember */: - case 152 /* Parameter */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 277 /* ShorthandPropertyAssignment */: - case 238 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 280 /* EnumMember */: + case 153 /* Parameter */: + case 277 /* PropertyAssignment */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 278 /* ShorthandPropertyAssignment */: + case 239 /* VariableDeclaration */: return true; } } @@ -9706,8 +10034,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 239 /* VariableDeclarationList */ - && node.parent.parent.kind === 220 /* VariableStatement */; + return node.parent.kind === 240 /* VariableDeclarationList */ + && node.parent.parent.kind === 221 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -9718,13 +10046,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: return true; } return false; @@ -9735,7 +10063,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 234 /* LabeledStatement */) { + if (node.statement.kind !== 235 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -9743,17 +10071,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 219 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 220 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 157 /* MethodDeclaration */ && node.parent.kind === 189 /* ObjectLiteralExpression */; + return node && node.kind === 158 /* MethodDeclaration */ && node.parent.kind === 190 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 157 /* MethodDeclaration */ && - (node.parent.kind === 189 /* ObjectLiteralExpression */ || - node.parent.kind === 210 /* ClassExpression */); + return node.kind === 158 /* MethodDeclaration */ && + (node.parent.kind === 190 /* ObjectLiteralExpression */ || + node.parent.kind === 211 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -9766,7 +10094,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 276 /* PropertyAssignment */) { + if (property.kind === 277 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -9807,14 +10135,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 285 /* SourceFile */); + ts.Debug.assert(node.kind !== 286 /* 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 150 /* ComputedPropertyName */: + case 151 /* 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 @@ -9829,9 +10157,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 153 /* Decorator */: + case 154 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 153 /* 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; @@ -9842,26 +10170,26 @@ var ts; node = node.parent; } break; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 245 /* ModuleDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 244 /* EnumDeclaration */: - case 285 /* SourceFile */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 246 /* ModuleDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 245 /* EnumDeclaration */: + case 286 /* SourceFile */: return node; } } @@ -9871,9 +10199,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 159 /* Constructor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: return container; } } @@ -9895,27 +10223,27 @@ var ts; return node; } switch (node.kind) { - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: node = node.parent; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return node; - case 153 /* Decorator */: + case 154 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 153 /* 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; @@ -9931,14 +10259,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 197 /* FunctionExpression */ || func.kind === 198 /* ArrowFunction */) { + if (func.kind === 198 /* FunctionExpression */ || func.kind === 199 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 196 /* ParenthesizedExpression */) { + while (parent.kind === 197 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 192 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 193 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -9954,7 +10282,7 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) + return (kind === 191 /* PropertyAccessExpression */ || kind === 192 /* ElementAccessExpression */) && node.expression.kind === 99 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; @@ -9963,20 +10291,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) + return (kind === 191 /* PropertyAccessExpression */ || kind === 192 /* ElementAccessExpression */) && node.expression.kind === 101 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return node; } return undefined; @@ -9984,10 +10312,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return node.tag; - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -9996,25 +10324,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: // classes are valid targets return true; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 241 /* ClassDeclaration */; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + return parent.kind === 242 /* ClassDeclaration */; + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 158 /* 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 === 241 /* ClassDeclaration */; - case 152 /* Parameter */: + && parent.kind === 242 /* ClassDeclaration */; + case 153 /* 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 === 158 /* Constructor */ - || parent.kind === 157 /* MethodDeclaration */ - || parent.kind === 160 /* SetAccessor */) - && grandparent.kind === 241 /* ClassDeclaration */; + && (parent.kind === 159 /* Constructor */ + || parent.kind === 158 /* MethodDeclaration */ + || parent.kind === 161 /* SetAccessor */) + && grandparent.kind === 242 /* ClassDeclaration */; } return false; } @@ -10030,10 +10358,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 161 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -10042,9 +10370,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 263 /* JsxOpeningElement */ || - parent.kind === 262 /* JsxSelfClosingElement */ || - parent.kind === 264 /* JsxClosingElement */) { + if (parent.kind === 264 /* JsxOpeningElement */ || + parent.kind === 263 /* JsxSelfClosingElement */ || + parent.kind === 265 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -10057,45 +10385,45 @@ var ts; case 103 /* TrueKeyword */: case 88 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 213 /* AsExpression */: - case 195 /* TypeAssertionExpression */: - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 209 /* SpreadElement */: - case 207 /* TemplateExpression */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 195 /* TaggedTemplateExpression */: + case 214 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 215 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: + case 198 /* FunctionExpression */: + case 211 /* ClassExpression */: + case 199 /* ArrowFunction */: + case 202 /* VoidExpression */: + case 200 /* DeleteExpression */: + case 201 /* TypeOfExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: + case 206 /* BinaryExpression */: + case 207 /* ConditionalExpression */: + case 210 /* SpreadElement */: + case 208 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: - case 211 /* OmittedExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 208 /* YieldExpression */: - case 202 /* AwaitExpression */: - case 215 /* MetaProperty */: + case 212 /* OmittedExpression */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 266 /* JsxFragment */: + case 209 /* YieldExpression */: + case 203 /* AwaitExpression */: + case 216 /* MetaProperty */: return true; - case 149 /* QualifiedName */: - while (node.parent.kind === 149 /* QualifiedName */) { + case 150 /* QualifiedName */: + while (node.parent.kind === 150 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node); + return node.parent.kind === 169 /* TypeQuery */ || isJSXTagName(node); case 73 /* Identifier */: - if (node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node)) { + if (node.parent.kind === 169 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through @@ -10112,49 +10440,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 187 /* BindingElement */: + case 239 /* VariableDeclaration */: + case 153 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 280 /* EnumMember */: + case 277 /* PropertyAssignment */: + case 188 /* BindingElement */: return parent.initializer === node; - case 222 /* ExpressionStatement */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 231 /* ReturnStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 235 /* ThrowStatement */: + case 223 /* ExpressionStatement */: + case 224 /* IfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 232 /* ReturnStatement */: + case 233 /* WithStatement */: + case 234 /* SwitchStatement */: + case 273 /* CaseClause */: + case 236 /* ThrowStatement */: return parent.expression === node; - case 226 /* ForStatement */: + case 227 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 240 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 240 /* VariableDeclarationList */) || forInStatement.expression === node; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: return node === parent.expression; - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return node === parent.expression; - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return node === parent.expression; - case 153 /* Decorator */: - case 271 /* JsxExpression */: - case 270 /* JsxSpreadAttribute */: - case 278 /* SpreadAssignment */: + case 154 /* Decorator */: + case 272 /* JsxExpression */: + case 271 /* JsxSpreadAttribute */: + case 279 /* SpreadAssignment */: return true; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -10162,7 +10490,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */; + return node.kind === 250 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 261 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -10171,7 +10499,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 260 /* ExternalModuleReference */; + return node.kind === 250 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 261 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -10203,7 +10531,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 192 /* CallExpression */) { + if (callExpression.kind !== 193 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -10315,11 +10643,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 197 /* FunctionExpression */ || e.kind === 198 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 198 /* FunctionExpression */ || e.kind === 199 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 197 /* FunctionExpression */ || - initializer.kind === 210 /* ClassExpression */ || - initializer.kind === 198 /* ArrowFunction */) { + if (initializer.kind === 198 /* FunctionExpression */ || + initializer.kind === 211 /* ClassExpression */ || + initializer.kind === 199 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -10487,7 +10815,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 222 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 223 /* ExpressionStatement */ && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -10496,7 +10824,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 240 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 241 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -10505,14 +10833,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: return node.parent; - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: return node.parent.parent; - case 192 /* CallExpression */: + case 193 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 183 /* LiteralType */: + case 184 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -10522,12 +10850,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: return node.moduleSpecifier; - case 249 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 260 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 184 /* ImportType */: + case 250 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 261 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 185 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -10536,11 +10864,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return node; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -10548,19 +10876,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 250 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 251 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 152 /* Parameter */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 277 /* ShorthandPropertyAssignment */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 153 /* Parameter */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 278 /* ShorthandPropertyAssignment */: + case 277 /* PropertyAssignment */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -10574,7 +10902,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 311 /* JSDocTypedefTag */ || node.kind === 304 /* JSDocCallbackTag */; + return node.kind === 313 /* JSDocTypedefTag */ || node.kind === 306 /* JSDocCallbackTag */ || node.kind === 307 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10599,12 +10927,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return node.initializer; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return node.initializer; } } @@ -10615,7 +10943,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 245 /* ModuleDeclaration */ + node.body.kind === 246 /* ModuleDeclaration */ ? node.body : undefined; } @@ -10630,11 +10958,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 152 /* Parameter */) { + if (node.kind === 153 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 151 /* TypeParameter */) { + if (node.kind === 152 /* TypeParameter */) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -10645,10 +10973,10 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 276 /* PropertyAssignment */ || - parent.kind === 255 /* ExportAssignment */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 222 /* ExpressionStatement */ && node.kind === 190 /* PropertyAccessExpression */ || + if (parent.kind === 277 /* PropertyAssignment */ || + parent.kind === 256 /* ExportAssignment */ || + parent.kind === 156 /* PropertyDeclaration */ || + parent.kind === 223 /* ExpressionStatement */ && node.kind === 191 /* PropertyAccessExpression */ || getNestedModuleDeclaration(parent) || ts.isBinaryExpression(node) && node.operatorToken.kind === 60 /* EqualsToken */) { return parent; @@ -10709,7 +11037,7 @@ var ts; function getTypeParameterFromJsDoc(node) { var name = node.name.escapedText; var typeParameters = node.parent.parent.parent.typeParameters; - return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); + return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { @@ -10719,7 +11047,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 === 296 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 297 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10732,31 +11060,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 60 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 44 /* PlusPlusToken */ || unaryOperator === 45 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 196 /* ParenthesizedExpression */: - case 188 /* ArrayLiteralExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: + case 189 /* ArrayLiteralExpression */: + case 210 /* SpreadElement */: + case 215 /* NonNullExpression */: node = parent; break; - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -10783,22 +11111,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 219 /* Block */: - case 220 /* VariableStatement */: - case 232 /* WithStatement */: - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 220 /* Block */: + case 221 /* VariableStatement */: + case 233 /* WithStatement */: + case 224 /* IfStatement */: + case 234 /* SwitchStatement */: + case 248 /* CaseBlock */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: + case 235 /* LabeledStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 237 /* TryStatement */: + case 276 /* CatchClause */: return true; } return false; @@ -10815,33 +11143,33 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 178 /* ParenthesizedType */); + return walkUp(node, 179 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 196 /* ParenthesizedExpression */); + return walkUp(node, 197 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 197 /* ParenthesizedExpression */) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 197 /* 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 !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 191 /* PropertyAccessExpression */ && node.kind !== 192 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 199 /* DeleteExpression */; + return node && node.kind === 200 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -10891,7 +11219,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 10 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 150 /* ComputedPropertyName */ && + node.parent.kind === 151 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -10899,32 +11227,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 190 /* PropertyAccessExpression */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 280 /* EnumMember */: + case 277 /* PropertyAssignment */: + case 191 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 149 /* QualifiedName */) { + while (parent.kind === 150 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 168 /* TypeQuery */ || parent.kind === 165 /* TypeReference */; + return parent.kind === 169 /* TypeQuery */ || parent.kind === 166 /* TypeReference */; } return false; - case 187 /* BindingElement */: - case 254 /* ImportSpecifier */: + case 188 /* BindingElement */: + case 255 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 258 /* ExportSpecifier */: - case 268 /* JsxAttribute */: + case 259 /* ExportSpecifier */: + case 269 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -10941,13 +11269,13 @@ var ts; // export default // module.exports = function isAliasSymbolDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 248 /* NamespaceExportDeclaration */ || - node.kind === 251 /* ImportClause */ && !!node.name || - node.kind === 252 /* NamespaceImport */ || - node.kind === 254 /* ImportSpecifier */ || - node.kind === 258 /* ExportSpecifier */ || - node.kind === 255 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + return node.kind === 250 /* ImportEqualsDeclaration */ || + node.kind === 249 /* NamespaceExportDeclaration */ || + node.kind === 252 /* ImportClause */ && !!node.name || + node.kind === 253 /* NamespaceImport */ || + node.kind === 255 /* ImportSpecifier */ || + node.kind === 259 /* ExportSpecifier */ || + node.kind === 256 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -10980,9 +11308,9 @@ var ts; ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { - return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray - : ts.emptyArray; + return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray : + ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : + ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { @@ -11013,17 +11341,21 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 74 /* FirstKeyword */ <= token && token <= 148 /* LastKeyword */; + return 74 /* FirstKeyword */ <= token && token <= 149 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 119 /* FirstContextualKeyword */ <= token && token <= 148 /* LastContextualKeyword */; + return 119 /* FirstContextualKeyword */ <= token && token <= 149 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { return isKeyword(token) && !isContextualKeyword(token); } ts.isNonContextualKeyword = isNonContextualKeyword; + function isFutureReservedKeyword(token) { + return 110 /* FirstFutureReservedWord */ <= token && token <= 118 /* LastFutureReservedWord */; + } + ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { var token = ts.stringToToken(name); return token !== undefined && isNonContextualKeyword(token); @@ -11052,14 +11384,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -11073,10 +11405,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -11109,7 +11441,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 150 /* ComputedPropertyName */ && + return name.kind === 151 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression) && !isSignedNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); @@ -11131,7 +11463,7 @@ var ts; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -11186,11 +11518,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 152 /* Parameter */; + return root.kind === 153 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 187 /* BindingElement */) { + while (node.kind === 188 /* BindingElement */) { node = node.parent.parent; } return node; @@ -11198,15 +11530,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 197 /* FunctionExpression */ - || kind === 240 /* FunctionDeclaration */ - || kind === 198 /* ArrowFunction */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 245 /* ModuleDeclaration */ - || kind === 285 /* SourceFile */; + return kind === 159 /* Constructor */ + || kind === 198 /* FunctionExpression */ + || kind === 241 /* FunctionDeclaration */ + || kind === 199 /* ArrowFunction */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */ + || kind === 246 /* ModuleDeclaration */ + || kind === 286 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -11225,23 +11557,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 194 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 193 /* NewExpression */: + case 194 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: + case 204 /* PrefixUnaryExpression */: + case 201 /* TypeOfExpression */: + case 202 /* VoidExpression */: + case 200 /* DeleteExpression */: + case 203 /* AwaitExpression */: + case 207 /* ConditionalExpression */: + case 209 /* YieldExpression */: return 1 /* Right */; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (operator) { case 41 /* AsteriskAsteriskToken */: case 60 /* EqualsToken */: @@ -11265,15 +11597,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 194 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 205 /* BinaryExpression */) { + if (expression.kind === 206 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 203 /* PrefixUnaryExpression */ || expression.kind === 204 /* PostfixUnaryExpression */) { + else if (expression.kind === 204 /* PrefixUnaryExpression */ || expression.kind === 205 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -11283,15 +11615,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: return 0; - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return 1; - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return 2; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return 4; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0; @@ -11312,21 +11644,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: + case 204 /* PrefixUnaryExpression */: + case 201 /* TypeOfExpression */: + case 202 /* VoidExpression */: + case 200 /* DeleteExpression */: + case 203 /* AwaitExpression */: return 16; - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return 17; - case 192 /* CallExpression */: + case 193 /* CallExpression */: return 18; - case 193 /* NewExpression */: + case 194 /* NewExpression */: return hasArguments ? 19 : 18; - case 194 /* TaggedTemplateExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 195 /* TaggedTemplateExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return 19; case 101 /* ThisKeyword */: case 99 /* SuperKeyword */: @@ -11337,19 +11669,19 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 211 /* ClassExpression */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 266 /* JsxFragment */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 196 /* ParenthesizedExpression */: - case 211 /* OmittedExpression */: + case 208 /* TemplateExpression */: + case 197 /* ParenthesizedExpression */: + case 212 /* OmittedExpression */: return 20; default: return -1; @@ -11469,6 +11801,10 @@ var ts; } } ts.createDiagnosticCollection = createDiagnosticCollection; + var templateSubstitutionRegExp = /\$\{/g; + function escapeTemplateSubstitution(str) { + return str.replace(templateSubstitutionRegExp, "\\${"); + } // This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, // paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in // the language service. These characters should be escaped when printing, and if any characters are added, @@ -11476,7 +11812,8 @@ var ts; // There is no reason for this other than that JSON.stringify does not handle it either. var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var backtickQuoteEscapedCharsRegExp = /[\\\`\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + // Template strings should be preserved as much as possible + var backtickQuoteEscapedCharsRegExp = /[\\\`]/g; var escapedCharsMap = ts.createMapFromTemplate({ "\t": "\\t", "\v": "\\v", @@ -11654,7 +11991,7 @@ var ts; }; } ts.createTextWriter = createTextWriter; - function getTrailingSemicolonOmittingWriter(writer) { + function getTrailingSemicolonDeferringWriter(writer) { var pendingTrailingSemicolon = false; function commitPendingTrailingSemicolon() { if (pendingTrailingSemicolon) { @@ -11662,7 +11999,7 @@ var ts; pendingTrailingSemicolon = false; } } - return __assign({}, writer, { writeTrailingSemicolon: function () { + return __assign(__assign({}, writer), { writeTrailingSemicolon: function () { pendingTrailingSemicolon = true; }, writeLiteral: function (s) { @@ -11716,6 +12053,17 @@ var ts; decreaseIndent: function () { commitPendingTrailingSemicolon(); writer.decreaseIndent(); + }, + resetPendingTrailingSemicolon: function () { + pendingTrailingSemicolon = false; + } }); + } + ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter; + function getTrailingSemicolonOmittingWriter(writer) { + var deferringWriter = getTrailingSemicolonDeferringWriter(writer); + return __assign(__assign({}, deferringWriter), { writeLine: function () { + deferringWriter.resetPendingTrailingSemicolon(); + writer.writeLine(); } }); } ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; @@ -11837,6 +12185,7 @@ var ts; return accessor.parameters[hasThis ? 1 : 0]; } } + ts.getSetAccessorValueParameter = getSetAccessorValueParameter; /** Get the type annotation for the value parameter. */ function getSetAccessorTypeAnnotationNode(accessor) { var parameter = getSetAccessorValueParameter(accessor); @@ -11873,10 +12222,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 160 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 160 /* SetAccessor */) { + else if (accessor.kind === 161 /* SetAccessor */) { setAccessor = accessor; } else { @@ -11896,10 +12245,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 159 /* GetAccessor */ && !getAccessor) { + if (member.kind === 160 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 160 /* SetAccessor */ && !setAccessor) { + if (member.kind === 161 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -11945,7 +12294,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 === 297 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 299 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -12243,8 +12592,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 189 /* ObjectLiteralExpression */ - || kind === 188 /* ArrayLiteralExpression */; + return kind === 190 /* ObjectLiteralExpression */ + || kind === 189 /* ArrayLiteralExpression */; } return false; } @@ -12276,17 +12625,17 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 150 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 191 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 189 /* ObjectLiteralExpression */ && + return expression.kind === 190 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 188 /* ArrayLiteralExpression */ && + return expression.kind === 189 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -12584,8 +12933,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 246 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -12662,35 +13011,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return accessKind(parent); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 44 /* PlusPlusToken */ || operator === 45 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? operatorToken.kind === 60 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 276 /* PropertyAssignment */: { + case 277 /* 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 277 /* ShorthandPropertyAssignment */: + case 278 /* 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 188 /* ArrayLiteralExpression */: + case 189 /* 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 === 222 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 223 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -12736,8 +13085,8 @@ var ts; /** * Mutates the map with newMap such that keys in map will be same as newMap. */ - function mutateMap(map, newMap, options) { - var createNewValue = options.createNewValue, onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; + function mutateMapSkippingNewValues(map, newMap, options) { + var onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; // Needs update map.forEach(function (existingValue, key) { var valueInNewMap = newMap.get(key); @@ -12751,6 +13100,15 @@ var ts; onExistingValue(existingValue, valueInNewMap, key); } }); + } + ts.mutateMapSkippingNewValues = mutateMapSkippingNewValues; + /** + * Mutates the map with newMap such that keys in map will be same as newMap. + */ + function mutateMap(map, newMap, options) { + // Needs update + mutateMapSkippingNewValues(map, newMap, options); + var createNewValue = options.createNewValue; // Add new values that are not already present newMap.forEach(function (valueInNewMap, key) { if (!map.has(key)) { @@ -12845,7 +13203,7 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) + return (kind >= 165 /* FirstTypeNode */ && kind <= 185 /* LastTypeNode */) || kind === 121 /* AnyKeyword */ || kind === 144 /* UnknownKeyword */ || kind === 136 /* NumberKeyword */ @@ -12859,18 +13217,18 @@ var ts; || kind === 142 /* UndefinedKeyword */ || kind === 97 /* NullKeyword */ || kind === 133 /* NeverKeyword */ - || kind === 212 /* ExpressionWithTypeArguments */ - || kind === 290 /* JSDocAllType */ - || kind === 291 /* JSDocUnknownType */ - || kind === 292 /* JSDocNullableType */ - || kind === 293 /* JSDocNonNullableType */ - || kind === 294 /* JSDocOptionalType */ - || kind === 295 /* JSDocFunctionType */ - || kind === 296 /* JSDocVariadicType */; + || kind === 213 /* ExpressionWithTypeArguments */ + || kind === 291 /* JSDocAllType */ + || kind === 292 /* JSDocUnknownType */ + || kind === 293 /* JSDocNullableType */ + || kind === 294 /* JSDocNonNullableType */ + || kind === 295 /* JSDocOptionalType */ + || kind === 296 /* JSDocFunctionType */ + || kind === 297 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */ || node.kind === 191 /* ElementAccessExpression */; + return node.kind === 191 /* PropertyAccessExpression */ || node.kind === 192 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function isBundleFileTextLike(section) { @@ -12990,7 +13348,7 @@ var ts; return { span: span, newLength: newLength }; } ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); // eslint-disable-line prefer-const /** * Called to merge all the changes that occurred across several versions of a script snapshot * into a single change. i.e. if a user keeps making successive edits to a script we will @@ -13107,17 +13465,17 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 151 /* TypeParameter */) { + if (d && d.kind === 152 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 243 /* InterfaceDeclaration */) { return current; } } } } ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 158 /* Constructor */; + function isParameterPropertyDeclaration(node, parent) { + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 159 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -13147,14 +13505,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 238 /* VariableDeclaration */) { + if (node.kind === 239 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 239 /* VariableDeclarationList */) { + if (node && node.kind === 240 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 220 /* VariableStatement */) { + if (node && node.kind === 221 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -13218,7 +13576,8 @@ var ts; return false; } try { - // tslint:disable-next-line no-unnecessary-qualifier (making clear this is a global mutation!) + // making clear this is a global mutation! + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier ts.localizedDiagnosticMessages = JSON.parse(fileContents); } catch (_a) { @@ -13300,27 +13659,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: var expr = hostNode.expression; + if (expr.kind === 206 /* BinaryExpression */ && expr.operatorToken.kind === 60 /* EqualsToken */) { + expr = expr.left; + } switch (expr.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return expr.name; - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 196 /* ParenthesizedExpression */: { + case 197 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 234 /* LabeledStatement */: { + case 235 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -13346,16 +13708,16 @@ var ts; switch (declaration.kind) { case 73 /* Identifier */: return declaration; - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: { + case 314 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 149 /* QualifiedName */) { + if (name.kind === 150 /* QualifiedName */) { return name.right; } break; } - case 192 /* CallExpression */: - case 205 /* BinaryExpression */: { + case 193 /* CallExpression */: + case 206 /* BinaryExpression */: { var expr = declaration; switch (ts.getAssignmentDeclarationKind(expr)) { case 1 /* ExportsProperty */: @@ -13371,9 +13733,11 @@ var ts; return undefined; } } - case 311 /* JSDocTypedefTag */: + case 313 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 255 /* ExportAssignment */: { + case 307 /* JSDocEnumTag */: + return nameForNamelessJSDocTypedef(declaration); + case 256 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } @@ -13578,7 +13942,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 297 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 299 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13598,10 +13962,9 @@ var ts; } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getEffectiveConstraintOfTypeParameter(node) { - return node.constraint ? node.constraint - : ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] - ? node.parent.constraint - : undefined; + return node.constraint ? node.constraint : + ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint : + undefined; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; })(ts || (ts = {})); @@ -13651,193 +14014,193 @@ var ts; ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 149 /* QualifiedName */; + return node.kind === 150 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 150 /* ComputedPropertyName */; + return node.kind === 151 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 151 /* TypeParameter */; + return node.kind === 152 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 152 /* Parameter */; + return node.kind === 153 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 153 /* Decorator */; + return node.kind === 154 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 154 /* PropertySignature */; + return node.kind === 155 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 155 /* PropertyDeclaration */; + return node.kind === 156 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 156 /* MethodSignature */; + return node.kind === 157 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 158 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 158 /* Constructor */; + return node.kind === 159 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 160 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 161 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 161 /* CallSignature */; + return node.kind === 162 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 162 /* ConstructSignature */; + return node.kind === 163 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 163 /* IndexSignature */; + return node.kind === 164 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */ || node.kind === 159 /* GetAccessor */; + return node.kind === 161 /* SetAccessor */ || node.kind === 160 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 164 /* TypePredicate */; + return node.kind === 165 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 165 /* TypeReference */; + return node.kind === 166 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 166 /* FunctionType */; + return node.kind === 167 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 167 /* ConstructorType */; + return node.kind === 168 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 168 /* TypeQuery */; + return node.kind === 169 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 169 /* TypeLiteral */; + return node.kind === 170 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 170 /* ArrayType */; + return node.kind === 171 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 171 /* TupleType */; + return node.kind === 172 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 174 /* UnionType */; + return node.kind === 175 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 175 /* IntersectionType */; + return node.kind === 176 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 176 /* ConditionalType */; + return node.kind === 177 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 177 /* InferType */; + return node.kind === 178 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 178 /* ParenthesizedType */; + return node.kind === 179 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 179 /* ThisType */; + return node.kind === 180 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 180 /* TypeOperator */; + return node.kind === 181 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 181 /* IndexedAccessType */; + return node.kind === 182 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 182 /* MappedType */; + return node.kind === 183 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 183 /* LiteralType */; + return node.kind === 184 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 184 /* ImportType */; + return node.kind === 185 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 185 /* ObjectBindingPattern */; + return node.kind === 186 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 186 /* ArrayBindingPattern */; + return node.kind === 187 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 187 /* BindingElement */; + return node.kind === 188 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 188 /* ArrayLiteralExpression */; + return node.kind === 189 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 189 /* ObjectLiteralExpression */; + return node.kind === 190 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */; + return node.kind === 191 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 191 /* ElementAccessExpression */; + return node.kind === 192 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 192 /* CallExpression */; + return node.kind === 193 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 193 /* NewExpression */; + return node.kind === 194 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 194 /* TaggedTemplateExpression */; + return node.kind === 195 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 195 /* TypeAssertionExpression */; + return node.kind === 196 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isConstTypeReference(node) { @@ -13846,376 +14209,376 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function isParenthesizedExpression(node) { - return node.kind === 196 /* ParenthesizedExpression */; + return node.kind === 197 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 315 /* PartiallyEmittedExpression */) { + while (node.kind === 317 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 197 /* FunctionExpression */; + return node.kind === 198 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 198 /* ArrowFunction */; + return node.kind === 199 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 199 /* DeleteExpression */; + return node.kind === 200 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 200 /* TypeOfExpression */; + return node.kind === 201 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 201 /* VoidExpression */; + return node.kind === 202 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 202 /* AwaitExpression */; + return node.kind === 203 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 203 /* PrefixUnaryExpression */; + return node.kind === 204 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 204 /* PostfixUnaryExpression */; + return node.kind === 205 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 205 /* BinaryExpression */; + return node.kind === 206 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 206 /* ConditionalExpression */; + return node.kind === 207 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 207 /* TemplateExpression */; + return node.kind === 208 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 208 /* YieldExpression */; + return node.kind === 209 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 209 /* SpreadElement */; + return node.kind === 210 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 210 /* ClassExpression */; + return node.kind === 211 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 211 /* OmittedExpression */; + return node.kind === 212 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 213 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 213 /* AsExpression */; + return node.kind === 214 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 214 /* NonNullExpression */; + return node.kind === 215 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 215 /* MetaProperty */; + return node.kind === 216 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 217 /* TemplateSpan */; + return node.kind === 218 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 218 /* SemicolonClassElement */; + return node.kind === 219 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 219 /* Block */; + return node.kind === 220 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 220 /* VariableStatement */; + return node.kind === 221 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 221 /* EmptyStatement */; + return node.kind === 222 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 222 /* ExpressionStatement */; + return node.kind === 223 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 223 /* IfStatement */; + return node.kind === 224 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 224 /* DoStatement */; + return node.kind === 225 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 225 /* WhileStatement */; + return node.kind === 226 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 226 /* ForStatement */; + return node.kind === 227 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 227 /* ForInStatement */; + return node.kind === 228 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 228 /* ForOfStatement */; + return node.kind === 229 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 229 /* ContinueStatement */; + return node.kind === 230 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 230 /* BreakStatement */; + return node.kind === 231 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 230 /* BreakStatement */ || node.kind === 229 /* ContinueStatement */; + return node.kind === 231 /* BreakStatement */ || node.kind === 230 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 231 /* ReturnStatement */; + return node.kind === 232 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 232 /* WithStatement */; + return node.kind === 233 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 233 /* SwitchStatement */; + return node.kind === 234 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 234 /* LabeledStatement */; + return node.kind === 235 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 235 /* ThrowStatement */; + return node.kind === 236 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 236 /* TryStatement */; + return node.kind === 237 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 237 /* DebuggerStatement */; + return node.kind === 238 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 238 /* VariableDeclaration */; + return node.kind === 239 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 239 /* VariableDeclarationList */; + return node.kind === 240 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 240 /* FunctionDeclaration */; + return node.kind === 241 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 241 /* ClassDeclaration */; + return node.kind === 242 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 242 /* InterfaceDeclaration */; + return node.kind === 243 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 243 /* TypeAliasDeclaration */; + return node.kind === 244 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 244 /* EnumDeclaration */; + return node.kind === 245 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */; + return node.kind === 246 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 246 /* ModuleBlock */; + return node.kind === 247 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 247 /* CaseBlock */; + return node.kind === 248 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 248 /* NamespaceExportDeclaration */; + return node.kind === 249 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */; + return node.kind === 250 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 250 /* ImportDeclaration */; + return node.kind === 251 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 251 /* ImportClause */; + return node.kind === 252 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 252 /* NamespaceImport */; + return node.kind === 253 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 253 /* NamedImports */; + return node.kind === 254 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 254 /* ImportSpecifier */; + return node.kind === 255 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 255 /* ExportAssignment */; + return node.kind === 256 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 256 /* ExportDeclaration */; + return node.kind === 257 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 257 /* NamedExports */; + return node.kind === 258 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 258 /* ExportSpecifier */; + return node.kind === 259 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 259 /* MissingDeclaration */; + return node.kind === 260 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 260 /* ExternalModuleReference */; + return node.kind === 261 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 261 /* JsxElement */; + return node.kind === 262 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 262 /* JsxSelfClosingElement */; + return node.kind === 263 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 263 /* JsxOpeningElement */; + return node.kind === 264 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 264 /* JsxClosingElement */; + return node.kind === 265 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 265 /* JsxFragment */; + return node.kind === 266 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 266 /* JsxOpeningFragment */; + return node.kind === 267 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 267 /* JsxClosingFragment */; + return node.kind === 268 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 268 /* JsxAttribute */; + return node.kind === 269 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 269 /* JsxAttributes */; + return node.kind === 270 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 270 /* JsxSpreadAttribute */; + return node.kind === 271 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 271 /* JsxExpression */; + return node.kind === 272 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 272 /* CaseClause */; + return node.kind === 273 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 273 /* DefaultClause */; + return node.kind === 274 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 274 /* HeritageClause */; + return node.kind === 275 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 275 /* CatchClause */; + return node.kind === 276 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 276 /* PropertyAssignment */; + return node.kind === 277 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 277 /* ShorthandPropertyAssignment */; + return node.kind === 278 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 278 /* SpreadAssignment */; + return node.kind === 279 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 280 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 285 /* SourceFile */; + return node.kind === 286 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 286 /* Bundle */; + return node.kind === 287 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 287 /* UnparsedSource */; + return node.kind === 288 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; function isUnparsedPrepend(node) { - return node.kind === 281 /* UnparsedPrepend */; + return node.kind === 282 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; function isUnparsedTextLike(node) { switch (node.kind) { - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 283 /* UnparsedText */: + case 284 /* UnparsedInternalText */: return true; default: return false; @@ -14224,105 +14587,105 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 280 /* UnparsedPrologue */ || - node.kind === 284 /* UnparsedSyntheticReference */; + node.kind === 281 /* UnparsedPrologue */ || + node.kind === 285 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 289 /* JSDocTypeExpression */; + return node.kind === 290 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 290 /* JSDocAllType */; + return node.kind === 291 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 291 /* JSDocUnknownType */; + return node.kind === 292 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 292 /* JSDocNullableType */; + return node.kind === 293 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 293 /* JSDocNonNullableType */; + return node.kind === 294 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 294 /* JSDocOptionalType */; + return node.kind === 295 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 295 /* JSDocFunctionType */; + return node.kind === 296 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 296 /* JSDocVariadicType */; + return node.kind === 297 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 297 /* JSDocComment */; + return node.kind === 299 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAuthorTag(node) { - return node.kind === 302 /* JSDocAuthorTag */; + return node.kind === 304 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocAugmentsTag(node) { - return node.kind === 301 /* JSDocAugmentsTag */; + return node.kind === 303 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 303 /* JSDocClassTag */; + return node.kind === 305 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 305 /* JSDocEnumTag */; + return node.kind === 307 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 308 /* JSDocThisTag */; + return node.kind === 310 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 306 /* JSDocParameterTag */; + return node.kind === 308 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 307 /* JSDocReturnTag */; + return node.kind === 309 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 309 /* JSDocTypeTag */; + return node.kind === 311 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 310 /* JSDocTemplateTag */; + return node.kind === 312 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 311 /* JSDocTypedefTag */; + return node.kind === 313 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 312 /* JSDocPropertyTag */; + return node.kind === 314 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 312 /* JSDocPropertyTag */ || node.kind === 306 /* JSDocParameterTag */; + return node.kind === 314 /* JSDocPropertyTag */ || node.kind === 308 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 298 /* JSDocTypeLiteral */; + return node.kind === 300 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 304 /* JSDocCallbackTag */; + return node.kind === 306 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 299 /* JSDocSignature */; + return node.kind === 301 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -14333,7 +14696,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 313 /* SyntaxList */; + return n.kind === 315 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -14343,7 +14706,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 149 /* FirstNode */; + return kind >= 150 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -14352,7 +14715,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 148 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 149 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -14437,7 +14800,7 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 149 /* QualifiedName */ + return kind === 150 /* QualifiedName */ || kind === 73 /* Identifier */; } ts.isEntityName = isEntityName; @@ -14446,14 +14809,14 @@ var ts; return kind === 73 /* Identifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 150 /* ComputedPropertyName */; + || kind === 151 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; return kind === 73 /* Identifier */ - || kind === 185 /* ObjectBindingPattern */ - || kind === 186 /* ArrayBindingPattern */; + || kind === 186 /* ObjectBindingPattern */ + || kind === 187 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -14468,13 +14831,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return true; default: return false; @@ -14483,14 +14846,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 167 /* ConstructorType */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 301 /* JSDocSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 167 /* FunctionType */: + case 296 /* JSDocFunctionType */: + case 168 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -14505,29 +14868,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 155 /* PropertyDeclaration */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 163 /* IndexSignature */ - || kind === 218 /* SemicolonClassElement */; + return kind === 159 /* Constructor */ + || kind === 156 /* PropertyDeclaration */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */ + || kind === 164 /* IndexSignature */ + || kind === 219 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */); + return node && (node.kind === 242 /* ClassDeclaration */ || node.kind === 211 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */); + return node && (node.kind === 160 /* GetAccessor */ || node.kind === 161 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return true; default: return false; @@ -14537,11 +14900,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 162 /* ConstructSignature */ - || kind === 161 /* CallSignature */ - || kind === 154 /* PropertySignature */ - || kind === 156 /* MethodSignature */ - || kind === 163 /* IndexSignature */; + return kind === 163 /* ConstructSignature */ + || kind === 162 /* CallSignature */ + || kind === 155 /* PropertySignature */ + || kind === 157 /* MethodSignature */ + || kind === 164 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -14550,12 +14913,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 276 /* PropertyAssignment */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 278 /* SpreadAssignment */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 277 /* PropertyAssignment */ + || kind === 278 /* ShorthandPropertyAssignment */ + || kind === 279 /* SpreadAssignment */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -14570,8 +14933,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: return true; } return false; @@ -14582,8 +14945,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 186 /* ArrayBindingPattern */ - || kind === 185 /* ObjectBindingPattern */; + return kind === 187 /* ArrayBindingPattern */ + || kind === 186 /* ObjectBindingPattern */; } return false; } @@ -14591,15 +14954,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 188 /* ArrayLiteralExpression */ - || kind === 189 /* ObjectLiteralExpression */; + return kind === 189 /* ArrayLiteralExpression */ + || kind === 190 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 187 /* BindingElement */ - || kind === 211 /* OmittedExpression */; + return kind === 188 /* BindingElement */ + || kind === 212 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -14608,9 +14971,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 239 /* VariableDeclaration */: + case 153 /* Parameter */: + case 188 /* BindingElement */: return true; } return false; @@ -14631,8 +14994,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 186 /* ObjectBindingPattern */: + case 190 /* ObjectLiteralExpression */: return true; } return false; @@ -14644,8 +15007,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 187 /* ArrayBindingPattern */: + case 189 /* ArrayLiteralExpression */: return true; } return false; @@ -14654,26 +15017,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */ - || kind === 184 /* ImportType */; + return kind === 191 /* PropertyAccessExpression */ + || kind === 150 /* QualifiedName */ + || kind === 185 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */; + return kind === 191 /* PropertyAccessExpression */ + || kind === 150 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 153 /* Decorator */: + case 264 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 195 /* TaggedTemplateExpression */: + case 154 /* Decorator */: return true; default: return false; @@ -14681,12 +15044,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 192 /* CallExpression */ || node.kind === 193 /* NewExpression */; + return node.kind === 193 /* CallExpression */ || node.kind === 194 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 207 /* TemplateExpression */ + return kind === 208 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -14697,33 +15060,33 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 193 /* NewExpression */: - case 192 /* CallExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 194 /* TaggedTemplateExpression */: - case 188 /* ArrayLiteralExpression */: - case 196 /* ParenthesizedExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: + case 194 /* NewExpression */: + case 193 /* CallExpression */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 266 /* JsxFragment */: + case 195 /* TaggedTemplateExpression */: + case 189 /* ArrayLiteralExpression */: + case 197 /* ParenthesizedExpression */: + case 190 /* ObjectLiteralExpression */: + case 211 /* ClassExpression */: + case 198 /* FunctionExpression */: case 73 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: case 88 /* FalseKeyword */: case 97 /* NullKeyword */: case 101 /* ThisKeyword */: case 103 /* TrueKeyword */: case 99 /* SuperKeyword */: - case 214 /* NonNullExpression */: - case 215 /* MetaProperty */: + case 215 /* NonNullExpression */: + case 216 /* MetaProperty */: case 93 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: @@ -14737,13 +15100,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 195 /* TypeAssertionExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: + case 200 /* DeleteExpression */: + case 201 /* TypeOfExpression */: + case 202 /* VoidExpression */: + case 203 /* AwaitExpression */: + case 196 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -14752,9 +15115,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return true; - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; default: @@ -14773,15 +15136,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: - case 198 /* ArrowFunction */: - case 205 /* BinaryExpression */: - case 209 /* SpreadElement */: - case 213 /* AsExpression */: - case 211 /* OmittedExpression */: - case 316 /* CommaListExpression */: - case 315 /* PartiallyEmittedExpression */: + case 207 /* ConditionalExpression */: + case 209 /* YieldExpression */: + case 199 /* ArrowFunction */: + case 206 /* BinaryExpression */: + case 210 /* SpreadElement */: + case 214 /* AsExpression */: + case 212 /* OmittedExpression */: + case 318 /* CommaListExpression */: + case 317 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -14789,18 +15152,18 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 195 /* TypeAssertionExpression */ - || kind === 213 /* AsExpression */; + return kind === 196 /* TypeAssertionExpression */ + || kind === 214 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 315 /* PartiallyEmittedExpression */; + return node.kind === 317 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 314 /* NotEmittedStatement */; + return node.kind === 316 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -14811,13 +15174,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: return true; - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -14825,7 +15188,7 @@ var ts; ts.isIterationStatement = isIterationStatement; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 227 /* ForInStatement */ || node.kind === 228 /* ForOfStatement */; + return node.kind === 228 /* ForInStatement */ || node.kind === 229 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -14849,113 +15212,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */ + return kind === 247 /* ModuleBlock */ + || kind === 246 /* ModuleDeclaration */ || kind === 73 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */; + return kind === 247 /* ModuleBlock */ + || kind === 246 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 73 /* Identifier */ - || kind === 245 /* ModuleDeclaration */; + || kind === 246 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 253 /* NamedImports */ - || kind === 252 /* NamespaceImport */; + return kind === 254 /* NamedImports */ + || kind === 253 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ || node.kind === 244 /* EnumDeclaration */; + return node.kind === 246 /* ModuleDeclaration */ || node.kind === 245 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 198 /* ArrowFunction */ - || kind === 187 /* BindingElement */ - || kind === 241 /* ClassDeclaration */ - || kind === 210 /* ClassExpression */ - || kind === 158 /* Constructor */ - || kind === 244 /* EnumDeclaration */ - || kind === 279 /* EnumMember */ - || kind === 258 /* ExportSpecifier */ - || kind === 240 /* FunctionDeclaration */ - || kind === 197 /* FunctionExpression */ - || kind === 159 /* GetAccessor */ - || kind === 251 /* ImportClause */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 254 /* ImportSpecifier */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 268 /* JsxAttribute */ - || kind === 157 /* MethodDeclaration */ - || kind === 156 /* MethodSignature */ - || kind === 245 /* ModuleDeclaration */ - || kind === 248 /* NamespaceExportDeclaration */ - || kind === 252 /* NamespaceImport */ - || kind === 152 /* Parameter */ - || kind === 276 /* PropertyAssignment */ - || kind === 155 /* PropertyDeclaration */ - || kind === 154 /* PropertySignature */ - || kind === 160 /* SetAccessor */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 151 /* TypeParameter */ - || kind === 238 /* VariableDeclaration */ - || kind === 311 /* JSDocTypedefTag */ - || kind === 304 /* JSDocCallbackTag */ - || kind === 312 /* JSDocPropertyTag */; + return kind === 199 /* ArrowFunction */ + || kind === 188 /* BindingElement */ + || kind === 242 /* ClassDeclaration */ + || kind === 211 /* ClassExpression */ + || kind === 159 /* Constructor */ + || kind === 245 /* EnumDeclaration */ + || kind === 280 /* EnumMember */ + || kind === 259 /* ExportSpecifier */ + || kind === 241 /* FunctionDeclaration */ + || kind === 198 /* FunctionExpression */ + || kind === 160 /* GetAccessor */ + || kind === 252 /* ImportClause */ + || kind === 250 /* ImportEqualsDeclaration */ + || kind === 255 /* ImportSpecifier */ + || kind === 243 /* InterfaceDeclaration */ + || kind === 269 /* JsxAttribute */ + || kind === 158 /* MethodDeclaration */ + || kind === 157 /* MethodSignature */ + || kind === 246 /* ModuleDeclaration */ + || kind === 249 /* NamespaceExportDeclaration */ + || kind === 253 /* NamespaceImport */ + || kind === 153 /* Parameter */ + || kind === 277 /* PropertyAssignment */ + || kind === 156 /* PropertyDeclaration */ + || kind === 155 /* PropertySignature */ + || kind === 161 /* SetAccessor */ + || kind === 278 /* ShorthandPropertyAssignment */ + || kind === 244 /* TypeAliasDeclaration */ + || kind === 152 /* TypeParameter */ + || kind === 239 /* VariableDeclaration */ + || kind === 313 /* JSDocTypedefTag */ + || kind === 306 /* JSDocCallbackTag */ + || kind === 314 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 240 /* FunctionDeclaration */ - || kind === 259 /* MissingDeclaration */ - || kind === 241 /* ClassDeclaration */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 244 /* EnumDeclaration */ - || kind === 245 /* ModuleDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */ - || kind === 255 /* ExportAssignment */ - || kind === 248 /* NamespaceExportDeclaration */; + return kind === 241 /* FunctionDeclaration */ + || kind === 260 /* MissingDeclaration */ + || kind === 242 /* ClassDeclaration */ + || kind === 243 /* InterfaceDeclaration */ + || kind === 244 /* TypeAliasDeclaration */ + || kind === 245 /* EnumDeclaration */ + || kind === 246 /* ModuleDeclaration */ + || kind === 251 /* ImportDeclaration */ + || kind === 250 /* ImportEqualsDeclaration */ + || kind === 257 /* ExportDeclaration */ + || kind === 256 /* ExportAssignment */ + || kind === 249 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 230 /* BreakStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 224 /* DoStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 221 /* EmptyStatement */ - || kind === 227 /* ForInStatement */ - || kind === 228 /* ForOfStatement */ - || kind === 226 /* ForStatement */ - || kind === 223 /* IfStatement */ - || kind === 234 /* LabeledStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 233 /* SwitchStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 236 /* TryStatement */ - || kind === 220 /* VariableStatement */ - || kind === 225 /* WhileStatement */ - || kind === 232 /* WithStatement */ - || kind === 314 /* NotEmittedStatement */ - || kind === 318 /* EndOfDeclarationMarker */ - || kind === 317 /* MergeDeclarationMarker */; + return kind === 231 /* BreakStatement */ + || kind === 230 /* ContinueStatement */ + || kind === 238 /* DebuggerStatement */ + || kind === 225 /* DoStatement */ + || kind === 223 /* ExpressionStatement */ + || kind === 222 /* EmptyStatement */ + || kind === 228 /* ForInStatement */ + || kind === 229 /* ForOfStatement */ + || kind === 227 /* ForStatement */ + || kind === 224 /* IfStatement */ + || kind === 235 /* LabeledStatement */ + || kind === 232 /* ReturnStatement */ + || kind === 234 /* SwitchStatement */ + || kind === 236 /* ThrowStatement */ + || kind === 237 /* TryStatement */ + || kind === 221 /* VariableStatement */ + || kind === 226 /* WhileStatement */ + || kind === 233 /* WithStatement */ + || kind === 316 /* NotEmittedStatement */ + || kind === 320 /* EndOfDeclarationMarker */ + || kind === 319 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 151 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 310 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 152 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 312 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14982,10 +15345,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 219 /* Block */) + if (node.kind !== 220 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 236 /* TryStatement */ || node.parent.kind === 275 /* CatchClause */) { + if (node.parent.kind === 237 /* TryStatement */ || node.parent.kind === 276 /* CatchClause */) { return false; } } @@ -14995,8 +15358,8 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 260 /* ExternalModuleReference */ - || kind === 149 /* QualifiedName */ + return kind === 261 /* ExternalModuleReference */ + || kind === 150 /* QualifiedName */ || kind === 73 /* Identifier */; } ts.isModuleReference = isModuleReference; @@ -15006,70 +15369,70 @@ var ts; var kind = node.kind; return kind === 101 /* ThisKeyword */ || kind === 73 /* Identifier */ - || kind === 190 /* PropertyAccessExpression */; + || kind === 191 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 261 /* JsxElement */ - || kind === 271 /* JsxExpression */ - || kind === 262 /* JsxSelfClosingElement */ + return kind === 262 /* JsxElement */ + || kind === 272 /* JsxExpression */ + || kind === 263 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 265 /* JsxFragment */; + || kind === 266 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 268 /* JsxAttribute */ - || kind === 270 /* JsxSpreadAttribute */; + return kind === 269 /* JsxAttribute */ + || kind === 271 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 271 /* JsxExpression */; + || kind === 272 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 263 /* JsxOpeningElement */ - || kind === 262 /* JsxSelfClosingElement */; + return kind === 264 /* JsxOpeningElement */ + || kind === 263 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 272 /* CaseClause */ - || kind === 273 /* DefaultClause */; + return kind === 273 /* CaseClause */ + || kind === 274 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 289 /* FirstJSDocNode */ && node.kind <= 312 /* LastJSDocNode */; + return node.kind >= 290 /* FirstJSDocNode */ && node.kind <= 314 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 297 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 299 /* JSDocComment */ || 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 >= 300 /* FirstJSDocTagNode */ && node.kind <= 312 /* LastJSDocTagNode */; + return node.kind >= 302 /* FirstJSDocTagNode */ && node.kind <= 314 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 161 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 160 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -15099,12 +15462,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 268 /* JsxAttribute */ || node.kind === 270 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 269 /* JsxAttribute */ || node.kind === 271 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 165 /* TypeReference */ || node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 166 /* TypeReference */ || node.kind === 213 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -15140,7 +15503,7 @@ var ts; /* @internal */ (function (ts) { function isNamedImportsOrExports(node) { - return node.kind === 253 /* NamedImports */ || node.kind === 257 /* NamedExports */; + return node.kind === 254 /* NamedImports */ || node.kind === 258 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -15158,7 +15521,7 @@ var ts; this.checker = checker; } } - function Signature() { } // tslint:disable-line no-empty + function Signature() { } function Node(kind, pos, end) { this.pos = pos; this.end = end; @@ -15175,6 +15538,7 @@ var ts; this.text = text; this.skipTrivia = skipTrivia || (function (pos) { return pos; }); } + // eslint-disable-next-line prefer-const ts.objectAllocator = { getNodeConstructor: function () { return Node; }, getTokenConstructor: function () { return Node; }, @@ -15621,7 +15985,7 @@ var ts; var rest = path.substring(rootLength).split(ts.directorySeparator); if (rest.length && !ts.lastOrUndefined(rest)) rest.pop(); - return [root].concat(rest); + return __spreadArrays([root], rest); } /** * Parse a path into an array containing a root component (at index 0) and zero or more path @@ -15721,7 +16085,7 @@ var ts; for (; start < fromComponents.length; start++) { relative.push(".."); } - return [""].concat(relative, components); + return __spreadArrays([""], relative, components); } ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; function getRelativePathFromFile(from, to, getCanonicalFileName) { @@ -15802,7 +16166,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { paths[_i - 1] = arguments[_i]; } - var combined = ts.some(paths) ? combinePaths.apply(void 0, [path].concat(paths)) : ts.normalizeSlashes(path); + var combined = ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : ts.normalizeSlashes(path); var normalized = ts.getPathFromPathComponents(ts.reducePathComponents(ts.getPathComponents(combined))); return normalized && hasTrailingDirectorySeparator(combined) ? ensureTrailingDirectorySeparator(normalized) : normalized; } @@ -16241,14 +16605,14 @@ var ts; ts.supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */]; ts.supportedJSExtensions = [".js" /* Js */, ".jsx" /* Jsx */]; ts.supportedJSAndJsonExtensions = [".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */]; - var allSupportedExtensions = ts.supportedTSExtensions.concat(ts.supportedJSExtensions); - var allSupportedExtensionsWithJson = ts.supportedTSExtensions.concat(ts.supportedJSExtensions, [".json" /* Json */]); + var allSupportedExtensions = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions); + var allSupportedExtensionsWithJson = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions, [".json" /* Json */]); function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && options.allowJs; if (!extraFileExtensions || extraFileExtensions.length === 0) { return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; } - var extensions = (needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions).concat(ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); + var extensions = __spreadArrays(needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions, ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); return ts.deduplicate(extensions, ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } ts.getSupportedExtensions = getSupportedExtensions; @@ -16262,7 +16626,7 @@ var ts; if (supportedExtensions === ts.supportedTSExtensions) { return ts.supportedTSExtensionsWithJson; } - return supportedExtensions.concat([".json" /* Json */]); + return __spreadArrays(supportedExtensions, [".json" /* Json */]); } ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { @@ -16582,6 +16946,7 @@ var ts; } ts.skipTypeChecking = skipTypeChecking; function isJsonEqual(a, b) { + // eslint-disable-next-line no-null/no-null return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && ts.equalOwnProperties(a, b, isJsonEqual); } ts.isJsonEqual = isJsonEqual; @@ -16685,14 +17050,12 @@ var ts; SignatureFlags[SignatureFlags["IgnoreMissingOpenBrace"] = 16] = "IgnoreMissingOpenBrace"; SignatureFlags[SignatureFlags["JSDoc"] = 32] = "JSDoc"; })(SignatureFlags || (SignatureFlags = {})); - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 285 /* SourceFile */) { + if (kind === 286 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 73 /* Identifier */) { @@ -16744,19 +17107,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 <= 148 /* LastToken */) { + if (!node || node.kind <= 149 /* LastToken */) { return; } switch (node.kind) { - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -16764,9 +17127,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 152 /* Parameter */: + case 153 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -16774,7 +17137,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -16782,51 +17145,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 154 /* PropertySignature */: + case 155 /* 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 276 /* PropertyAssignment */: + case 277 /* 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 238 /* VariableDeclaration */: + case 239 /* 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 187 /* BindingElement */: + case 188 /* 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 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -16838,345 +17201,345 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 171 /* TupleType */: + case 172 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 177 /* InferType */: + case 178 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 184 /* ImportType */: + case 185 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 178 /* ParenthesizedType */: - case 180 /* TypeOperator */: + case 179 /* ParenthesizedType */: + case 181 /* TypeOperator */: return visitNode(cbNode, node.type); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 182 /* MappedType */: + case 183 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 183 /* LiteralType */: + case 184 /* LiteralType */: return visitNode(cbNode, node.literal); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 213 /* AsExpression */: + case 214 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return visitNode(cbNode, node.name); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 220 /* Block */: + case 247 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 285 /* SourceFile */: + case 286 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 230 /* ContinueStatement */: + case 231 /* BreakStatement */: return visitNode(cbNode, node.label); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 272 /* CaseClause */: + case 273 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 153 /* Decorator */: + case 154 /* Decorator */: return visitNode(cbNode, node.expression); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* 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 242 /* InterfaceDeclaration */: + case 243 /* 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 243 /* TypeAliasDeclaration */: + case 244 /* 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 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 279 /* EnumMember */: + case 280 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 254 /* NamedImports */: + case 258 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 259 /* MissingDeclaration */: + case 260 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 261 /* JsxElement */: + case 262 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 172 /* OptionalType */: - case 173 /* RestType */: - case 289 /* JSDocTypeExpression */: - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 294 /* JSDocOptionalType */: - case 296 /* JSDocVariadicType */: + case 173 /* OptionalType */: + case 174 /* RestType */: + case 290 /* JSDocTypeExpression */: + case 294 /* JSDocNonNullableType */: + case 293 /* JSDocNullableType */: + case 295 /* JSDocOptionalType */: + case 297 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 297 /* JSDocComment */: + case 299 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: + case 314 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 302 /* JSDocAuthorTag */: + case 304 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName); - case 301 /* JSDocAugmentsTag */: + case 303 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 311 /* JSDocTypedefTag */: + case 313 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 289 /* JSDocTypeExpression */ + node.typeExpression.kind === 290 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 304 /* JSDocCallbackTag */: + case 306 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 308 /* JSDocThisTag */: - case 305 /* JSDocEnumTag */: + case 309 /* JSDocReturnTag */: + case 311 /* JSDocTypeTag */: + case 310 /* JSDocThisTag */: + case 307 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 299 /* JSDocSignature */: + case 301 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 298 /* JSDocTypeLiteral */: + case 300 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 300 /* JSDocTag */: - case 303 /* JSDocClassTag */: + case 302 /* JSDocTag */: + case 305 /* JSDocClassTag */: return visitNode(cbNode, node.tagName); - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -17185,12 +17548,14 @@ var ts; if (setParentNodes === void 0) { setParentNodes = false; } ts.performance.mark("beforeParse"); var result; + ts.perfLogger.logStartParseSourceFile(fileName); if (languageVersion === 100 /* JSON */) { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */); } else { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind); } + ts.perfLogger.logStopParseSourceFile(); ts.performance.mark("afterParse"); ts.performance.measure("Parse", "beforeParse", "afterParse"); return result; @@ -17259,12 +17624,10 @@ var ts; var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); var disallowInAndDecoratorContext = 2048 /* DisallowInContext */ | 8192 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name var sourceFile; var parseDiagnostics; var syntaxCursor; @@ -17274,6 +17637,7 @@ var ts; var identifiers; var identifierCount; var parsingContext; + var notParenthesizedArrow; // Flags that dictate what parsing context we're in. For example: // Whether or not we are in strict parsing mode. All that changes in strict parsing mode is // that some tokens that would be considered identifiers may be considered keywords. @@ -17394,7 +17758,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(222 /* ExpressionStatement */); + var statement = createNode(223 /* ExpressionStatement */); switch (token()) { case 22 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); @@ -17430,6 +17794,9 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; sourceFile.parseDiagnostics = parseDiagnostics; var result = sourceFile; clearState(); @@ -17481,6 +17848,7 @@ var ts; identifiers = undefined; syntaxCursor = undefined; sourceText = undefined; + notParenthesizedArrow = undefined; } function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { var isDeclarationFile = isDeclarationFileName(fileName); @@ -17550,7 +17918,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(285 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(286 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -17690,9 +18058,17 @@ var ts; function token() { return currentToken; } - function nextToken() { + function nextTokenWithoutCheck() { return currentToken = scanner.scan(); } + function nextToken() { + // if the keyword had an escape + if (ts.isKeyword(currentToken) && (scanner.hasUnicodeEscape() || scanner.hasExtendedUnicodeEscape())) { + // issue a parse error for the escape + parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), ts.Diagnostics.Keywords_cannot_contain_escape_characters); + } + return nextTokenWithoutCheck(); + } function nextTokenJSDoc() { return currentToken = scanner.scanJsDocToken(); } @@ -17931,7 +18307,7 @@ var ts; node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); - nextToken(); + nextTokenWithoutCheck(); return finishNode(node); } // Only for end of file because the error gets reported incorrectly on embedded script tags. @@ -17967,7 +18343,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(150 /* ComputedPropertyName */); + var node = createNode(151 /* ComputedPropertyName */); parseExpected(22 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -18401,14 +18777,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 158 /* Constructor */: - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 218 /* SemicolonClassElement */: + case 159 /* Constructor */: + case 164 /* IndexSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 219 /* SemicolonClassElement */: return true; - case 157 /* MethodDeclaration */: + case 158 /* 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. @@ -18423,8 +18799,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: return true; } } @@ -18433,58 +18809,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 220 /* VariableStatement */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 222 /* ExpressionStatement */: - case 235 /* ThrowStatement */: - case 231 /* ReturnStatement */: - case 233 /* SwitchStatement */: - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 221 /* EmptyStatement */: - case 236 /* TryStatement */: - case 234 /* LabeledStatement */: - case 224 /* DoStatement */: - case 237 /* DebuggerStatement */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 241 /* FunctionDeclaration */: + case 221 /* VariableStatement */: + case 220 /* Block */: + case 224 /* IfStatement */: + case 223 /* ExpressionStatement */: + case 236 /* ThrowStatement */: + case 232 /* ReturnStatement */: + case 234 /* SwitchStatement */: + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 227 /* ForStatement */: + case 226 /* WhileStatement */: + case 233 /* WithStatement */: + case 222 /* EmptyStatement */: + case 237 /* TryStatement */: + case 235 /* LabeledStatement */: + case 225 /* DoStatement */: + case 238 /* DebuggerStatement */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 257 /* ExportDeclaration */: + case 256 /* ExportAssignment */: + case 246 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 280 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 154 /* PropertySignature */: - case 161 /* CallSignature */: + case 163 /* ConstructSignature */: + case 157 /* MethodSignature */: + case 164 /* IndexSignature */: + case 155 /* PropertySignature */: + case 162 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 238 /* VariableDeclaration */) { + if (node.kind !== 239 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -18505,7 +18881,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 152 /* Parameter */) { + if (node.kind !== 153 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -18572,7 +18948,7 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */); + parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use @@ -18610,6 +18986,9 @@ var ts; } return result; } + function getExpectedCommaDiagnostic(kind) { + return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + } function createMissingList() { var list = createNodeArray([], getNodePos()); list.isMissingList = true; @@ -18641,7 +19020,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(149 /* QualifiedName */, entity.pos); + var node = createNode(150 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -18678,7 +19057,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(207 /* TemplateExpression */); + var template = createNode(208 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -18690,7 +19069,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(217 /* TemplateSpan */); + var span = createNode(218 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 19 /* CloseBraceToken */) { @@ -18719,6 +19098,16 @@ var ts; function parseLiteralLikeNode(kind) { var node = createNode(kind); node.text = scanner.getTokenValue(); + switch (kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + var isLast = kind === 14 /* NoSubstitutionTemplateLiteral */ || kind === 17 /* TemplateTail */; + var tokenText = scanner.getTokenText(); + node.rawText = tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); + break; + } if (scanner.hasExtendedUnicodeEscape()) { node.hasExtendedUnicodeEscape = true; } @@ -18740,7 +19129,7 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(165 /* TypeReference */); + var node = createNode(166 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); @@ -18750,14 +19139,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: { + case 167 /* FunctionType */: + case 168 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -18765,20 +19154,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(164 /* TypePredicate */, lhs.pos); + var node = createNode(165 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(179 /* ThisType */); + var node = createNode(180 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(290 /* JSDocAllType */); + var result = createNode(291 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(294 /* JSDocOptionalType */, result); + return createPostfixType(295 /* JSDocOptionalType */, result); } else { nextToken(); @@ -18786,7 +19175,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(293 /* JSDocNonNullableType */); + var result = createNode(294 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -18810,28 +19199,28 @@ var ts; token() === 30 /* GreaterThanToken */ || token() === 60 /* EqualsToken */ || token() === 50 /* BarToken */) { - var result = createNode(291 /* JSDocUnknownType */, pos); + var result = createNode(292 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(292 /* JSDocNullableType */, pos); + var result = createNode(293 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(295 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(296 /* JSDocFunctionType */); nextToken(); fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(165 /* TypeReference */); + var node = createNode(166 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(152 /* Parameter */); + var parameter = createNode(153 /* Parameter */); if (token() === 101 /* ThisKeyword */ || token() === 96 /* NewKeyword */) { parameter.name = parseIdentifierName(); parseExpected(57 /* ColonToken */); @@ -18841,27 +19230,44 @@ var ts; } function parseJSDocType() { scanner.setInJSDocType(true); + var moduleSpecifier = parseOptionalToken(131 /* ModuleKeyword */); + if (moduleSpecifier) { + var moduleTag = createNode(298 /* JSDocNamepathType */, moduleSpecifier.pos); + terminate: while (true) { + switch (token()) { + case 19 /* CloseBraceToken */: + case 1 /* EndOfFileToken */: + case 27 /* CommaToken */: + case 5 /* WhitespaceTrivia */: + break terminate; + default: + nextTokenJSDoc(); + } + } + scanner.setInJSDocType(false); + return finishNode(moduleTag); + } var dotdotdot = parseOptionalToken(25 /* DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(296 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(297 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 60 /* EqualsToken */) { - return createPostfixType(294 /* JSDocOptionalType */, type); + return createPostfixType(295 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(168 /* TypeQuery */); + var node = createNode(169 /* TypeQuery */); parseExpected(105 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(152 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(87 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -18906,7 +19312,7 @@ var ts; isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(152 /* Parameter */); + var node = createNodeWithJSDoc(153 /* Parameter */); if (token() === 101 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); @@ -19007,7 +19413,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 162 /* ConstructSignature */) { + if (kind === 163 /* ConstructSignature */) { parseExpected(96 /* NewKeyword */); } fillSignature(57 /* ColonToken */, 4 /* Type */, node); @@ -19068,7 +19474,7 @@ var ts; return token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 163 /* IndexSignature */; + node.kind = 164 /* IndexSignature */; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -19078,13 +19484,13 @@ var ts; node.name = parsePropertyName(); node.questionToken = parseOptionalToken(56 /* QuestionToken */); if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - node.kind = 156 /* MethodSignature */; + node.kind = 157 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] fillSignature(57 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 154 /* PropertySignature */; + node.kind = 155 /* PropertySignature */; node.type = parseTypeAnnotation(); if (token() === 60 /* EqualsToken */) { // Although type literal properties cannot not have initializers, we attempt @@ -19130,10 +19536,10 @@ var ts; } function parseTypeMember() { if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - return parseSignatureMember(161 /* CallSignature */); + return parseSignatureMember(162 /* CallSignature */); } if (token() === 96 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(162 /* ConstructSignature */); + return parseSignatureMember(163 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -19159,7 +19565,7 @@ var ts; return false; } function parseTypeLiteral() { - var node = createNode(169 /* TypeLiteral */); + var node = createNode(170 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -19185,14 +19591,14 @@ var ts; return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 94 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(152 /* TypeParameter */); node.name = parseIdentifier(); parseExpected(94 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(182 /* MappedType */); + var node = createNode(183 /* MappedType */); parseExpected(18 /* OpenBraceToken */); if (token() === 134 /* ReadonlyKeyword */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { node.readonlyToken = parseTokenNode(); @@ -19217,23 +19623,23 @@ var ts; function parseTupleElementType() { var pos = getNodePos(); if (parseOptional(25 /* DotDotDotToken */)) { - var node = createNode(173 /* RestType */, pos); + var node = createNode(174 /* RestType */, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 292 /* JSDocNullableType */ && type.pos === type.type.pos) { - type.kind = 172 /* OptionalType */; + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 293 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 173 /* OptionalType */; } return type; } function parseTupleType() { - var node = createNode(171 /* TupleType */); + var node = createNode(172 /* TupleType */); node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(178 /* ParenthesizedType */); + var node = createNode(179 /* ParenthesizedType */); parseExpected(20 /* OpenParenToken */); node.type = parseType(); parseExpected(21 /* CloseParenToken */); @@ -19241,7 +19647,7 @@ var ts; } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(96 /* NewKeyword */) ? 167 /* ConstructorType */ : 166 /* FunctionType */; + var kind = parseOptional(96 /* NewKeyword */) ? 168 /* ConstructorType */ : 167 /* FunctionType */; var node = createNodeWithJSDoc(kind, pos); fillSignature(37 /* EqualsGreaterThanToken */, 4 /* Type */, node); return finishNode(node); @@ -19251,10 +19657,10 @@ var ts; return token() === 24 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(183 /* LiteralType */); + var node = createNode(184 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(203 /* PrefixUnaryExpression */); + unaryMinusExpression = createNode(204 /* PrefixUnaryExpression */); unaryMinusExpression.operator = 39 /* MinusToken */; nextToken(); } @@ -19275,7 +19681,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(184 /* ImportType */); + var node = createNode(185 /* ImportType */); if (parseOptional(105 /* TypeOfKeyword */)) { node.isTypeOf = true; } @@ -19365,6 +19771,7 @@ var ts; case 134 /* ReadonlyKeyword */: case 140 /* SymbolKeyword */: case 143 /* UniqueKeyword */: + case 148 /* TagKeyword */: case 107 /* VoidKeyword */: case 142 /* UndefinedKeyword */: case 97 /* NullKeyword */: @@ -19411,26 +19818,26 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 52 /* ExclamationToken */: - type = createPostfixType(293 /* JSDocNonNullableType */, type); + type = createPostfixType(294 /* JSDocNonNullableType */, type); break; case 56 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(292 /* JSDocNullableType */, type); + type = createPostfixType(293 /* JSDocNullableType */, type); break; case 22 /* OpenBracketToken */: parseExpected(22 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(181 /* IndexedAccessType */, type.pos); + var node = createNode(182 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(170 /* ArrayType */, type.pos); + var node = createNode(171 /* ArrayType */, type.pos); node.elementType = type; parseExpected(23 /* CloseBracketToken */); type = finishNode(node); @@ -19449,16 +19856,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(180 /* TypeOperator */); + var node = createNode(181 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(177 /* InferType */); + var node = createNode(178 /* InferType */); parseExpected(128 /* InferKeyword */); - var typeParameter = createNode(151 /* TypeParameter */); + var typeParameter = createNode(152 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -19469,6 +19876,7 @@ var ts; case 130 /* KeyOfKeyword */: case 143 /* UniqueKeyword */: case 134 /* ReadonlyKeyword */: + case 148 /* TagKeyword */: return parseTypeOperator(operator); case 128 /* InferKeyword */: return parseInferType(); @@ -19491,10 +19899,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(175 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); + return parseUnionOrIntersectionType(176 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(174 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); + return parseUnionOrIntersectionType(175 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); } function isStartOfFunctionType() { if (token() === 28 /* LessThanToken */) { @@ -19551,7 +19959,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(164 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(165 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -19578,7 +19986,7 @@ var ts; } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(87 /* ExtendsKeyword */)) { - var node = createNode(176 /* ConditionalType */, type.pos); + var node = createNode(177 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); @@ -19772,7 +20180,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(208 /* YieldExpression */); + var node = createNode(209 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -19794,13 +20202,13 @@ var ts; ts.Debug.assert(token() === 37 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(198 /* ArrowFunction */, asyncModifier.pos); + node = createNode(199 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(198 /* ArrowFunction */, identifier.pos); + node = createNode(199 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(152 /* Parameter */, identifier.pos); + var parameter = createNode(153 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); @@ -19964,7 +20372,15 @@ var ts; } } function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + var tokenPos = scanner.getTokenPos(); + if (notParenthesizedArrow && notParenthesizedArrow.has(tokenPos.toString())) { + return undefined; + } + var result = parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + if (!result) { + (notParenthesizedArrow || (notParenthesizedArrow = ts.createMap())).set(tokenPos.toString(), true); + } + return result; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" @@ -19997,7 +20413,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(198 /* ArrowFunction */); + var node = createNodeWithJSDoc(199 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -20063,7 +20479,7 @@ var ts; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(206 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(207 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -20078,7 +20494,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 94 /* InKeyword */ || t === 148 /* OfKeyword */; + return t === 94 /* InKeyword */ || t === 149 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -20143,39 +20559,39 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(205 /* BinaryExpression */, left.pos); + var node = createNode(206 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(213 /* AsExpression */, left.pos); + var node = createNode(214 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(203 /* PrefixUnaryExpression */); + var node = createNode(204 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(199 /* DeleteExpression */); + var node = createNode(200 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(200 /* TypeOfExpression */); + var node = createNode(201 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(201 /* VoidExpression */); + var node = createNode(202 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -20191,7 +20607,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(202 /* AwaitExpression */); + var node = createNode(203 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -20235,7 +20651,7 @@ var ts; if (token() === 41 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 195 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 196 /* 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 { @@ -20332,7 +20748,7 @@ var ts; */ function parseUpdateExpression() { if (token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) { - var node = createNode(203 /* PrefixUnaryExpression */); + var node = createNode(204 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -20345,7 +20761,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(204 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(205 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -20401,7 +20817,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(215 /* MetaProperty */, fullStart); + var node = createNode(216 /* MetaProperty */, fullStart); node.keywordToken = 93 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); @@ -20483,7 +20899,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(190 /* PropertyAccessExpression */, expression.pos); + var node = createNode(191 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -20492,8 +20908,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 263 /* JsxOpeningElement */) { - var node = createNode(261 /* JsxElement */, opening.pos); + if (opening.kind === 264 /* JsxOpeningElement */) { + var node = createNode(262 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -20502,15 +20918,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 266 /* JsxOpeningFragment */) { - var node = createNode(265 /* JsxFragment */, opening.pos); + else if (opening.kind === 267 /* JsxOpeningFragment */) { + var node = createNode(266 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 262 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 263 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -20525,7 +20941,7 @@ var ts; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(205 /* BinaryExpression */, result.pos); + var badNode = createNode(206 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -20584,7 +21000,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(269 /* JsxAttributes */); + var jsxAttributes = createNode(270 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -20593,7 +21009,7 @@ var ts; parseExpected(28 /* LessThanToken */); if (token() === 30 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(266 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(267 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -20605,7 +21021,7 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(263 /* JsxOpeningElement */, fullStart); + node = createNode(264 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -20617,7 +21033,7 @@ var ts; parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(262 /* JsxSelfClosingElement */, fullStart); + node = createNode(263 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -20634,7 +21050,7 @@ var ts; var expression = token() === 101 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(191 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -20642,7 +21058,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(271 /* JsxExpression */); + var node = createNode(272 /* JsxExpression */); if (!parseExpected(18 /* OpenBraceToken */)) { return undefined; } @@ -20668,7 +21084,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(268 /* JsxAttribute */); + var node = createNode(269 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 60 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -20683,7 +21099,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(270 /* JsxSpreadAttribute */); + var node = createNode(271 /* JsxSpreadAttribute */); parseExpected(18 /* OpenBraceToken */); parseExpected(25 /* DotDotDotToken */); node.expression = parseExpression(); @@ -20691,7 +21107,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(264 /* JsxClosingElement */); + var node = createNode(265 /* JsxClosingElement */); parseExpected(29 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -20704,7 +21120,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(267 /* JsxClosingFragment */); + var node = createNode(268 /* JsxClosingFragment */); parseExpected(29 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -20719,7 +21135,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(195 /* TypeAssertionExpression */); + var node = createNode(196 /* TypeAssertionExpression */); parseExpected(28 /* LessThanToken */); node.type = parseType(); parseExpected(30 /* GreaterThanToken */); @@ -20730,7 +21146,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(24 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(191 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -20738,14 +21154,14 @@ var ts; } if (token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(214 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(215 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(22 /* OpenBracketToken */)) { - var indexedAccess = createNode(191 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(192 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; if (token() === 23 /* CloseBracketToken */) { indexedAccess.argumentExpression = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); @@ -20772,7 +21188,7 @@ var ts; return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(194 /* TaggedTemplateExpression */, tag.pos); + var tagExpression = createNode(195 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 14 /* NoSubstitutionTemplateLiteral */ @@ -20797,7 +21213,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(192 /* CallExpression */, expression.pos); + var callExpr = createNode(193 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -20805,7 +21221,7 @@ var ts; continue; } else if (token() === 20 /* OpenParenToken */) { - var callExpr = createNode(192 /* CallExpression */, expression.pos); + var callExpr = createNode(193 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -20843,6 +21259,7 @@ var ts; case 15 /* TemplateHead */: // foo `...${100}...` // these are the only tokens can legally follow a type argument // list. So we definitely want to treat them as type arg lists. + // falls through case 24 /* DotToken */: // foo. case 21 /* CloseParenToken */: // foo) case 23 /* CloseBracketToken */: // foo] @@ -20869,6 +21286,7 @@ var ts; // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. + // falls through default: // Anything else treat as an expression. return false; @@ -20919,28 +21337,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(196 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(197 /* ParenthesizedExpression */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(209 /* SpreadElement */); + var node = createNode(210 /* SpreadElement */); parseExpected(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? createNode(211 /* OmittedExpression */) : + token() === 27 /* CommaToken */ ? createNode(212 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(188 /* ArrayLiteralExpression */); + var node = createNode(189 /* ArrayLiteralExpression */); parseExpected(22 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -20952,17 +21370,17 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(25 /* DotDotDotToken */)) { - node.kind = 278 /* SpreadAssignment */; + node.kind = 279 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + return parseAccessorDeclaration(node, 160 /* GetAccessor */); } if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + return parseAccessorDeclaration(node, 161 /* SetAccessor */); } var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); @@ -20980,7 +21398,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 57 /* ColonToken */); if (isShorthandPropertyAssignment) { - node.kind = 277 /* ShorthandPropertyAssignment */; + node.kind = 278 /* ShorthandPropertyAssignment */; var equalsToken = parseOptionalToken(60 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; @@ -20988,14 +21406,14 @@ var ts; } } else { - node.kind = 276 /* PropertyAssignment */; + node.kind = 277 /* PropertyAssignment */; parseExpected(57 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(189 /* ObjectLiteralExpression */); + var node = createNode(190 /* ObjectLiteralExpression */); parseExpected(18 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21014,7 +21432,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(197 /* FunctionExpression */); + var node = createNodeWithJSDoc(198 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(91 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); @@ -21039,7 +21457,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(96 /* NewKeyword */); if (parseOptional(24 /* DotToken */)) { - var node_2 = createNode(215 /* MetaProperty */, fullStart); + var node_2 = createNode(216 /* MetaProperty */, fullStart); node_2.keywordToken = 96 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -21056,7 +21474,7 @@ var ts; } break; } - var node = createNode(193 /* NewExpression */, fullStart); + var node = createNode(194 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 20 /* OpenParenToken */) { @@ -21066,7 +21484,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(219 /* Block */); + var node = createNode(220 /* Block */); if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21099,12 +21517,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(221 /* EmptyStatement */); + var node = createNode(222 /* EmptyStatement */); parseExpected(26 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(223 /* IfStatement */); + var node = createNode(224 /* IfStatement */); parseExpected(92 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -21114,7 +21532,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(224 /* DoStatement */); + var node = createNode(225 /* DoStatement */); parseExpected(83 /* DoKeyword */); node.statement = parseStatement(); parseExpected(108 /* WhileKeyword */); @@ -21129,7 +21547,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(225 /* WhileStatement */); + var node = createNode(226 /* WhileStatement */); parseExpected(108 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -21152,8 +21570,8 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(148 /* OfKeyword */) : parseOptional(148 /* OfKeyword */)) { - var forOfStatement = createNode(228 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(149 /* OfKeyword */) : parseOptional(149 /* OfKeyword */)) { + var forOfStatement = createNode(229 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -21161,14 +21579,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(94 /* InKeyword */)) { - var forInStatement = createNode(227 /* ForInStatement */, pos); + var forInStatement = createNode(228 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(226 /* ForStatement */, pos); + var forStatement = createNode(227 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(26 /* SemicolonToken */); if (token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */) { @@ -21186,7 +21604,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 230 /* BreakStatement */ ? 74 /* BreakKeyword */ : 79 /* ContinueKeyword */); + parseExpected(kind === 231 /* BreakStatement */ ? 74 /* BreakKeyword */ : 79 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -21194,7 +21612,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(231 /* ReturnStatement */); + var node = createNode(232 /* ReturnStatement */); parseExpected(98 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -21203,7 +21621,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(232 /* WithStatement */); + var node = createNode(233 /* WithStatement */); parseExpected(109 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -21212,7 +21630,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(272 /* CaseClause */); + var node = createNode(273 /* CaseClause */); parseExpected(75 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(57 /* ColonToken */); @@ -21220,7 +21638,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(273 /* DefaultClause */); + var node = createNode(274 /* DefaultClause */); parseExpected(81 /* DefaultKeyword */); parseExpected(57 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -21230,12 +21648,12 @@ var ts; return token() === 75 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(233 /* SwitchStatement */); + var node = createNode(234 /* SwitchStatement */); parseExpected(100 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - var caseBlock = createNode(247 /* CaseBlock */); + var caseBlock = createNode(248 /* CaseBlock */); parseExpected(18 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(19 /* CloseBraceToken */); @@ -21250,7 +21668,7 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(235 /* ThrowStatement */); + var node = createNode(236 /* ThrowStatement */); parseExpected(102 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -21258,7 +21676,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(236 /* TryStatement */); + var node = createNode(237 /* TryStatement */); parseExpected(104 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 76 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -21271,7 +21689,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(275 /* CatchClause */); + var result = createNode(276 /* CatchClause */); parseExpected(76 /* CatchKeyword */); if (parseOptional(20 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -21285,7 +21703,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(237 /* DebuggerStatement */); + var node = createNode(238 /* DebuggerStatement */); parseExpected(80 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -21297,12 +21715,12 @@ var ts; var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); if (expression.kind === 73 /* Identifier */ && parseOptional(57 /* ColonToken */)) { - node.kind = 234 /* LabeledStatement */; + node.kind = 235 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 222 /* ExpressionStatement */; + node.kind = 223 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -21424,6 +21842,7 @@ var ts; case 80 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. + // falls through case 76 /* CatchKeyword */: case 89 /* FinallyKeyword */: return true; @@ -21469,16 +21888,16 @@ var ts; case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); case 106 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(239 /* VariableDeclaration */)); case 112 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(239 /* VariableDeclaration */)); } break; case 91 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(240 /* FunctionDeclaration */)); + return parseFunctionDeclaration(createNodeWithJSDoc(241 /* FunctionDeclaration */)); case 77 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(241 /* ClassDeclaration */)); + return parseClassDeclaration(createNodeWithJSDoc(242 /* ClassDeclaration */)); case 92 /* IfKeyword */: return parseIfStatement(); case 83 /* DoKeyword */: @@ -21488,9 +21907,9 @@ var ts; case 90 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 79 /* ContinueKeyword */: - return parseBreakOrContinueStatement(229 /* ContinueStatement */); + return parseBreakOrContinueStatement(230 /* ContinueStatement */); case 74 /* BreakKeyword */: - return parseBreakOrContinueStatement(230 /* BreakStatement */); + return parseBreakOrContinueStatement(231 /* BreakStatement */); case 98 /* ReturnKeyword */: return parseReturnStatement(); case 109 /* WithKeyword */: @@ -21501,6 +21920,7 @@ var ts; return parseThrowStatement(); case 104 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. + // falls through case 76 /* CatchKeyword */: case 89 /* FinallyKeyword */: return parseTryStatement(); @@ -21536,10 +21956,21 @@ var ts; return modifier.kind === 126 /* DeclareKeyword */; } function parseDeclaration() { + var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); }); + // `parseListElement` attempted to get the reused node at this position, + // but the ambient context flag was not yet set, so the node appeared + // not reusable in that context. + var isAmbient = ts.some(modifiers, isDeclareModifier); + if (isAmbient) { + var node_3 = tryReuseAmbientDeclaration(); + if (node_3) { + return node_3; + } + } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (ts.some(node.modifiers, isDeclareModifier)) { + if (isAmbient) { for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var m = _a[_i]; m.flags |= 4194304 /* Ambient */; @@ -21550,6 +21981,14 @@ var ts; return parseDeclarationWorker(node); } } + function tryReuseAmbientDeclaration() { + return doInsideOfContext(4194304 /* Ambient */, function () { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + }); + } function parseDeclarationWorker(node) { switch (token()) { case 106 /* VarKeyword */: @@ -21587,7 +22026,7 @@ var ts; if (node.decorators || node.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(259 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(260 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -21610,16 +22049,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 27 /* CommaToken */) { - return createNode(211 /* OmittedExpression */); + return createNode(212 /* OmittedExpression */); } - var node = createNode(187 /* BindingElement */); + var node = createNode(188 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(187 /* BindingElement */); + var node = createNode(188 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -21635,14 +22074,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(185 /* ObjectBindingPattern */); + var node = createNode(186 /* ObjectBindingPattern */); parseExpected(18 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(186 /* ArrayBindingPattern */); + var node = createNode(187 /* ArrayBindingPattern */); parseExpected(22 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(23 /* CloseBracketToken */); @@ -21664,7 +22103,7 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(238 /* VariableDeclaration */); + var node = createNode(239 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 73 /* Identifier */ && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { @@ -21677,7 +22116,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(239 /* VariableDeclarationList */); + var node = createNode(240 /* VariableDeclarationList */); switch (token()) { case 106 /* VarKeyword */: break; @@ -21700,7 +22139,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 148 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 149 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -21715,13 +22154,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 220 /* VariableStatement */; + node.kind = 221 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 240 /* FunctionDeclaration */; + node.kind = 241 /* FunctionDeclaration */; parseExpected(91 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); @@ -21745,7 +22184,7 @@ var ts; function tryParseConstructorDeclaration(node) { return tryParse(function () { if (parseConstructorName()) { - node.kind = 158 /* Constructor */; + node.kind = 159 /* Constructor */; fillSignature(57 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); @@ -21753,7 +22192,7 @@ var ts; }); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 157 /* MethodDeclaration */; + node.kind = 158 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; @@ -21762,7 +22201,7 @@ var ts; return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 155 /* PropertyDeclaration */; + node.kind = 156 /* PropertyDeclaration */; if (!node.questionToken && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } @@ -21867,7 +22306,7 @@ var ts; if (!parseOptional(58 /* AtToken */)) { break; } - var decorator = createNode(153 /* Decorator */, decoratorStart); + var decorator = createNode(154 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -21917,7 +22356,7 @@ var ts; } function parseClassElement() { if (token() === 26 /* SemicolonToken */) { - var result = createNode(218 /* SemicolonClassElement */); + var result = createNode(219 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -21925,10 +22364,10 @@ var ts; node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + return parseAccessorDeclaration(node, 160 /* GetAccessor */); } if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + return parseAccessorDeclaration(node, 161 /* SetAccessor */); } if (token() === 125 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(node); @@ -21957,10 +22396,10 @@ var ts; return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 210 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 211 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 241 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 242 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -22003,22 +22442,21 @@ var ts; function parseHeritageClause() { var tok = token(); ts.Debug.assert(tok === 87 /* ExtendsKeyword */ || tok === 110 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(274 /* HeritageClause */); + var node = createNode(275 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(213 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 28 /* LessThanToken */ - ? parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) - : undefined; + return token() === 28 /* LessThanToken */ ? + parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) : undefined; } function isHeritageClause() { return token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; @@ -22027,7 +22465,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 242 /* InterfaceDeclaration */; + node.kind = 243 /* InterfaceDeclaration */; parseExpected(111 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -22036,7 +22474,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 243 /* TypeAliasDeclaration */; + node.kind = 244 /* TypeAliasDeclaration */; parseExpected(141 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -22050,13 +22488,13 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNodeWithJSDoc(279 /* EnumMember */); + var node = createNodeWithJSDoc(280 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 244 /* EnumDeclaration */; + node.kind = 245 /* EnumDeclaration */; parseExpected(85 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(18 /* OpenBraceToken */)) { @@ -22069,7 +22507,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(246 /* ModuleBlock */); + var node = createNode(247 /* ModuleBlock */); if (parseExpected(18 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(19 /* CloseBraceToken */); @@ -22080,7 +22518,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 245 /* ModuleDeclaration */; + node.kind = 246 /* ModuleDeclaration */; // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -22092,7 +22530,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 245 /* ModuleDeclaration */; + node.kind = 246 /* ModuleDeclaration */; if (token() === 146 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); @@ -22138,7 +22576,7 @@ var ts; return nextToken() === 42 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 248 /* NamespaceExportDeclaration */; + node.kind = 249 /* NamespaceExportDeclaration */; parseExpected(120 /* AsKeyword */); parseExpected(132 /* NamespaceKeyword */); node.name = parseIdentifier(); @@ -22156,7 +22594,7 @@ var ts; } } // Import statement - node.kind = 250 /* ImportDeclaration */; + node.kind = 251 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; @@ -22171,7 +22609,7 @@ var ts; return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 249 /* ImportEqualsDeclaration */; + node.kind = 250 /* ImportEqualsDeclaration */; node.name = identifier; parseExpected(60 /* EqualsToken */); node.moduleReference = parseModuleReference(); @@ -22185,7 +22623,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(251 /* ImportClause */, fullStart); + var importClause = createNode(252 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -22195,7 +22633,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(27 /* CommaToken */)) { - importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(253 /* NamedImports */); + importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(254 /* NamedImports */); } return finishNode(importClause); } @@ -22205,7 +22643,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(260 /* ExternalModuleReference */); + var node = createNode(261 /* ExternalModuleReference */); parseExpected(135 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -22228,7 +22666,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(252 /* NamespaceImport */); + var namespaceImport = createNode(253 /* NamespaceImport */); parseExpected(40 /* AsteriskToken */); parseExpected(120 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -22243,14 +22681,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 253 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); + node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 254 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(258 /* ExportSpecifier */); + return parseImportOrExportSpecifier(259 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(254 /* ImportSpecifier */); + return parseImportOrExportSpecifier(255 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -22275,19 +22713,19 @@ var ts; else { node.name = identifierName; } - if (kind === 254 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 255 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 256 /* ExportDeclaration */; + node.kind = 257 /* ExportDeclaration */; if (parseOptional(40 /* AsteriskToken */)) { parseExpected(145 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(257 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(258 /* 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. @@ -22300,7 +22738,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 255 /* ExportAssignment */; + node.kind = 256 /* ExportAssignment */; if (parseOptional(60 /* EqualsToken */)) { node.isExportEquals = true; } @@ -22320,12 +22758,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */ - || node.kind === 250 /* ImportDeclaration */ - || node.kind === 255 /* ExportAssignment */ - || node.kind === 256 /* ExportDeclaration */ - ? node - : undefined; + || node.kind === 250 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 261 /* ExternalModuleReference */ + || node.kind === 251 /* ImportDeclaration */ + || node.kind === 256 /* ExportAssignment */ + || node.kind === 257 /* ExportDeclaration */ ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { return sourceFile.flags & 1048576 /* PossiblyContainsImportMeta */ ? @@ -22387,7 +22823,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(289 /* JSDocTypeExpression */); + var result = createNode(290 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -22399,8 +22835,8 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseIsolatedJSDocComment(content, start, length) { initializeState(content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = { languageVariant: 0 /* Standard */, text: content }; // tslint:disable-line no-object-literal-type-assertion - var jsDoc = parseJSDocCommentWorker(start, length); + sourceFile = { languageVariant: 0 /* Standard */, text: content }; + var jsDoc = doInsideOfContext(2097152 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); var diagnostics = parseDiagnostics; clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -22411,7 +22847,7 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = parseJSDocCommentWorker(start, length); + var comment = doInsideOfContext(2097152 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); if (comment) { comment.parent = parent; } @@ -22550,7 +22986,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(297 /* JSDocComment */, start); + var result = createNode(299 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -22750,7 +23186,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(300 /* JSDocTag */, start); + var result = createNode(302 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -22797,7 +23233,7 @@ var ts; switch (node.kind) { case 137 /* ObjectKeyword */: return true; - case 170 /* ArrayType */: + case 171 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -22813,8 +23249,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(312 /* JSDocPropertyTag */, start) : - createNode(306 /* JSDocParameterTag */, start); + createNode(314 /* JSDocPropertyTag */, start) : + createNode(308 /* JSDocParameterTag */, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -22831,20 +23267,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(289 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(290 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; - var start_2 = scanner.getStartPos(); + var start_3 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 306 /* JSDocParameterTag */ || child.kind === 312 /* JSDocPropertyTag */) { + if (child.kind === 308 /* JSDocParameterTag */ || child.kind === 314 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(298 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(300 /* JSDocTypeLiteral */, start_3); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression.type.kind === 171 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -22856,7 +23292,7 @@ var ts; if (ts.some(tags, ts.isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(307 /* JSDocReturnTag */, start); + var result = createNode(309 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); @@ -22865,13 +23301,13 @@ var ts; if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(309 /* JSDocTypeTag */, start); + var result = createNode(311 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAuthorTag(start, tagName, indent) { - var result = createNode(302 /* JSDocAuthorTag */, start); + var result = createNode(304 /* JSDocAuthorTag */, start); result.tagName = tagName; var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); }); if (!authorInfoWithEmail) { @@ -22925,14 +23361,14 @@ var ts; } } function parseAugmentsTag(start, tagName) { - var result = createNode(301 /* JSDocAugmentsTag */, start); + var result = createNode(303 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18 /* OpenBraceToken */); - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(213 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -22944,7 +23380,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var prop = createNode(190 /* PropertyAccessExpression */, node.pos); + var prop = createNode(191 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -22952,19 +23388,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(303 /* JSDocClassTag */, start); + var tag = createNode(305 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(308 /* JSDocThisTag */, start); + var tag = createNode(310 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(305 /* JSDocEnumTag */, start); + var tag = createNode(307 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); @@ -22973,7 +23409,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(311 /* JSDocTypedefTag */, start); + var typedefTag = createNode(313 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -22987,9 +23423,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(298 /* JSDocTypeLiteral */, start); + jsdocTypeLiteral = createNode(300 /* JSDocTypeLiteral */, start); } - if (child.kind === 309 /* JSDocTypeTag */) { + if (child.kind === 311 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -23002,7 +23438,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 171 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -23021,7 +23457,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(24 /* DotToken */)) { - var jsDocNamespaceNode = createNode(245 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(246 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -23035,14 +23471,14 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(304 /* JSDocCallbackTag */, start); + var callbackTag = createNode(306 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(299 /* JSDocSignature */, start); + var jsdocSignature = createNode(301 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -23050,7 +23486,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(58 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 307 /* JSDocReturnTag */) { + if (tag && tag.kind === 309 /* JSDocReturnTag */) { return tag; } } @@ -23095,7 +23531,7 @@ var ts; case 58 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 306 /* JSDocParameterTag */ || child.kind === 312 /* JSDocPropertyTag */) && + if (child && (child.kind === 308 /* JSDocParameterTag */ || child.kind === 314 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -23159,13 +23595,13 @@ var ts; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(151 /* TypeParameter */); + var typeParameter = createNode(152 /* TypeParameter */); typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); finishNode(typeParameter); skipWhitespace(); typeParameters.push(typeParameter); } while (parseOptionalJsdoc(27 /* CommaToken */)); - var result = createNode(310 /* JSDocTemplateTag */, start); + var result = createNode(312 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -23200,16 +23636,19 @@ var ts; if (!ts.tokenIsIdentifierOrKeyword(token())) { return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } + identifierCount++; var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); var result = createNode(73 /* Identifier */, pos); - result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); + if (token() !== 73 /* Identifier */) { + result.originalKeywordKind = token(); + } + result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); finishNode(result, end); nextTokenJSDoc(); return result; } } - JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {})); })(Parser || (Parser = {})); var IncrementalParser; @@ -24055,6 +24494,7 @@ var ts; type: "boolean", category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_incremental_compilation, + transpileOptionValue: undefined }, { name: "locale", @@ -24064,7 +24504,7 @@ var ts; }, ]; /* @internal */ - ts.optionDeclarations = ts.commonOptionsWithBuild.concat([ + ts.optionDeclarations = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "all", type: "boolean", @@ -24166,7 +24606,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation + description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation, + transpileOptionValue: undefined }, { name: "allowJs", @@ -24203,6 +24644,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "declarationMap", @@ -24211,6 +24653,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "emitDeclarationOnly", @@ -24218,6 +24661,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Only_emit_d_ts_declaration_files, + transpileOptionValue: undefined }, { name: "sourceMap", @@ -24236,6 +24680,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "outDir", @@ -24263,6 +24708,7 @@ var ts; isTSConfigOnly: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_project_compilation, + transpileOptionValue: undefined }, { name: "tsBuildInfoFile", @@ -24272,6 +24718,7 @@ var ts; paramType: ts.Diagnostics.FILE, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, + transpileOptionValue: undefined }, { name: "removeComments", @@ -24288,6 +24735,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Do_not_emit_outputs, + transpileOptionValue: undefined }, { name: "importHelpers", @@ -24307,7 +24755,8 @@ var ts; name: "isolatedModules", type: "boolean", category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule + description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule, + transpileOptionValue: true }, // Strict Type Checks { @@ -24441,7 +24890,8 @@ var ts; affectsModuleResolution: true, isTSConfigOnly: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl + description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl, + transpileOptionValue: undefined }, { // this option can only be specified in tsconfig.json @@ -24456,7 +24906,8 @@ var ts; }, affectsModuleResolution: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime + description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime, + transpileOptionValue: undefined }, { name: "typeRoots", @@ -24480,7 +24931,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation, + transpileOptionValue: undefined }, { name: "allowSyntheticDefaultImports", @@ -24577,6 +25029,7 @@ var ts; category: ts.Diagnostics.Advanced_Options, paramType: ts.Diagnostics.FILE, description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "reactNamespace", @@ -24626,14 +25079,20 @@ var ts; type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts + description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts, + // We are not returning a sourceFile for lib file when asked by the program, + // so pass --noLib to avoid reporting a file not found error. + transpileOptionValue: true }, { name: "noResolve", type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files + description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files, + // We are not doing a full typecheck, we are not resolving the whole context, + // so pass --noResolve to avoid reporting missing file errors. + transpileOptionValue: true }, { name: "stripInternal", @@ -24669,6 +25128,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + transpileOptionValue: undefined }, { name: "preserveConstEnums", @@ -24684,7 +25144,8 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Output_directory_for_generated_declaration_files + description: ts.Diagnostics.Output_directory_for_generated_declaration_files, + transpileOptionValue: undefined }, { name: "skipLibCheck", @@ -24771,7 +25232,11 @@ var ts; return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics; }); /* @internal */ - ts.buildOpts = ts.commonOptionsWithBuild.concat([ + ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) { + return ts.hasProperty(option, "transpileOptionValue"); + }); + /* @internal */ + ts.buildOpts = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "verbose", shortName: "v", @@ -25335,7 +25800,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 276 /* PropertyAssignment */) { + if (element.kind !== 277 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -25399,7 +25864,7 @@ var ts; return false; case 97 /* NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for - return null; // tslint:disable-line:no-null-keyword + return null; // eslint-disable-line no-null/no-null case 10 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); @@ -25417,13 +25882,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: if (valueExpression.operator !== 39 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -25440,7 +25905,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25491,13 +25956,13 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName); }); var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames }); - var config = __assign({ compilerOptions: __assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { + var config = __assign(__assign({ compilerOptions: __assign(__assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { var _a; - return (__assign({}, prev, (_a = {}, _a[cur[0]] = cur[1], _a))); - }, {}), { showConfig: undefined, configFile: undefined, configFilePath: undefined, help: undefined, init: undefined, listFiles: undefined, listEmittedFiles: undefined, project: undefined, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign({}, r, { path: r.originalPath, originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { + return (__assign(__assign({}, prev), (_a = {}, _a[cur[0]] = cur[1], _a))); + }, {})), { showConfig: undefined, configFile: undefined, configFilePath: undefined, help: undefined, init: undefined, listFiles: undefined, listEmittedFiles: undefined, project: undefined, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign(__assign({}, r), { path: r.originalPath ? r.originalPath : "", originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs), exclude: configParseResult.configFileSpecs.validatedExcludeSpecs - } : {}), { compilerOnSave: !!configParseResult.compileOnSave ? true : undefined }); + } : {})), { compileOnSave: !!configParseResult.compileOnSave ? true : undefined }); return config; } ts.convertToTSConfig = convertToTSConfig; @@ -25722,8 +26187,7 @@ var ts; } ts.setConfigFileInOptions = setConfigFileInOptions; function isNullOrUndefined(x) { - // tslint:disable-next-line:no-null-keyword - return x === undefined || x === null; + return x === undefined || x === null; // eslint-disable-line no-null/no-null } function directoryOfCombinedPath(fileName, basePath) { // Use the `getNormalizedAbsolutePath` function to avoid canonicalizing the path, as it must remain noncanonical @@ -25889,7 +26353,7 @@ var ts; basePath = ts.normalizeSlashes(basePath); var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath); if (resolutionStack.indexOf(resolvedPath) >= 0) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))); + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, __spreadArrays(resolutionStack, [resolvedPath]).join(" -> "))); return { raw: json || convertToObject(sourceFile, errors) }; } var ownConfig = json ? @@ -26578,8 +27042,9 @@ var ts; return; } var value = jsonContent[fieldName]; - if (typeof value !== typeOfTag || value === null) { + if (typeof value !== typeOfTag || value === null) { // eslint-disable-line no-null/no-null if (state.traceEnabled) { + // eslint-disable-next-line no-null/no-null trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, fieldName, typeOfTag, value === null ? "null" : typeof value); } return; @@ -26838,7 +27303,7 @@ var ts; var packageJsonPath = ts.combinePaths(root, normalized, "package.json"); // `types-publisher` sometimes creates packages with `"typings": null` for packages that don't provide their own types. // See `createNotNeededPackageJSON` in the types-publisher` repo. - // tslint:disable-next-line:no-null-keyword + // eslint-disable-next-line no-null/no-null var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); @@ -27022,6 +27487,7 @@ var ts; trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); } } + ts.perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/); switch (moduleResolution) { case ts.ModuleResolutionKind.NodeJs: result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); @@ -27032,6 +27498,9 @@ var ts; default: return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); } + if (result && result.resolvedModule) + ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, result); if (!ts.isExternalModuleNameRelative(moduleName)) { @@ -27241,7 +27710,7 @@ var ts; ts.tryResolveJSModule = tryResolveJSModule; var jsOnlyExtensions = [Extensions.JavaScript]; var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript]; - var tsPlusJsonExtensions = tsExtensions.concat([Extensions.Json]); + var tsPlusJsonExtensions = __spreadArrays(tsExtensions, [Extensions.Json]); var tsconfigExtensions = [Extensions.TSConfig]; function tryResolveJSModuleWorker(moduleName, initialDir, host) { return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); @@ -27277,7 +27746,7 @@ var ts; if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) { var path = realPath(resolvedValue.path, host, traceEnabled); var originalPath = path === resolvedValue.path ? undefined : resolvedValue.path; - resolvedValue = __assign({}, resolvedValue, { path: path, originalPath: originalPath }); + resolvedValue = __assign(__assign({}, resolvedValue), { path: path, originalPath: originalPath }); } // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } }; @@ -27298,7 +27767,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); // tslint:disable-line + ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -27786,24 +28255,24 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. other uninstantiated module declarations. - case 246 /* ModuleBlock */: { + case 247 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -27825,7 +28294,7 @@ var ts; }); return state_1; } - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return getModuleInstanceState(node); case 73 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should @@ -27864,7 +28333,9 @@ var ts; var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); + ts.perfLogger.logStartBindFile("" + file.fileName); binder(file, options); + ts.perfLogger.logStopBindFile(); ts.performance.mark("afterBind"); ts.performance.measure("Bind", "beforeBind", "afterBind"); } @@ -27898,7 +28369,7 @@ var ts; // or if compiler options contain alwaysStrict. var inStrictMode; var symbolCount = 0; - var Symbol; // tslint:disable-line variable-name + var Symbol; var classifiableNames; var unreachableFlow = { flags: 1 /* Unreachable */ }; var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; @@ -27966,7 +28437,7 @@ var ts; function addDeclarationToSymbol(symbol, node, symbolFlags) { symbol.flags |= symbolFlags; node.symbol = symbol; - symbol.declarations = ts.append(symbol.declarations, node); + symbol.declarations = ts.appendIfUnique(symbol.declarations, node); if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -27977,7 +28448,7 @@ var ts; if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 67220415 /* Value */) { + if (symbolFlags & 111551 /* Value */) { setValueDeclaration(symbol, node); } } @@ -27993,7 +28464,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 === 255 /* ExportAssignment */) { + if (node.kind === 256 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -28002,7 +28473,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 151 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -28017,36 +28488,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: return "__constructor" /* Constructor */; - case 166 /* FunctionType */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: + case 167 /* FunctionType */: + case 162 /* CallSignature */: + case 301 /* JSDocSignature */: return "__call" /* Call */; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 168 /* ConstructorType */: + case 163 /* ConstructSignature */: return "__new" /* New */; - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: return "__index" /* Index */; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 285 /* SourceFile */: + case 286 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 152 /* Parameter */: + case 153 /* 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 === 295 /* 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 === 296 /* 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; @@ -28146,7 +28617,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 === 255 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 256 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -28164,7 +28635,7 @@ var ts; } }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); - file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInformation_1)) : diag); + file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInformation_1)) : diag); symbol = createSymbol(0 /* None */, name); } } @@ -28181,7 +28652,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 258 /* ExportSpecifier */ || (node.kind === 249 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 259 /* ExportSpecifier */ || (node.kind === 250 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -28206,10 +28677,10 @@ var ts; if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { - if (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node)) { + if (!container.locals || (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } - var exportKind = symbolFlags & 67220415 /* Value */ ? 1048576 /* ExportValue */ : 0; + var exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -28248,7 +28719,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 !== 198 /* ArrowFunction */) { + if (node.kind !== 199 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -28281,7 +28752,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 === 158 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 159 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -28295,13 +28766,13 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 158 /* Constructor */) { + if (node.kind === 159 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -28345,8 +28816,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 241 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 241 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -28379,78 +28850,82 @@ var ts; return; } switch (node.kind) { - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: bindWhileStatement(node); break; - case 224 /* DoStatement */: + case 225 /* DoStatement */: bindDoStatement(node); break; - case 226 /* ForStatement */: + case 227 /* ForStatement */: bindForStatement(node); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 223 /* IfStatement */: + case 224 /* IfStatement */: bindIfStatement(node); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 232 /* ReturnStatement */: + case 236 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 236 /* TryStatement */: + case 237 /* TryStatement */: bindTryStatement(node); break; - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: bindSwitchStatement(node); break; - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: bindCaseBlock(node); break; - case 272 /* CaseClause */: + case 273 /* CaseClause */: bindCaseClause(node); break; - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: bindLabeledStatement(node); break; - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 192 /* CallExpression */: + case 193 /* CallExpression */: bindCallExpressionFlow(node); break; - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; + case 305 /* JSDocClassTag */: + bindJSDocClassTag(node); + break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 285 /* SourceFile */: { + case 286 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 220 /* Block */: + case 247 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -28463,18 +28938,18 @@ var ts; switch (expr.kind) { case 73 /* Identifier */: case 101 /* ThisKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return isNarrowableReference(expr); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return hasNarrowableArgument(expr); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return expr.operator === 52 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; @@ -28482,7 +28957,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 73 /* Identifier */ || expr.kind === 101 /* ThisKeyword */ || expr.kind === 99 /* SuperKeyword */ || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isElementAccessExpression(expr) && expr.argumentExpression && + ts.isElementAccessExpression(expr) && (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && isNarrowableReference(expr.expression); } @@ -28495,7 +28970,7 @@ var ts; } } } - if (expr.expression.kind === 190 /* PropertyAccessExpression */ && + if (expr.expression.kind === 191 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -28528,9 +29003,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 60 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -28608,33 +29083,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 224 /* IfStatement */: + case 226 /* WhileStatement */: + case 225 /* DoStatement */: return parent.expression === node; - case 226 /* ForStatement */: - case 206 /* ConditionalExpression */: + case 227 /* ForStatement */: + case 207 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 196 /* ParenthesizedExpression */) { + if (node.kind === 197 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 203 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { + else if (node.kind === 204 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 205 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || + return node.kind === 206 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 55 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */ || - node.parent.kind === 203 /* PrefixUnaryExpression */ && + while (node.parent.kind === 197 /* ParenthesizedExpression */ || + node.parent.kind === 204 /* PrefixUnaryExpression */ && node.parent.operator === 52 /* ExclamationToken */) { node = node.parent; } @@ -28676,7 +29151,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 234 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 235 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -28710,13 +29185,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 228 /* ForOfStatement */) { + if (node.kind === 229 /* ForOfStatement */) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 239 /* VariableDeclarationList */) { + if (node.initializer.kind !== 240 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -28738,7 +29213,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 231 /* ReturnStatement */) { + if (node.kind === 232 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -28758,7 +29233,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 230 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 231 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -28886,7 +29361,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 273 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 274 /* 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). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -28953,14 +29428,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 224 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 225 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */) { + if (node.kind === 206 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -28971,10 +29446,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 188 /* ArrayLiteralExpression */) { + else if (node.kind === 189 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 209 /* SpreadElement */) { + if (e.kind === 210 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -28982,16 +29457,16 @@ var ts; } } } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 190 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 276 /* PropertyAssignment */) { + if (p.kind === 277 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 277 /* ShorthandPropertyAssignment */) { + else if (p.kind === 278 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 278 /* SpreadAssignment */) { + else if (p.kind === 279 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -29047,7 +29522,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 60 /* EqualsToken */ && node.left.kind === 191 /* ElementAccessExpression */) { + if (operator === 60 /* EqualsToken */ && node.left.kind === 192 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29058,7 +29533,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + if (node.expression.kind === 191 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -29097,19 +29572,26 @@ var ts; } function bindJSDocTypeAlias(node) { node.tagName.parent = node; - if (node.fullName) { + if (node.kind !== 307 /* JSDocEnumTag */ && node.fullName) { setParentPointers(node, node.fullName); } } + function bindJSDocClassTag(node) { + bindEachChild(node); + var host = ts.getHostSignatureFromJSDoc(node); + if (host && host.kind !== 158 /* MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* Class */); + } + } function bindCallExpressionFlow(node) { // If the target of the call expression is a function expression or arrow function we have // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = node.expression; - while (expr.kind === 196 /* ParenthesizedExpression */) { + while (expr.kind === 197 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 197 /* FunctionExpression */ || expr.kind === 198 /* ArrowFunction */) { + if (expr.kind === 198 /* FunctionExpression */ || expr.kind === 199 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -29117,7 +29599,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + if (node.expression.kind === 191 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29126,54 +29608,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 269 /* JsxAttributes */: + case 211 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 190 /* ObjectLiteralExpression */: + case 170 /* TypeLiteral */: + case 300 /* JSDocTypeLiteral */: + case 270 /* JsxAttributes */: return 1 /* IsContainer */; - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 246 /* ModuleDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 183 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 285 /* SourceFile */: + case 286 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: - case 295 /* JSDocFunctionType */: - case 166 /* FunctionType */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 167 /* ConstructorType */: + case 159 /* Constructor */: + case 241 /* FunctionDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 162 /* CallSignature */: + case 301 /* JSDocSignature */: + case 296 /* JSDocFunctionType */: + case 167 /* FunctionType */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 168 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 275 /* CatchClause */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 247 /* CaseBlock */: + case 276 /* CatchClause */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 248 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 219 /* Block */: + case 220 /* 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 @@ -29206,45 +29688,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 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 285 /* SourceFile */: + case 286 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 242 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 189 /* ObjectLiteralExpression */: - case 242 /* InterfaceDeclaration */: - case 269 /* JsxAttributes */: + case 170 /* TypeLiteral */: + case 300 /* JSDocTypeLiteral */: + case 190 /* ObjectLiteralExpression */: + case 243 /* InterfaceDeclaration */: + case 270 /* 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 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 299 /* JSDocSignature */: - case 163 /* IndexSignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 295 /* JSDocFunctionType */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 301 /* JSDocSignature */: + case 164 /* IndexSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 296 /* JSDocFunctionType */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 244 /* TypeAliasDeclaration */: + case 183 /* 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 @@ -29345,7 +29827,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */ || prop.name.kind !== 73 /* Identifier */) { + if (prop.kind === 279 /* SpreadAssignment */ || prop.name.kind !== 73 /* Identifier */) { continue; } var identifier = prop.name; @@ -29357,7 +29839,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 === 276 /* PropertyAssignment */ || prop.kind === 277 /* ShorthandPropertyAssignment */ || prop.kind === 157 /* MethodDeclaration */ + var currentKind = prop.kind === 277 /* PropertyAssignment */ || prop.kind === 278 /* ShorthandPropertyAssignment */ || prop.kind === 158 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -29389,10 +29871,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -29423,9 +29905,37 @@ var ts; currentFlow = { flags: 2 /* Start */ }; parent = typeAlias; bind(typeAlias.typeExpression); - if (!typeAlias.fullName || typeAlias.fullName.kind === 73 /* Identifier */) { + var declName = ts.getNameOfDeclaration(typeAlias); + if ((ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName) && declName && ts.isPropertyAccessEntityNameExpression(declName.parent)) { + // typedef anchored to an A.B.C assignment - we need to bind into B's namespace under name C + var isTopLevel = isTopLevelNamespaceAssignment(declName.parent); + if (isTopLevel) { + bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); + var oldContainer = container; + switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { + case 1 /* ExportsProperty */: + case 2 /* ModuleExports */: + container = file; + break; + case 4 /* ThisProperty */: + container = declName.parent.expression; + break; + case 3 /* PrototypeProperty */: + container = declName.parent.expression.name; + break; + case 5 /* Property */: + container = ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; + break; + case 0 /* None */: + return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); + } + declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + container = oldContainer; + } + } + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 73 /* Identifier */) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); } else { bind(typeAlias.fullName); @@ -29444,7 +29954,8 @@ var ts; node.originalKeywordKind >= 110 /* FirstFutureReservedWord */ && node.originalKeywordKind <= 118 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && - !(node.flags & 4194304 /* Ambient */)) { + !(node.flags & 4194304 /* Ambient */) && + !(node.flags & 2097152 /* JSDoc */)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -29530,8 +30041,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 285 /* SourceFile */ && - blockScopeContainer.kind !== 245 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 286 /* SourceFile */ && + blockScopeContainer.kind !== 246 /* 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. @@ -29592,7 +30103,7 @@ var ts; file.bindDiagnostics.push(diag); } else { - file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } } function bind(node) { @@ -29626,7 +30137,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 > 148 /* LastToken */) { + if (node.kind > 149 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -29697,17 +30208,17 @@ var ts; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); break; } // falls through case 101 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 277 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 278 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -29718,10 +30229,10 @@ var ts; file.commonJsModuleIndicator && ts.isModuleExportsPropertyAccessExpression(node) && !lookupSymbolForNameWorker(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 67220414 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -29749,76 +30260,76 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return checkStrictModeCatchClause(node); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return checkStrictModeWithStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 179 /* ThisType */: + case 180 /* ThisType */: seenThisKeyword = true; return; - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: break; // Binding the children will handle everything - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return bindTypeParameter(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return bindParameter(node); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 187 /* BindingElement */: + case 188 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return bindPropertyWorker(node); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 279 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 280 /* EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* 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 */ : 67212223 /* MethodExcludes */); - case 240 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); + case 241 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 158 /* Constructor */: + case 159 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 159 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 67154879 /* GetAccessorExcludes */); - case 160 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67187647 /* SetAccessorExcludes */); - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 299 /* JSDocSignature */: - case 167 /* ConstructorType */: + case 160 /* GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); + case 161 /* SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); + case 167 /* FunctionType */: + case 296 /* JSDocFunctionType */: + case 301 /* JSDocSignature */: + case 168 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 182 /* MappedType */: + case 170 /* TypeLiteral */: + case 300 /* JSDocTypeLiteral */: + case 183 /* MappedType */: return bindAnonymousTypeWorker(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return bindFunctionExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -29837,64 +30348,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 242 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 242 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 67897736 /* InterfaceExcludes */); - case 243 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); - case 244 /* EnumDeclaration */: + case 243 /* InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); + case 244 /* TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + case 245 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return bindJsxAttributes(node); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 250 /* ImportEqualsDeclaration */: + case 253 /* NamespaceImport */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return bindImportClause(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return bindExportDeclaration(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return bindExportAssignment(node); - case 285 /* SourceFile */: + case 286 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 219 /* Block */: + case 220 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 306 /* JSDocParameterTag */: - if (node.parent.kind === 299 /* JSDocSignature */) { + case 308 /* JSDocParameterTag */: + if (node.parent.kind === 301 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 298 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 300 /* JSDocTypeLiteral */) { break; } // falls through - case 312 /* JSDocPropertyTag */: + case 314 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 294 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 295 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -30038,8 +30550,8 @@ var ts; ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 198 /* 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 === 60 /* EqualsToken */) { @@ -30053,26 +30565,27 @@ var ts; constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable(); // It's acceptable for multiple 'this' assignments of the same identifier to occur declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 159 /* Constructor */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 285 /* SourceFile */: + case 286 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220414 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); } break; default: @@ -30083,7 +30596,7 @@ var ts; if (node.expression.kind === 101 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 285 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 286 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -30097,7 +30610,7 @@ var ts; node.left.parent = node; node.right.parent = node; var lhs = node.left; - bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false); + bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false, /*containerIsClass*/ true); } function bindObjectDefinePrototypeProperty(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); @@ -30116,12 +30629,12 @@ var ts; lhs.parent = parent; constructorFunction.parent = classPrototype; classPrototype.parent = lhs; - bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true); + bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true, /*containerIsClass*/ true); } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); + var isToplevel = node.parent.parent.kind === 286 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } function bindSpecialPropertyAssignment(node) { @@ -30150,10 +30663,10 @@ var ts; */ function bindStaticPropertyAssignment(node) { node.expression.parent = node; - bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } - function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { - if (isToplevel && !isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */))) { + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { + if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* Assignment */; var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; @@ -30169,6 +30682,9 @@ var ts; } }); } + if (containerIsClass && namespaceSymbol) { + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + } return namespaceSymbol; } function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { @@ -30181,15 +30697,18 @@ var ts; (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); var includes = isMethod ? 8192 /* Method */ : 4 /* Property */; - var excludes = isMethod ? 67212223 /* MethodExcludes */ : 0 /* PropertyExcludes */; + var excludes = isMethod ? 103359 /* MethodExcludes */ : 0 /* PropertyExcludes */; declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + function isTopLevelNamespaceAssignment(propertyAccess) { + return ts.isBinaryExpression(propertyAccess.parent) + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 286 /* SourceFile */ + : propertyAccess.parent.parent.kind === 286 /* SourceFile */; + } + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); - var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 285 /* SourceFile */ - : propertyAccess.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } /** @@ -30258,8 +30777,8 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 241 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); + if (node.kind === 242 /* ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { var bindingName = node.name ? node.name.escapedText : "__class" /* Class */; @@ -30292,19 +30811,16 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 68008831 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 68008191 /* RegularEnumExcludes */); + ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - var isEnum = ts.isInJSFile(node) && !!ts.getJSDocEnumTag(node); - var enumFlags = (isEnum ? 256 /* RegularEnum */ : 0 /* None */); - var enumExcludes = (isEnum ? 68008191 /* RegularEnumExcludes */ : 0 /* None */); if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */ | enumFlags, 67220415 /* BlockScopedVariableExcludes */ | enumExcludes); + bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); } else if (ts.isParameterDeclaration(node)) { // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration @@ -30316,15 +30832,15 @@ var ts; // function foo([a,a]) {} // Duplicate Identifier error // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter // // which correctly set excluded symbols - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220415 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */ | enumFlags, 67220414 /* FunctionScopedVariableExcludes */ | enumExcludes); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); } } } function bindParameter(node) { - if (node.kind === 306 /* JSDocParameterTag */ && container.kind !== 299 /* JSDocSignature */) { + if (node.kind === 308 /* JSDocParameterTag */ && container.kind !== 301 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -30336,11 +30852,11 @@ var ts; bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220415 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); } // If this is a property-parameter, then also declare the property symbol into the // containing class. - if (ts.isParameterPropertyDeclaration(node)) { + if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); } @@ -30354,10 +30870,10 @@ var ts; checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16 /* Function */, 67219887 /* FunctionExcludes */); + bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 67219887 /* FunctionExcludes */); + declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */); } } function bindFunctionExpression(node) { @@ -30395,26 +30911,26 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 177 /* InferType */) { + else if (node.parent.kind === 178 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } else { bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } // reachability checks @@ -30429,11 +30945,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 221 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 222 /* EmptyStatement */) || // report error on class declarations - node.kind === 241 /* ClassDeclaration */ || + node.kind === 242 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 245 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 246 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -30477,12 +30993,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: return true; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; @@ -30531,58 +31047,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 192 /* CallExpression */: + case 193 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 152 /* Parameter */: + case 153 /* Parameter */: return computeParameter(node, subtreeFlags); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 158 /* Constructor */: + case 159 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -30627,12 +31143,12 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 189 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 190 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ES2018 if they contain rest transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 188 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 189 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } @@ -30680,8 +31196,8 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 213 /* AsExpression */ - || expressionKind === 195 /* TypeAssertionExpression */) { + if (expressionKind === 214 /* AsExpression */ + || expressionKind === 196 /* TypeAssertionExpression */) { transformFlags |= 1 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -31019,13 +31535,13 @@ var ts; var excludeFlags = 536870912 /* NodeExcludes */; switch (kind) { case 122 /* AsyncKeyword */: - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ES2018 syntax (for async generators) transformFlags |= 16 /* AssertES2018 */ | 32 /* AssertES2017 */; break; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 315 /* PartiallyEmittedExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: + case 317 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; excludeFlags = 536870912 /* OuterExpressionExcludes */; @@ -31036,25 +31552,25 @@ var ts; case 119 /* AbstractKeyword */: case 126 /* DeclareKeyword */: case 78 /* ConstKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 214 /* NonNullExpression */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 215 /* NonNullExpression */: case 134 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: case 11 /* JsxText */: - case 264 /* JsxClosingElement */: - case 265 /* JsxFragment */: - case 266 /* JsxOpeningFragment */: - case 267 /* JsxClosingFragment */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 271 /* JsxExpression */: + case 265 /* JsxClosingElement */: + case 266 /* JsxFragment */: + case 267 /* JsxOpeningFragment */: + case 268 /* JsxClosingFragment */: + case 269 /* JsxAttribute */: + case 270 /* JsxAttributes */: + case 271 /* JsxSpreadAttribute */: + case 272 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 2 /* AssertJsx */; break; @@ -31062,11 +31578,11 @@ var ts; case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: - case 277 /* ShorthandPropertyAssignment */: + case 208 /* TemplateExpression */: + case 195 /* TaggedTemplateExpression */: + case 278 /* ShorthandPropertyAssignment */: case 117 /* StaticKeyword */: - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; @@ -31083,14 +31599,14 @@ var ts; case 9 /* BigIntLiteral */: transformFlags |= 4 /* AssertESNext */; break; - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 16 /* AssertES2018 */; } transformFlags |= 128 /* AssertES2015 */; break; - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 131072 /* ContainsYield */; @@ -31104,49 +31620,49 @@ var ts; case 124 /* BooleanKeyword */: case 140 /* SymbolKeyword */: case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 164 /* TypePredicate */: - case 165 /* TypeReference */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 168 /* TypeQuery */: - case 169 /* TypeLiteral */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 177 /* InferType */: - case 178 /* ParenthesizedType */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: - case 248 /* NamespaceExportDeclaration */: + case 152 /* TypeParameter */: + case 155 /* PropertySignature */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 165 /* TypePredicate */: + case 166 /* TypeReference */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 169 /* TypeQuery */: + case 170 /* TypeLiteral */: + case 171 /* ArrayType */: + case 172 /* TupleType */: + case 173 /* OptionalType */: + case 174 /* RestType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: + case 177 /* ConditionalType */: + case 178 /* InferType */: + case 179 /* ParenthesizedType */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 180 /* ThisType */: + case 181 /* TypeOperator */: + case 182 /* IndexedAccessType */: + case 183 /* MappedType */: + case 184 /* LiteralType */: + case 249 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 1 /* AssertTypeScript */; excludeFlags = -2 /* TypeExcludes */; break; - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. transformFlags |= 16384 /* ContainsComputedPropertyName */; break; - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: transformFlags |= 128 /* AssertES2015 */ | 4096 /* ContainsRestOrSpread */; break; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; break; case 99 /* SuperKeyword */: @@ -31158,28 +31674,28 @@ var ts; // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 2048 /* ContainsLexicalThis */; break; - case 185 /* ObjectBindingPattern */: + case 186 /* ObjectBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; if (subtreeFlags & 4096 /* ContainsRestOrSpread */) { transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; } excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 187 /* BindingElement */: + case 188 /* BindingElement */: transformFlags |= 128 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 4096 /* ContainsRestOrSpread */; } break; - case 153 /* Decorator */: + case 154 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */ | 1024 /* ContainsTypeScriptClassSyntax */; break; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: excludeFlags = 536896512 /* ObjectLiteralExcludes */; if (subtreeFlags & 16384 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -31192,26 +31708,26 @@ var ts; transformFlags |= 16 /* AssertES2018 */; } break; - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: excludeFlags = 536875008 /* ArrayLiteralOrCallOrNewExcludes */; break; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 32768 /* ContainsBlockScopedBinding */) { transformFlags |= 128 /* AssertES2015 */; } break; - case 285 /* SourceFile */: + case 286 /* SourceFile */: break; - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: // Return statements may require an `await` in ES2018. transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */ | 16 /* AssertES2018 */; break; - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 230 /* ContinueStatement */: + case 231 /* BreakStatement */: transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -31229,33 +31745,33 @@ var ts; * than calling this function. */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) { + if (kind >= 165 /* FirstTypeNode */ && kind <= 185 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 188 /* ArrayLiteralExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 189 /* ArrayLiteralExpression */: return 536875008 /* ArrayLiteralOrCallOrNewExcludes */; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return 537168896 /* ModuleExcludes */; - case 152 /* Parameter */: + case 153 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return 537371648 /* ArrowFunctionExcludes */; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: return 537373696 /* FunctionExcludes */; - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return 536944640 /* VariableDeclarationListExcludes */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return 536888320 /* ClassExcludes */; - case 158 /* Constructor */: + case 159 /* Constructor */: return 537372672 /* ConstructorExcludes */; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return 537372672 /* MethodOrAccessorExcludes */; case 121 /* AnyKeyword */: case 136 /* NumberKeyword */: @@ -31266,30 +31782,30 @@ var ts; case 124 /* BooleanKeyword */: case 140 /* SymbolKeyword */: case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 152 /* TypeParameter */: + case 155 /* PropertySignature */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return 536896512 /* ObjectLiteralExcludes */; - case 275 /* CatchClause */: + case 276 /* CatchClause */: return 536879104 /* CatchClauseExcludes */; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: return 536875008 /* BindingPatternExcludes */; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 315 /* PartiallyEmittedExpression */: - case 196 /* ParenthesizedExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: + case 317 /* PartiallyEmittedExpression */: + case 197 /* ParenthesizedExpression */: case 99 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -31464,7 +31980,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 === 168 /* TypeQuery */) { + if (d.type && d.type.kind === 169 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -31515,6 +32031,179 @@ var ts; WideningKind[WideningKind["Normal"] = 0] = "Normal"; WideningKind[WideningKind["GeneratorYield"] = 1] = "GeneratorYield"; })(WideningKind || (WideningKind = {})); + var TypeFacts; + (function (TypeFacts) { + TypeFacts[TypeFacts["None"] = 0] = "None"; + TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; + TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; + TypeFacts[TypeFacts["TypeofEQBigInt"] = 4] = "TypeofEQBigInt"; + TypeFacts[TypeFacts["TypeofEQBoolean"] = 8] = "TypeofEQBoolean"; + TypeFacts[TypeFacts["TypeofEQSymbol"] = 16] = "TypeofEQSymbol"; + TypeFacts[TypeFacts["TypeofEQObject"] = 32] = "TypeofEQObject"; + TypeFacts[TypeFacts["TypeofEQFunction"] = 64] = "TypeofEQFunction"; + TypeFacts[TypeFacts["TypeofEQHostObject"] = 128] = "TypeofEQHostObject"; + TypeFacts[TypeFacts["TypeofNEString"] = 256] = "TypeofNEString"; + TypeFacts[TypeFacts["TypeofNENumber"] = 512] = "TypeofNENumber"; + TypeFacts[TypeFacts["TypeofNEBigInt"] = 1024] = "TypeofNEBigInt"; + TypeFacts[TypeFacts["TypeofNEBoolean"] = 2048] = "TypeofNEBoolean"; + TypeFacts[TypeFacts["TypeofNESymbol"] = 4096] = "TypeofNESymbol"; + TypeFacts[TypeFacts["TypeofNEObject"] = 8192] = "TypeofNEObject"; + TypeFacts[TypeFacts["TypeofNEFunction"] = 16384] = "TypeofNEFunction"; + TypeFacts[TypeFacts["TypeofNEHostObject"] = 32768] = "TypeofNEHostObject"; + TypeFacts[TypeFacts["EQUndefined"] = 65536] = "EQUndefined"; + TypeFacts[TypeFacts["EQNull"] = 131072] = "EQNull"; + TypeFacts[TypeFacts["EQUndefinedOrNull"] = 262144] = "EQUndefinedOrNull"; + TypeFacts[TypeFacts["NEUndefined"] = 524288] = "NEUndefined"; + TypeFacts[TypeFacts["NENull"] = 1048576] = "NENull"; + TypeFacts[TypeFacts["NEUndefinedOrNull"] = 2097152] = "NEUndefinedOrNull"; + TypeFacts[TypeFacts["Truthy"] = 4194304] = "Truthy"; + TypeFacts[TypeFacts["Falsy"] = 8388608] = "Falsy"; + TypeFacts[TypeFacts["All"] = 16777215] = "All"; + // The following members encode facts about particular kinds of types for use in the getTypeFacts function. + // The presence of a particular fact means that the given test is true for some (and possibly all) values + // of that kind of type. + TypeFacts[TypeFacts["BaseStringStrictFacts"] = 3735041] = "BaseStringStrictFacts"; + TypeFacts[TypeFacts["BaseStringFacts"] = 12582401] = "BaseStringFacts"; + TypeFacts[TypeFacts["StringStrictFacts"] = 16317953] = "StringStrictFacts"; + TypeFacts[TypeFacts["StringFacts"] = 16776705] = "StringFacts"; + TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 12123649] = "EmptyStringStrictFacts"; + TypeFacts[TypeFacts["EmptyStringFacts"] = 12582401] = "EmptyStringFacts"; + TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 7929345] = "NonEmptyStringStrictFacts"; + TypeFacts[TypeFacts["NonEmptyStringFacts"] = 16776705] = "NonEmptyStringFacts"; + TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 3734786] = "BaseNumberStrictFacts"; + TypeFacts[TypeFacts["BaseNumberFacts"] = 12582146] = "BaseNumberFacts"; + TypeFacts[TypeFacts["NumberStrictFacts"] = 16317698] = "NumberStrictFacts"; + TypeFacts[TypeFacts["NumberFacts"] = 16776450] = "NumberFacts"; + TypeFacts[TypeFacts["ZeroNumberStrictFacts"] = 12123394] = "ZeroNumberStrictFacts"; + TypeFacts[TypeFacts["ZeroNumberFacts"] = 12582146] = "ZeroNumberFacts"; + TypeFacts[TypeFacts["NonZeroNumberStrictFacts"] = 7929090] = "NonZeroNumberStrictFacts"; + TypeFacts[TypeFacts["NonZeroNumberFacts"] = 16776450] = "NonZeroNumberFacts"; + TypeFacts[TypeFacts["BaseBigIntStrictFacts"] = 3734276] = "BaseBigIntStrictFacts"; + TypeFacts[TypeFacts["BaseBigIntFacts"] = 12581636] = "BaseBigIntFacts"; + TypeFacts[TypeFacts["BigIntStrictFacts"] = 16317188] = "BigIntStrictFacts"; + TypeFacts[TypeFacts["BigIntFacts"] = 16775940] = "BigIntFacts"; + TypeFacts[TypeFacts["ZeroBigIntStrictFacts"] = 12122884] = "ZeroBigIntStrictFacts"; + TypeFacts[TypeFacts["ZeroBigIntFacts"] = 12581636] = "ZeroBigIntFacts"; + TypeFacts[TypeFacts["NonZeroBigIntStrictFacts"] = 7928580] = "NonZeroBigIntStrictFacts"; + TypeFacts[TypeFacts["NonZeroBigIntFacts"] = 16775940] = "NonZeroBigIntFacts"; + TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 3733256] = "BaseBooleanStrictFacts"; + TypeFacts[TypeFacts["BaseBooleanFacts"] = 12580616] = "BaseBooleanFacts"; + TypeFacts[TypeFacts["BooleanStrictFacts"] = 16316168] = "BooleanStrictFacts"; + TypeFacts[TypeFacts["BooleanFacts"] = 16774920] = "BooleanFacts"; + TypeFacts[TypeFacts["FalseStrictFacts"] = 12121864] = "FalseStrictFacts"; + TypeFacts[TypeFacts["FalseFacts"] = 12580616] = "FalseFacts"; + TypeFacts[TypeFacts["TrueStrictFacts"] = 7927560] = "TrueStrictFacts"; + TypeFacts[TypeFacts["TrueFacts"] = 16774920] = "TrueFacts"; + TypeFacts[TypeFacts["SymbolStrictFacts"] = 7925520] = "SymbolStrictFacts"; + TypeFacts[TypeFacts["SymbolFacts"] = 16772880] = "SymbolFacts"; + TypeFacts[TypeFacts["ObjectStrictFacts"] = 7888800] = "ObjectStrictFacts"; + TypeFacts[TypeFacts["ObjectFacts"] = 16736160] = "ObjectFacts"; + TypeFacts[TypeFacts["FunctionStrictFacts"] = 7880640] = "FunctionStrictFacts"; + TypeFacts[TypeFacts["FunctionFacts"] = 16728000] = "FunctionFacts"; + TypeFacts[TypeFacts["UndefinedFacts"] = 9830144] = "UndefinedFacts"; + TypeFacts[TypeFacts["NullFacts"] = 9363232] = "NullFacts"; + TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts"; + TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts"; + })(TypeFacts || (TypeFacts = {})); + var typeofEQFacts = ts.createMapFromTemplate({ + string: 1 /* TypeofEQString */, + number: 2 /* TypeofEQNumber */, + bigint: 4 /* TypeofEQBigInt */, + boolean: 8 /* TypeofEQBoolean */, + symbol: 16 /* TypeofEQSymbol */, + undefined: 65536 /* EQUndefined */, + object: 32 /* TypeofEQObject */, + function: 64 /* TypeofEQFunction */ + }); + var typeofNEFacts = ts.createMapFromTemplate({ + string: 256 /* TypeofNEString */, + number: 512 /* TypeofNENumber */, + bigint: 1024 /* TypeofNEBigInt */, + boolean: 2048 /* TypeofNEBoolean */, + symbol: 4096 /* TypeofNESymbol */, + undefined: 524288 /* NEUndefined */, + object: 8192 /* TypeofNEObject */, + function: 16384 /* TypeofNEFunction */ + }); + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; + TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; + TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); + var CheckMode; + (function (CheckMode) { + CheckMode[CheckMode["Normal"] = 0] = "Normal"; + CheckMode[CheckMode["Contextual"] = 1] = "Contextual"; + CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; + CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive"; + CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; + CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; + })(CheckMode || (CheckMode = {})); + var ContextFlags; + (function (ContextFlags) { + ContextFlags[ContextFlags["None"] = 0] = "None"; + ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; + })(ContextFlags || (ContextFlags = {})); + var AccessFlags; + (function (AccessFlags) { + AccessFlags[AccessFlags["None"] = 0] = "None"; + AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; + AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; + AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; + AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; + })(AccessFlags || (AccessFlags = {})); + var CallbackCheck; + (function (CallbackCheck) { + CallbackCheck[CallbackCheck["None"] = 0] = "None"; + CallbackCheck[CallbackCheck["Bivariant"] = 1] = "Bivariant"; + CallbackCheck[CallbackCheck["Strict"] = 2] = "Strict"; + })(CallbackCheck || (CallbackCheck = {})); + var MappedTypeModifiers; + (function (MappedTypeModifiers) { + MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly"; + MappedTypeModifiers[MappedTypeModifiers["ExcludeReadonly"] = 2] = "ExcludeReadonly"; + MappedTypeModifiers[MappedTypeModifiers["IncludeOptional"] = 4] = "IncludeOptional"; + MappedTypeModifiers[MappedTypeModifiers["ExcludeOptional"] = 8] = "ExcludeOptional"; + })(MappedTypeModifiers || (MappedTypeModifiers = {})); + var ExpandingFlags; + (function (ExpandingFlags) { + ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; + ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; + ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; + ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; + })(ExpandingFlags || (ExpandingFlags = {})); + var MembersOrExportsResolutionKind; + (function (MembersOrExportsResolutionKind) { + MembersOrExportsResolutionKind["resolvedExports"] = "resolvedExports"; + MembersOrExportsResolutionKind["resolvedMembers"] = "resolvedMembers"; + })(MembersOrExportsResolutionKind || (MembersOrExportsResolutionKind = {})); + var UnusedKind; + (function (UnusedKind) { + UnusedKind[UnusedKind["Local"] = 0] = "Local"; + UnusedKind[UnusedKind["Parameter"] = 1] = "Parameter"; + })(UnusedKind || (UnusedKind = {})); + var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); + var DeclarationMeaning; + (function (DeclarationMeaning) { + DeclarationMeaning[DeclarationMeaning["GetAccessor"] = 1] = "GetAccessor"; + DeclarationMeaning[DeclarationMeaning["SetAccessor"] = 2] = "SetAccessor"; + DeclarationMeaning[DeclarationMeaning["PropertyAssignment"] = 4] = "PropertyAssignment"; + DeclarationMeaning[DeclarationMeaning["Method"] = 8] = "Method"; + DeclarationMeaning[DeclarationMeaning["GetOrSetAccessor"] = 3] = "GetOrSetAccessor"; + DeclarationMeaning[DeclarationMeaning["PropertyAssignmentOrMethod"] = 12] = "PropertyAssignmentOrMethod"; + })(DeclarationMeaning || (DeclarationMeaning = {})); + var DeclarationSpaces; + (function (DeclarationSpaces) { + DeclarationSpaces[DeclarationSpaces["None"] = 0] = "None"; + DeclarationSpaces[DeclarationSpaces["ExportValue"] = 1] = "ExportValue"; + DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; + DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; + })(DeclarationSpaces || (DeclarationSpaces = {})); function getNodeId(node) { if (!node.id) { node.id = nextNodeId; @@ -31562,11 +32251,9 @@ var ts; var cancellationToken; var requestedExternalEmitHelpers; var externalHelpersModule; - // tslint:disable variable-name var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); - // tslint:enable variable-name var typeCount = 0; var symbolCount = 0; var enumCount = 0; @@ -31840,7 +32527,7 @@ var ts; // Ensure file is type checked checkSourceFile(file); ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); - diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.get(file.fileName)); + diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); if (!file.isDeclarationFile && (!unusedIsError(0 /* Local */) || !unusedIsError(1 /* Parameter */))) { addUnusedDiagnostics(); } @@ -31852,7 +32539,7 @@ var ts; function addUnusedDiagnostics() { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { if (!ts.containsParseError(containingNode) && !unusedIsError(kind)) { - (diagnostics || (diagnostics = [])).push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); } @@ -31881,6 +32568,7 @@ var ts; var literalTypes = ts.createMap(); var indexedAccessTypes = ts.createMap(); var substitutionTypes = ts.createMap(); + var structuralTags = ts.createMap(); var evolvingArrayTypes = []; var undefinedProperties = ts.createMap(); var unknownSymbol = createSymbol(4 /* Property */, "unknown"); @@ -32064,102 +32752,7 @@ var ts; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); - // Suggestion diagnostics must have a file. Keyed by source file name. - var suggestionDiagnostics = ts.createMultiMap(); - var TypeFacts; - (function (TypeFacts) { - TypeFacts[TypeFacts["None"] = 0] = "None"; - TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; - TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; - TypeFacts[TypeFacts["TypeofEQBigInt"] = 4] = "TypeofEQBigInt"; - TypeFacts[TypeFacts["TypeofEQBoolean"] = 8] = "TypeofEQBoolean"; - TypeFacts[TypeFacts["TypeofEQSymbol"] = 16] = "TypeofEQSymbol"; - TypeFacts[TypeFacts["TypeofEQObject"] = 32] = "TypeofEQObject"; - TypeFacts[TypeFacts["TypeofEQFunction"] = 64] = "TypeofEQFunction"; - TypeFacts[TypeFacts["TypeofEQHostObject"] = 128] = "TypeofEQHostObject"; - TypeFacts[TypeFacts["TypeofNEString"] = 256] = "TypeofNEString"; - TypeFacts[TypeFacts["TypeofNENumber"] = 512] = "TypeofNENumber"; - TypeFacts[TypeFacts["TypeofNEBigInt"] = 1024] = "TypeofNEBigInt"; - TypeFacts[TypeFacts["TypeofNEBoolean"] = 2048] = "TypeofNEBoolean"; - TypeFacts[TypeFacts["TypeofNESymbol"] = 4096] = "TypeofNESymbol"; - TypeFacts[TypeFacts["TypeofNEObject"] = 8192] = "TypeofNEObject"; - TypeFacts[TypeFacts["TypeofNEFunction"] = 16384] = "TypeofNEFunction"; - TypeFacts[TypeFacts["TypeofNEHostObject"] = 32768] = "TypeofNEHostObject"; - TypeFacts[TypeFacts["EQUndefined"] = 65536] = "EQUndefined"; - TypeFacts[TypeFacts["EQNull"] = 131072] = "EQNull"; - TypeFacts[TypeFacts["EQUndefinedOrNull"] = 262144] = "EQUndefinedOrNull"; - TypeFacts[TypeFacts["NEUndefined"] = 524288] = "NEUndefined"; - TypeFacts[TypeFacts["NENull"] = 1048576] = "NENull"; - TypeFacts[TypeFacts["NEUndefinedOrNull"] = 2097152] = "NEUndefinedOrNull"; - TypeFacts[TypeFacts["Truthy"] = 4194304] = "Truthy"; - TypeFacts[TypeFacts["Falsy"] = 8388608] = "Falsy"; - TypeFacts[TypeFacts["All"] = 16777215] = "All"; - // The following members encode facts about particular kinds of types for use in the getTypeFacts function. - // The presence of a particular fact means that the given test is true for some (and possibly all) values - // of that kind of type. - TypeFacts[TypeFacts["BaseStringStrictFacts"] = 3735041] = "BaseStringStrictFacts"; - TypeFacts[TypeFacts["BaseStringFacts"] = 12582401] = "BaseStringFacts"; - TypeFacts[TypeFacts["StringStrictFacts"] = 16317953] = "StringStrictFacts"; - TypeFacts[TypeFacts["StringFacts"] = 16776705] = "StringFacts"; - TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 12123649] = "EmptyStringStrictFacts"; - TypeFacts[TypeFacts["EmptyStringFacts"] = 12582401] = "EmptyStringFacts"; - TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 7929345] = "NonEmptyStringStrictFacts"; - TypeFacts[TypeFacts["NonEmptyStringFacts"] = 16776705] = "NonEmptyStringFacts"; - TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 3734786] = "BaseNumberStrictFacts"; - TypeFacts[TypeFacts["BaseNumberFacts"] = 12582146] = "BaseNumberFacts"; - TypeFacts[TypeFacts["NumberStrictFacts"] = 16317698] = "NumberStrictFacts"; - TypeFacts[TypeFacts["NumberFacts"] = 16776450] = "NumberFacts"; - TypeFacts[TypeFacts["ZeroNumberStrictFacts"] = 12123394] = "ZeroNumberStrictFacts"; - TypeFacts[TypeFacts["ZeroNumberFacts"] = 12582146] = "ZeroNumberFacts"; - TypeFacts[TypeFacts["NonZeroNumberStrictFacts"] = 7929090] = "NonZeroNumberStrictFacts"; - TypeFacts[TypeFacts["NonZeroNumberFacts"] = 16776450] = "NonZeroNumberFacts"; - TypeFacts[TypeFacts["BaseBigIntStrictFacts"] = 3734276] = "BaseBigIntStrictFacts"; - TypeFacts[TypeFacts["BaseBigIntFacts"] = 12581636] = "BaseBigIntFacts"; - TypeFacts[TypeFacts["BigIntStrictFacts"] = 16317188] = "BigIntStrictFacts"; - TypeFacts[TypeFacts["BigIntFacts"] = 16775940] = "BigIntFacts"; - TypeFacts[TypeFacts["ZeroBigIntStrictFacts"] = 12122884] = "ZeroBigIntStrictFacts"; - TypeFacts[TypeFacts["ZeroBigIntFacts"] = 12581636] = "ZeroBigIntFacts"; - TypeFacts[TypeFacts["NonZeroBigIntStrictFacts"] = 7928580] = "NonZeroBigIntStrictFacts"; - TypeFacts[TypeFacts["NonZeroBigIntFacts"] = 16775940] = "NonZeroBigIntFacts"; - TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 3733256] = "BaseBooleanStrictFacts"; - TypeFacts[TypeFacts["BaseBooleanFacts"] = 12580616] = "BaseBooleanFacts"; - TypeFacts[TypeFacts["BooleanStrictFacts"] = 16316168] = "BooleanStrictFacts"; - TypeFacts[TypeFacts["BooleanFacts"] = 16774920] = "BooleanFacts"; - TypeFacts[TypeFacts["FalseStrictFacts"] = 12121864] = "FalseStrictFacts"; - TypeFacts[TypeFacts["FalseFacts"] = 12580616] = "FalseFacts"; - TypeFacts[TypeFacts["TrueStrictFacts"] = 7927560] = "TrueStrictFacts"; - TypeFacts[TypeFacts["TrueFacts"] = 16774920] = "TrueFacts"; - TypeFacts[TypeFacts["SymbolStrictFacts"] = 7925520] = "SymbolStrictFacts"; - TypeFacts[TypeFacts["SymbolFacts"] = 16772880] = "SymbolFacts"; - TypeFacts[TypeFacts["ObjectStrictFacts"] = 7888800] = "ObjectStrictFacts"; - TypeFacts[TypeFacts["ObjectFacts"] = 16736160] = "ObjectFacts"; - TypeFacts[TypeFacts["FunctionStrictFacts"] = 7880640] = "FunctionStrictFacts"; - TypeFacts[TypeFacts["FunctionFacts"] = 16728000] = "FunctionFacts"; - TypeFacts[TypeFacts["UndefinedFacts"] = 9830144] = "UndefinedFacts"; - TypeFacts[TypeFacts["NullFacts"] = 9363232] = "NullFacts"; - TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts"; - TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts"; - })(TypeFacts || (TypeFacts = {})); - var typeofEQFacts = ts.createMapFromTemplate({ - string: 1 /* TypeofEQString */, - number: 2 /* TypeofEQNumber */, - bigint: 4 /* TypeofEQBigInt */, - boolean: 8 /* TypeofEQBoolean */, - symbol: 16 /* TypeofEQSymbol */, - undefined: 65536 /* EQUndefined */, - object: 32 /* TypeofEQObject */, - function: 64 /* TypeofEQFunction */ - }); - var typeofNEFacts = ts.createMapFromTemplate({ - string: 256 /* TypeofNEString */, - number: 512 /* TypeofNENumber */, - bigint: 1024 /* TypeofNEBigInt */, - boolean: 2048 /* TypeofNEBoolean */, - symbol: 4096 /* TypeofNESymbol */, - undefined: 524288 /* NEUndefined */, - object: 8192 /* TypeofNEObject */, - function: 16384 /* TypeofNEFunction */ - }); + var suggestionDiagnostics = ts.createDiagnosticCollection(); var typeofTypesByName = ts.createMapFromTemplate({ string: stringType, number: numberType, @@ -32177,71 +32770,8 @@ var ts; var comparableRelation = ts.createMap(); var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); - var TypeSystemPropertyName; - (function (TypeSystemPropertyName) { - TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; - TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; - TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; - TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; - TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; - })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); - var CheckMode; - (function (CheckMode) { - CheckMode[CheckMode["Normal"] = 0] = "Normal"; - CheckMode[CheckMode["Contextual"] = 1] = "Contextual"; - CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; - CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive"; - CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; - CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; - })(CheckMode || (CheckMode = {})); - var ContextFlags; - (function (ContextFlags) { - ContextFlags[ContextFlags["None"] = 0] = "None"; - ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; - })(ContextFlags || (ContextFlags = {})); - var AccessFlags; - (function (AccessFlags) { - AccessFlags[AccessFlags["None"] = 0] = "None"; - AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; - AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; - AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; - AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; - })(AccessFlags || (AccessFlags = {})); - var CallbackCheck; - (function (CallbackCheck) { - CallbackCheck[CallbackCheck["None"] = 0] = "None"; - CallbackCheck[CallbackCheck["Bivariant"] = 1] = "Bivariant"; - CallbackCheck[CallbackCheck["Strict"] = 2] = "Strict"; - })(CallbackCheck || (CallbackCheck = {})); - var MappedTypeModifiers; - (function (MappedTypeModifiers) { - MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly"; - MappedTypeModifiers[MappedTypeModifiers["ExcludeReadonly"] = 2] = "ExcludeReadonly"; - MappedTypeModifiers[MappedTypeModifiers["IncludeOptional"] = 4] = "IncludeOptional"; - MappedTypeModifiers[MappedTypeModifiers["ExcludeOptional"] = 8] = "ExcludeOptional"; - })(MappedTypeModifiers || (MappedTypeModifiers = {})); - var ExpandingFlags; - (function (ExpandingFlags) { - ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; - ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; - ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; - ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; - })(ExpandingFlags || (ExpandingFlags = {})); - var MembersOrExportsResolutionKind; - (function (MembersOrExportsResolutionKind) { - MembersOrExportsResolutionKind["resolvedExports"] = "resolvedExports"; - MembersOrExportsResolutionKind["resolvedMembers"] = "resolvedMembers"; - })(MembersOrExportsResolutionKind || (MembersOrExportsResolutionKind = {})); - var UnusedKind; - (function (UnusedKind) { - UnusedKind[UnusedKind["Local"] = 0] = "Local"; - UnusedKind[UnusedKind["Parameter"] = 1] = "Parameter"; - })(UnusedKind || (UnusedKind = {})); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); - var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; function getJsxNamespace(location) { @@ -32253,7 +32783,7 @@ var ts; } var jsxPragma = file.pragmas.get("jsx"); if (jsxPragma) { - var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; // TODO: GH#18217 + var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; file.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion); if (file.localJsxFactory) { return file.localJsxNamespace = getFirstIdentifier(file.localJsxFactory).escapedText; @@ -32306,11 +32836,11 @@ var ts; diagnostics.add(diagnostic); } else { - suggestionDiagnostics.add(diagnostic.file.fileName, __assign({}, diagnostic, { category: ts.DiagnosticCategory.Suggestion })); + suggestionDiagnostics.add(__assign(__assign({}, diagnostic), { category: ts.DiagnosticCategory.Suggestion })); } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { - addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); + addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { var diagnostic = error(location, message, arg0, arg1, arg2, arg3); @@ -32332,35 +32862,35 @@ var ts; function getExcludedSymbolFlags(flags) { var result = 0; if (flags & 2 /* BlockScopedVariable */) - result |= 67220415 /* BlockScopedVariableExcludes */; + result |= 111551 /* BlockScopedVariableExcludes */; if (flags & 1 /* FunctionScopedVariable */) - result |= 67220414 /* FunctionScopedVariableExcludes */; + result |= 111550 /* FunctionScopedVariableExcludes */; if (flags & 4 /* Property */) result |= 0 /* PropertyExcludes */; if (flags & 8 /* EnumMember */) - result |= 68008959 /* EnumMemberExcludes */; + result |= 900095 /* EnumMemberExcludes */; if (flags & 16 /* Function */) - result |= 67219887 /* FunctionExcludes */; + result |= 110991 /* FunctionExcludes */; if (flags & 32 /* Class */) - result |= 68008383 /* ClassExcludes */; + result |= 899503 /* ClassExcludes */; if (flags & 64 /* Interface */) - result |= 67897736 /* InterfaceExcludes */; + result |= 788872 /* InterfaceExcludes */; if (flags & 256 /* RegularEnum */) - result |= 68008191 /* RegularEnumExcludes */; + result |= 899327 /* RegularEnumExcludes */; if (flags & 128 /* ConstEnum */) - result |= 68008831 /* ConstEnumExcludes */; + result |= 899967 /* ConstEnumExcludes */; if (flags & 512 /* ValueModule */) result |= 110735 /* ValueModuleExcludes */; if (flags & 8192 /* Method */) - result |= 67212223 /* MethodExcludes */; + result |= 103359 /* MethodExcludes */; if (flags & 32768 /* GetAccessor */) - result |= 67154879 /* GetAccessorExcludes */; + result |= 46015 /* GetAccessorExcludes */; if (flags & 65536 /* SetAccessor */) - result |= 67187647 /* SetAccessorExcludes */; + result |= 78783 /* SetAccessorExcludes */; if (flags & 262144 /* TypeParameter */) - result |= 67635688 /* TypeParameterExcludes */; + result |= 526824 /* TypeParameterExcludes */; if (flags & 524288 /* TypeAlias */) - result |= 67897832 /* TypeAliasExcludes */; + result |= 788968 /* TypeAliasExcludes */; if (flags & 2097152 /* Alias */) result |= 2097152 /* AliasExcludes */; return result; @@ -32583,7 +33113,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 286 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -32613,8 +33143,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 67220415 /* Value */); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 67220415 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* Value */); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -32641,17 +33171,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 187 /* BindingElement */) { + if (declaration.kind === 188 /* 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, 187 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 188 /* 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, 238 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 239 /* VariableDeclaration */), usage); } - else if (declaration.kind === 238 /* VariableDeclaration */) { + else if (declaration.kind === 239 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -32674,12 +33204,12 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 258 /* ExportSpecifier */ || (usage.parent.kind === 255 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 259 /* ExportSpecifier */ || (usage.parent.kind === 256 /* 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 === 255 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 256 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -32687,9 +33217,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 220 /* VariableStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 221 /* VariableStatement */: + case 227 /* ForStatement */: + case 229 /* 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, container)) { @@ -32710,16 +33240,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 155 /* PropertyDeclaration */ && + current.parent.kind === 156 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 157 /* MethodDeclaration */) { + if (declaration.kind === 158 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 156 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -32740,14 +33270,14 @@ var ts; return "quit"; } switch (node.kind) { - case 198 /* ArrowFunction */: - case 155 /* PropertyDeclaration */: + case 199 /* ArrowFunction */: + case 156 /* PropertyDeclaration */: return true; - case 219 /* Block */: + case 220 /* Block */: switch (node.parent.kind) { - case 159 /* GetAccessor */: - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 158 /* MethodDeclaration */: + case 161 /* SetAccessor */: return true; default: return false; @@ -32793,12 +33323,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 & 67897832 /* Type */ && lastLocation.kind !== 297 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 299 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 152 /* Parameter */ || - lastLocation.kind === 151 /* TypeParameter */ + lastLocation.kind === 153 /* Parameter */ || + lastLocation.kind === 152 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -32815,13 +33345,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 === 152 /* Parameter */ || + lastLocation.kind === 153 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 176 /* ConditionalType */) { + else if (location.kind === 177 /* 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; @@ -32836,14 +33366,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 286 /* SourceFile */ || ts.isAmbientModule(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 */)) { @@ -32867,7 +33397,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 258 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 259 /* ExportSpecifier */)) { break; } } @@ -32881,12 +33411,12 @@ var ts; } } break; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 155 /* PropertyDeclaration */: + case 156 /* 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 @@ -32896,20 +33426,20 @@ var ts; if (!ts.hasModifier(location, 32 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 67220415 /* Value */)) { + if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) { // Remember the property node, it will be used later to report appropriate error propertyWithInvalidInitializer = location; } } } break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* 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! - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 67897832 /* Type */)) { + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -32924,7 +33454,7 @@ var ts; } break loop; } - if (location.kind === 210 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 211 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -32932,11 +33462,11 @@ var ts; } } break; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. if (lastLocation === location.expression && location.parent.token === 87 /* ExtendsKeyword */) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 67897832 /* Type */))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -32952,34 +33482,34 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 242 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 243 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67897832 /* Type */)) { + 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); return undefined; } } break; - case 198 /* ArrowFunction */: + case 199 /* 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 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -32992,7 +33522,7 @@ var ts; } } break; - case 153 /* Decorator */: + case 154 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -33001,7 +33531,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 === 152 /* Parameter */) { + if (location.parent && location.parent.kind === 153 /* Parameter */) { location = location.parent; } // @@ -33016,24 +33546,25 @@ 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 === 241 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 242 /* ClassDeclaration */)) { location = location.parent; } break; - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; - case 152 /* Parameter */: + case 153 /* Parameter */: if (lastLocation && lastLocation === location.initializer) { associatedDeclarationForContainingInitializer = location; } break; - case 187 /* BindingElement */: + case 188 /* BindingElement */: if (lastLocation && lastLocation === location.initializer) { var root = ts.getRootDeclaration(location); - if (root.kind === 152 /* Parameter */) { + if (root.kind === 153 /* Parameter */) { associatedDeclarationForContainingInitializer = location; } } @@ -33053,7 +33584,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 285 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 286 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -33119,21 +33650,21 @@ var ts; // we want to check for block-scoped if (errorLocation && (meaning & 2 /* BlockScopedVariable */ || - ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 67220415 /* Value */) === 67220415 /* Value */))) { + ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 67220415 /* Value */) === 67220415 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } // If we're in a parameter initializer, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 67220415 /* Value */) === 67220415 /* Value */) { + if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializer); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself @@ -33149,10 +33680,10 @@ var ts; return result; } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 198 /* ArrowFunction */ && location.kind !== 197 /* FunctionExpression */) { + if (location.kind !== 199 /* ArrowFunction */ && location.kind !== 198 /* 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 === 155 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 156 /* PropertyDeclaration */ && !ts.hasModifier(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; @@ -33165,12 +33696,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: // For `namespace N { N; }` + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 246 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -33182,7 +33713,7 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 151 /* TypeParameter */) { + if (decl.kind === 152 /* 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 @@ -33238,9 +33769,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -33250,9 +33781,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 67220415 /* Value */ : 0); + var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* Value */ : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -33271,8 +33802,8 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (67897832 /* Type */ & ~1920 /* Namespace */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~67897832 /* Type */ & 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1920 /* Namespace */)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here, ts.unescapeLeadingUnderscores(name)); return true; @@ -33281,12 +33812,12 @@ var ts; return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 /* Value */ & ~1024 /* NamespaceModule */)) { + if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) { if (name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never") { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 /* Type */ & ~67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { var message = isES2015OrLaterConstructorName(name) ? ts.Diagnostics._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 @@ -33310,15 +33841,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 /* Value */ & ~1024 /* NamespaceModule */ & ~67897832 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */ & ~788968 /* Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (67897832 /* Type */ & ~1024 /* NamespaceModule */ & ~67220415 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~67897832 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + else if (meaning & (788968 /* Type */ & ~1024 /* NamespaceModule */ & ~111551 /* Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~788968 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -33328,10 +33859,14 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { 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 === 244 /* EnumDeclaration */) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 245 /* EnumDeclaration */); }); if (declaration === undefined) - return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); + return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); @@ -33364,13 +33899,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return node; - case 251 /* ImportClause */: + case 252 /* ImportClause */: return node.parent; - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return node.parent.parent; - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -33380,7 +33915,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 261 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -33481,7 +34016,7 @@ var ts; if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (67897832 /* Type */ | 1920 /* Namespace */)) { + if (valueSymbol.flags & (788968 /* Type */ | 1920 /* Namespace */)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -33571,7 +34106,7 @@ var ts; if (ts.isClassExpression(expression)) { return checkExpression(expression).symbol; } - var aliasLike = resolveEntityName(expression, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); + var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } @@ -33581,20 +34116,20 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 258 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 255 /* ExportAssignment */: - case 205 /* BinaryExpression */: + case 259 /* ExportSpecifier */: + return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); + case 256 /* ExportAssignment */: + case 206 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -33605,7 +34140,7 @@ var ts; * OR Is a JSContainer which may merge an alias with a local declaration */ function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */; } + if (excludes === void 0) { excludes = 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */; } if (!symbol) return false; return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* Assignment */); @@ -33639,7 +34174,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 67220415 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); + ((target.flags & 111551 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -33655,17 +34190,15 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 255 /* ExportAssignment */) { - // export default - checkExpressionCached(node.expression); - } - else if (node.kind === 258 /* ExportSpecifier */) { - // export { } or export { as foo } - checkExpressionCached(node.propertyName || node.name); - } - else if (ts.isInternalModuleImportEqualsDeclaration(node)) { - // import foo = - checkExpressionCached(node.moduleReference); + // We defer checking of the reference of an `import =` until the import itself is referenced, + // This way a chain of imports can be elided if ultimately the final input is only used in a type + // position. + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + var target = resolveSymbol(symbol); + if (target === unknownSymbol || target.flags & 111551 /* Value */) { + // import foo = + checkExpressionCached(node.moduleReference); + } } } } @@ -33681,14 +34214,14 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 73 /* Identifier */ || entityName.parent.kind === 149 /* QualifiedName */) { + if (entityName.kind === 73 /* Identifier */ || entityName.parent.kind === 150 /* 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 === 249 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 250 /* ImportEqualsDeclaration */); + return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { @@ -33701,7 +34234,7 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 67220415 /* Value */ : 0); + var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; if (name.kind === 73 /* Identifier */) { var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name)); @@ -33711,9 +34244,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 149 /* QualifiedName */ || name.kind === 190 /* PropertyAccessExpression */) { - var left = name.kind === 149 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 149 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 150 /* QualifiedName */ || name.kind === 191 /* PropertyAccessExpression */) { + var left = name.kind === 150 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 150 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -33804,6 +34337,20 @@ var ts; undefined; return initializer || decl; } + /** + * Get the real symbol of a declaration with an expando initializer. + * + * Normally, declarations have an associated symbol, but when a declaration has an expando + * initializer, the expando's symbol is the one that has all the members merged into it. + */ + function getExpandoSymbol(symbol) { + var decl = symbol.valueDeclaration; + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */) { + return undefined; + } + var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); + return init && getSymbolOfNode(init) || undefined; + } function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0); } @@ -33815,9 +34362,6 @@ var ts; } function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReference === undefined) { - return; - } if (ts.startsWith(moduleReference, "@types/")) { var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1; var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/"); @@ -33946,7 +34490,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 285 /* SourceFile */)) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 286 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -34202,13 +34746,13 @@ var ts; return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? symbol.exportSymbol : symbol); } function symbolIsValue(symbol) { - return !!(symbol.flags & 67220415 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 67220415 /* Value */); + return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 158 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 159 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -34294,12 +34838,12 @@ var ts; } } switch (location.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -34310,7 +34854,7 @@ var ts; } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 67220415 /* Value */ ? 67220415 /* Value */ : 1920 /* Namespace */; + return rightMeaning === 111551 /* Value */ ? 111551 /* Value */ : 1920 /* Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = ts.createMap(); } @@ -34363,7 +34907,7 @@ var ts; && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) // 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, 258 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 259 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -34399,7 +34943,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, 258 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 259 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -34414,10 +34958,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: continue; default: return false; @@ -34428,11 +34972,11 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67897832 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 788968 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); return access.accessibility === 0 /* Accessible */; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67220415 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 111551 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false); return access.accessibility === 0 /* Accessible */; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible) { @@ -34475,7 +35019,7 @@ var ts; // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. var firstDecl = ts.first(symbol.declarations); - if (!ts.length(containers) && meaning & 67220415 /* Value */ && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { + if (!ts.length(containers) && meaning & 111551 /* Value */ && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { if (firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent) && firstDecl === firstDecl.parent.initializer) { containers = [getSymbolOfNode(firstDecl.parent)]; } @@ -34534,10 +35078,10 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 286 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 286 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -34584,21 +35128,21 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 168 /* TypeQuery */ || + if (entityName.parent.kind === 169 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 150 /* ComputedPropertyName */) { + entityName.parent.kind === 151 /* ComputedPropertyName */) { // Typeof value - meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; + meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 149 /* QualifiedName */ || entityName.kind === 190 /* PropertyAccessExpression */ || - entityName.parent.kind === 249 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 150 /* QualifiedName */ || entityName.kind === 191 /* PropertyAccessExpression */ || + entityName.parent.kind === 250 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; } else { // Type Reference or TypeAlias entity = Identifier - meaning = 67897832 /* Type */; + meaning = 788968 /* Type */; } var firstIdentifier = getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); @@ -34640,15 +35184,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 167 /* ConstructorType */ : 166 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 168 /* ConstructorType */ : 167 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 162 /* ConstructSignature */ : 161 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 163 /* ConstructSignature */ : 162 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } @@ -34671,14 +35215,17 @@ var ts; return result; } function getTypeNamesForErrorDisplay(left, right) { - var leftStr = typeToString(left); - var rightStr = typeToString(right); + var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left); + var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right); if (leftStr === rightStr) { leftStr = typeToString(left, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); rightStr = typeToString(right, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); } return [leftStr, rightStr]; } + function symbolValueDeclarationIsContextSensitive(symbol) { + return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0 /* None */; } return flags & 9469291 /* NodeBuilderFlagsMask */; @@ -34770,14 +35317,14 @@ var ts; } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 67897832 /* Type */); + var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */); var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), /*typeArguments*/ undefined)); return enumLiteralName; } if (type.flags & 1056 /* EnumLike */) { - return symbolToTypeNode(type.symbol, context, 67897832 /* Type */); + return symbolToTypeNode(type.symbol, context, 788968 /* Type */); } if (type.flags & 128 /* StringLiteral */) { context.approximateLength += (type.value.length + 2); @@ -34800,7 +35347,7 @@ var ts; if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 67220415 /* Value */); + return symbolToTypeNode(type.symbol, context, 111551 /* Value */); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); @@ -34863,14 +35410,14 @@ var ts; } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. return type.symbol - ? symbolToTypeNode(type.symbol, context, 67897832 /* Type */) + ? symbolToTypeNode(type.symbol, context, 788968 /* Type */) : ts.createTypeReferenceNode(ts.createIdentifier("?"), /*typeArguments*/ undefined); } if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 67897832 /* Type */, typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); } if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; @@ -34879,7 +35426,7 @@ var ts; } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 174 /* UnionType */ : 175 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 175 /* UnionType */ : 176 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -34920,6 +35467,36 @@ var ts; if (type.flags & 33554432 /* Substitution */) { return typeToTypeNodeHelper(type.typeVariable, context); } + if (type.flags & 134217728 /* StructuralTag */) { + var innerType = type.type; + if (innerType.flags & 2097152 /* Intersection */) { + // If some inner type of the intersection has an alias when hoisted out, (attempt to) hoist out all of the aliasable things + if (ts.some(innerType.types, function (t) { return !!getStructuralTagForType(t).aliasSymbol; })) { + var aliasingTypes = []; + var nonAliasingTypes = []; + for (var _i = 0, _a = innerType.types; _i < _a.length; _i++) { + var t = _a[_i]; + var taggedVersion = getStructuralTagForType(t); + if (taggedVersion.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(taggedVersion.aliasSymbol, context.enclosingDeclaration))) { + aliasingTypes.push(taggedVersion); + } + else { + nonAliasingTypes.push(t); + } + } + if (ts.length(aliasingTypes)) { + if (ts.length(nonAliasingTypes)) { + aliasingTypes.push(getStructuralTagForType(getIntersectionType(nonAliasingTypes))); + } + // Do note: this can make an intersection become nested within another intersection - this _is_ handled correctly + // during emit, so is fine (and honestly is more clear, since it groups all the tags together) + return ts.createUnionOrIntersectionTypeNode(176 /* IntersectionType */, ts.map(aliasingTypes, function (t) { return typeToTypeNodeHelper(t, context); })); + } + } + } + context.approximateLength += 4; + return ts.createTypeOperatorNode(148 /* TagKeyword */, typeToTypeNodeHelper(innerType, context)); + } return ts.Debug.fail("Should be unreachable."); function createMappedTypeNodeFromType(type) { ts.Debug.assert(!!(type.flags & 524288 /* Object */)); @@ -34949,21 +35526,21 @@ var ts; id = (isConstructorObject ? "+" : "") + getSymbolId(symbol); if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. - var isInstanceType = type === getInferredClassType(symbol) ? 67897832 /* Type */ : 67220415 /* Value */; + var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 /* Type */ : 111551 /* Value */; 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 === 210 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 211 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { - return symbolToTypeNode(symbol, context, 67220415 /* Value */); + return symbolToTypeNode(symbol, context, 111551 /* Value */); } else if (context.visitedTypes && context.visitedTypes.has(typeId)) { // If type is an anonymous type literal in a type alias declaration, use type alias name var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags - return symbolToTypeNode(typeAlias, context, 67897832 /* Type */); + return symbolToTypeNode(typeAlias, context, 788968 /* Type */); } else { return createElidedInformationPlaceholder(context); @@ -35000,12 +35577,12 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 285 /* SourceFile */ || declaration.parent.kind === 246 /* ModuleBlock */; + return declaration.parent.kind === 286 /* SourceFile */ || declaration.parent.kind === 247 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedTypes && context.visitedTypes.has(typeId))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // TODO: GH#18217 // And the build is going to succeed without visibility error or there is no structural fallback allowed + (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } @@ -35021,12 +35598,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 166 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 167 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 167 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 168 /* ConstructorType */, context); return signatureNode; } } @@ -35096,7 +35673,7 @@ var ts; var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_2 = context.flags; context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var ref = symbolToTypeNode(parent, context, 67897832 /* Type */, typeArgumentSlice); + var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice); context.flags = flags_2; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -35109,7 +35686,7 @@ var ts; } var flags = context.flags; context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var finalRef = symbolToTypeNode(type.symbol, context, 67897832 /* Type */, typeArgumentNodes); + var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* Type */, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -35161,11 +35738,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 161 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 162 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 162 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 163 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; @@ -35226,7 +35803,7 @@ var ts; trackComputedName(decl.name, saveEnclosingDeclaration, context); } } - var propertyName = symbolToName(propertySymbol, context, 67220415 /* Value */, /*expectsIdentifier*/ true); + var propertyName = symbolToName(propertySymbol, context, 111551 /* Value */, /*expectsIdentifier*/ true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(56 /* QuestionToken */) : undefined; @@ -35234,7 +35811,7 @@ var ts; var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 156 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 157 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; if (propertySymbol.valueDeclaration) { @@ -35330,7 +35907,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 158 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 159 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -35374,9 +35951,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 152 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 153 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 306 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 308 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -35386,13 +35963,12 @@ var ts; var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(25 /* DotDotDotToken */) : undefined; - var name = parameterDeclaration - ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 73 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 149 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : - cloneBindingName(parameterDeclaration.name) : - ts.symbolName(parameterSymbol) - : ts.symbolName(parameterSymbol); + var name = parameterDeclaration ? parameterDeclaration.name ? + parameterDeclaration.name.kind === 73 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 150 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + cloneBindingName(parameterDeclaration.name) : + ts.symbolName(parameterSymbol) : + ts.symbolName(parameterSymbol); var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */; var questionToken = isOptional ? ts.createToken(56 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( @@ -35408,7 +35984,7 @@ var ts; } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 187 /* BindingElement */) { + if (clone.kind === 188 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); @@ -35420,9 +35996,9 @@ var ts; return; // get symbol of the first identifier of the entityName var firstIdentifier = getFirstIdentifier(node.expression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 67220415 /* Value */); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { @@ -35539,7 +36115,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 285 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 286 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -35575,7 +36151,7 @@ var ts; // using the `baseUrl` compiler option (which we would otherwise never use in declaration emit) and a non-relative // specifier preference var moduleResolverHost = context.tracker.moduleResolverHost; - var specifierCompilerOptions = isBundle_1 ? __assign({}, compilerOptions, { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; + var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, host.getSourceFiles(), { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative" }, host.redirectTargetsMap)); links.specifierCache = links.specifierCache || ts.createMap(); links.specifierCache.set(contextFile.path, specifier); @@ -35584,7 +36160,7 @@ var ts; } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - var isTypeOf = meaning === 67220415 /* Value */; + var isTypeOf = meaning === 111551 /* Value */; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; @@ -35663,7 +36239,7 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context) { - return !!resolveName(context.enclosingDeclaration, escapedName, 67897832 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + return !!resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); } function typeParameterToName(type, context) { if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { @@ -35672,7 +36248,7 @@ var ts; return cached; } } - var result = symbolToName(type.symbol, context, 67897832 /* Type */, /*expectsIdentifier*/ true); + var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = 0; @@ -35718,9 +36294,6 @@ var ts; function createExpressionFromSymbolChain(chain, index) { var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; - if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { - return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); - } if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; } @@ -35729,6 +36302,9 @@ var ts; context.flags ^= 16777216 /* InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); + if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); + } var canUsePropertyAccess = ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); @@ -35806,8 +36382,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 178 /* ParenthesizedType */; }); - if (node.kind === 243 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 179 /* ParenthesizedType */; }); + if (node.kind === 244 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -35815,11 +36391,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 246 /* ModuleBlock */ && + node.parent.kind === 247 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 286 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -35857,9 +36433,9 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - var name_2 = ts.getNameOfDeclaration(declaration); - if (name_2) { + var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; }); // Try using a declaration with a name, first + var name_2 = declaration && ts.getNameOfDeclaration(declaration); + if (declaration && name_2) { if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } @@ -35872,17 +36448,20 @@ var ts; } return ts.declarationNameToString(name_2); } - if (declaration.parent && declaration.parent.kind === 238 /* VariableDeclaration */) { + if (!declaration) { + declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway + } + if (declaration.parent && declaration.parent.kind === 239 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 211 /* ClassExpression */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 210 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 211 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -35899,27 +36478,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 307 /* 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 187 /* BindingElement */: + case 188 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 238 /* VariableDeclaration */: + case 239 /* 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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 240 /* FunctionDeclaration */: - case 244 /* EnumDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 246 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 241 /* FunctionDeclaration */: + case 245 /* EnumDeclaration */: + case 250 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -35927,53 +36507,54 @@ 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 !== 249 /* ImportEqualsDeclaration */ && parent.kind !== 285 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 250 /* ImportEqualsDeclaration */ && parent.kind !== 286 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.hasModifier(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 158 /* Constructor */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 152 /* Parameter */: - case 246 /* ModuleBlock */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 165 /* TypeReference */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 178 /* ParenthesizedType */: + case 159 /* Constructor */: + case 163 /* ConstructSignature */: + case 162 /* CallSignature */: + case 164 /* IndexSignature */: + case 153 /* Parameter */: + case 247 /* ModuleBlock */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 170 /* TypeLiteral */: + case 166 /* TypeReference */: + case 171 /* ArrayType */: + case 172 /* TupleType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: + case 179 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: + case 252 /* ImportClause */: + case 253 /* NamespaceImport */: + case 255 /* ImportSpecifier */: return false; // Type parameters are always visible - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: // Source file and namespace export are always visible - case 285 /* SourceFile */: - case 248 /* NamespaceExportDeclaration */: + // falls through + case 286 /* SourceFile */: + case 249 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return false; default: return false; @@ -35982,11 +36563,11 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 255 /* ExportAssignment */) { - exportSymbol = resolveName(node, node.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); + if (node.parent && node.parent.kind === 256 /* ExportAssignment */) { + exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 258 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + else if (node.parent.kind === 259 /* ExportSpecifier */) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; if (exportSymbol) { @@ -36007,7 +36588,7 @@ var ts; // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); if (importSymbol) { buildVisibleNodeList(importSymbol.declarations); } @@ -36071,8 +36652,10 @@ var ts; } return ts.Debug.assertNever(propertyName); } - // Pop an entry from the type resolution stack and return its associated result value. The result value will - // be true if no circularities were detected, or false if a circularity was found. + /** + * Pop an entry from the type resolution stack and return its associated result value. The result value will + * be true if no circularities were detected, or false if a circularity was found. + */ function popTypeResolution() { resolutionTargets.pop(); resolutionPropertyNames.pop(); @@ -36081,12 +36664,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 238 /* VariableDeclaration */: - case 239 /* VariableDeclarationList */: - case 254 /* ImportSpecifier */: - case 253 /* NamedImports */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + case 239 /* VariableDeclaration */: + case 240 /* VariableDeclarationList */: + case 255 /* ImportSpecifier */: + case 254 /* NamedImports */: + case 253 /* NamespaceImport */: + case 252 /* ImportClause */: return false; default: return true; @@ -36119,7 +36702,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 150 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 151 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); @@ -36171,7 +36754,7 @@ var ts; if (parentAccess && parentAccess.flowNode) { var propName = getDestructuringPropertyName(node); if (propName) { - var result = ts.createNode(191 /* ElementAccessExpression */, node.pos, node.end); + var result = ts.createNode(192 /* ElementAccessExpression */, node.pos, node.end); result.parent = node; result.expression = parentAccess; var literal = ts.createNode(10 /* StringLiteral */, node.pos, node.end); @@ -36186,23 +36769,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 187 /* BindingElement */: - case 276 /* PropertyAssignment */: + case 188 /* BindingElement */: + case 277 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ancestor.initializer; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 187 /* BindingElement */ && parent.kind === 185 /* ObjectBindingPattern */) { + if (node.kind === 188 /* BindingElement */ && parent.kind === 186 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 276 /* PropertyAssignment */ || node.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.kind === 277 /* PropertyAssignment */ || node.kind === 278 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -36224,7 +36807,7 @@ var ts; parentType = getNonNullableType(parentType); } var type; - if (pattern.kind === 185 /* ObjectBindingPattern */) { + if (pattern.kind === 186 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -36296,26 +36879,26 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 188 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 189 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function isParameterOfContextuallyTypedFunction(node) { - return node.kind === 152 /* Parameter */ && - (node.parent.kind === 197 /* FunctionExpression */ || node.parent.kind === 198 /* ArrowFunction */) && + return node.kind === 153 /* Parameter */ && + (node.parent.kind === 198 /* FunctionExpression */ || node.parent.kind === 199 /* ArrowFunction */) && !!getContextualType(node.parent); } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 227 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 228 /* 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 === 228 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 229 /* 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, @@ -36334,7 +36917,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 238 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 239 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no @@ -36348,11 +36931,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 152 /* Parameter */) { + if (declaration.kind === 153 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 160 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 159 /* GetAccessor */); + if (func.kind === 161 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 160 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -36562,9 +37145,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 === 158 /* Constructor */ || - thisContainer.kind === 240 /* FunctionDeclaration */ || - (thisContainer.kind === 197 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 159 /* Constructor */ || + thisContainer.kind === 241 /* FunctionDeclaration */ || + (thisContainer.kind === 198 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -36639,7 +37222,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 187 /* BindingElement */ && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 188 /* BindingElement */ && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -36662,7 +37245,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 185 /* ObjectBindingPattern */ + return pattern.kind === 186 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -36701,7 +37284,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 152 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 153 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -36763,7 +37346,7 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 255 /* ExportAssignment */) { + if (declaration.kind === 256 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } else if (ts.isInJSFile(declaration) && @@ -36827,7 +37410,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 160 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -36854,8 +37437,8 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 160 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 160 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 161 /* SetAccessor */); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -36885,7 +37468,9 @@ var ts; // Otherwise, fall back to 'any'. else { if (setter) { - errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); + 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 existed getter as we are current checking either setter or getter in this function"); @@ -36898,7 +37483,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 160 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -36914,19 +37499,10 @@ var ts; if (!links.type) { var jsDeclaration = ts.getDeclarationOfExpando(symbol.valueDeclaration); if (jsDeclaration) { - var jsSymbol = getSymbolOfNode(jsDeclaration); - if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { - symbol = cloneSymbol(symbol); + var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration)); + if (merged) { // note:we overwrite links because we just cloned the symbol - links = symbol; - if (ts.hasEntries(jsSymbol.exports)) { - symbol.exports = symbol.exports || ts.createSymbolTable(); - mergeSymbolTable(symbol.exports, jsSymbol.exports); - } - if (ts.hasEntries(jsSymbol.members)) { - symbol.members = symbol.members || ts.createSymbolTable(); - mergeSymbolTable(symbol.members, jsSymbol.members); - } + symbol = links = merged; } } originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol); @@ -36938,8 +37514,8 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 205 /* BinaryExpression */ || - declaration.kind === 190 /* PropertyAccessExpression */ && declaration.parent.kind === 205 /* BinaryExpression */) { + else if (declaration.kind === 206 /* BinaryExpression */ || + declaration.kind === 191 /* PropertyAccessExpression */ && declaration.parent.kind === 206 /* BinaryExpression */) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -36978,7 +37554,7 @@ var ts; // 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 & 67220415 /* Value */ + links.type = targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) : errorType; } @@ -37006,7 +37582,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 152 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 153 /* 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 @@ -37087,39 +37663,50 @@ var ts; function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; // TODO: GH#18217 Use SourceFile kind check instead + if (node && ts.isBinaryExpression(node)) { + // prototype assignments get the outer type parameters of their constructor function + var assignmentKind = ts.getAssignmentDeclarationKind(node); + if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + var symbol = getSymbolOfNode(node.left); + if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { + node = symbol.parent.valueDeclaration; + } + } + } if (!node) { return undefined; } switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 182 /* MappedType */: - case 176 /* ConditionalType */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 157 /* MethodSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 296 /* JSDocFunctionType */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 244 /* TypeAliasDeclaration */: + case 312 /* JSDocTemplateTag */: + case 313 /* JSDocTypedefTag */: + case 307 /* JSDocEnumTag */: + case 306 /* JSDocCallbackTag */: + case 183 /* MappedType */: + case 177 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 182 /* MappedType */) { + if (node.kind === 183 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 176 /* ConditionalType */) { + else if (node.kind === 177 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */ || node.kind === 242 /* InterfaceDeclaration */) && + (node.kind === 242 /* ClassDeclaration */ || node.kind === 211 /* ClassExpression */ || node.kind === 243 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -37127,7 +37714,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 243 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -37136,9 +37723,10 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 241 /* ClassDeclaration */ || - node.kind === 210 /* ClassExpression */ || + if (node.kind === 243 /* InterfaceDeclaration */ || + node.kind === 242 /* ClassDeclaration */ || + node.kind === 211 /* ClassExpression */ || + isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -37169,7 +37757,7 @@ var ts; var constraint = getBaseConstraintOfType(type); return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } - return isJSConstructorType(type); + return false; } function getBaseTypeNodeOfClass(type) { return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); @@ -37264,9 +37852,7 @@ var ts; var baseTypeNode = getBaseTypeNodeOfClass(type); var typeArgs = typeArgumentsFromTypeReferenceNode(baseTypeNode); var baseType; - var originalBaseType = isJSConstructorType(baseConstructorType) ? baseConstructorType : - baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : - undefined; + var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the @@ -37277,9 +37863,6 @@ var ts; else if (baseConstructorType.flags & 1 /* Any */) { baseType = baseConstructorType; } - else if (isJSConstructorType(baseConstructorType)) { - baseType = !baseTypeNode.typeArguments && getJSClassType(baseConstructorType.symbol) || anyType; - } else { // The class derives from a "class-like" constructor function, check that we have at least one construct signature // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere @@ -37332,7 +37915,7 @@ var ts; 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 === 242 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 243 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -37368,7 +37951,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242 /* InterfaceDeclaration */) { + if (declaration.kind === 243 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -37377,7 +37960,7 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 67897832 /* Type */, /*ignoreErrors*/ true); + var baseSymbol = resolveEntityName(node.expression, 788968 /* Type */, /*ignoreErrors*/ true); if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } @@ -37390,9 +37973,15 @@ var ts; } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); + var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; - var type = links.declaredType = createObjectType(kind, symbol); + var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + if (merged) { + // note:we overwrite links because we just cloned the symbol + symbol = links = merged; + } + var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type @@ -37424,9 +38013,10 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return errorType; } - var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 243 /* TypeAliasDeclaration */; - }); + var declaration = ts.find(symbol.declarations, ts.isTypeAlias); + if (!declaration) { + return ts.Debug.fail("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; @@ -37442,7 +38032,7 @@ var ts; } else { type = errorType; - error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + error(ts.isJSDocEnumTag(declaration) ? declaration : declaration.name || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } links.declaredType = type; } @@ -37452,7 +38042,7 @@ var ts; if (expr.kind === 10 /* StringLiteral */) { return true; } - else if (expr.kind === 205 /* BinaryExpression */) { + else if (expr.kind === 206 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -37466,12 +38056,12 @@ var ts; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return true; - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return expr.operator === 39 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; case 73 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -37485,7 +38075,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 245 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && member.initializer.kind === 10 /* StringLiteral */) { @@ -37512,7 +38102,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 245 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -37596,11 +38186,11 @@ var ts; case 142 /* UndefinedKeyword */: case 97 /* NullKeyword */: case 133 /* NeverKeyword */: - case 183 /* LiteralType */: + case 184 /* LiteralType */: return true; - case 170 /* ArrayType */: + case 171 /* ArrayType */: return isThislessType(node.elementType); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -37626,7 +38216,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 158 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 159 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -37642,14 +38232,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -37759,7 +38349,7 @@ var ts; else { symbol.declarations.push(member); } - if (symbolFlags & 67220415 /* Value */) { + if (symbolFlags & 111551 /* Value */) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -38021,7 +38611,7 @@ var ts; var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; // TODO: GH#18217 + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -38065,8 +38655,9 @@ var ts; } var result; for (var i = 0; i < signatureLists.length; i++) { - // Allow matching non-generic signatures to have excess parameters and different return types - var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true); + // Allow matching non-generic signatures to have excess parameters and different return types. + // Prefer matching this types if possible. + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true); if (!match) { return undefined; } @@ -38090,7 +38681,7 @@ var ts; for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { var signature = _a[_i]; // Only process signatures with parameter lists that aren't already in the result list - if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true)) { + if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true)) { var unionSignatures = findMatchingSignatures(signatureLists, signature, i); if (unionSignatures) { var s = signature; @@ -38099,7 +38690,7 @@ var ts; var thisParameter = signature.thisParameter; var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; }); if (firstThisParameterOfUnionSignatures) { - var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType; }), 2 /* Subtype */); + var thisType = getIntersectionType(ts.mapDefined(unionSignatures, function (sig) { return sig.thisParameter && getTypeOfSymbol(sig.thisParameter); })); thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType); } s = createUnionSignature(signature, unionSignatures); @@ -38143,8 +38734,8 @@ var ts; } // 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 - // permissive when calling, for now, we'll union the `this` types just like the overlapping-union-signature check does - var thisType = getUnionType([getTypeOfSymbol(left), getTypeOfSymbol(right)], 2 /* Subtype */); + // permissive when calling, for now, we'll intersect the `this` types just like we do for param types in union signatures. + var thisType = getIntersectionType([getTypeOfSymbol(left), getTypeOfSymbol(right)]); return createSymbolWithType(left, thisType); } function combineUnionParameters(left, right) { @@ -38298,7 +38889,7 @@ var ts; * Converts an AnonymousType to a ResolvedType. */ function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; + var symbol = getMergedSymbol(type.symbol); if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); @@ -38354,14 +38945,18 @@ var ts; // will never be observed because a qualified name can't reference signatures. if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); - type.constructSignatures = ts.filter(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration); }); } // And likewise for construct signatures for classes if (symbol.flags & 32 /* Class */) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)); + var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* Function */) { + constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes) : + undefined; })); + } if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); + constructSignatures = getDefaultConstructSignatures(classType_1); } type.constructSignatures = constructSignatures; } @@ -38504,7 +39099,7 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 180 /* TypeOperator */ && + return constraintDeclaration.kind === 181 /* TypeOperator */ && constraintDeclaration.operator === 130 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { @@ -38518,7 +39113,7 @@ var ts; else { // Otherwise, get the declared constraint type, and if the constraint type is a type parameter, // get the constraint of that type parameter. If the resulting type is an indexed type 'keyof T', - // the modifiers type is T. Otherwise, the modifiers type is {}. + // the modifiers type is T. Otherwise, the modifiers type is unknown. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; @@ -38572,9 +39167,16 @@ var ts; else if (type.flags & 2097152 /* Intersection */) { resolveIntersectionTypeMembers(type); } + else if (type.flags & 134217728 /* StructuralTag */) { + resolveStructuralTagTypeMembers(type); + } } return type; } + function resolveStructuralTagTypeMembers(type) { + // Explicitly do nothing - structured tags, despite "containing structure" (in their argument), do not have any visible structure. + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { if (type.flags & 524288 /* Object */) { @@ -38889,6 +39491,9 @@ var ts; if (t.flags & 33554432 /* Substitution */) { return getBaseConstraint(t.substitute); } + if (t.flags & 134217728 /* StructuralTag */) { + return unknownType; + } return t; } } @@ -39135,7 +39740,7 @@ var ts; return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 137887744 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; } @@ -39149,7 +39754,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 137887744 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* String */ ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -39208,10 +39813,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 === 294 /* JSDocOptionalType */ + node.type && node.type.kind === 295 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 295 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -39245,7 +39850,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 295 /* JSDocOptionalType */; } function createIdentifierTypePredicate(parameterName, parameterIndex, type) { return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -39317,7 +39922,7 @@ var ts; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; // Include parameter symbol instead of property symbol in the signature if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 67220415 /* Value */, undefined, undefined, /*isUse*/ false); + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } if (i === 0 && paramSymbol.escapedName === "this" /* This */) { @@ -39327,7 +39932,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 183 /* LiteralType */) { + if (type && type.kind === 184 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -39341,16 +39946,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 === 159 /* GetAccessor */ || declaration.kind === 160 /* SetAccessor */) && + if ((declaration.kind === 160 /* GetAccessor */ || declaration.kind === 161 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = declaration.kind === 160 /* GetAccessor */ ? 161 /* SetAccessor */ : 160 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 158 /* Constructor */ ? + var classType = declaration.kind === 159 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -39410,11 +40015,11 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return node.name.kind === 150 /* ComputedPropertyName */ + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + return node.name.kind === 151 /* ComputedPropertyName */ && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -39504,7 +40109,6 @@ var ts; var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) : getReturnTypeFromAnnotation(signature.declaration) || - isJSConstructor(signature.declaration) && getJSClassType(getSymbolOfNode(signature.declaration)) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); if (!popTypeResolution()) { if (signature.declaration) { @@ -39530,7 +40134,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 158 /* Constructor */) { + if (declaration.kind === 159 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -39540,12 +40144,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 159 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 160 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 160 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 161 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -39635,7 +40239,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 === 158 /* Constructor */ || kind === 162 /* ConstructSignature */ || kind === 167 /* ConstructorType */; + var isConstructor = kind === 159 /* Constructor */ || kind === 163 /* ConstructSignature */ || kind === 168 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -39676,7 +40280,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 151 /* TypeParameter */); + var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 152 /* TypeParameter */); return decl && ts.getEffectiveConstraintOfTypeParameter(decl); } function getInferredTypeParameterConstraint(typeParameter) { @@ -39684,13 +40288,13 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 177 /* InferType */) { + if (declaration.parent.kind === 178 /* 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 grandParent = declaration.parent.parent; - if (grandParent.kind === 165 /* TypeReference */) { + if (grandParent.kind === 166 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -39715,7 +40319,7 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter // declaration, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 152 /* Parameter */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 153 /* Parameter */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -39739,7 +40343,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 151 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 152 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -39816,13 +40420,13 @@ var ts; var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent); - var diag = minTypeArgumentCount === typeParameters.length - ? missingAugmentsTag - ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : missingAugmentsTag - ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; + var diag = minTypeArgumentCount === typeParameters.length ? + missingAugmentsTag ? + ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + missingAugmentsTag ? + ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { @@ -39861,9 +40465,9 @@ var ts; var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { - error(node, minTypeArgumentCount === typeParameters.length - ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); + error(node, minTypeArgumentCount === typeParameters.length ? + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } return getTypeAliasInstantiation(symbol, typeArguments); @@ -39872,9 +40476,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -39885,34 +40489,23 @@ var ts; } return undefined; } - function resolveTypeReferenceName(typeReferenceName, meaning) { + function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) { if (!typeReferenceName) { return unknownSymbol; } - return resolveEntityName(typeReferenceName, meaning) || unknownSymbol; + return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. if (symbol === unknownSymbol) { return errorType; } - var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); - if (type) { - return type; + symbol = getExpandoSymbol(symbol) || symbol; + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); } - // JS enums are 'string' or 'number', not an enum type. - var enumTag = ts.isInJSFile(node) && symbol.valueDeclaration && ts.getJSDocEnumTag(symbol.valueDeclaration); - if (enumTag) { - var links = getNodeLinks(enumTag); - if (!pushTypeResolution(enumTag, 5 /* EnumTagType */)) { - return errorType; - } - var type_4 = enumTag.typeExpression ? getTypeFromTypeNode(enumTag.typeExpression) : errorType; - if (!popTypeResolution()) { - type_4 = errorType; - error(node, ts.Diagnostics.Enum_type_0_circularly_references_itself, symbolToString(symbol)); - } - return (links.resolvedEnumType = type_4); + if (symbol.flags & 524288 /* TypeAlias */) { + return getTypeFromTypeAliasReference(node, symbol, typeArguments); } // Get type from reference to named type that cannot be generic (enum or type parameter) var res = tryGetDeclaredTypeOfSymbol(symbol); @@ -39921,55 +40514,31 @@ var ts; res.flags & 262144 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } - if (!(symbol.flags & 67220415 /* Value */ && isJSDocTypeReference(node))) { - return errorType; - } - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; + if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + var jsdocType = getTypeFromJSAlias(node, symbol); + if (jsdocType) { + return jsdocType; + } + else { + // Resolve the type reference as a Type for the purpose of reporting errors. + resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */); + return getTypeOfSymbol(symbol); + } } - // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(getTypeReferenceName(node), 67897832 /* Type */); - return getTypeOfSymbol(symbol); + return errorType; } /** - * A jsdoc TypeReference may have resolved to a value (as opposed to a type). If - * the symbol is a constructor function, return the inferred class type; otherwise, - * the type of this reference is just the type of the value we resolved to. + * A JSdoc TypeReference may be to a value imported from commonjs. + * These should really be aliases, but this special-case code fakes alias resolution + * by producing a type from a value. */ - function getJSDocTypeReference(node, symbol, typeArguments) { - // In the case of an assignment of a function expression (binary expressions, variable declarations, etc.), we will get the - // correct instance type for the symbol on the LHS by finding the type for RHS. For example if we want to get the type of the symbol `foo`: - // var foo = function() {} - // We will find the static type of the assigned anonymous function. - var staticType = getTypeOfSymbol(symbol); - var instanceType = staticType.symbol && - staticType.symbol !== symbol && // Make sure this is an assignment like expression by checking that symbol -> type -> symbol doesn't roundtrips. - getTypeReferenceTypeWorker(node, staticType.symbol, typeArguments); // Get the instance type of the RHS symbol. - if (instanceType) { - return getSymbolLinks(symbol).resolvedJSDocType = instanceType; - } - } - function getTypeReferenceTypeWorker(node, symbol, typeArguments) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (symbol.valueDeclaration && symbol.valueDeclaration.parent && ts.isBinaryExpression(symbol.valueDeclaration.parent)) { - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; - } - } - return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); - } - if (symbol.flags & 524288 /* TypeAlias */) { - return getTypeFromTypeAliasReference(node, symbol, typeArguments); - } - if (symbol.flags & 16 /* Function */ && - isJSDocTypeReference(node) && - isJSConstructor(symbol.valueDeclaration)) { - var resolved = resolveStructuredTypeMembers(getTypeOfSymbol(symbol)); - if (resolved.callSignatures.length === 1) { - return getReturnTypeOfSignature(resolved.callSignatures[0]); - } + function getTypeFromJSAlias(node, symbol) { + var valueType = getTypeOfSymbol(symbol); + var typeType = valueType.symbol && + valueType.symbol !== symbol && // Make sure this is a commonjs export by checking that symbol -> type -> symbol doesn't roundtrip. + getTypeReferenceType(node, valueType.symbol); + if (typeType) { + return getSymbolLinks(symbol).resolvedJSDocType = typeType; } } function getSubstitutionType(typeVariable, substitute) { @@ -39988,7 +40557,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 171 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 172 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -39997,9 +40566,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 297 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 299 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 176 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 177 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -40010,7 +40579,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 165 /* TypeReference */ || node.kind === 184 /* ImportType */); + return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 166 /* TypeReference */ || node.kind === 185 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -40047,10 +40616,10 @@ var ts; return globalFunctionType; case "Array": case "array": - return !typeArgs || !typeArgs.length ? anyArrayType : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined; case "Promise": case "promise": - return !typeArgs || !typeArgs.length ? createPromiseType(anyType) : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined; case "Object": if (typeArgs && typeArgs.length === 2) { if (ts.isJSDocIndexSignature(node)) { @@ -40062,7 +40631,7 @@ var ts; return anyType; } checkNoTypeArguments(node); - return anyType; + return !noImplicitAny ? anyType : undefined; } } } @@ -40075,10 +40644,19 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - var meaning = 67897832 /* Type */; + var meaning = 788968 /* Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); - meaning |= 67220415 /* Value */; + if (!type) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, /*ignoreErrors*/ true); + if (symbol === unknownSymbol) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551 /* Value */); + } + else { + resolveTypeReferenceName(getTypeReferenceName(node), meaning); // Resolve again to mark errors, if any + } + type = getTypeReferenceType(node, symbol); + } } if (!type) { symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning); @@ -40111,9 +40689,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: return declaration; } } @@ -40133,10 +40711,10 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67220415 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67897832 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { // Don't track references for global symbols anyway, so value if `isReference` is arbitrary @@ -40205,7 +40783,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 67897832 /* Type */, /*diagnostic*/ undefined); + var symbol = getGlobalSymbol(name, 788968 /* Type */, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -40315,8 +40893,8 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 173 /* RestType */ ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 172 /* OptionalType */ && n !== restElement_1; }) + 1; + var restElement_1 = lastElement && lastElement.kind === 174 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 173 /* OptionalType */ && n !== restElement_1; }) + 1; var elementTypes = ts.map(node.elementTypes, function (n) { var type = getTypeFromTypeNode(n); return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; @@ -40359,7 +40937,7 @@ var ts; // We ignore 'never' types in unions if (!(flags & 131072 /* Never */)) { includes |= flags & 68943871 /* IncludesMask */; - if (flags & 66846720 /* StructuredOrInstantiable */) + if (flags & 201064448 /* StructuredOrInstantiable */) includes |= 262144 /* IncludesStructuredOrInstantiable */; if (type === wildcardType) includes |= 4194304 /* IncludesWildcard */; @@ -40491,7 +41069,7 @@ var ts; neverType; } } - return getUnionTypeFromSortedList(typeSet, includes & 66994211 /* NotPrimitiveUnion */ ? 0 : 131072 /* PrimitiveUnion */, aliasSymbol, aliasTypeArguments); + return getUnionTypeFromSortedList(typeSet, includes & 201211939 /* NotPrimitiveUnion */ ? 0 : 131072 /* PrimitiveUnion */, aliasSymbol, aliasTypeArguments); } function getUnionTypePredicate(signatures) { var first; @@ -40561,10 +41139,10 @@ var ts; } return links.resolvedType; } - function addTypeToIntersection(typeSet, includes, type) { + function addTypeToIntersection(typeSet, includes, type, tagSet) { var flags = type.flags; if (flags & 2097152 /* Intersection */) { - return addTypesToIntersection(typeSet, includes, type.types); + return addTypesToIntersection(typeSet, includes, type.types, tagSet); } if (isEmptyAnonymousObjectType(type)) { if (!(includes & 8388608 /* IncludesEmptyObject */)) { @@ -40577,6 +41155,9 @@ var ts; if (type === wildcardType) includes |= 4194304 /* IncludesWildcard */; } + else if (flags & 134217728 /* StructuralTag */) { + tagSet.set(type.id.toString(), type); + } else if ((strictNullChecks || !(flags & 98304 /* Nullable */)) && !typeSet.has(type.id.toString())) { if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) { // We have seen two distinct unit types which means we should reduce to an @@ -40591,10 +41172,27 @@ var ts; } // Add the given types to the given type set. Order is preserved, freshness is removed from literal // types, duplicates are removed, and nested types of the given kind are flattened into the set. - function addTypesToIntersection(typeSet, includes, types) { + function addTypesToIntersection(typeSet, includes, types, tagSet) { + var isTopLevel = !tagSet; + tagSet = tagSet || ts.createMap(); for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { var type = types_8[_i]; - includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); + includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type), tagSet); + } + if (isTopLevel && tagSet.size) { + var tag = void 0; + if (tagSet.size === 1) { + tag = tagSet.values().next().value; + } + else { + var tagTypes_1 = []; + tagSet.forEach(function (t) { return tagTypes_1.push(t.type); }); + tag = getStructuralTagForType(getIntersectionType(tagTypes_1)); + if (tag.flags & 1048576 /* Union */) { + includes |= 1048576 /* Union */; + } + } + typeSet.set(tag.id.toString(), tag); } return includes; } @@ -40631,6 +41229,15 @@ var ts; } return true; } + function extractIrreducible(types, flag) { + if (ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); })) { + for (var i = 0; i < types.length; i++) { + types[i] = filterType(types[i], function (t) { return !(t.flags & flag); }); + } + return true; + } + return false; + } // If the given list of types contains more than one union of primitive types, replace the // first with a union containing an intersection of those primitive types, then remove the // other unions and return true. Otherwise, do nothing and return false. @@ -40749,6 +41356,12 @@ var ts; // reduced we'll never reduce again, so this occurs at most once. result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } + else if (extractIrreducible(typeSet, 32768 /* Undefined */)) { + result = getUnionType([getIntersectionType(typeSet), undefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + } + else if (extractIrreducible(typeSet, 65536 /* Null */)) { + result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + } else { // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain. @@ -40864,9 +41477,16 @@ var ts; case 134 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; + case 148 /* TagKeyword */: + var aliasSymbol = getAliasSymbolForTypeNode(node); + var aliasParams = getTypeArgumentsForAliasSymbol(aliasSymbol); + links.resolvedType = getStructuralTagForType(getTypeFromTypeNode(node.type), aliasSymbol, aliasParams); + break; + default: + throw ts.Debug.assertNever(node.operator); } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function createIndexedAccessType(objectType, indexType) { var type = createType(8388608 /* IndexedAccess */); @@ -40874,6 +41494,26 @@ var ts; type.indexType = indexType; return type; } + function getStructuralTagForType(type, aliasSymbol, aliasTypeArguments) { + if (typeof aliasSymbol === "number") { + aliasSymbol = undefined; + } + var tid = "" + getTypeId(type); + if (structuralTags.has(tid)) { + return structuralTags.get(tid); + } + if (type.flags & 1048576 /* Union */) { + var union = getUnionType(ts.map(type.types, getStructuralTagForType), 2 /* Subtype */, aliasSymbol, aliasTypeArguments); + structuralTags.set(tid, union); + return union; + } + var tag = createType(134217728 /* StructuralTag */); + tag.type = type; + tag.aliasSymbol = aliasSymbol; + tag.aliasTypeArguments = aliasTypeArguments; + structuralTags.set(tid, tag); + return tag; + } /** * Returns if a type is or consists of a JSLiteral object type * In addition to objects which are directly literals, @@ -40902,7 +41542,7 @@ var ts; return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 192 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -40913,7 +41553,7 @@ var ts; undefined; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 192 /* ElementAccessExpression */ ? accessNode : undefined; var propName = getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); @@ -41050,13 +41690,10 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 191 /* ElementAccessExpression */ - ? accessNode.argumentExpression - : accessNode.kind === 181 /* IndexedAccessType */ - ? accessNode.indexType - : accessNode.kind === 150 /* ComputedPropertyName */ - ? accessNode.expression - : accessNode; + return accessNode.kind === 192 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 182 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 151 /* ComputedPropertyName */ ? accessNode.expression : + accessNode; } function isGenericObjectType(type) { return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 131072 /* GenericMappedType */); @@ -41181,7 +41818,7 @@ var ts; // object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in // an expression. This is to preserve backwards compatibility. For example, an element access 'this["foo"]' // has always been resolved eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 181 /* IndexedAccessType */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 182 /* IndexedAccessType */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -41393,7 +42030,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 67220415 /* Value */ : node.flags & 2097152 /* JSDoc */ ? 67220415 /* Value */ | 67897832 /* Type */ : 67897832 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 2097152 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { @@ -41416,14 +42053,14 @@ var ts; getNodeLinks(current.parent).resolvedSymbol = next; currentNamespace = next; } - resolveImportSymbolType(node, links, currentNamespace, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning); } else { if (moduleSymbol.flags & targetMeaning) { - resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 67220415 /* Value */ + var errorMessage = targetMeaning === 111551 /* Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -41432,16 +42069,16 @@ var ts; } } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 67220415 /* Value */) { - return links.resolvedType = getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias + if (meaning === 111551 /* Value */) { + return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { - return links.resolvedType = getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol + return getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol } } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { @@ -41465,7 +42102,11 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined; + var host = node.parent; + while (ts.isParenthesizedTypeNode(host)) { + host = host.parent; + } + return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; } function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; @@ -41654,12 +42295,26 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 242 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 243 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 158 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } + // inside x.prototype = { ... } + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; + } + // /** @return {this} */ + // x.prototype.m = function() { ... } + var host = node.flags & 2097152 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; + } + // inside constructor function C() { ... } + if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType; + } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); return errorType; } @@ -41673,8 +42328,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 121 /* AnyKeyword */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 291 /* JSDocAllType */: + case 292 /* JSDocUnknownType */: return anyType; case 144 /* UnknownKeyword */: return unknownType; @@ -41698,63 +42353,63 @@ var ts; return neverType; case 137 /* ObjectKeyword */: return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 179 /* ThisType */: + case 180 /* ThisType */: case 101 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 183 /* LiteralType */: + case 184 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return getTypeFromTypeReference(node); - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return booleanType; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 171 /* TupleType */: + case 172 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 172 /* OptionalType */: + case 173 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 174 /* UnionType */: + case 175 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 175 /* IntersectionType */: + case 176 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 292 /* JSDocNullableType */: + case 293 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 294 /* JSDocOptionalType */: + case 295 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 178 /* ParenthesizedType */: - case 173 /* RestType */: - case 293 /* JSDocNonNullableType */: - case 289 /* JSDocTypeExpression */: + case 179 /* ParenthesizedType */: + case 174 /* RestType */: + case 294 /* JSDocNonNullableType */: + case 290 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 296 /* JSDocVariadicType */: + case 297 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 295 /* JSDocFunctionType */: - case 299 /* JSDocSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 170 /* TypeLiteral */: + case 300 /* JSDocTypeLiteral */: + case 296 /* JSDocFunctionType */: + case 301 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 182 /* MappedType */: + case 183 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 177 /* InferType */: + case 178 /* InferType */: return getTypeFromInferTypeNode(node); - case 184 /* ImportType */: + case 185 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -41883,7 +42538,7 @@ var ts; } function instantiateSymbol(symbol, mapper) { var links = getSymbolLinks(symbol); - if (links.type && !maybeTypeOfKind(links.type, 524288 /* Object */ | 63176704 /* Instantiable */)) { + if (links.type && !maybeTypeOfKind(links.type, 524288 /* Object */ | 63176704 /* Instantiable */ | 134217728 /* StructuralTag */)) { // If the type of the symbol is already resolved, and if that type could not possibly // be affected by instantiation, simply return the symbol itself. return symbol; @@ -41963,8 +42618,9 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 149 /* QualifiedName */ || - node.parent.kind === 165 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 150 /* QualifiedName */ || + node.parent.kind === 166 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 185 /* 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 @@ -41973,7 +42629,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 219 /* Block */ || n.kind === 176 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 220 /* Block */ || n.kind === 177 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -41982,12 +42638,12 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 179 /* ThisType */: + case 180 /* ThisType */: return !!tp.isThisType; case 73 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return true; } return !!ts.forEachChild(node, containsReference); @@ -42181,6 +42837,10 @@ var ts; return sub; } } + if (flags & 134217728 /* StructuralTag */) { + var newType = instantiateType(type.type, mapper); + return newType !== type ? getStructuralTagForType(newType, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; + } return type; } function getPermissiveInstantiation(type) { @@ -42209,35 +42869,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 !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return node.operatorToken.kind === 55 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 268 /* JsxAttribute */: { + case 269 /* 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 271 /* JsxExpression */: { + case 272 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -42257,7 +42917,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 198 /* ArrowFunction */) { + if (node.kind !== 199 /* 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); @@ -42269,7 +42929,7 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !!node.body && node.body.kind !== 219 /* Block */ && isContextSensitive(node.body); + return !!node.body && node.body.kind !== 220 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -42372,23 +43032,23 @@ var ts; return true; } switch (node.kind) { - case 271 /* JsxExpression */: - case 196 /* ParenthesizedExpression */: + case 272 /* JsxExpression */: + case 197 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (node.operatorToken.kind) { case 60 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -42560,7 +43220,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -42569,9 +43229,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 266 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -42645,7 +43305,7 @@ var ts; var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName); var childrenTargetType = getIndexedAccessType(target, getLiteralType(childrenPropName)); var diagnostic = ts.Diagnostics._0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2; - invalidTextDiagnostic = __assign({}, diagnostic, { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); + invalidTextDiagnostic = __assign(__assign({}, diagnostic), { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); } return invalidTextDiagnostic; } @@ -42713,11 +43373,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 160 /* SetAccessor */: return [3 /*break*/, 2]; - case 159 /* GetAccessor */: return [3 /*break*/, 2]; - case 157 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 277 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 276 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 161 /* SetAccessor */: return [3 /*break*/, 2]; + case 160 /* GetAccessor */: return [3 /*break*/, 2]; + case 158 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 278 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 277 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -42789,8 +43449,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 157 /* MethodDeclaration */ && - kind !== 156 /* MethodSignature */ && kind !== 158 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 158 /* MethodDeclaration */ && + kind !== 157 /* MethodSignature */ && kind !== 159 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -42838,15 +43498,17 @@ var ts; result &= related; } if (!ignoreReturnTypes) { - // If a signature reolution is already in-flight, skip issuing a circularity error + // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly - var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType : (target.declaration && isJSConstructor(target.declaration)) ? - getJSClassType(target.declaration.symbol) : getReturnTypeOfSignature(target); + var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType + : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(target.declaration.symbol) + : getReturnTypeOfSignature(target); if (targetReturnType === voidType) { return result; } - var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType : (source.declaration && isJSConstructor(source.declaration)) ? - getJSClassType(source.declaration.symbol) : getReturnTypeOfSignature(source); + var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType + : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(source.declaration.symbol) + : getReturnTypeOfSignature(source); // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions var targetTypePredicate = getTypePredicateOfSignature(target); if (targetTypePredicate) { @@ -43032,7 +43694,7 @@ var ts; return related === 1 /* Succeeded */; } } - if (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */) { + if (source.flags & 201064448 /* StructuredOrInstantiable */ || target.flags & 201064448 /* StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; @@ -43093,7 +43755,7 @@ var ts; } var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); if (relatedInfo) { - ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInfo)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInfo)); } if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -43138,8 +43800,8 @@ var ts; reportError(message, sourceType, targetType); } function tryElaborateErrorsForPrimitivesAndObjects(source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); + var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source); + var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target); if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || @@ -43232,7 +43894,7 @@ var ts; isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); - var isPerformingExcessPropertyChecks = (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); + var isPerformingExcessPropertyChecks = !isApparentIntersectionConstituent && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); if (isPerformingExcessPropertyChecks) { var discriminantType = target.flags & 1048576 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { @@ -43242,11 +43904,11 @@ var ts; return 0 /* False */; } } - if (relation !== comparableRelation && !isApparentIntersectionConstituent && + var isPerformingCommonPropertyChecks = relation !== comparableRelation && !isApparentIntersectionConstituent && source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType && target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) && - (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)) && - !hasCommonProperties(source, target, isComparingJsxAttributes)) { + (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); + if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var calls = getSignaturesOfType(source, 0 /* Call */); var constructs = getSignaturesOfType(source, 1 /* Construct */); @@ -43268,16 +43930,16 @@ var ts; // and we need to handle "each" relations before "some" relations for the same kind of type. if (source.flags & 1048576 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)) : + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), isIntersectionConstituent) : eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)); } else { if (target.flags & 1048576 /* Union */) { result = typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { // Validate against excess props using the original `source` var discriminantType = findMatchingDiscriminantType(source, target) || filterPrimitivesIfContainsNonPrimitive(target); - if (!propertiesRelatedTo(source, discriminantType, reportErrors, /*excludedProperties*/ undefined)) { + if (!propertiesRelatedTo(source, discriminantType, reportErrors, /*excludedProperties*/ undefined, isIntersectionConstituent)) { return 0 /* False */; } } @@ -43285,9 +43947,9 @@ var ts; else if (target.flags & 2097152 /* Intersection */) { isIntersectionConstituent = true; // set here to affect the following trio of checks result = typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { // Validate against excess props using the original `source` - if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined)) { + if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, /*isIntersectionConstituent*/ false)) { return 0 /* False */; } } @@ -43306,9 +43968,9 @@ var ts; // // - For a primitive type or type parameter (such as 'number = A & B') there is no point in // breaking the intersection apart. - result = someTypeRelatedToType(source, target, /*reportErrors*/ false); + result = someTypeRelatedToType(source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ true); } - if (!result && (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */)) { + if (!result && (source.flags & 201064448 /* StructuredOrInstantiable */ || target.flags & 201064448 /* StructuredOrInstantiable */)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { errorInfo = saveErrorInfo; } @@ -43575,14 +44237,14 @@ var ts; } return result; } - function someTypeRelatedToType(source, target, reportErrors) { + function someTypeRelatedToType(source, target, reportErrors, isIntersectionConstituent) { var sourceTypes = source.types; if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, isIntersectionConstituent); if (related) { return related; } @@ -43602,7 +44264,7 @@ var ts; } return result; } - function typeArgumentsRelatedTo(sources, targets, variances, reportErrors) { + function typeArgumentsRelatedTo(sources, targets, variances, reportErrors, isIntersectionConstituent) { if (sources === void 0) { sources = ts.emptyArray; } if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } @@ -43629,10 +44291,10 @@ var ts; related = relation === identityRelation ? isRelatedTo(s, t, /*reportErrors*/ false) : compareTypesIdentical(s, t); } else if (variance === 1 /* Covariant */) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } else if (variance === 2 /* Contravariant */) { - related = isRelatedTo(t, s, reportErrors); + related = isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } else if (variance === 3 /* Bivariant */) { // In the bivariant case we first compare contravariantly without reporting @@ -43641,16 +44303,16 @@ var ts; // which is generally easier to reason about. related = isRelatedTo(t, s, /*reportErrors*/ false); if (!related) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } else { // In the invariant case we first compare covariantly, and only when that // succeeds do we proceed to compare contravariantly. Thus, error elaboration // will typically be based on the covariant check. - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); if (related) { - related &= isRelatedTo(t, s, reportErrors); + related &= isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } if (!related) { @@ -43780,6 +44442,9 @@ var ts; if (flags & 33554432 /* Substitution */) { return isRelatedTo(source.substitute, target.substitute, /*reportErrors*/ false); } + if (flags & 134217728 /* StructuralTag */) { + return isRelatedTo(source.type, target.type, /*reportErrors*/ false); + } return 0 /* False */; } var result; @@ -43793,7 +44458,7 @@ var ts; source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) { var variances = getAliasVariances(source.aliasSymbol); - var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances); + var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -43879,6 +44544,12 @@ var ts; } } } + else if (target.flags & 134217728 /* StructuralTag */) { + if (source.flags & 134217728 /* StructuralTag */) { + return isRelatedTo(source.type, target.type, reportErrors); + } + return 0 /* False */; + } 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. @@ -43922,9 +44593,19 @@ var ts; // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. - if (isTypeIdenticalTo(source.extendsType, target.extendsType) && + var sourceParams = source.root.inferTypeParameters; + var sourceExtends = source.extendsType; + var mapper = void 0; + if (sourceParams) { + // If the source has infer type parameters, we instantiate them in the context of the target + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedTo); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 64 /* NoConstraints */ | 128 /* AlwaysStrict */); + sourceExtends = instantiateType(sourceExtends, ctx.mapper); + mapper = ctx.mapper; + } + if (isTypeIdenticalTo(sourceExtends, target.extendsType) && (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { - if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } if (result) { @@ -43977,7 +44658,7 @@ var ts; // type references (which are intended by be compared structurally). Obtain the variance // information for the type parameters and relate the type arguments accordingly. var variances = getVariances(source.target); - var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances); + var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -44005,7 +44686,7 @@ var ts; if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 524288 /* Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; - result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined); + result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, isIntersectionConstituent); if (result) { result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); if (result) { @@ -44040,8 +44721,8 @@ var ts; } } return 0 /* False */; - function relateVariances(sourceTypeArguments, targetTypeArguments, variances) { - if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors)) { + function relateVariances(sourceTypeArguments, targetTypeArguments, variances, isIntersectionConstituent) { + if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, isIntersectionConstituent)) { return result; } if (ts.some(variances, function (v) { return !!(v & 24 /* AllowsStructuralFallback */); })) { @@ -44166,7 +44847,7 @@ var ts; if (sourceProperty === targetProperty) return "continue"; // We compare the source property to the target in the context of a single discriminant type. - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, /*isIntersectionConstituent*/ false); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -44196,7 +44877,7 @@ var ts; var result = -1 /* True */; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties); + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, /*isIntersectionConstituent*/ false); if (result) { result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false); if (result) { @@ -44231,7 +44912,7 @@ var ts; } return result || properties; } - function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); var source = getTypeOfSourceProperty(sourceProp); if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { @@ -44271,10 +44952,10 @@ var ts; return result_7; } else { - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } - function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { @@ -44312,7 +44993,7 @@ var ts; return 0 /* False */; } // If the target comes from a partial union prop, allow `undefined` in the target type - var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors); + var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); @@ -44335,7 +45016,7 @@ var ts; } return related; } - function propertiesRelatedTo(source, target, reportErrors, excludedProperties) { + function propertiesRelatedTo(source, target, reportErrors, excludedProperties, isIntersectionConstituent) { if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } @@ -44351,7 +45032,7 @@ var ts; } if (props.length === 1) { var propName = symbolToString(unmatchedProperty); - reportError.apply(void 0, [ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName].concat(getTypeNamesForErrorDisplay(source, target))); + reportError.apply(void 0, __spreadArrays([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target))); if (ts.length(unmatchedProperty.declarations)) { associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); } @@ -44424,7 +45105,7 @@ var ts; if (!(targetProp.flags & 4194304 /* Prototype */)) { var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp && sourceProp !== targetProp) { - var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors); + var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, isIntersectionConstituent); if (!related) { return 0 /* False */; } @@ -44603,7 +45284,7 @@ var ts; if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U } // if T is related to U. - return (kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); // TODO: GH#18217 + return kind === 0 /* String */ ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) : 0 /* False */; } if (isObjectTypeWithInferableIndex(source)) { var related = -1 /* True */; @@ -44659,23 +45340,27 @@ var ts; } } function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue) { - var match; + // undefined=unknown, true=discriminated, false=not discriminated + // The state of each type progresses from left to right. Discriminated types stop at 'true'. + var discriminable = target.types.map(function (_) { return undefined; }); for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; + var i = 0; for (var _b = 0, _c = target.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, propertyName); if (targetType && related(getDiscriminatingType(), targetType)) { - if (match) { - if (type === match) - continue; // Finding multiple fields which discriminate to the same type is fine - return defaultValue; - } - match = type; + discriminable[i] = discriminable[i] === undefined ? true : discriminable[i]; } + else { + discriminable[i] = false; + } + i++; } } - return match || defaultValue; + var match = discriminable.indexOf(/*searchElement*/ true); + // make sure exactly 1 matches before returning it + return match === -1 || discriminable.indexOf(/*searchElement*/ true, match + 1) !== -1 ? defaultValue : target.types[match]; } /** * A type is 'weak' if it is an object type with at least one optional property @@ -44878,6 +45563,9 @@ var ts; // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least 5 // levels, but unequal at some level beyond that. + // In addition, this will also detect when an indexed access has been chained off of 5 or more times (which is essentially + // the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding false positives + // for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`). function isDeeplyNestedType(type, stack, depth) { // We track all object types that have an associated symbol (representing the origin of the type) if (depth >= 5 && type.flags & 524288 /* Object */) { @@ -44894,8 +45582,30 @@ var ts; } } } + if (depth >= 5 && type.flags & 8388608 /* IndexedAccess */) { + var root = getRootObjectTypeFromIndexedAccessChain(type); + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (getRootObjectTypeFromIndexedAccessChain(t) === root) { + count++; + if (count >= 5) + return true; + } + } + } return false; } + /** + * Gets the leftmost object type in a chain of indexed accesses, eg, in A[P][Q], returns A + */ + function getRootObjectTypeFromIndexedAccessChain(type) { + var t = type; + while (t.flags & 8388608 /* IndexedAccess */) { + t = t.objectType; + } + return t; + } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; } @@ -45257,8 +45967,8 @@ var ts; * with no call or construct signatures. */ function isObjectTypeWithInferableIndex(type) { - return type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && - !typeHasCallOrConstructSignatures(type); + return !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); @@ -45477,17 +46187,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 205 /* BinaryExpression */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 206 /* BinaryExpression */: + case 156 /* PropertyDeclaration */: + case 155 /* 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 152 /* Parameter */: + case 153 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 67897832 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || + (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, ts.declarationNameToString(param.name)); @@ -45497,23 +46207,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 187 /* BindingElement */: + case 188 /* 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 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 1 /* 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); @@ -45527,7 +46237,7 @@ var ts; wideningKind === 1 /* 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 182 /* MappedType */: + case 183 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -45648,10 +46358,11 @@ var ts; function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); return !!(type.flags & 63176704 /* Instantiable */ || + type.flags & 134217728 /* StructuralTag */ && couldContainTypeVariables(type.type) || objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, 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 */ || - type.flags & 3145728 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { @@ -45806,8 +46517,7 @@ var ts; var visited; var bivariant = false; var propagationType; - var inferenceCount = 0; - var inferenceIncomplete = false; + var inferencePriority = 256 /* MaxValue */; var allowComplexConstraintInference = true; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { @@ -45830,50 +46540,57 @@ var ts; inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); return; } - if (source.flags & 1048576 /* Union */ && target.flags & 1048576 /* Union */ && !(source.flags & 1024 /* EnumLiteral */ && target.flags & 1024 /* EnumLiteral */) || - source.flags & 2097152 /* Intersection */ && target.flags & 2097152 /* Intersection */) { - // Source and target are both unions or both intersections. If source and target - // are the same type, just relate each constituent type to itself. - if (source === target) { - for (var _i = 0, _a = source.types; _i < _a.length; _i++) { - var t = _a[_i]; - inferFromTypes(t, t); - } - return; - } - // Find each source constituent type that has an identically matching target constituent - // type, and for each such type infer from the type to itself. When inferring from a - // type to itself we effectively find all type parameter occurrences within that type - // and infer themselves as their type arguments. We have special handling for numeric - // and string literals because the number and string types are not represented as unions - // of all their possible values. - var matchingTypes = void 0; - for (var _b = 0, _c = source.types; _b < _c.length; _b++) { - var t = _c[_b]; - var matched = findMatchedType(t, target); - if (matched) { - (matchingTypes || (matchingTypes = [])).push(matched); - inferFromTypes(matched, matched); - } - } - // Next, to improve the quality of inferences, reduce the source and target types by - // removing the identically matched constituents. For example, when inferring from - // 'string | string[]' to 'string | T' we reduce the types to 'string[]' and 'T'. - if (matchingTypes) { - var s = removeTypesFromUnionOrIntersection(source, matchingTypes); - var t = removeTypesFromUnionOrIntersection(target, matchingTypes); - if (!(s && t)) - return; - source = s; - target = t; + if (source === target && source.flags & 3145728 /* UnionOrIntersection */) { + // When source and target are the same union or intersection type, just relate each constituent + // type to itself. + for (var _i = 0, _a = source.types; _i < _a.length; _i++) { + var t = _a[_i]; + inferFromTypes(t, t); } + return; } - else if (target.flags & 1048576 /* Union */ && !(target.flags & 1024 /* EnumLiteral */) || target.flags & 2097152 /* Intersection */) { - var matched = findMatchedType(source, target); - if (matched) { - inferFromTypes(matched, matched); + if (target.flags & 1048576 /* Union */) { + // First, infer between identically matching source and target constituents and remove the + // matching types. + var _b = inferFromMatchingTypes(source.flags & 1048576 /* Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + // Next, infer between closely matching source and target constituents and remove + // the matching types. Types closely match when they are instantiations of the same + // object type or instantiations of the same type alias. + var _c = inferFromMatchingTypes(tempSources, tempTargets, isTypeCloselyMatchedBy), sources = _c[0], targets = _c[1]; + if (targets.length === 0) { return; } + target = getUnionType(targets); + if (sources.length === 0) { + // All source constituents have been matched and there is nothing further to infer from. + // However, simply making no inferences is undesirable because it could ultimately mean + // inferring a type parameter constraint. Instead, make a lower priority inference from + // the full source to whatever remains in the target. For example, when inferring from + // string to 'string | T', make a lower priority inference of string for T. + var savePriority = priority; + priority |= 1 /* NakedTypeVariable */; + inferFromTypes(source, target); + priority = savePriority; + return; + } + source = getUnionType(sources); + } + else if (target.flags & 2097152 /* Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + // We reduce intersection types only when they contain naked type parameters. For example, when + // inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and + // infer { extra: any } for T. But when inferring to 'string[] & Iterable' we want to keep the + // string[] on the source side and infer string for T. + // Likewise, we consider a homomorphic mapped type constrainted to the target type parameter as similar to a "naked type variable" + // in such scenarios. + if (!(source.flags & 1048576 /* Union */)) { + // Infer between identically matching source and target constituents and remove the matching types. + var _d = inferFromMatchingTypes(source.flags & 2097152 /* Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + if (sources.length === 0 || targets.length === 0) { + return; + } + source = getIntersectionType(sources); + target = getIntersectionType(targets); + } } else if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) { target = getActualTypeVariable(target); @@ -45918,7 +46635,7 @@ var ts; clearCachedInferences(inferences); } } - inferenceCount++; + inferencePriority = Math.min(inferencePriority, priority); return; } else { @@ -45949,6 +46666,9 @@ var ts; inferFromTypes(source.type, target.type); contravariant = !contravariant; } + else if (source.flags & 134217728 /* StructuralTag */ && target.flags & 134217728 /* StructuralTag */) { + inferFromTypes(source.type, target.type); + } else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; @@ -45975,11 +46695,17 @@ var ts; else if (target.flags & 3145728 /* UnionOrIntersection */) { inferToMultipleTypes(source, target.types, target.flags); } + else if (target.flags & 134217728 /* StructuralTag */ && source.flags & 2097152 /* Intersection */) { + var tagsOnly = getIntersectionType(ts.filter(source.types, function (t) { return !!(t.flags & 134217728 /* StructuralTag */); })); + if (tagsOnly !== source) { + inferFromTypes(tagsOnly, target); + } + } else if (source.flags & 1048576 /* Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; - for (var _d = 0, sourceTypes_3 = sourceTypes; _d < sourceTypes_3.length; _d++) { - var sourceType = sourceTypes_3[_d]; + for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { + var sourceType = sourceTypes_3[_e]; inferFromTypes(sourceType, target); } } @@ -46009,15 +46735,36 @@ var ts; } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; - var count = visited && visited.get(key); - if (count !== undefined) { - inferenceCount += count; + var status = visited && visited.get(key); + if (status !== undefined) { + inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = ts.createMap())).set(key, 0); - var startCount = inferenceCount; + (visited || (visited = ts.createMap())).set(key, -1 /* Circularity */); + var saveInferencePriority = inferencePriority; + inferencePriority = 256 /* MaxValue */; action(source, target); - visited.set(key, inferenceCount - startCount); + visited.set(key, inferencePriority); + inferencePriority = Math.min(inferencePriority, saveInferencePriority); + } + function inferFromMatchingTypes(sources, targets, matches) { + var matchedSources; + var matchedTargets; + for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { + var t = targets_1[_i]; + for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) { + var s = sources_1[_a]; + if (matches(s, t)) { + inferFromTypes(s, t); + matchedSources = ts.appendIfUnique(matchedSources, s); + matchedTargets = ts.appendIfUnique(matchedTargets, t); + } + } + } + return [ + matchedSources ? ts.filter(sources, function (t) { return !ts.contains(matchedSources, t); }) : sources, + matchedTargets ? ts.filter(targets, function (t) { return !ts.contains(matchedTargets, t); }) : targets, + ]; } function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; @@ -46057,31 +46804,34 @@ var ts; var nakedTypeVariable = void 0; var sources = source.flags & 1048576 /* Union */ ? source.types : [source]; var matched_1 = new Array(sources.length); - var saveInferenceIncomplete = inferenceIncomplete; - inferenceIncomplete = false; + var inferenceCircularity = false; // First infer to types that are not naked type variables. For each source type we - // track whether inferences were made from that particular type to some target. - for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { - var t = targets_1[_i]; + // track whether inferences were made from that particular type to some target with + // equal priority (i.e. of equal quality) to what we would infer for a naked type + // parameter. + for (var _i = 0, targets_2 = targets; _i < targets_2.length; _i++) { + var t = targets_2[_i]; if (getInferenceInfoForType(t)) { nakedTypeVariable = t; typeVariableCount++; } else { for (var i = 0; i < sources.length; i++) { - var count = inferenceCount; + var saveInferencePriority = inferencePriority; + inferencePriority = 256 /* MaxValue */; inferFromTypes(sources[i], t); - if (count !== inferenceCount) + if (inferencePriority === priority) matched_1[i] = true; + inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* Circularity */; + inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } } - var inferenceComplete = !inferenceIncomplete; - inferenceIncomplete = inferenceIncomplete || saveInferenceIncomplete; - // If the target has a single naked type variable and inference completed (meaning we - // explored the types fully), create a union of the source types from which no inferences - // have been made so far and infer from that union to the naked type variable. - if (typeVariableCount === 1 && inferenceComplete) { + // If the target has a single naked type variable and no inference circularities were + // encountered above (meaning we explored the types fully), create a union of the source + // types from which no inferences have been made so far and infer from that union to the + // naked type variable. + if (typeVariableCount === 1 && !inferenceCircularity) { var unmatched = ts.flatMap(sources, function (s, i) { return matched_1[i] ? undefined : s; }); if (unmatched.length) { inferFromTypes(getUnionType(unmatched), nakedTypeVariable); @@ -46093,8 +46843,8 @@ var ts; // We infer from types that are not naked type variables first so that inferences we // make from nested naked type variables and given slightly higher priority by virtue // of being first in the candidates array. - for (var _a = 0, targets_2 = targets; _a < targets_2.length; _a++) { - var t = targets_2[_a]; + for (var _a = 0, targets_3 = targets; _a < targets_3.length; _a++) { + var t = targets_3[_a]; if (getInferenceInfoForType(t)) { typeVariableCount++; } @@ -46110,8 +46860,8 @@ var ts; if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { var savePriority = priority; priority |= 1 /* NakedTypeVariable */; - for (var _b = 0, targets_3 = targets; _b < targets_3.length; _b++) { - var t = targets_3[_b]; + for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { + var t = targets_4[_b]; if (getInferenceInfoForType(t)) { inferFromTypes(source, t); } @@ -46185,7 +46935,7 @@ var ts; var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { if (ts.contains(symbolStack, symbol)) { - inferenceIncomplete = true; + inferencePriority = -1 /* Circularity */; return; } (symbolStack || (symbolStack = [])).push(symbol); @@ -46269,7 +47019,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 === 157 /* MethodDeclaration */ || kind === 156 /* MethodSignature */ || kind === 158 /* Constructor */; + bivariant = bivariant || kind === 158 /* MethodDeclaration */ || kind === 157 /* MethodSignature */ || kind === 159 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -46295,46 +47045,12 @@ var ts; } } } - function isMatchableType(type) { - // We exclude non-anonymous object types because some frameworks (e.g. Ember) rely on the ability to - // infer between types that don't witness their type variables. Such types would otherwise be eliminated - // because they appear identical. - return !(type.flags & 524288 /* Object */) || !!(ts.getObjectFlags(type) & 16 /* Anonymous */); + function isTypeOrBaseIdenticalTo(s, t) { + return isTypeIdenticalTo(s, t) || !!(s.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) && isTypeIdenticalTo(getBaseTypeOfLiteralType(s), t); } - function typeMatchedBySomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; - if (t === type || isMatchableType(t) && isMatchableType(type) && isTypeIdenticalTo(t, type)) { - return true; - } - } - return false; - } - function findMatchedType(type, target) { - if (typeMatchedBySomeType(type, target.types)) { - return type; - } - if (type.flags & (256 /* NumberLiteral */ | 128 /* StringLiteral */) && target.flags & 1048576 /* Union */) { - var base = getBaseTypeOfLiteralType(type); - if (typeMatchedBySomeType(base, target.types)) { - return base; - } - } - return undefined; - } - /** - * Return a new union or intersection type computed by removing a given set of types - * from a given union or intersection type. - */ - function removeTypesFromUnionOrIntersection(type, typesToRemove) { - var reducedTypes = []; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (!typeMatchedBySomeType(t, typesToRemove)) { - reducedTypes.push(t); - } - } - return reducedTypes.length ? type.flags & 1048576 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes) : undefined; + function isTypeCloselyMatchedBy(s, t) { + return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || + s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); @@ -46473,7 +47189,7 @@ var ts; case "AsyncIterator": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later; default: - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 278 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -46485,7 +47201,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), + resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), /*excludeGlobals*/ false, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; } return links.resolvedSymbol; @@ -46494,7 +47210,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 168 /* TypeQuery */ ? true : n.kind === 73 /* Identifier */ || n.kind === 149 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 169 /* TypeQuery */ ? true : n.kind === 73 /* Identifier */ || n.kind === 150 /* 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 @@ -46509,11 +47225,11 @@ var ts; return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; case 101 /* ThisKeyword */: return "0"; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 215 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -46524,24 +47240,24 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 196 /* ParenthesizedExpression */: - case 214 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: + case 215 /* NonNullExpression */: return isMatchingReference(source, target.expression); } switch (source.kind) { case 73 /* Identifier */: return target.kind === 73 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 238 /* VariableDeclaration */ || target.kind === 187 /* BindingElement */) && + (target.kind === 239 /* VariableDeclaration */ || target.kind === 188 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 101 /* ThisKeyword */: return target.kind === 101 /* ThisKeyword */; case 99 /* SuperKeyword */: return target.kind === 99 /* SuperKeyword */; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 215 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); @@ -46549,7 +47265,7 @@ var ts; return false; } function getAccessedPropertyName(access) { - return access.kind === 190 /* PropertyAccessExpression */ ? access.name.escapedText : + return access.kind === 191 /* PropertyAccessExpression */ ? access.name.escapedText : ts.isStringLiteral(access.argumentExpression) || ts.isNumericLiteral(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } @@ -46633,7 +47349,7 @@ var ts; } } } - if (callExpression.expression.kind === 190 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 191 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -46682,8 +47398,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; result |= getTypeFacts(t); } return result; @@ -46788,15 +47504,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 188 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 189 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 277 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 205 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 228 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 206 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 229 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -46813,21 +47529,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return stringType; - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return undefinedType; - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -46835,7 +47551,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 185 /* ObjectBindingPattern */ ? + var type = pattern.kind === 186 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -46853,35 +47569,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 227 /* ForInStatement */) { + if (node.parent.parent.kind === 228 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.parent.kind === 229 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 238 /* VariableDeclaration */ ? + return node.kind === 239 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */ ? + return getConstraintForLocation(node.kind === 239 /* VariableDeclaration */ || node.kind === 188 /* BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } function isEmptyArrayAssignment(node) { - return node.kind === 238 /* VariableDeclaration */ && node.initializer && + return node.kind === 239 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 187 /* BindingElement */ && node.parent.kind === 205 /* BinaryExpression */ && + node.kind !== 188 /* BindingElement */ && node.parent.kind === 206 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (node.operatorToken.kind) { case 60 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -46893,13 +47609,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 196 /* ParenthesizedExpression */ || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */ && parent.left === node || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 197 /* ParenthesizedExpression */ || + parent.kind === 206 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */ && parent.left === node || + parent.kind === 206 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 273 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -46921,7 +47637,7 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 273 /* CaseClause */) { if (clause.expression.kind === 10 /* StringLiteral */) { witnesses.push(clause.expression.text); continue; @@ -47005,8 +47721,7 @@ var ts; return mapType(typeWithPrimitives, function (t) { return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */) : t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : - t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : - t; + t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -47058,8 +47773,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -47082,11 +47797,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 190 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 192 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 191 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 191 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 193 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 192 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 205 /* BinaryExpression */ && + parent.parent.kind === 206 /* BinaryExpression */ && parent.parent.operatorToken.kind === 60 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -47124,7 +47839,7 @@ var ts; if (flowAnalysisDisabled) { return errorType; } - if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943 /* Narrowable */)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 268188671 /* Narrowable */)) { return declaredType; } var sharedFlowStart = sharedFlowCount; @@ -47135,7 +47850,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 (reference.parent && reference.parent.kind === 214 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (reference.parent && reference.parent.kind === 215 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -47232,8 +47947,8 @@ var ts; // Check if we should continue with the control flow of the containing function. var container = flow.container; if (container && container !== flowContainer && - reference.kind !== 190 /* PropertyAccessExpression */ && - reference.kind !== 191 /* ElementAccessExpression */ && + reference.kind !== 191 /* PropertyAccessExpression */ && + reference.kind !== 192 /* ElementAccessExpression */ && reference.kind !== 101 /* ThisKeyword */) { flow = container.flowNode; continue; @@ -47286,14 +48001,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 === 197 /* FunctionExpression */ || init.kind === 198 /* ArrowFunction */)) { + if (init && (init.kind === 198 /* FunctionExpression */ || init.kind === 199 /* 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 === 227 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 228 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference @@ -47302,7 +48017,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 192 /* CallExpression */ ? + var expr = node.kind === 193 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -47310,7 +48025,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 193 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -47363,7 +48078,7 @@ var ts; else if (isMatchingReferenceDiscriminant(expr, type)) { type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); } - else if (expr.kind === 200 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 201 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else if (containsMatchingReferenceDiscriminant(reference, expr)) { @@ -47538,10 +48253,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 201 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 201 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -47619,7 +48334,7 @@ var ts; return type; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { - // We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands + // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { // For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the @@ -47901,16 +48616,16 @@ var ts; case 73 /* Identifier */: case 101 /* ThisKeyword */: case 99 /* SuperKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: if (expr.operator === 52 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -47946,9 +48661,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 246 /* ModuleBlock */ || - node.kind === 285 /* SourceFile */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 247 /* ModuleBlock */ || + node.kind === 286 /* SourceFile */ || + node.kind === 156 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -47970,7 +48685,7 @@ var ts; if (node.kind === 73 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 152 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 153 /* Parameter */) { symbol.isAssigned = true; } } @@ -47985,7 +48700,7 @@ var ts; /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 152 /* Parameter */ && + declaration.kind === 153 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -47993,10 +48708,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 190 /* PropertyAccessExpression */ || - parent.kind === 192 /* CallExpression */ && parent.expression === node || - parent.kind === 191 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 187 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 191 /* PropertyAccessExpression */ || + parent.kind === 193 /* CallExpression */ && parent.expression === node || + parent.kind === 192 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 188 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); @@ -48011,8 +48726,11 @@ var ts; } return type; } + function isExportOrExportExpression(location) { + return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); + } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 67220415 /* Value */) && !isInTypeQuery(location) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && ((compilerOptions.preserveConstEnums && isExportOrExportExpression(location)) || !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol)))) { markAliasSymbolAsReferenced(symbol); } } @@ -48030,7 +48748,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 198 /* ArrowFunction */) { + if (container.kind === 199 /* 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.hasModifier(container, 256 /* Async */)) { @@ -48051,7 +48769,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 241 /* ClassDeclaration */ + if (declaration.kind === 242 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -48063,14 +48781,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 210 /* ClassExpression */) { + else if (declaration.kind === 211 /* 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 !== 285 /* SourceFile */) { + while (container.kind !== 286 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 155 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 156 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -48119,7 +48837,7 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 152 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 153 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -48128,8 +48846,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 === 197 /* FunctionExpression */ || - flowContainer.kind === 198 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 198 /* FunctionExpression */ || + flowContainer.kind === 199 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -48137,10 +48855,10 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 258 /* ExportSpecifier */) || - node.parent.kind === 214 /* NonNullExpression */ || - declaration.kind === 238 /* VariableDeclaration */ && declaration.exclamationToken || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 259 /* ExportSpecifier */) || + node.parent.kind === 215 /* NonNullExpression */ || + declaration.kind === 239 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 4194304 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -48175,7 +48893,7 @@ var ts; if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 275 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 276 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -48198,7 +48916,7 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container) && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 240 /* VariableDeclarationList */).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -48216,8 +48934,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 226 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container && + if (container.kind === 227 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 240 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -48235,7 +48953,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 196 /* ParenthesizedExpression */) { + while (current.parent.kind === 197 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -48243,7 +48961,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 203 /* PrefixUnaryExpression */ || current.parent.kind === 204 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 204 /* PrefixUnaryExpression */ || current.parent.kind === 205 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; } @@ -48256,7 +48974,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 155 /* PropertyDeclaration */ || container.kind === 158 /* Constructor */) { + if (container.kind === 156 /* PropertyDeclaration */ || container.kind === 159 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -48324,37 +49042,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 158 /* Constructor */) { + if (container.kind === 159 /* 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 === 198 /* ArrowFunction */) { + if (container.kind === 199 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 245 /* ModuleDeclaration */: + case 246 /* 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 244 /* EnumDeclaration */: + case 245 /* 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 158 /* Constructor */: + case 159 /* 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 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: if (ts.hasModifier(container, 32 /* Static */)) { 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 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -48393,10 +49111,8 @@ var ts; if (isInJS && className) { var classSymbol = checkExpression(className).symbol; if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { - var classType = getJSClassType(classSymbol); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(classSymbol).thisType; + return getFlowTypeOfReference(node, classType); } } // Check if it's a constructor definition, can be either a variable decl or function decl @@ -48404,12 +49120,10 @@ var ts; // * /** @constructor */ function [name]() { ... } // * /** @constructor */ var x = function() { ... } else if (isInJS && - (container.kind === 197 /* FunctionExpression */ || container.kind === 240 /* FunctionDeclaration */) && + (container.kind === 198 /* FunctionExpression */ || container.kind === 241 /* FunctionDeclaration */) && ts.getJSDocClassTag(container)) { - var classType = getJSClassType(getMergedSymbol(container.symbol)); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType; + return getFlowTypeOfReference(node, classType); } var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { @@ -48440,7 +49154,7 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 197 /* FunctionExpression */ && + if (container.kind === 198 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -48450,16 +49164,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 157 /* MethodDeclaration */ && - container.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 158 /* MethodDeclaration */ && + container.parent.kind === 190 /* 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 === 197 /* FunctionExpression */ && - container.parent.kind === 276 /* PropertyAssignment */ && - container.parent.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 198 /* FunctionExpression */ && + container.parent.kind === 277 /* PropertyAssignment */ && + container.parent.parent.kind === 190 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -48467,7 +49181,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 === 197 /* FunctionExpression */ && + else if (container.kind === 198 /* 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") && @@ -48492,7 +49206,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 295 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 296 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -48506,15 +49220,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 152 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 153 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 192 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 193 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); 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 === 198 /* ArrowFunction */) { + while (container && container.kind === 199 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -48527,14 +49241,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 150 /* ComputedPropertyName */; }); - if (current && current.kind === 150 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 151 /* ComputedPropertyName */; }); + if (current && current.kind === 151 /* 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 === 189 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 190 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -48542,7 +49256,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 158 /* Constructor */) { + if (!isCallExpression && container.kind === 159 /* 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.hasModifier(container, 32 /* Static */) || isCallExpression) { @@ -48611,7 +49325,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 === 157 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 158 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -48625,7 +49339,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 189 /* ObjectLiteralExpression */) { + if (container.parent.kind === 190 /* 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; @@ -48646,7 +49360,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 158 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 159 /* 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; @@ -48661,7 +49375,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 === 158 /* Constructor */; + return container.kind === 159 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -48669,21 +49383,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 === 189 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 190 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */; + return container.kind === 158 /* MethodDeclaration */ || + container.kind === 157 /* MethodSignature */ || + container.kind === 160 /* GetAccessor */ || + container.kind === 161 /* SetAccessor */; } else { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */ || - container.kind === 155 /* PropertyDeclaration */ || - container.kind === 154 /* PropertySignature */ || - container.kind === 158 /* Constructor */; + return container.kind === 158 /* MethodDeclaration */ || + container.kind === 157 /* MethodSignature */ || + container.kind === 160 /* GetAccessor */ || + container.kind === 161 /* SetAccessor */ || + container.kind === 156 /* PropertyDeclaration */ || + container.kind === 155 /* PropertySignature */ || + container.kind === 159 /* Constructor */; } } } @@ -48691,10 +49405,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 157 /* MethodDeclaration */ || - func.kind === 159 /* GetAccessor */ || - func.kind === 160 /* SetAccessor */) && func.parent.kind === 189 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 197 /* FunctionExpression */ && func.parent.kind === 276 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 158 /* MethodDeclaration */ || + func.kind === 160 /* GetAccessor */ || + func.kind === 161 /* SetAccessor */) && func.parent.kind === 190 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 198 /* FunctionExpression */ && func.parent.kind === 277 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -48706,7 +49420,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 199 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -48733,7 +49447,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 276 /* PropertyAssignment */) { + if (literal.parent.kind !== 277 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -48747,9 +49461,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent.kind === 206 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */) { var target = parent.left; - if (target.kind === 190 /* PropertyAccessExpression */ || target.kind === 191 /* ElementAccessExpression */) { + if (target.kind === 191 /* PropertyAccessExpression */ || target.kind === 192 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -48813,9 +49527,9 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 152 /* Parameter */: + case 153 /* Parameter */: return getContextuallyTypedParameterType(declaration, /*forCache*/ false); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return getContextualTypeForBindingElement(declaration); // By default, do nothing and return undefined - only parameters and binding elements have context implied by a parent } @@ -48905,6 +49619,15 @@ var ts; } return false; } + function getContextualIterationType(kind, functionDecl) { + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */); + var contextualReturnType = getContextualReturnType(functionDecl); + if (contextualReturnType) { + return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) + || undefined; + } + return undefined; + } function getContextualReturnType(functionDecl) { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed @@ -48936,7 +49659,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 194 /* TaggedTemplateExpression */) { + if (template.parent.kind === 195 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -48998,7 +49721,7 @@ var ts; } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 67220415 /* Value */, undefined, id.escapedText, /*isUse*/ true); + var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated) { @@ -49049,7 +49772,7 @@ var ts; return substituteIndexedMappedType(t, propertyNameType); } } - else if (t.flags & 3670016 /* StructuredType */) { + else if (t.flags & 137887744 /* StructuredType */) { var prop = getPropertyOfType(t, name); if (prop) { return getTypeOfSymbol(prop); @@ -49169,26 +49892,29 @@ var ts; case 73 /* Identifier */: case 142 /* UndefinedKeyword */: return true; - case 190 /* PropertyAccessExpression */: - case 196 /* ParenthesizedExpression */: + case 191 /* PropertyAccessExpression */: + case 197 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 271 /* JsxExpression */: + case 272 /* 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 === 276 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 277 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 268 /* 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.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 269 /* 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 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. function getApparentTypeOfContextualType(node, contextFlags) { - var contextualType = instantiateContextualType(getContextualType(node, contextFlags), node, contextFlags); - if (contextualType) { - var apparentType = mapType(contextualType, getApparentType, /*noReductions*/ true); + var contextualType = ts.isObjectLiteralMethod(node) ? + getContextualTypeForObjectLiteralMethod(node, contextFlags) : + getContextualType(node, contextFlags); + var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); + if (instantiatedType) { + var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); if (apparentType.flags & 1048576 /* Union */) { if (ts.isObjectLiteralExpression(node)) { return discriminateContextualTypeByObjectMembers(node, apparentType); @@ -49226,7 +49952,7 @@ var ts; // are classified as instantiable (i.e. it doesn't instantiate object types), and (b) it performs // no reductions on instantiated union types. function instantiateInstantiableTypes(type, mapper) { - if (type.flags & 63176704 /* Instantiable */) { + if (type.flags & (63176704 /* Instantiable */ | 134217728 /* StructuralTag */)) { return instantiateType(type, mapper); } if (type.flags & 1048576 /* Union */) { @@ -49264,58 +49990,58 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 187 /* BindingElement */: + case 239 /* VariableDeclaration */: + case 153 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 188 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 198 /* ArrowFunction */: - case 231 /* ReturnStatement */: + case 199 /* ArrowFunction */: + case 232 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent); - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (parent.expression.kind === 93 /* ImportKeyword */) { return stringType; } /* falls through */ - case 193 /* NewExpression */: + case 194 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 188 /* ArrayLiteralExpression */: { + case 189 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 217 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 207 /* TemplateExpression */); + case 218 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 208 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 196 /* ParenthesizedExpression */: { + case 197 /* 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 271 /* JsxExpression */: + case 272 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: + case 269 /* JsxAttribute */: + case 271 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -49470,7 +50196,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 197 /* FunctionExpression */ || node.kind === 198 /* ArrowFunction */; + return node.kind === 198 /* FunctionExpression */ || node.kind === 199 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -49484,14 +50210,12 @@ 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 !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = ts.isObjectLiteralMethod(node) ? - getContextualTypeForObjectLiteralMethod(node, 1 /* Signature */) : - getApparentTypeOfContextualType(node, 1 /* Signature */); + var type = getApparentTypeOfContextualType(node, 1 /* Signature */); if (!type) { return undefined; } @@ -49500,8 +50224,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var current = types_13[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -49531,8 +50255,8 @@ var ts; return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); } function hasDefaultValue(node) { - return (node.kind === 187 /* BindingElement */ && !!node.initializer) || - (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */); + return (node.kind === 188 /* BindingElement */ && !!node.initializer) || + (node.kind === 206 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -49544,7 +50268,7 @@ var ts; var inConstContext = isConstContext(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 209 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 210 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -49569,12 +50293,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 209 /* SpreadElement */) { + if (index < elementCount - 1 && e.kind === 210 /* SpreadElement */) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 209 /* SpreadElement */; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 210 /* SpreadElement */; var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". @@ -49616,7 +50340,7 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return isNumericComputedName(name); case 73 /* Identifier */: return isNumericLiteralName(name.escapedText); @@ -49706,7 +50430,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 185 /* ObjectBindingPattern */ || contextualType.pattern.kind === 189 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 186 /* ObjectBindingPattern */ || contextualType.pattern.kind === 190 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -49721,13 +50445,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 150 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 151 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 276 /* PropertyAssignment */ || - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 277 /* PropertyAssignment */ || + memberDecl.kind === 278 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 276 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 277 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 278 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -49750,8 +50474,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 === 276 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 277 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 277 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 278 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -49776,7 +50500,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 278 /* SpreadAssignment */) { + else if (memberDecl.kind === 279 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -49802,7 +50526,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 === 159 /* GetAccessor */ || memberDecl.kind === 160 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 160 /* GetAccessor */ || memberDecl.kind === 161 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -49862,7 +50586,13 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (3 /* AnyOrUnknown */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || + if (type.flags & 63176704 /* Instantiable */) { + var constraint = getBaseConstraintOfType(type); + if (constraint !== undefined) { + return isValidSpreadType(constraint); + } + } + return !!(type.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 134217728 /* StructuralTag */ | 58982400 /* InstantiableNonPrimitive */) || getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } @@ -49955,7 +50685,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 270 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 271 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -49978,7 +50708,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 261 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 262 /* 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); @@ -50052,7 +50782,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 67897832 /* Type */); + var typeSymbol = exports && getSymbol(exports, name, 788968 /* Type */); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** @@ -50126,7 +50856,7 @@ var ts; */ function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 67897832 /* Type */); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* Type */); // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute @@ -50150,7 +50880,7 @@ var ts; } function getJsxLibraryManagedAttributes(jsxNamespace) { // JSX.LibraryManagedAttributes [symbol] - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67897832 /* Type */); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* Type */); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -50302,13 +51032,13 @@ var ts; var reactRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var reactNamespace = getJsxNamespace(node); var reactLocation = isNodeOpeningLikeElement ? node.tagName : node; - var reactSym = resolveName(reactLocation, reactNamespace, 67220415 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); + var reactSym = resolveName(reactLocation, reactNamespace, 111551 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); if (reactSym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not react as there wont be error being emitted reactSym.isReferenced = 67108863 /* All */; - // If react symbol is alias, mark it as referenced - if (reactSym.flags & 2097152 /* Alias */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { + // If react symbol is alias, mark it as refereced + if (reactSym.flags & 2097152 /* Alias */) { markAliasSymbolAsReferenced(reactSym); } } @@ -50397,7 +51127,7 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 149 /* QualifiedName */ ? node.right : node.kind === 184 /* ImportType */ ? node : node.name; + var errorNode = node.kind === 150 /* QualifiedName */ ? node.right : node.kind === 185 /* ImportType */ ? node : node.name; if (ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */) { // Synthetic property with private constituent property error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); @@ -50532,7 +51262,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } function isMethodAccessForCall(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */) { + while (node.parent.kind === 197 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -50598,7 +51328,7 @@ var ts; // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (node.kind !== 191 /* ElementAccessExpression */ && node.kind !== 190 /* PropertyAccessExpression */ || + if (node.kind !== 192 /* ElementAccessExpression */ && node.kind !== 191 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; @@ -50612,7 +51342,7 @@ var ts; var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 158 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 159 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -50633,7 +51363,7 @@ var ts; } function checkPropertyNotUsedBeforeDeclaration(prop, node, right) { var valueDeclaration = prop.valueDeclaration; - if (!valueDeclaration) { + if (!valueDeclaration || ts.getSourceFileOfNode(node).isDeclarationFile) { return; } var diagnosticMessage; @@ -50643,8 +51373,8 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 241 /* ClassDeclaration */ && - node.parent.kind !== 165 /* TypeReference */ && + else if (valueDeclaration.kind === 242 /* ClassDeclaration */ && + node.parent.kind !== 166 /* TypeReference */ && !(valueDeclaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -50656,22 +51386,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return true; - case 276 /* PropertyAssignment */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 278 /* SpreadAssignment */: - case 150 /* ComputedPropertyName */: - case 217 /* TemplateSpan */: - case 271 /* JsxExpression */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 263 /* JsxOpeningElement */: - case 212 /* ExpressionWithTypeArguments */: - case 274 /* HeritageClause */: + case 277 /* PropertyAssignment */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 279 /* SpreadAssignment */: + case 151 /* ComputedPropertyName */: + case 218 /* TemplateSpan */: + case 272 /* JsxExpression */: + case 269 /* JsxAttribute */: + case 270 /* JsxAttributes */: + case 271 /* JsxSpreadAttribute */: + case 264 /* JsxOpeningElement */: + case 213 /* ExpressionWithTypeArguments */: + case 275 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -50711,7 +51441,7 @@ var ts; if (containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; - if (!getPropertyOfType(subtype, propNode.escapedText)) { + if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0 /* String */)) { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); break; } @@ -50749,7 +51479,7 @@ var ts; return prop !== undefined && prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 32 /* Static */); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { - return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67220415 /* Value */); + return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551 /* Value */); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -50844,16 +51574,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return isValidPropertyAccessWithType(node, node.expression.kind === 99 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 184 /* ImportType */: + case 185 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 190 /* PropertyAccessExpression */ && node.expression.kind === 99 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 191 /* PropertyAccessExpression */ && node.expression.kind === 99 /* 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) { @@ -50870,7 +51600,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer.kind === 240 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -50899,7 +51629,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 227 /* ForInStatement */ && + if (node.kind === 228 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -50916,20 +51646,6 @@ var ts; var exprType = checkNonNullExpression(node.expression); var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; - if (!indexExpression) { - var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 193 /* NewExpression */ && node.parent.expression === node) { - var start = ts.skipTrivia(sourceFile.text, node.expression.end); - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - return errorType; - } var indexType = checkExpression(indexExpression); if (objectType === errorType || objectType === silentNeverType) { return objectType; @@ -50989,13 +51705,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 195 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 153 /* Decorator */) { + else if (node.kind !== 154 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -51059,7 +51775,7 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 209 /* SpreadElement */ || arg.kind === 216 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 210 /* SpreadElement */ || arg.kind === 217 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -51073,9 +51789,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 === 194 /* TaggedTemplateExpression */) { + if (node.kind === 195 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 207 /* TemplateExpression */) { + if (node.template.kind === 208 /* 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. @@ -51090,7 +51806,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 153 /* Decorator */) { + else if (node.kind === 154 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -51105,7 +51821,7 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 193 /* NewExpression */); + ts.Debug.assert(node.kind === 194 /* NewExpression */); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -51198,7 +51914,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 !== 153 /* Decorator */) { + if (node.kind !== 154 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -51241,7 +51957,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 !== 211 /* OmittedExpression */) { + if (arg.kind !== 212 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -51265,7 +51981,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 arg.kind === 216 /* SyntheticExpression */ ? + return arg.kind === 217 /* SyntheticExpression */ ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0 /* Normal */)); } @@ -51340,12 +52056,12 @@ var ts; if (ts.isJsxOpeningLikeElement(node)) { if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 193 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 194 /* 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. @@ -51355,7 +52071,7 @@ var ts; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; @@ -51363,7 +52079,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 !== 211 /* OmittedExpression */) { + if (arg.kind !== 212 /* 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), @@ -51373,7 +52089,7 @@ var ts; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } } @@ -51383,7 +52099,7 @@ var ts; if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, /*containingMessageChain*/ undefined, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(errorNode, spreadType, restType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } return undefined; @@ -51404,15 +52120,15 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 193 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 190 /* PropertyAccessExpression */ || callee.kind === 191 /* ElementAccessExpression */) { + if (callee.kind === 191 /* PropertyAccessExpression */ || callee.kind === 192 /* ElementAccessExpression */) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(216 /* SyntheticExpression */, parent.pos, parent.end); + var result = ts.createNode(217 /* SyntheticExpression */, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; @@ -51422,17 +52138,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 195 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 207 /* TemplateExpression */) { + if (template.kind === 208 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 153 /* Decorator */) { + if (node.kind === 154 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -51462,30 +52178,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* 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 152 /* Parameter */: + case 153 /* 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 === 158 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 159 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* 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 !== 155 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 156 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -51499,17 +52215,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return 1; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return 2; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* 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 152 /* Parameter */: + case 153 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -51634,8 +52350,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, fallbackError) { - var isTaggedTemplate = node.kind === 194 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 153 /* Decorator */; + var isTaggedTemplate = node.kind === 195 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 154 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; @@ -51697,7 +52413,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 === 192 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 193 /* 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 @@ -52233,8 +52949,8 @@ var ts; if (apparentType.flags & 1048576 /* Union */) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var constituent = types_15[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var constituent = types_14[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -52332,16 +53048,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 152 /* Parameter */: + case 153 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -52385,8 +53101,8 @@ var ts; var exports = namespace && getExportsOfSymbol(namespace); // We fake up a SFC signature for each intrinsic, however a more specific per-element signature drawn from the JSX declaration // file would probably be preferable. - var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 67897832 /* Type */); - var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 67897832 /* Type */, node); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node); var declaration = ts.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.createKeywordTypeNode(121 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; @@ -52434,16 +53150,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 192 /* CallExpression */: + case 193 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 153 /* Decorator */: + case 154 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -52494,43 +53210,45 @@ var ts; return true; // If the symbol of the node has members, treat it like a constructor. var symbol = getSymbolOfNode(func); - return !!symbol && (symbol.members !== undefined || symbol.exports !== undefined && symbol.exports.get("prototype") !== undefined); + return !!symbol && ts.hasEntries(symbol.members); } return false; } - function isJSConstructorType(type) { - if (type.flags & 524288 /* Object */) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); - } - return false; - } - function getJSClassType(symbol) { - var inferred; - if (isJSConstructor(symbol.valueDeclaration)) { - inferred = getInferredClassType(symbol); + function mergeJSSymbols(target, source) { + if (source && (ts.hasEntries(source.exports) || ts.hasEntries(source.members))) { + var links = getSymbolLinks(source); + if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) { + var inferred = isTransientSymbol(target) ? target : cloneSymbol(target); + inferred.exports = inferred.exports || ts.createSymbolTable(); + inferred.members = inferred.members || ts.createSymbolTable(); + inferred.flags |= source.flags & 32 /* Class */; + if (ts.hasEntries(source.exports)) { + mergeSymbolTable(inferred.exports, source.exports); + } + if (ts.hasEntries(source.members)) { + mergeSymbolTable(inferred.members, source.members); + } + (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred); + return inferred; + } + return links.inferredClassSymbol.get("" + getSymbolId(target)); } - var assigned = getAssignedClassType(symbol); - return assigned && inferred ? - getIntersectionType([inferred, assigned]) : - assigned || inferred; } - function getAssignedClassType(symbol) { - var decl = symbol.valueDeclaration; + function getAssignedClassSymbol(decl) { var assignmentSymbol = decl && decl.parent && (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype"); var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration); - return init ? getWidenedType(checkExpressionCached(init)) : undefined; + return init ? getSymbolOfNode(init) : undefined; } function getAssignedJSPrototype(node) { if (!node.parent) { return false; } var parent = node.parent; - while (parent && parent.kind === 190 /* PropertyAccessExpression */) { + while (parent && parent.kind === 191 /* PropertyAccessExpression */) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 60 /* EqualsToken */) { @@ -52538,13 +53256,6 @@ var ts; return ts.isObjectLiteralExpression(right) && right; } } - function getInferredClassType(symbol) { - var links = getSymbolLinks(symbol); - if (!links.inferredClassType) { - links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol) || emptySymbols, ts.emptyArray, ts.emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined); - } - return links.inferredClassType; - } /** * Syntactically and semantically checks a call or new expression. * @param node The call/new expression to be checked. @@ -52562,12 +53273,12 @@ var ts; if (node.expression.kind === 99 /* SuperKeyword */) { return voidType; } - if (node.kind === 193 /* NewExpression */) { + if (node.kind === 194 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 158 /* Constructor */ && - declaration.kind !== 162 /* ConstructSignature */ && - declaration.kind !== 167 /* ConstructorType */ && + declaration.kind !== 159 /* Constructor */ && + declaration.kind !== 163 /* ConstructSignature */ && + declaration.kind !== 168 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -52615,7 +53326,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } function checkImportCallExpression(node) { // Check grammar of dynamic import @@ -52675,7 +53386,7 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } @@ -52684,9 +53395,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 240 /* FunctionDeclaration */ + ? 241 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 238 /* VariableDeclaration */ + ? 239 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -52713,18 +53424,18 @@ var ts; case 9 /* BigIntLiteral */: case 103 /* TrueKeyword */: case 88 /* FalseKeyword */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return true; - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; return op === 39 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || op === 38 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -52774,7 +53485,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 === 158 /* Constructor */) { + else if (container.kind === 159 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -52784,8 +53495,8 @@ var ts; } } function checkImportMetaProperty(node) { - if (languageVersion < 99 /* ESNext */ || moduleKind < ts.ModuleKind.ESNext) { - error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options); + if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) { + error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system); } var file = ts.getSourceFileOfNode(node); ts.Debug.assert(!!(file.flags & 1048576 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); @@ -52975,7 +53686,7 @@ var ts; links.type = contextualType; var decl = parameter.valueDeclaration; if (decl.name.kind !== 73 /* Identifier */) { - // if inference didn't come up with anything but {}, fall back to the binding pattern if present. + // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(decl.name); } @@ -53029,7 +53740,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 219 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 220 /* 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 @@ -53101,7 +53812,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* Next */, func) || unknownType, isAsync); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -53215,14 +53926,14 @@ var ts; if (!node.possiblyExhaustive) { return false; } - if (node.expression.kind === 200 /* TypeOfExpression */) { + if (node.expression.kind === 201 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); // This cast is safe because the switch is possibly exhaustive and does not contain a default case, so there can be no undefined. var witnesses = getSwitchClauseTypeOfWitnesses(node); // notEqualFacts states that the type of the switched value is not equal to every type in the switch. var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true); - var type_5 = getBaseConstraintOfType(operandType) || operandType; - return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); + var type_4 = getBaseConstraintOfType(operandType) || operandType; + return !!(filterType(type_4, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -53238,7 +53949,7 @@ var ts; if (!(func.flags & 128 /* HasImplicitReturn */)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 233 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 234 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -53281,11 +53992,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return true; - case 157 /* MethodDeclaration */: - return func.parent.kind === 189 /* ObjectLiteralExpression */; + case 158 /* MethodDeclaration */: + return func.parent.kind === 190 /* ObjectLiteralExpression */; default: return false; } @@ -53311,7 +54022,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 156 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 219 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 157 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 220 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -53344,7 +54055,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 /* 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)) { @@ -53364,7 +54075,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 197 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 198 /* FunctionExpression */) { checkGrammarForGenerator(node); } var type = getTypeOfSymbol(getMergedSymbol(node.symbol)); @@ -53418,7 +54129,7 @@ var ts; type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -53431,7 +54142,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 219 /* Block */) { + if (node.body.kind === 220 /* Block */) { checkSourceElement(node.body); } else { @@ -53512,11 +54223,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) && + (expr.kind === 191 /* PropertyAccessExpression */ || expr.kind === 192 /* ElementAccessExpression */) && expr.expression.kind === 101 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 158 /* Constructor */)) { + if (!(func && func.kind === 159 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -53529,13 +54240,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) { + if (expr.kind === 191 /* PropertyAccessExpression */ || expr.kind === 192 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); if (node.kind === 73 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 252 /* NamespaceImport */; + return !!declaration && declaration.kind === 253 /* NamespaceImport */; } } } @@ -53544,7 +54255,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 73 /* Identifier */ && node.kind !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 73 /* Identifier */ && node.kind !== 191 /* PropertyAccessExpression */ && node.kind !== 192 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -53553,7 +54264,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 190 /* PropertyAccessExpression */ && expr.kind !== 191 /* ElementAccessExpression */) { + if (expr.kind !== 191 /* PropertyAccessExpression */ && expr.kind !== 192 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -53582,7 +54293,7 @@ var ts; var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); var func = ts.getContainingFunction(node); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 159 /* 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); @@ -53595,7 +54306,11 @@ var ts; } } var operandType = checkExpression(node.expression); - return checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + var awaitedType = checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + if (awaitedType === operandType && awaitedType !== errorType && !(operandType.flags & 3 /* AnyOrUnknown */)) { + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); + } + return awaitedType; } function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); @@ -53629,7 +54344,7 @@ var ts; } if (node.operator === 38 /* PlusToken */) { if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { - error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(operandType)); + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } @@ -53680,8 +54395,8 @@ var ts; } if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -53770,7 +54485,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 276 /* PropertyAssignment */ || property.kind === 277 /* ShorthandPropertyAssignment */) { + if (property.kind === 277 /* PropertyAssignment */ || property.kind === 278 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -53783,9 +54498,9 @@ var ts; } var elementType = getIndexedAccessType(objectLiteralType, exprType, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 277 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 278 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 278 /* SpreadAssignment */) { + else if (property.kind === 279 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -53828,8 +54543,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 211 /* OmittedExpression */) { - if (element.kind !== 209 /* SpreadElement */) { + if (element.kind !== 212 /* OmittedExpression */) { + if (element.kind !== 210 /* SpreadElement */) { var indexType = getLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused @@ -53847,7 +54562,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 205 /* BinaryExpression */ && restExpression.operatorToken.kind === 60 /* EqualsToken */) { + if (restExpression.kind === 206 /* BinaryExpression */ && restExpression.operatorToken.kind === 60 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -53863,7 +54578,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 277 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 278 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -53879,21 +54594,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 205 /* BinaryExpression */ && target.operatorToken.kind === 60 /* EqualsToken */) { + if (target.kind === 206 /* BinaryExpression */ && target.operatorToken.kind === 60 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 189 /* ObjectLiteralExpression */) { + if (target.kind === 190 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 188 /* ArrayLiteralExpression */) { + if (target.kind === 189 /* 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 === 278 /* SpreadAssignment */ ? + var error = target.parent.kind === 279 /* 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; if (checkReferenceExpression(target, error)) { @@ -53915,8 +54630,8 @@ var ts; case 73 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 194 /* TaggedTemplateExpression */: - case 207 /* TemplateExpression */: + case 195 /* TaggedTemplateExpression */: + case 208 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: @@ -53924,27 +54639,27 @@ var ts; case 88 /* FalseKeyword */: case 97 /* NullKeyword */: case 142 /* UndefinedKeyword */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 200 /* TypeOfExpression */: - case 214 /* NonNullExpression */: - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: + case 198 /* FunctionExpression */: + case 211 /* ClassExpression */: + case 199 /* ArrowFunction */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: + case 201 /* TypeOfExpression */: + case 215 /* NonNullExpression */: + case 263 /* JsxSelfClosingElement */: + case 262 /* JsxElement */: return true; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -53956,9 +54671,9 @@ var ts; } return false; // Some forms listed here for clarity - case 201 /* VoidExpression */: // Explicit opt-out - case 195 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 213 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 202 /* VoidExpression */: // Explicit opt-out + case 196 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 214 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -53974,7 +54689,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 60 /* EqualsToken */ && (left.kind === 189 /* ObjectLiteralExpression */ || left.kind === 188 /* ArrayLiteralExpression */)) { + if (operator === 60 /* EqualsToken */ && (left.kind === 190 /* ObjectLiteralExpression */ || left.kind === 189 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 101 /* ThisKeyword */); } var leftType; @@ -54034,7 +54749,7 @@ var ts; resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */)) { + else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { case 48 /* GreaterThanGreaterThanGreaterThanToken */: case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: @@ -54044,7 +54759,7 @@ var ts; } // Exactly one of leftType/rightType is assignable to bigint else { - reportOperatorError(function (awaitedLeft, awaitedRight) { return isTypeAssignableToKind(awaitedLeft, 2112 /* BigIntLike */) && isTypeAssignableToKind(awaitedRight, 2112 /* BigIntLike */); }); + reportOperatorError(bothAreBigIntLike); resultType_1 = errorType; } if (leftOk && rightOk) { @@ -54090,9 +54805,9 @@ var ts; // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 3 /* AnyOrUnknown */; - reportOperatorError(function (awaitedLeft, awaitedRight) { - return isTypeAssignableToKind(awaitedLeft, closeEnoughKind_1) && - isTypeAssignableToKind(awaitedRight, closeEnoughKind_1); + reportOperatorError(function (left, right) { + return isTypeAssignableToKind(left, closeEnoughKind_1) && + isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } @@ -54157,6 +54872,9 @@ var ts; default: return ts.Debug.fail(); } + function bothAreBigIntLike(left, right) { + return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + } function checkAssignmentDeclaration(kind, rightType) { if (kind === 2 /* ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { @@ -54164,7 +54882,7 @@ var ts; var propType = getTypeOfSymbol(prop); if (propType.symbol && propType.symbol.flags & 32 /* Class */) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 67897832 /* Type */, undefined, name, /*isUse*/ false); + var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) { grammarErrorOnNode(symbol.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); return grammarErrorOnNode(prop.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); @@ -54244,17 +54962,23 @@ var ts; } return false; } - function reportOperatorError(awaitedTypesAreCompatible) { + function reportOperatorError(isRelated) { + var _a; var wouldWorkWithAwait = false; var errNode = errorNode || operatorToken; - var _a = getTypeNamesForErrorDisplay(leftType, rightType), leftStr = _a[0], rightStr = _a[1]; - if (awaitedTypesAreCompatible) { + if (isRelated) { var awaitedLeftType = getAwaitedType(leftType); var awaitedRightType = getAwaitedType(rightType); wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType) && !!(awaitedLeftType && awaitedRightType) - && awaitedTypesAreCompatible(awaitedLeftType, awaitedRightType); + && isRelated(awaitedLeftType, awaitedRightType); } + var effectiveLeft = leftType; + var effectiveRight = rightType; + if (!wouldWorkWithAwait && isRelated) { + _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1]; + } + var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1]; if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) { errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); } @@ -54276,6 +55000,17 @@ var ts; return undefined; } } + function getBaseTypesIfUnrelated(leftType, rightType, isRelated) { + var effectiveLeft = leftType; + var effectiveRight = rightType; + var leftBase = getBaseTypeOfLiteralType(leftType); + var rightBase = getBaseTypeOfLiteralType(rightType); + if (!isRelated(leftBase, rightBase)) { + effectiveLeft = leftBase; + effectiveRight = rightBase; + } + return [effectiveLeft, effectiveRight]; + } function isYieldExpressionInClass(node) { var current = node; var parent = node.parent; @@ -54343,12 +55078,7 @@ var ts; return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync) || anyType; } - var contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, contextualReturnType, isAsync) - || anyType; - } - return anyType; + return getContextualIterationType(2 /* Next */, func) || anyType; } function checkConditionalExpression(node, checkMode) { checkTruthinessExpression(node.condition); @@ -54370,7 +55100,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 269 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 270 /* 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; @@ -54409,12 +55139,12 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 195 /* TypeAssertionExpression */ || node.kind === 213 /* AsExpression */; + return node.kind === 196 /* TypeAssertionExpression */ || node.kind === 214 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, /*cache*/ true); - var padded = ts.isParameter(declaration) && declaration.name.kind === 186 /* ArrayBindingPattern */ && + var padded = ts.isParameter(declaration) && declaration.name.kind === 187 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || @@ -54439,7 +55169,7 @@ var ts; var elementTypes = arity ? type.typeArguments.slice() : []; for (var i = arity; i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 187 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 188 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); @@ -54491,7 +55221,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -54502,7 +55232,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -54645,7 +55375,7 @@ var ts; var expr = ts.skipParentheses(node); // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (expr.kind === 192 /* CallExpression */ && expr.expression.kind !== 99 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (expr.kind === 193 /* CallExpression */ && expr.expression.kind !== 99 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var funcType = checkNonNullExpression(expr.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -54695,10 +55425,11 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 191 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 168 /* TypeQuery */ && node.parent.exprName === node)); + var ok = (node.parent.kind === 191 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 192 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 73 /* Identifier */ || node.kind === 150 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 169 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 259 /* ExportSpecifier */ && (compilerOptions.preserveConstEnums || node.flags & 4194304 /* Ambient */)); // 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); } @@ -54718,7 +55449,18 @@ var ts; return checkExpression(node.expression, checkMode); } function checkExpressionWorker(node, checkMode, forceTuple) { - switch (node.kind) { + var kind = node.kind; + if (cancellationToken) { + // 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 211 /* ClassExpression */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + cancellationToken.throwIfCancellationRequested(); + } + } + switch (kind) { case 73 /* Identifier */: return checkIdentifier(node); case 101 /* ThisKeyword */: @@ -54740,78 +55482,78 @@ var ts; return trueType; case 88 /* FalseKeyword */: return falseType; - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return checkQualifiedName(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (node.expression.kind === 93 /* ImportKeyword */) { return checkImportCallExpression(node); } - /* falls through */ - case 193 /* NewExpression */: + // falls through + case 194 /* NewExpression */: return checkCallExpression(node, checkMode); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return checkClassExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: return checkAssertion(node); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: return checkNonNullAssertion(node); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return checkMetaProperty(node); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return checkDeleteExpression(node); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return checkVoidExpression(node); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return checkAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 211 /* OmittedExpression */: + case 212 /* OmittedExpression */: return undefinedWideningType; - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return checkYieldExpression(node); - case 216 /* SyntheticExpression */: + case 217 /* SyntheticExpression */: return node.type; - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 261 /* JsxElement */: + case 262 /* JsxElement */: return checkJsxElement(node, checkMode); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return checkJsxFragment(node); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 263 /* JsxOpeningElement */: + case 264 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -54848,7 +55590,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 158 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 159 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -54859,10 +55601,10 @@ 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 === 158 /* Constructor */ || func.kind === 162 /* ConstructSignature */ || func.kind === 167 /* ConstructorType */) { + if (func.kind === 159 /* Constructor */ || func.kind === 163 /* ConstructSignature */ || func.kind === 168 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 199 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -54918,13 +55660,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 198 /* ArrowFunction */: - case 161 /* CallSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 166 /* FunctionType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 199 /* ArrowFunction */: + case 162 /* CallSignature */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 167 /* FunctionType */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -54942,7 +55684,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 === 186 /* ArrayBindingPattern */ || name.kind === 185 /* ObjectBindingPattern */) { + else if (name.kind === 187 /* ArrayBindingPattern */ || name.kind === 186 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -54951,13 +55693,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 164 /* 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 === 166 /* FunctionType */ || node.kind === 240 /* FunctionDeclaration */ || node.kind === 167 /* ConstructorType */ || - node.kind === 161 /* CallSignature */ || node.kind === 158 /* Constructor */ || - node.kind === 162 /* ConstructSignature */) { + else if (node.kind === 167 /* FunctionType */ || node.kind === 241 /* FunctionDeclaration */ || node.kind === 168 /* ConstructorType */ || + node.kind === 162 /* CallSignature */ || node.kind === 159 /* Constructor */ || + node.kind === 163 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -54987,10 +55729,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 161 /* CallSignature */: + case 162 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -55020,28 +55762,21 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 163 /* IndexSignature */ && node.kind !== 295 /* JSDocFunctionType */) { + if (node.kind !== 164 /* IndexSignature */ && node.kind !== 296 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } } function checkClassForDuplicateDeclarations(node) { - var Declaration; - (function (Declaration) { - Declaration[Declaration["Getter"] = 1] = "Getter"; - Declaration[Declaration["Setter"] = 2] = "Setter"; - Declaration[Declaration["Method"] = 4] = "Method"; - Declaration[Declaration["Property"] = 3] = "Property"; - })(Declaration || (Declaration = {})); var instanceNames = ts.createUnderscoreEscapedMap(); var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 158 /* Constructor */) { + if (member.kind === 159 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; - if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { - addName(instanceNames, param.name, param.name.escapedText, 3 /* Property */); + if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { + addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); } } } @@ -55052,17 +55787,17 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 159 /* GetAccessor */: - addName(names, name, memberName, 1 /* Getter */); + case 160 /* GetAccessor */: + addName(names, name, memberName, 1 /* GetAccessor */); break; - case 160 /* SetAccessor */: - addName(names, name, memberName, 2 /* Setter */); + case 161 /* SetAccessor */: + addName(names, name, memberName, 2 /* SetAccessor */); break; - case 155 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* Property */); + case 156 /* PropertyDeclaration */: + addName(names, name, memberName, 3 /* GetOrSetAccessor */); break; - case 157 /* MethodDeclaration */: - addName(names, name, memberName, 4 /* Method */); + case 158 /* MethodDeclaration */: + addName(names, name, memberName, 8 /* Method */); break; } } @@ -55071,8 +55806,8 @@ var ts; function addName(names, location, name, meaning) { var prev = names.get(name); if (prev) { - if (prev & 4 /* Method */) { - if (meaning !== 4 /* Method */) { + if (prev & 8 /* Method */) { + if (meaning !== 8 /* Method */) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } } @@ -55124,7 +55859,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154 /* PropertySignature */) { + if (member.kind === 155 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -55149,7 +55884,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 243 /* 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 @@ -55204,7 +55939,7 @@ var ts; 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.hasModifier(node, 128 /* Abstract */) && node.kind === 157 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 158 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -55229,7 +55964,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 155 /* PropertyDeclaration */ && + return n.kind === 156 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -55259,7 +55994,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 223 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -55284,7 +56019,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 160 /* GetAccessor */) { if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -55294,13 +56029,13 @@ 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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(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 === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = node.kind === 160 /* GetAccessor */ ? 161 /* SetAccessor */ : 160 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -55318,7 +56053,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 160 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -55366,7 +56101,7 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 165 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 166 /* 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); } var type = getTypeFromTypeReference(node); @@ -55414,7 +56149,7 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 173 /* RestType */) { + if (e.kind === 174 /* RestType */) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; @@ -55423,7 +56158,7 @@ var ts; error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 172 /* OptionalType */) { + else if (e.kind === 173 /* OptionalType */) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -55444,7 +56179,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 191 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 192 /* 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)); } @@ -55495,7 +56230,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 176 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 177 /* 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); @@ -55512,9 +56247,9 @@ var ts; var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 242 /* InterfaceDeclaration */ && - n.parent.kind !== 241 /* ClassDeclaration */ && - n.parent.kind !== 210 /* ClassExpression */ && + if (n.parent.kind !== 243 /* InterfaceDeclaration */ && + n.parent.kind !== 242 /* ClassDeclaration */ && + n.parent.kind !== 211 /* ClassExpression */ && n.flags & 4194304 /* 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 @@ -55605,7 +56340,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */) && + var reportError = (node.kind === 158 /* MethodDeclaration */ || node.kind === 157 /* MethodSignature */) && ts.hasModifier(node, 32 /* Static */) !== ts.hasModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -55640,11 +56375,12 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; + var hasNonAmbientClass = false; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 242 /* InterfaceDeclaration */ || node.parent.kind === 169 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 243 /* InterfaceDeclaration */ || node.parent.kind === 170 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -55655,7 +56391,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 240 /* FunctionDeclaration */ || node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */ || node.kind === 158 /* Constructor */) { + if ((node.kind === 242 /* ClassDeclaration */ || node.kind === 211 /* ClassExpression */) && !inAmbientContext) { + hasNonAmbientClass = true; + } + if (node.kind === 241 /* FunctionDeclaration */ || node.kind === 158 /* MethodDeclaration */ || node.kind === 157 /* MethodSignature */ || node.kind === 159 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -55696,6 +56435,15 @@ var ts; error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Duplicate_function_implementation); }); } + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */) { + // A non-ambient class cannot be an implementation for a non-constructor function/class merge + // TODO: The below just replicates our older error from when classes and functions were + // entirely unable to merge - a more helpful message like "Class declaration cannot implement overload list" + // might be warranted. :shrug: + ts.forEach(declarations, function (declaration) { + addDuplicateDeclarationError(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), ts.filter(declarations, function (d) { return d !== declaration; })); + }); + } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && !ts.hasModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { @@ -55717,13 +56465,6 @@ var ts; } } } - var DeclarationSpaces; - (function (DeclarationSpaces) { - DeclarationSpaces[DeclarationSpaces["None"] = 0] = "None"; - DeclarationSpaces[DeclarationSpaces["ExportValue"] = 1] = "ExportValue"; - DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; - DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; - })(DeclarationSpaces || (DeclarationSpaces = {})); function checkExportsOnMergedDeclarations(node) { if (!produceDiagnostics) { return; @@ -55784,40 +56525,42 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - // A jsdoc typedef and callback are, by definition, type aliases - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + // A jsdoc typedef and callback are, by definition, type aliases. + // falls through + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: return 2 /* ExportType */; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 285 /* SourceFile */: + case 286 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; } d = d.expression; - /* falls through */ - // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + // The below options all declare an Alias, which is allowed to merge with other values within the importing module. + // falls through + case 250 /* ImportEqualsDeclaration */: + case 253 /* NamespaceImport */: + case 252 /* ImportClause */: var result_8 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_8 |= getDeclarationSpaces(d); }); return result_8; - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 240 /* FunctionDeclaration */: - case 254 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 239 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 241 /* FunctionDeclaration */: + case 255 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); @@ -55886,9 +56629,6 @@ var ts; */ function checkAwaitedType(type, errorNode, diagnosticMessage, arg0) { var awaitedType = getAwaitedType(type, errorNode, diagnosticMessage, arg0); - if (awaitedType === type && !(type.flags & 3 /* AnyOrUnknown */)) { - addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(errorNode, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); - } return awaitedType || errorType; } function getAwaitedType(type, errorNode, diagnosticMessage, arg0) { @@ -56047,7 +56787,7 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67220415 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { if (promiseConstructorName.kind === 73 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { @@ -56070,7 +56810,7 @@ var ts; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 67220415 /* Value */); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -56089,24 +56829,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 152 /* Parameter */: + case 153 /* 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 155 /* PropertyDeclaration */: + case 156 /* 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 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -56127,7 +56867,7 @@ var ts; if (!typeName) return; var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 73 /* Identifier */ ? 67897832 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 73 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -56152,23 +56892,23 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 176 /* IntersectionType */: + case 175 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return node.typeName; } } } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var typeNode = types_17[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var typeNode = types_16[_i]; + while (typeNode.kind === 179 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 133 /* NeverKeyword */) { @@ -56220,14 +56960,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 152 /* Parameter */) { + if (node.kind === 153 /* 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 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -56236,23 +56976,23 @@ var ts; } } break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - var otherKind = node.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + var otherKind = node.kind === 160 /* GetAccessor */ ? 161 /* SetAccessor */ : 160 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 157 /* MethodDeclaration */: + case 158 /* 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 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 152 /* Parameter */: + case 153 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -56315,7 +57055,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 === 149 /* 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 === 150 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -56350,7 +57090,7 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return node; - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -56363,7 +57103,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 151 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -56392,7 +57132,7 @@ var ts; } } } - var body = node.kind === 156 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 157 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -56434,42 +57174,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 285 /* SourceFile */: - case 245 /* ModuleDeclaration */: - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 286 /* SourceFile */: + case 246 /* ModuleDeclaration */: + case 220 /* Block */: + case 248 /* CaseBlock */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 159 /* Constructor */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 177 /* InferType */: + case 178 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -56489,11 +57229,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 157 /* MethodDeclaration */: - case 155 /* PropertyDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - if (member.kind === 160 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 158 /* MethodDeclaration */: + case 156 /* PropertyDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + if (member.kind === 161 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -56502,7 +57242,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 158 /* Constructor */: + case 159 /* Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { @@ -56510,8 +57250,8 @@ var ts; } } break; - case 163 /* IndexSignature */: - case 218 /* SemicolonClassElement */: + case 164 /* IndexSignature */: + case 219 /* SemicolonClassElement */: // Can't be private break; default: @@ -56538,7 +57278,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 177 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 178 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) // Whole @template tag @@ -56608,7 +57348,7 @@ var ts; var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -56623,7 +57363,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 252 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 253 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -56641,7 +57381,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 === 238 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 239 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 239 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 240 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -56662,7 +57402,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 === 220 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 221 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -56676,22 +57416,22 @@ var ts; switch (name.kind) { case 73 /* Identifier */: return ts.idText(name); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 251 /* ImportClause */ || node.kind === 254 /* ImportSpecifier */ || node.kind === 252 /* NamespaceImport */; + return node.kind === 252 /* ImportClause */ || node.kind === 255 /* ImportSpecifier */ || node.kind === 253 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 251 /* ImportClause */ ? decl : decl.kind === 252 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 252 /* ImportClause */ ? decl : decl.kind === 253 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 219 /* Block */) { + if (node.kind === 220 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -56721,12 +57461,12 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 155 /* PropertyDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 157 /* MethodDeclaration */ || - node.kind === 156 /* MethodSignature */ || - node.kind === 159 /* GetAccessor */ || - node.kind === 160 /* SetAccessor */) { + if (node.kind === 156 /* PropertyDeclaration */ || + node.kind === 155 /* PropertySignature */ || + node.kind === 158 /* MethodDeclaration */ || + node.kind === 157 /* MethodSignature */ || + node.kind === 160 /* GetAccessor */ || + node.kind === 161 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -56735,7 +57475,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 152 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 153 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -56786,7 +57526,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 === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 286 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -56801,7 +57541,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 === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 286 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(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)); } @@ -56836,7 +57576,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 === 238 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 239 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -56848,17 +57588,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 239 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 220 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 240 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 221 /* 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 === 219 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 246 /* ModuleBlock */ || - container.kind === 245 /* ModuleDeclaration */ || - container.kind === 285 /* SourceFile */); + (container.kind === 220 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 247 /* ModuleBlock */ || + container.kind === 246 /* ModuleDeclaration */ || + container.kind === 286 /* 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 @@ -56888,18 +57628,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 187 /* BindingElement */) { - if (node.parent.kind === 185 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (node.kind === 188 /* BindingElement */) { + if (node.parent.kind === 186 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 150 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -56920,19 +57660,19 @@ var ts; } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 186 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 187 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 152 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 153 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 227 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 228 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -56969,7 +57709,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 227 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 228 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -56995,10 +57735,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */) { + if (node.kind !== 156 /* PropertyDeclaration */ && node.kind !== 155 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 239 /* VariableDeclaration */ || node.kind === 188 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -57007,7 +57747,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 155 /* PropertyDeclaration */ || nextDeclaration.kind === 154 /* PropertySignature */ + var message = nextDeclaration.kind === 156 /* PropertyDeclaration */ || nextDeclaration.kind === 155 /* 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); @@ -57017,8 +57757,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 152 /* Parameter */ && right.kind === 238 /* VariableDeclaration */) || - (left.kind === 238 /* VariableDeclaration */ && right.kind === 152 /* Parameter */)) { + if ((left.kind === 153 /* Parameter */ && right.kind === 239 /* VariableDeclaration */) || + (left.kind === 239 /* VariableDeclaration */ && right.kind === 153 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -57057,7 +57797,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkTruthinessExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 221 /* EmptyStatement */) { + if (node.thenStatement.kind === 222 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -57084,12 +57824,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 240 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 240 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -57123,14 +57863,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 === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 240 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 189 /* ArrayLiteralExpression */ || varExpr.kind === 190 /* 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. @@ -57162,7 +57902,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 === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 240 /* 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); @@ -57176,7 +57916,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 === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 189 /* ArrayLiteralExpression */ || varExpr.kind === 190 /* 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)) { @@ -57840,12 +58580,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 === 160 /* SetAccessor */) { + if (func.kind === 161 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 158 /* Constructor */) { + else if (func.kind === 159 /* 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); } @@ -57863,7 +58603,7 @@ var ts; } } } - else if (func.kind !== 158 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 159 /* 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); } @@ -57892,7 +58632,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 === 273 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 274 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -57904,7 +58644,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 272 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 273 /* 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. @@ -57933,7 +58673,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 234 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 235 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -58040,8 +58780,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 === 205 /* BinaryExpression */ || - name.kind === 150 /* ComputedPropertyName */ || + (propDeclaration.kind === 206 /* BinaryExpression */ || + name.kind === 151 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -58118,7 +58858,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 165 /* TypeReference */) { + if (node.kind === 166 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -58367,7 +59107,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 241 /* ClassDeclaration */ || d.kind === 242 /* InterfaceDeclaration */; + return d.kind === 242 /* ClassDeclaration */ || d.kind === 243 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -58386,7 +59126,7 @@ var ts; // derived class instance member variables and accessors, but not by other kinds of members. // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfType(baseType); - for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { + basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); if (base.flags & 4194304 /* Prototype */) { @@ -58395,53 +59135,64 @@ var ts; var derived = getTargetSymbol(getPropertyOfObjectType(type, base.escapedName)); // TODO: GH#18217 var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base); ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); - if (derived) { - // In order to resolve whether the inherited method was overridden in the base class or not, - // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* - // type declaration, derived and base resolve to the same symbol even in the case of generic classes. - if (derived === base) { - // derived class inherits base without override/redeclaration - var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); - // It is an error to inherit an abstract member without implementing it or being declared abstract. - // If there is no declaration for the derived class (as in the case of class expressions), - // then the class cannot be declared abstract. - if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 210 /* ClassExpression */) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); - } - else { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + // In order to resolve whether the inherited method was overridden in the base class or not, + // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* + // type declaration, derived and base resolve to the same symbol even in the case of generic classes. + if (derived === base) { + // derived class inherits base without override/redeclaration + var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); + // It is an error to inherit an abstract member without implementing it or being declared abstract. + // If there is no declaration for the derived class (as in the case of class expressions), + // then the class cannot be declared abstract. + if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { + // 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]; + if (otherBaseType === baseType) + continue; + var baseSymbol = getPropertyOfObjectType(otherBaseType, base.escapedName); + var derivedElsewhere = baseSymbol && getTargetSymbol(baseSymbol); + if (derivedElsewhere && derivedElsewhere !== base) { + continue basePropertyCheck; } } - } - else { - // derived overrides base. - var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { - // either base or derived property is private - not override, skip it - continue; - } - if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; + if (derivedClassDecl.kind === 211 /* ClassExpression */) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } - var errorMessage = void 0; - if (isPrototypeProperty(base)) { - if (derived.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } - else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); } - else if (base.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + } + else { + // derived overrides base. + var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); + if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + // either base or derived property is private - not override, skip it + continue; + } + if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { + // method is overridden with method or property/accessor is overridden with property/accessor - correct case + continue; + } + var errorMessage = void 0; + if (isPrototypeProperty(base)) { + if (derived.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } - error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } + else if (base.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } @@ -58498,7 +59249,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 155 /* PropertyDeclaration */ && + return node.kind === 156 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -58522,7 +59273,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 243 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -58627,7 +59378,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -58637,7 +59388,7 @@ var ts; } } break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -58665,7 +59416,7 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return evaluate(expr.expression); case 73 /* Identifier */: var identifier = expr; @@ -58673,20 +59424,18 @@ var ts; return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: + case 191 /* 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 === 190 /* PropertyAccessExpression */) { + if (ex.kind === 191 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { - var argument = ex.argumentExpression; - ts.Debug.assert(ts.isLiteralExpression(argument)); - name = ts.escapeLeadingUnderscores(argument.text); + name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text); } return evaluateEnumMember(expr, type.symbol, name); } @@ -58712,8 +59461,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 73 /* Identifier */ || - node.kind === 190 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 191 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.kind === 191 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 192 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && node.argumentExpression.kind === 10 /* StringLiteral */; } function checkEnumDeclaration(node) { @@ -58748,7 +59497,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 !== 244 /* EnumDeclaration */) { + if (declaration.kind !== 245 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -58771,8 +59520,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 241 /* ClassDeclaration */ || - (declaration.kind === 240 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 242 /* ClassDeclaration */ || + (declaration.kind === 241 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304 /* Ambient */)) { return declaration; } @@ -58835,7 +59584,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, 241 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 242 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -58885,23 +59634,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* 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]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 256 /* ExportAssignment */: + case 257 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 239 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -58912,12 +59661,12 @@ var ts; break; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 240 /* FunctionDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 241 /* FunctionDeclaration */: + case 243 /* InterfaceDeclaration */: + case 246 /* ModuleDeclaration */: + case 244 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -58940,12 +59689,12 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return node; - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: do { node = node.left; } while (node.kind !== 73 /* Identifier */); return node; - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 73 /* Identifier */); @@ -58962,9 +59711,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 256 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 247 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 286 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 257 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -58986,26 +59735,27 @@ var ts; function checkAliasSymbol(node) { var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); - if (target !== unknownSymbol) { - // For external modules symbol represent local symbol for an alias. + var shouldSkipWithJSExpandoTargets = symbol.flags & 67108864 /* Assignment */; + if (!shouldSkipWithJSExpandoTargets && target !== unknownSymbol) { + // For external modules symbol represents local symbol for an alias. // This local symbol will merge any other local declarations (excluding other aliases) // and symbol.flags will contains combined representation for all merged declaration. // Based on symbol.flags we can compute a set of excluded meanings (meaning that resolved alias should not have, // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export* // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). - var excludedMeanings = (symbol.flags & (67220415 /* Value */ | 1048576 /* ExportValue */) ? 67220415 /* Value */ : 0) | - (symbol.flags & 67897832 /* Type */ ? 67897832 /* Type */ : 0) | + var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | + (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 258 /* ExportSpecifier */ ? + var message = node.kind === 259 /* 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 === 258 /* ExportSpecifier */ - && !(target.flags & 67220415 /* Value */) + && node.kind === 259 /* ExportSpecifier */ + && !(target.flags & 111551 /* Value */) && !(node.flags & 4194304 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); } @@ -59031,7 +59781,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 253 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -59055,17 +59805,17 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 261 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 67220415 /* Value */) { + if (target.flags & 111551 /* Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name var moduleName = getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 67220415 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { + if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 67897832 /* Type */) { + if (target.flags & 788968 /* Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } @@ -59091,10 +59841,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 246 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 247 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 247 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 286 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -59111,7 +59861,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 285 /* SourceFile */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 245 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 286 /* SourceFile */ || node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 246 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -59125,13 +59875,17 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) - var symbol = resolveName(exportedName, exportedName.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || 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 { markExportAsReferenced(node); + var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) { + checkExpressionCached(node.propertyName || node.name); + } } } } @@ -59140,8 +59894,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 286 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 246 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -59155,7 +59909,17 @@ var ts; grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 73 /* Identifier */) { - markExportAsReferenced(node); + var id = node.expression; + var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); + if (sym) { + markAliasReferenced(sym, id); + // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`) + var target = sym.flags & 2097152 /* Alias */ ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551 /* Value */) { + // However if it is a value, we need to check it's being used correctly + checkExpressionCached(node.expression); + } + } if (ts.getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression, /*setVisibility*/ true); } @@ -59224,14 +59988,6 @@ var ts; links.exportsChecked = true; } } - function isNotAccessor(declaration) { - // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks - return !ts.isAccessor(declaration); - } - function isNotOverload(declaration) { - return (declaration.kind !== 240 /* FunctionDeclaration */ && declaration.kind !== 157 /* MethodDeclaration */) || - !!declaration.body; - } function checkSourceElement(node) { if (node) { var saveCurrentNode = currentNode; @@ -59253,158 +60009,159 @@ 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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 241 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return checkTypeParameter(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return checkParameter(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return checkPropertyDeclaration(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: return checkSignatureDeclaration(node); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: return checkMethodDeclaration(node); - case 158 /* Constructor */: + case 159 /* Constructor */: return checkConstructorDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return checkAccessorDeclaration(node); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return checkTypeReferenceNode(node); - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return checkTypePredicate(node); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return checkTypeQuery(node); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return checkTypeLiteral(node); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return checkArrayType(node); - case 171 /* TupleType */: + case 172 /* TupleType */: return checkTupleType(node); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 178 /* ParenthesizedType */: - case 172 /* OptionalType */: - case 173 /* RestType */: + case 179 /* ParenthesizedType */: + case 173 /* OptionalType */: + case 174 /* RestType */: return checkSourceElement(node.type); - case 179 /* ThisType */: + case 180 /* ThisType */: return checkThisType(node); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: return checkTypeOperator(node); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return checkConditionalType(node); - case 177 /* InferType */: + case 178 /* InferType */: return checkInferType(node); - case 184 /* ImportType */: + case 185 /* ImportType */: return checkImportType(node); - case 301 /* JSDocAugmentsTag */: + case 303 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 309 /* JSDocTypeTag */: + case 311 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 306 /* JSDocParameterTag */: + case 308 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: - case 298 /* JSDocTypeLiteral */: + case 294 /* JSDocNonNullableType */: + case 293 /* JSDocNullableType */: + case 291 /* JSDocAllType */: + case 292 /* JSDocUnknownType */: + case 300 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 296 /* JSDocVariadicType */: + case 297 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 289 /* JSDocTypeExpression */: + case 290 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 182 /* MappedType */: + case 183 /* MappedType */: return checkMappedType(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 220 /* Block */: + case 247 /* ModuleBlock */: return checkBlock(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return checkVariableStatement(node); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return checkExpressionStatement(node); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return checkIfStatement(node); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return checkDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return checkWhileStatement(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return checkForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return checkForInStatement(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return checkForOfStatement(node); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 230 /* ContinueStatement */: + case 231 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return checkReturnStatement(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return checkWithStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return checkSwitchStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return checkLabeledStatement(node); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return checkThrowStatement(node); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return checkTryStatement(node); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return checkBindingElement(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return checkClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return checkImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return checkExportDeclaration(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return checkExportAssignment(node); - case 221 /* EmptyStatement */: - case 237 /* DebuggerStatement */: + case 222 /* EmptyStatement */: + case 238 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 259 /* MissingDeclaration */: + case 260 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -59499,23 +60256,23 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 261 /* JsxElement */: + case 262 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -59645,35 +60402,35 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; // falls through - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - // falls through // this fall-through is necessary because we would like to handle - // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. + // falls through + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!isStatic) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67897832 /* Type */); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -59721,11 +60478,11 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 151 /* TypeParameter */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 152 /* TypeParameter */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 245 /* EnumDeclaration */: return true; default: return false; @@ -59733,16 +60490,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 150 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 165 /* TypeReference */; + return node.parent.kind === 166 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 190 /* PropertyAccessExpression */) { + while (node.parent.kind === 191 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 212 /* ExpressionWithTypeArguments */; + return node.parent.kind === 213 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -59770,13 +60527,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 149 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 150 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 249 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 250 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 255 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 256 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -59802,7 +60559,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 184 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 185 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -59812,7 +60569,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 190 /* PropertyAccessExpression */ && + entityName.parent.kind === 191 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -59820,17 +60577,17 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 255 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 256 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, - /*all meanings*/ 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); + /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); if (success && success !== unknownSymbol) { return success; } } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 249 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 250 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -59848,11 +60605,11 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 212 /* ExpressionWithTypeArguments */) { - meaning = 67897832 /* Type */; + if (entityName.parent.kind === 213 /* ExpressionWithTypeArguments */) { + meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { - meaning |= 67220415 /* Value */; + meaning |= 111551 /* Value */; } } else { @@ -59864,10 +60621,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 306 /* JSDocParameterTag */) { + if (entityName.parent.kind === 308 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 151 /* TypeParameter */ && entityName.parent.parent.kind === 310 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 152 /* TypeParameter */ && entityName.parent.parent.kind === 312 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -59882,14 +60639,14 @@ var ts; var symbol = getIntrinsicTagSymbol(entityName.parent); return symbol === unknownSymbol ? undefined : symbol; } - return resolveEntityName(entityName, 67220415 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); + return resolveEntityName(entityName, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 190 /* PropertyAccessExpression */ || entityName.kind === 149 /* QualifiedName */) { + else if (entityName.kind === 191 /* PropertyAccessExpression */ || entityName.kind === 150 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 190 /* PropertyAccessExpression */) { + if (entityName.kind === 191 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -59899,17 +60656,17 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 165 /* TypeReference */ ? 67897832 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 166 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - if (entityName.parent.kind === 164 /* TypePredicate */) { + if (entityName.parent.kind === 165 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -59932,8 +60689,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 187 /* BindingElement */ && - grandParent.kind === 185 /* ObjectBindingPattern */ && + else if (parent.kind === 188 /* BindingElement */ && + grandParent.kind === 186 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -59944,8 +60701,8 @@ var ts; } switch (node.kind) { case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 191 /* PropertyAccessExpression */: + case 150 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 101 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); @@ -59959,14 +60716,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 179 /* ThisType */: + case 180 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; case 99 /* SuperKeyword */: return checkExpression(node).symbol; case 125 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 158 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 159 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -59977,7 +60734,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 === 250 /* ImportDeclaration */ || node.parent.kind === 256 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 251 /* ImportDeclaration */ || node.parent.kind === 257 /* 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); @@ -59999,7 +60756,7 @@ var ts; case 37 /* EqualsGreaterThanToken */: case 77 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 184 /* ImportType */: + case 185 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; case 86 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; @@ -60008,8 +60765,8 @@ var ts; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 277 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 67220415 /* Value */ | 2097152 /* Alias */); + if (location && location.kind === 278 /* ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; } @@ -60017,7 +60774,7 @@ var ts; function getExportSpecifierLocalTargetSymbol(node) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } function getTypeOfNode(node) { if (node.flags & 8388608 /* InWithStatement */) { @@ -60076,27 +60833,27 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 189 /* ObjectLiteralExpression */ || expr.kind === 188 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 190 /* ObjectLiteralExpression */ || expr.kind === 189 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 228 /* ForOfStatement */) { + if (expr.parent.kind === 229 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 205 /* BinaryExpression */) { + if (expr.parent.kind === 206 /* 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 === 276 /* 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); + if (expr.parent.kind === 277 /* PropertyAssignment */) { + var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); + var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType; + var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex); } // Array literal assignment - array destructuring pattern var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); @@ -60140,7 +60897,7 @@ var ts; case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: @@ -60197,7 +60954,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 191 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -60218,13 +60975,13 @@ var ts; // for export assignments - check if resolved symbol for RHS is itself a value // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 67220415 /* Value */) + ? !!(moduleSymbol.flags & 111551 /* Value */) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 67220415 /* Value */); + return s && !!(s.flags & 111551 /* Value */); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -60253,7 +61010,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 285 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 286 /* 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. @@ -60273,7 +61030,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 67220415 /* Value */)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -60281,7 +61038,7 @@ var ts; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 276 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { @@ -60290,7 +61047,7 @@ var ts; var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { + if (resolveName(container.parent, symbol.escapedName, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } @@ -60312,7 +61069,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 === 219 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 220 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -60353,26 +61110,25 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 250 /* ImportEqualsDeclaration */: + case 252 /* ImportClause */: + case 253 /* NamespaceImport */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 255 /* ExportAssignment */: - return node.expression - && node.expression.kind === 73 /* Identifier */ - ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) - : true; + case 256 /* ExportAssignment */: + return node.expression && node.expression.kind === 73 /* Identifier */ ? + isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : + true; } return false; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 285 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 286 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -60386,7 +61142,7 @@ var ts; } // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true - return !!(target.flags & 67220415 /* Value */) && + return !!(target.flags & 111551 /* Value */) && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -60400,7 +61156,7 @@ var ts; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 if (target && ts.getModifierFlags(node) & 1 /* Export */ && - target.flags & 67220415 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { + target.flags & 111551 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -60454,7 +61210,7 @@ var ts; if (!symbol || !(symbol.flags & 16 /* Function */)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 67220415 /* Value */ && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -60473,15 +61229,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 279 /* EnumMember */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 280 /* EnumMember */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 279 /* EnumMember */) { + if (node.kind === 280 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -60508,9 +61264,9 @@ var ts; return ts.TypeReferenceSerializationKind.Unknown; } // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. - var valueSymbol = resolveEntityName(typeName, 67220415 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 67897832 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (valueSymbol && valueSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { @@ -60615,7 +61371,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + return resolveName(location, reference.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -60636,7 +61392,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 67220415 /* Value */, enclosing, /*flags*/ undefined, tracker) + var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse(); return enumResult || ts.createLiteral(type.value); } @@ -60717,12 +61473,12 @@ var ts; getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 160 /* SetAccessor */ ? 159 /* GetAccessor */ : 160 /* SetAccessor */; + var otherKind = accessor.kind === 161 /* SetAccessor */ ? 160 /* GetAccessor */ : 161 /* 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 === 160 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 159 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 161 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 160 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -60738,7 +61494,7 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 212 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 274 /* HeritageClause */; + return node.parent && node.parent.kind === 213 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 275 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -60749,9 +61505,9 @@ var ts; // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = 67897832 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 73 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 190 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { - meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; + var meaning = 788968 /* Type */ | 1920 /* Namespace */; + if ((node.kind === 73 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 191 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -60801,7 +61557,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 285 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 286 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -60829,12 +61585,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 245 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 246 /* 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, 285 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 286 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -60974,7 +61730,7 @@ var ts; for (var helper = 1 /* FirstEmitHelper */; helper <= 131072 /* LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 67220415 /* Value */); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); if (!symbol) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); } @@ -61023,14 +61779,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 157 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 158 /* 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 === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */) { + else if (node.kind === 160 /* GetAccessor */ || node.kind === 161 /* 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); @@ -61048,16 +61804,16 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 134 /* ReadonlyKeyword */) { - if (node.kind === 154 /* PropertySignature */ || node.kind === 156 /* MethodSignature */) { + if (node.kind === 155 /* PropertySignature */ || node.kind === 157 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 164 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 78 /* ConstKeyword */: - if (node.kind !== 244 /* EnumDeclaration */) { + if (node.kind !== 245 /* EnumDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(78 /* ConstKeyword */)); } break; @@ -61077,7 +61833,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 === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 286 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -61100,10 +61856,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 286 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 153 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -61116,7 +61872,7 @@ var ts; if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */ && node.kind !== 163 /* IndexSignature */ && node.kind !== 152 /* Parameter */) { + else if (node.kind !== 156 /* PropertyDeclaration */ && node.kind !== 155 /* PropertySignature */ && node.kind !== 164 /* IndexSignature */ && node.kind !== 153 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report 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); } @@ -61136,17 +61892,17 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 153 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; case 81 /* DefaultKeyword */: - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 286 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 246 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; @@ -61158,13 +61914,13 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 153 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 246 /* ModuleBlock */) { + else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 247 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -61174,14 +61930,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 241 /* ClassDeclaration */) { - if (node.kind !== 157 /* MethodDeclaration */ && - node.kind !== 155 /* PropertyDeclaration */ && - node.kind !== 159 /* GetAccessor */ && - node.kind !== 160 /* SetAccessor */) { + if (node.kind !== 242 /* ClassDeclaration */) { + if (node.kind !== 158 /* MethodDeclaration */ && + node.kind !== 156 /* PropertyDeclaration */ && + node.kind !== 160 /* GetAccessor */ && + node.kind !== 161 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 241 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 242 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -61200,7 +61956,7 @@ var ts; else if (flags & 2 /* Ambient */ || node.parent.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 153 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -61208,7 +61964,7 @@ var ts; break; } } - if (node.kind === 158 /* Constructor */) { + if (node.kind === 159 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -61223,13 +61979,13 @@ var ts; } return false; } - else if ((node.kind === 250 /* ImportDeclaration */ || node.kind === 249 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 251 /* ImportDeclaration */ || node.kind === 250 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 153 /* Parameter */ && (flags & 92 /* 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 === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 153 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -61250,37 +62006,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 245 /* ModuleDeclaration */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 152 /* Parameter */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 159 /* Constructor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 164 /* IndexSignature */: + case 246 /* ModuleDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 257 /* ExportDeclaration */: + case 256 /* ExportAssignment */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 153 /* Parameter */: return false; default: - if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 286 /* SourceFile */) { return false; } switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 122 /* AsyncKeyword */); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 119 /* AbstractKeyword */); - case 242 /* InterfaceDeclaration */: - case 220 /* VariableStatement */: - case 243 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 221 /* VariableStatement */: + case 244 /* TypeAliasDeclaration */: return true; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 78 /* ConstKeyword */); default: ts.Debug.fail(); @@ -61293,10 +62049,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -61359,7 +62115,7 @@ var ts; ts.addRelatedInfo(error(parameter, ts.Diagnostics.This_parameter_is_not_allowed_with_use_strict_directive), ts.createDiagnosticForNode(useStrictDirective_1, ts.Diagnostics.use_strict_directive_used_here)); }); var diagnostics_1 = nonSimpleParameters.map(function (parameter, index) { return (index === 0 ? ts.createDiagnosticForNode(parameter, ts.Diagnostics.Non_simple_parameter_declared_here) : ts.createDiagnosticForNode(parameter, ts.Diagnostics.and_here)); }); - ts.addRelatedInfo.apply(void 0, [error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)].concat(diagnostics_1)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)], diagnostics_1)); return true; } } @@ -61447,7 +62203,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 === 211 /* OmittedExpression */) { + if (arg.kind === 212 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -61524,20 +62280,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 150 /* ComputedPropertyName */) { + if (node.kind !== 151 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 205 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 206 /* 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 === 240 /* FunctionDeclaration */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 157 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 241 /* FunctionDeclaration */ || + node.kind === 198 /* FunctionExpression */ || + node.kind === 158 /* MethodDeclaration */); if (node.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -61553,17 +62309,10 @@ var ts; return !!exclamationToken && grammarErrorOnNode(exclamationToken, message); } function checkGrammarObjectLiteralExpression(node, inDestructuring) { - var Flags; - (function (Flags) { - Flags[Flags["Property"] = 1] = "Property"; - Flags[Flags["GetAccessor"] = 2] = "GetAccessor"; - Flags[Flags["SetAccessor"] = 4] = "SetAccessor"; - Flags[Flags["GetOrSetAccessor"] = 6] = "GetOrSetAccessor"; - })(Flags || (Flags = {})); var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */) { + if (prop.kind === 279 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -61574,11 +62323,11 @@ var ts; continue; } var name = prop.name; - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 151 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 277 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 278 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -61587,7 +62336,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 157 /* MethodDeclaration */) { + if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 158 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -61602,24 +62351,25 @@ 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 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); - /* tslint:disable:no-switch-case-fall-through */ - case 276 /* PropertyAssignment */: + // falls through + case 277 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name); } - // falls through - case 157 /* MethodDeclaration */: - currentKind = 1 /* Property */; + currentKind = 4 /* PropertyAssignment */; + break; + case 158 /* MethodDeclaration */: + currentKind = 8 /* Method */; break; - case 159 /* GetAccessor */: - currentKind = 2 /* GetAccessor */; + case 160 /* GetAccessor */: + currentKind = 1 /* GetAccessor */; break; - case 160 /* SetAccessor */: - currentKind = 4 /* SetAccessor */; + case 161 /* SetAccessor */: + currentKind = 2 /* SetAccessor */; break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); @@ -61633,11 +62383,11 @@ var ts; seen.set(effectiveName, currentKind); } else { - if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { + if ((currentKind & 12 /* PropertyAssignmentOrMethod */) && (existingKind & 12 /* PropertyAssignmentOrMethod */)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 6 /* GetOrSetAccessor */) && (existingKind & 6 /* GetOrSetAccessor */)) { - if (existingKind !== 6 /* GetOrSetAccessor */ && currentKind !== existingKind) { + else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) { + if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -61655,7 +62405,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 270 /* JsxSpreadAttribute */) { + if (attr.kind === 271 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -61665,7 +62415,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 271 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 272 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -61679,14 +62429,14 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 228 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 229 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { // use of 'for-await-of' in non-async function var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 159 /* 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); @@ -61697,7 +62447,7 @@ var ts; return false; } } - if (forInOrOfStatement.initializer.kind === 239 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 240 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -61712,20 +62462,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 228 /* 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 === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 228 /* 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 === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 228 /* 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); @@ -61735,42 +62485,38 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - var kind = accessor.kind; - if (languageVersion < 1 /* ES5 */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (accessor.flags & 4194304 /* Ambient */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); - } - else if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { - return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + if (!(accessor.flags & 4194304 /* Ambient */)) { + if (languageVersion < 1 /* ES5 */) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { + return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + } } - else if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { + if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - else if (accessor.typeParameters) { + if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 159 /* GetAccessor */ ? + if (!doesAccessorHaveCorrectParameterCount(accessor)) { + return grammarErrorOnNode(accessor.name, accessor.kind === 160 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 160 /* SetAccessor */) { + if (accessor.kind === 161 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } - else { - var parameter = accessor.parameters[0]; - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); - } - else if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); - } - else if (parameter.initializer) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); - } + var parameter = ts.Debug.assertDefined(ts.getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion."); + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); + } + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); + } + if (parameter.initializer) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); } } return false; @@ -61780,10 +62526,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 === 159 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 160 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 159 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 160 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -61794,7 +62540,7 @@ var ts; } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: var decl = parent; if (decl.name.kind !== 73 /* Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); @@ -61806,13 +62552,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: if (!ts.hasModifier(parent, 32 /* Static */) || !ts.hasModifier(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 154 /* PropertySignature */: + case 155 /* PropertySignature */: if (!ts.hasModifier(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); } @@ -61822,7 +62568,7 @@ var ts; } } else if (node.operator === 134 /* ReadonlyKeyword */) { - if (node.type.kind !== 170 /* ArrayType */ && node.type.kind !== 171 /* TupleType */) { + if (node.type.kind !== 171 /* ArrayType */ && node.type.kind !== 172 /* TupleType */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(140 /* SymbolKeyword */)); } } @@ -61836,8 +62582,8 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 157 /* MethodDeclaration */) { - if (node.parent.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 158 /* MethodDeclaration */) { + if (node.parent.kind === 190 /* 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 === 122 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -61865,14 +62611,14 @@ var ts; if (node.flags & 4194304 /* 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 === 157 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 158 /* 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 === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 243 /* 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 === 169 /* TypeLiteral */) { + else if (node.parent.kind === 170 /* 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); } } @@ -61883,11 +62629,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 234 /* LabeledStatement */: + case 235 /* 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 === 229 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 230 /* 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); @@ -61895,8 +62641,8 @@ var ts; return false; } break; - case 233 /* SwitchStatement */: - if (node.kind === 230 /* BreakStatement */ && !node.label) { + case 234 /* SwitchStatement */: + if (node.kind === 231 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -61911,13 +62657,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 230 /* BreakStatement */ + var message = node.kind === 231 /* 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 === 230 /* BreakStatement */ + var message = node.kind === 231 /* 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); @@ -61941,12 +62687,12 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 10 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.kind === 204 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.kind === 204 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -61976,7 +62722,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 227 /* ForInStatement */ && node.parent.parent.kind !== 228 /* ForOfStatement */) { + if (node.parent.parent.kind !== 228 /* ForInStatement */ && node.parent.parent.kind !== 229 /* ForOfStatement */) { if (node.flags & 4194304 /* Ambient */) { checkAmbientInitializer(node); } @@ -61989,7 +62735,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 220 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 221 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && @@ -62051,15 +62797,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 224 /* IfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 233 /* WithStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: return false; - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -62140,7 +62886,7 @@ var ts; return true; } } - else if (node.parent.kind === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 243 /* 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; } @@ -62148,7 +62894,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 169 /* TypeLiteral */) { + else if (node.parent.kind === 170 /* 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; } @@ -62177,13 +62923,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 243 /* TypeAliasDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 256 /* ExportDeclaration */ || - node.kind === 255 /* ExportAssignment */ || - node.kind === 248 /* NamespaceExportDeclaration */ || + if (node.kind === 243 /* InterfaceDeclaration */ || + node.kind === 244 /* TypeAliasDeclaration */ || + node.kind === 251 /* ImportDeclaration */ || + node.kind === 250 /* ImportEqualsDeclaration */ || + node.kind === 257 /* ExportDeclaration */ || + node.kind === 256 /* ExportAssignment */ || + node.kind === 249 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -62192,7 +62938,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 === 220 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 221 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -62205,13 +62951,9 @@ var ts; } function checkGrammarStatementInAmbientContext(node) { if (node.flags & 4194304 /* Ambient */) { - // An accessors is already reported about the ambient context - if (ts.isAccessor(node.parent)) { - return getNodeLinks(node).hasReportedStatementInAmbientContext = true; - } // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); - if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { + if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } // We are either parented by another statement, or some sort of block. @@ -62219,7 +62961,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 === 219 /* Block */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 220 /* Block */ || node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 286 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -62241,10 +62983,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, 183 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 184 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 279 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 280 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -62253,8 +62995,27 @@ var ts; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + // Realism (size) checking + checkNumericLiteralValueSize(node); return false; } + function checkNumericLiteralValueSize(node) { + // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint + // Literals with 15 or fewer characters aren't long enough to reach past 2^53 - 1 + // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway + if (node.numericLiteralFlags & 16 /* Scientific */ || node.text.length <= 15 || node.text.indexOf(".") !== -1) { + return; + } + // We can't rely on the runtime to accurately store and compare extremely large numeric values + // Even for internal use, we use getTextOfNode: https://github.com/microsoft/TypeScript/issues/33298 + // Thus, if the runtime claims a too-large number is lower than Number.MAX_SAFE_INTEGER, + // it's likely addition operations on it will fail too + var apparentValue = +ts.getTextOfNode(node); + if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) { + return; + } + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers)); + } function checkGrammarBigIntLiteral(node) { var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); @@ -62309,11 +63070,19 @@ var ts; } } ts.createTypeChecker = createTypeChecker; + function isNotAccessor(declaration) { + // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks + return !ts.isAccessor(declaration); + } + function isNotOverload(declaration) { + return (declaration.kind !== 241 /* FunctionDeclaration */ && declaration.kind !== 158 /* 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 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -62321,21 +63090,20 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 251 /* ImportClause */: // For default import - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: // For rename import `x as y` + case 252 /* ImportClause */: // For default import + case 250 /* ImportEqualsDeclaration */: + case 253 /* NamespaceImport */: + case 255 /* ImportSpecifier */: // For rename import `x as y` return true; case 73 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 254 /* ImportSpecifier */; + return decl.parent.kind === 255 /* ImportSpecifier */; default: return false; } } var JsxNames; (function (JsxNames) { - // tslint:disable variable-name JsxNames.JSX = "JSX"; JsxNames.IntrinsicElements = "IntrinsicElements"; JsxNames.ElementClass = "ElementClass"; @@ -62345,7 +63113,6 @@ var ts; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; - // tslint:enable variable-name })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { @@ -62416,6 +63183,7 @@ var ts; if (typeof value === "number") { return createNumericLiteral(value + ""); } + // eslint-disable-next-line no-in-operator if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n"); } @@ -62608,7 +63376,7 @@ var ts; ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(149 /* QualifiedName */); + var node = createSynthesizedNode(150 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -62627,7 +63395,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(150 /* ComputedPropertyName */); + var node = createSynthesizedNode(151 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -62640,7 +63408,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(151 /* TypeParameter */); + var node = createSynthesizedNode(152 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -62656,7 +63424,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(152 /* Parameter */); + var node = createSynthesizedNode(153 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -62680,7 +63448,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(153 /* Decorator */); + var node = createSynthesizedNode(154 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -62693,7 +63461,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(154 /* PropertySignature */); + var node = createSynthesizedNode(155 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -62713,7 +63481,7 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(155 /* PropertyDeclaration */); + var node = createSynthesizedNode(156 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62737,7 +63505,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(156 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(157 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -62754,7 +63522,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(157 /* MethodDeclaration */); + var node = createSynthesizedNode(158 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -62782,7 +63550,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(158 /* Constructor */); + var node = createSynthesizedNode(159 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -62802,7 +63570,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(159 /* GetAccessor */); + var node = createSynthesizedNode(160 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62825,7 +63593,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(160 /* SetAccessor */); + var node = createSynthesizedNode(161 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62846,7 +63614,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(161 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(162 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -62854,7 +63622,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(162 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(163 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -62862,7 +63630,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(163 /* IndexSignature */); + var node = createSynthesizedNode(164 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -62902,7 +63670,7 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(164 /* TypePredicate */); + var node = createSynthesizedNode(165 /* TypePredicate */); node.parameterName = asName(parameterName); node.type = type; return node; @@ -62916,7 +63684,7 @@ var ts; } ts.updateTypePredicateNode = updateTypePredicateNode; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(165 /* TypeReference */); + var node = createSynthesizedNode(166 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -62930,7 +63698,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(166 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(167 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -62938,7 +63706,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(167 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(168 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -62946,7 +63714,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(168 /* TypeQuery */); + var node = createSynthesizedNode(169 /* TypeQuery */); node.exprName = exprName; return node; } @@ -62958,7 +63726,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(169 /* TypeLiteral */); + var node = createSynthesizedNode(170 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -62970,7 +63738,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(170 /* ArrayType */); + var node = createSynthesizedNode(171 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -62982,7 +63750,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(171 /* TupleType */); + var node = createSynthesizedNode(172 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -62994,7 +63762,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(172 /* OptionalType */); + var node = createSynthesizedNode(173 /* OptionalType */); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -63006,7 +63774,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(173 /* RestType */); + var node = createSynthesizedNode(174 /* RestType */); node.type = type; return node; } @@ -63018,7 +63786,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(174 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(175 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -63026,7 +63794,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(175 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(176 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -63045,7 +63813,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(176 /* ConditionalType */); + var node = createSynthesizedNode(177 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -63063,7 +63831,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(177 /* InferType */); + var node = createSynthesizedNode(178 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -63075,7 +63843,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(184 /* ImportType */); + var node = createSynthesizedNode(185 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = ts.parenthesizeTypeParameters(typeArguments); @@ -63093,7 +63861,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(178 /* ParenthesizedType */); + var node = createSynthesizedNode(179 /* ParenthesizedType */); node.type = type; return node; } @@ -63105,11 +63873,11 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(179 /* ThisType */); + return createSynthesizedNode(180 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(180 /* TypeOperator */); + var node = createSynthesizedNode(181 /* TypeOperator */); node.operator = typeof operatorOrType === "number" ? operatorOrType : 130 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; @@ -63120,7 +63888,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(181 /* IndexedAccessType */); + var node = createSynthesizedNode(182 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -63134,7 +63902,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(182 /* MappedType */); + var node = createSynthesizedNode(183 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -63152,7 +63920,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(183 /* LiteralType */); + var node = createSynthesizedNode(184 /* LiteralType */); node.literal = literal; return node; } @@ -63165,7 +63933,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(185 /* ObjectBindingPattern */); + var node = createSynthesizedNode(186 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63177,7 +63945,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(186 /* ArrayBindingPattern */); + var node = createSynthesizedNode(187 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63189,7 +63957,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(187 /* BindingElement */); + var node = createSynthesizedNode(188 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -63208,7 +63976,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(188 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(189 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -63222,7 +63990,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(189 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(190 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -63236,7 +64004,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(190 /* PropertyAccessExpression */); + var node = createSynthesizedNode(191 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072 /* NoIndentation */); @@ -63253,7 +64021,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(191 /* ElementAccessExpression */); + var node = createSynthesizedNode(192 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -63267,7 +64035,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(192 /* CallExpression */); + var node = createSynthesizedNode(193 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -63283,7 +64051,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(193 /* NewExpression */); + var node = createSynthesizedNode(194 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -63299,7 +64067,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(194 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(195 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -63322,7 +64090,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(195 /* TypeAssertionExpression */); + var node = createSynthesizedNode(196 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -63336,7 +64104,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(196 /* ParenthesizedExpression */); + var node = createSynthesizedNode(197 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -63348,7 +64116,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(197 /* FunctionExpression */); + var node = createSynthesizedNode(198 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -63372,7 +64140,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(198 /* ArrowFunction */); + var node = createSynthesizedNode(199 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); @@ -63394,7 +64162,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(199 /* DeleteExpression */); + var node = createSynthesizedNode(200 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63406,7 +64174,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(200 /* TypeOfExpression */); + var node = createSynthesizedNode(201 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63418,7 +64186,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(201 /* VoidExpression */); + var node = createSynthesizedNode(202 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63430,7 +64198,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(202 /* AwaitExpression */); + var node = createSynthesizedNode(203 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63442,7 +64210,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(203 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(204 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -63455,7 +64223,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(204 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(205 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -63468,7 +64236,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(205 /* BinaryExpression */); + var node = createSynthesizedNode(206 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -63485,7 +64253,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(206 /* ConditionalExpression */); + var node = createSynthesizedNode(207 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); @@ -63505,7 +64273,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(207 /* TemplateExpression */); + var node = createSynthesizedNode(208 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -63518,32 +64286,91 @@ var ts; : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createTemplateHead(text) { - var node = createSynthesizedNode(15 /* TemplateHead */); + var rawTextScanner; + var invalidValueSentinel = {}; + function getCookedText(kind, rawText) { + if (!rawTextScanner) { + rawTextScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + } + switch (kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + rawTextScanner.setText("`" + rawText + "`"); + break; + case 15 /* TemplateHead */: + rawTextScanner.setText("`" + rawText + "${"); + break; + case 16 /* TemplateMiddle */: + rawTextScanner.setText("}" + rawText + "${"); + break; + case 17 /* TemplateTail */: + rawTextScanner.setText("}" + rawText + "`"); + break; + } + var token = rawTextScanner.scan(); + if (token === 23 /* CloseBracketToken */) { + token = rawTextScanner.reScanTemplateToken(); + } + if (rawTextScanner.isUnterminated()) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + var tokenValue; + switch (token) { + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + tokenValue = rawTextScanner.getTokenValue(); + break; + } + if (rawTextScanner.scan() !== 1 /* EndOfFileToken */) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + rawTextScanner.setText(undefined); + return tokenValue; + } + function createTemplateLiteralLikeNode(kind, text, rawText) { + var node = createSynthesizedNode(kind); + node.text = text; + if (rawText === undefined || text === rawText) { + node.rawText = rawText; + } + else { + var cooked = getCookedText(kind, rawText); + if (typeof cooked === "object") { + return ts.Debug.fail("Invalid raw text"); + } + ts.Debug.assert(text === cooked, "Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'."); + node.rawText = rawText; + } + return node; + } + function createTemplateHead(text, rawText) { + var node = createTemplateLiteralLikeNode(15 /* TemplateHead */, text, rawText); node.text = text; return node; } ts.createTemplateHead = createTemplateHead; - function createTemplateMiddle(text) { - var node = createSynthesizedNode(16 /* TemplateMiddle */); + function createTemplateMiddle(text, rawText) { + var node = createTemplateLiteralLikeNode(16 /* TemplateMiddle */, text, rawText); node.text = text; return node; } ts.createTemplateMiddle = createTemplateMiddle; - function createTemplateTail(text) { - var node = createSynthesizedNode(17 /* TemplateTail */); + function createTemplateTail(text, rawText) { + var node = createTemplateLiteralLikeNode(17 /* TemplateTail */, text, rawText); node.text = text; return node; } ts.createTemplateTail = createTemplateTail; - function createNoSubstitutionTemplateLiteral(text) { - var node = createSynthesizedNode(14 /* NoSubstitutionTemplateLiteral */); - node.text = text; + function createNoSubstitutionTemplateLiteral(text, rawText) { + var node = createTemplateLiteralLikeNode(14 /* NoSubstitutionTemplateLiteral */, text, rawText); return node; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(208 /* YieldExpression */); + var node = createSynthesizedNode(209 /* YieldExpression */); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; @@ -63557,7 +64384,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(209 /* SpreadElement */); + var node = createSynthesizedNode(210 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -63569,7 +64396,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(210 /* ClassExpression */); + var node = createSynthesizedNode(211 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63590,11 +64417,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(211 /* OmittedExpression */); + return createSynthesizedNode(212 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(212 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(213 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -63608,7 +64435,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(213 /* AsExpression */); + var node = createSynthesizedNode(214 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -63622,7 +64449,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(214 /* NonNullExpression */); + var node = createSynthesizedNode(215 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -63634,7 +64461,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(215 /* MetaProperty */); + var node = createSynthesizedNode(216 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -63648,7 +64475,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(217 /* TemplateSpan */); + var node = createSynthesizedNode(218 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -63662,12 +64489,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(218 /* SemicolonClassElement */); + return createSynthesizedNode(219 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(219 /* Block */); + var block = createSynthesizedNode(220 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -63681,7 +64508,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(220 /* VariableStatement */); + var node = createSynthesizedNode(221 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -63696,11 +64523,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(221 /* EmptyStatement */); + return createSynthesizedNode(222 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(222 /* ExpressionStatement */); + var node = createSynthesizedNode(223 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -63716,7 +64543,7 @@ var ts; /** @deprecated Use `updateExpressionStatement` instead. */ ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(223 /* IfStatement */); + var node = createSynthesizedNode(224 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -63732,7 +64559,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(224 /* DoStatement */); + var node = createSynthesizedNode(225 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; return node; @@ -63746,7 +64573,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(225 /* WhileStatement */); + var node = createSynthesizedNode(226 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -63760,7 +64587,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(226 /* ForStatement */); + var node = createSynthesizedNode(227 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -63778,7 +64605,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(227 /* ForInStatement */); + var node = createSynthesizedNode(228 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -63794,7 +64621,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(228 /* ForOfStatement */); + var node = createSynthesizedNode(229 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -63812,7 +64639,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(229 /* ContinueStatement */); + var node = createSynthesizedNode(230 /* ContinueStatement */); node.label = asName(label); return node; } @@ -63824,7 +64651,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(230 /* BreakStatement */); + var node = createSynthesizedNode(231 /* BreakStatement */); node.label = asName(label); return node; } @@ -63836,7 +64663,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(231 /* ReturnStatement */); + var node = createSynthesizedNode(232 /* ReturnStatement */); node.expression = expression; return node; } @@ -63848,7 +64675,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(232 /* WithStatement */); + var node = createSynthesizedNode(233 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -63862,7 +64689,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(233 /* SwitchStatement */); + var node = createSynthesizedNode(234 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -63876,7 +64703,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(234 /* LabeledStatement */); + var node = createSynthesizedNode(235 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); return node; @@ -63890,7 +64717,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(235 /* ThrowStatement */); + var node = createSynthesizedNode(236 /* ThrowStatement */); node.expression = expression; return node; } @@ -63902,7 +64729,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(236 /* TryStatement */); + var node = createSynthesizedNode(237 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -63918,11 +64745,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(237 /* DebuggerStatement */); + return createSynthesizedNode(238 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(238 /* VariableDeclaration */); + var node = createSynthesizedNode(239 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -63939,7 +64766,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* VariableDeclarationList */); + var node = createSynthesizedNode(240 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -63952,7 +64779,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(240 /* FunctionDeclaration */); + var node = createSynthesizedNode(241 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -63978,7 +64805,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(241 /* ClassDeclaration */); + var node = createSynthesizedNode(242 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64000,7 +64827,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(242 /* InterfaceDeclaration */); + var node = createSynthesizedNode(243 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64022,7 +64849,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(243 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(244 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64042,7 +64869,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(244 /* EnumDeclaration */); + var node = createSynthesizedNode(245 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64061,7 +64888,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(245 /* ModuleDeclaration */); + var node = createSynthesizedNode(246 /* ModuleDeclaration */); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -64080,7 +64907,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(246 /* ModuleBlock */); + var node = createSynthesizedNode(247 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -64092,7 +64919,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(247 /* CaseBlock */); + var node = createSynthesizedNode(248 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -64104,7 +64931,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(248 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(249 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -64116,7 +64943,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(249 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(250 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64134,7 +64961,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ImportDeclaration */); + var node = createSynthesizedNode(251 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -64152,7 +64979,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(251 /* ImportClause */); + var node = createSynthesizedNode(252 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -64166,7 +64993,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(252 /* NamespaceImport */); + var node = createSynthesizedNode(253 /* NamespaceImport */); node.name = name; return node; } @@ -64178,7 +65005,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(253 /* NamedImports */); + var node = createSynthesizedNode(254 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -64190,7 +65017,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(254 /* ImportSpecifier */); + var node = createSynthesizedNode(255 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -64204,7 +65031,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(255 /* ExportAssignment */); + var node = createSynthesizedNode(256 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -64221,7 +65048,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(256 /* ExportDeclaration */); + var node = createSynthesizedNode(257 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -64239,7 +65066,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(257 /* NamedExports */); + var node = createSynthesizedNode(258 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -64251,7 +65078,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(258 /* ExportSpecifier */); + var node = createSynthesizedNode(259 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -64266,7 +65093,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(260 /* ExternalModuleReference */); + var node = createSynthesizedNode(261 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -64280,14 +65107,14 @@ var ts; // JSDoc /* @internal */ function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(289 /* JSDocTypeExpression */); + var node = createSynthesizedNode(290 /* JSDocTypeExpression */); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; /* @internal */ function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(309 /* JSDocTypeTag */, "type"); + var tag = createJSDocTag(311 /* JSDocTypeTag */, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64295,7 +65122,7 @@ var ts; ts.createJSDocTypeTag = createJSDocTypeTag; /* @internal */ function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(307 /* JSDocReturnTag */, "returns"); + var tag = createJSDocTag(309 /* JSDocReturnTag */, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64303,14 +65130,14 @@ var ts; ts.createJSDocReturnTag = createJSDocReturnTag; /** @internal */ function createJSDocThisTag(typeExpression) { - var tag = createJSDocTag(308 /* JSDocThisTag */, "this"); + var tag = createJSDocTag(310 /* JSDocThisTag */, "this"); tag.typeExpression = typeExpression; return tag; } ts.createJSDocThisTag = createJSDocThisTag; /* @internal */ function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(306 /* JSDocParameterTag */, "param"); + var tag = createJSDocTag(308 /* JSDocParameterTag */, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -64320,7 +65147,7 @@ var ts; ts.createJSDocParamTag = createJSDocParamTag; /* @internal */ function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(297 /* JSDocComment */); + var node = createSynthesizedNode(299 /* JSDocComment */); node.comment = comment; node.tags = tags; return node; @@ -64334,7 +65161,7 @@ var ts; } // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(261 /* JsxElement */); + var node = createSynthesizedNode(262 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -64350,7 +65177,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(262 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(263 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64366,7 +65193,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(263 /* JsxOpeningElement */); + var node = createSynthesizedNode(264 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64382,7 +65209,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(264 /* JsxClosingElement */); + var node = createSynthesizedNode(265 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -64394,7 +65221,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(265 /* JsxFragment */); + var node = createSynthesizedNode(266 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -64416,11 +65243,11 @@ var ts; } ts.updateJsxText = updateJsxText; function createJsxOpeningFragment() { - return createSynthesizedNode(266 /* JsxOpeningFragment */); + return createSynthesizedNode(267 /* JsxOpeningFragment */); } ts.createJsxOpeningFragment = createJsxOpeningFragment; function createJsxJsxClosingFragment() { - return createSynthesizedNode(267 /* JsxClosingFragment */); + return createSynthesizedNode(268 /* JsxClosingFragment */); } ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment; function updateJsxFragment(node, openingFragment, children, closingFragment) { @@ -64432,7 +65259,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(268 /* JsxAttribute */); + var node = createSynthesizedNode(269 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -64446,7 +65273,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(269 /* JsxAttributes */); + var node = createSynthesizedNode(270 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -64458,7 +65285,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(270 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(271 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -64470,7 +65297,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(271 /* JsxExpression */); + var node = createSynthesizedNode(272 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -64484,7 +65311,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(272 /* CaseClause */); + var node = createSynthesizedNode(273 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -64498,7 +65325,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(273 /* DefaultClause */); + var node = createSynthesizedNode(274 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -64510,7 +65337,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(274 /* HeritageClause */); + var node = createSynthesizedNode(275 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -64523,7 +65350,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(275 /* CatchClause */); + var node = createSynthesizedNode(276 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -64538,7 +65365,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(276 /* PropertyAssignment */); + var node = createSynthesizedNode(277 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -64553,7 +65380,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(277 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(278 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -64567,7 +65394,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(278 /* SpreadAssignment */); + var node = createSynthesizedNode(279 /* SpreadAssignment */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -64580,7 +65407,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(279 /* EnumMember */); + var node = createSynthesizedNode(280 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -64601,7 +65428,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(285 /* SourceFile */); + var updated = createSynthesizedNode(286 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -64685,7 +65512,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(314 /* NotEmittedStatement */); + var node = createSynthesizedNode(316 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -64697,7 +65524,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(318 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(320 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -64709,7 +65536,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(317 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(319 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -64724,7 +65551,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(315 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(317 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -64740,7 +65567,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 316 /* CommaListExpression */) { + if (node.kind === 318 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { @@ -64750,7 +65577,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(316 /* CommaListExpression */); + var node = createSynthesizedNode(318 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -64763,7 +65590,7 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(286 /* Bundle */); + var node = ts.createNode(287 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -64794,7 +65621,7 @@ var ts; ], function (helper) { return helper.name; })); } function createUnparsedSource() { - var node = ts.createNode(287 /* UnparsedSource */); + var node = ts.createNode(288 /* UnparsedSource */); node.prologues = ts.emptyArray; node.referencedFiles = ts.emptyArray; node.libReferenceDirectives = ts.emptyArray; @@ -64926,10 +65753,10 @@ var ts; } function mapBundleFileSectionKindToSyntaxKind(kind) { switch (kind) { - case "prologue" /* Prologue */: return 280 /* UnparsedPrologue */; - case "prepend" /* Prepend */: return 281 /* UnparsedPrepend */; - case "internal" /* Internal */: return 283 /* UnparsedInternalText */; - case "text" /* Text */: return 282 /* UnparsedText */; + case "prologue" /* Prologue */: return 281 /* UnparsedPrologue */; + case "prepend" /* Prepend */: return 282 /* UnparsedPrepend */; + case "internal" /* Internal */: return 284 /* UnparsedInternalText */; + case "text" /* Text */: return 283 /* UnparsedText */; case "emitHelpers" /* EmitHelpers */: case "no-default-lib" /* NoDefaultLib */: case "reference" /* Reference */: @@ -64947,14 +65774,14 @@ var ts; return node; } function createUnparsedSyntheticReference(section, parent) { - var node = ts.createNode(284 /* UnparsedSyntheticReference */, section.pos, section.end); + var node = ts.createNode(285 /* UnparsedSyntheticReference */, section.pos, section.end); node.parent = parent; node.data = section.data; node.section = section; return node; } function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { - var node = ts.createNode(288 /* InputFiles */); + var node = ts.createNode(289 /* InputFiles */); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -65000,8 +65827,8 @@ var ts; node.declarationMapPath = declarationMapPath; node.declarationMapText = declarationMapTextOrBuildInfoPath; node.javascriptPath = javascriptPath; - node.declarationPath = declarationPath, - node.buildInfoPath = buildInfoPath; + node.declarationPath = declarationPath; + node.buildInfoPath = buildInfoPath; node.buildInfo = buildInfo; node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } @@ -65144,7 +65971,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 === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -65209,7 +66036,6 @@ var ts; return node; } ts.setSourceMapRange = setSourceMapRange; - // tslint:disable-next-line variable-name var SourceMapSource; /** * Create an external source map source file reference @@ -65495,9 +66321,9 @@ var ts; ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createFunctionCall(func, thisArg, argumentsList, location) { return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ thisArg - ].concat(argumentsList)), location); + ], argumentsList)), location); } ts.createFunctionCall = createFunctionCall; function createFunctionApply(func, thisArg, argumentsExpression, location) { @@ -65598,29 +66424,34 @@ var ts; } ts.createExpressionForJsxFragment = createExpressionForJsxFragment; // Helpers - function getHelperName(name) { + /** + * Gets an identifier for the name of an *unscoped* emit helper. + */ + function getUnscopedHelperName(name) { return ts.setEmitFlags(ts.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } - ts.getHelperName = getHelperName; + ts.getUnscopedHelperName = getUnscopedHelperName; ts.valuesHelper = { name: "typescript:values", + importName: "__values", scoped: false, - text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };" + text: "\n var __values = (this && this.__values) || function(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n };" }; function createValuesHelper(context, expression, location) { context.requestEmitHelper(ts.valuesHelper); - return ts.setTextRange(ts.createCall(getHelperName("__values"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__values"), /*typeArguments*/ undefined, [expression]), location); } ts.createValuesHelper = createValuesHelper; ts.readHelper = { name: "typescript:read", + importName: "__read", scoped: false, text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };" }; function createReadHelper(context, iteratorRecord, count, location) { context.requestEmitHelper(ts.readHelper); - return ts.setTextRange(ts.createCall(getHelperName("__read"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__read"), /*typeArguments*/ undefined, count !== undefined ? [iteratorRecord, ts.createLiteral(count)] : [iteratorRecord]), location); @@ -65628,24 +66459,26 @@ var ts; ts.createReadHelper = createReadHelper; ts.spreadHelper = { name: "typescript:spread", + importName: "__spread", scoped: false, text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" }; function createSpreadHelper(context, argumentList, location) { context.requestEmitHelper(ts.readHelper); context.requestEmitHelper(ts.spreadHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spread"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spread"), /*typeArguments*/ undefined, argumentList), location); } ts.createSpreadHelper = createSpreadHelper; ts.spreadArraysHelper = { name: "typescript:spreadArrays", + importName: "__spreadArrays", scoped: false, text: "\n var __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n };" }; function createSpreadArraysHelper(context, argumentList, location) { context.requestEmitHelper(ts.spreadArraysHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spreadArrays"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spreadArrays"), /*typeArguments*/ undefined, argumentList), location); } ts.createSpreadArraysHelper = createSpreadArraysHelper; @@ -65667,7 +66500,7 @@ var ts; ts.createForOfBindingStatement = createForOfBindingStatement; function insertLeadingStatement(dest, source) { if (ts.isBlock(dest)) { - return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray([source].concat(dest.statements)), dest.statements)); + return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray(__spreadArrays([source], dest.statements)), dest.statements)); } else { return ts.createBlock(ts.createNodeArray([dest, source]), /*multiLine*/ true); @@ -65678,7 +66511,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 234 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 235 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -65697,13 +66530,13 @@ var ts; case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -65730,7 +66563,7 @@ var ts; } else { switch (callee.kind) { - case 190 /* PropertyAccessExpression */: { + case 191 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -65743,7 +66576,7 @@ var ts; } break; } - case 191 /* ElementAccessExpression */: { + case 192 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -65800,14 +66633,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -66114,9 +66947,9 @@ var ts; function ensureUseStrict(statements) { var foundUseStrict = findUseStrictPrologue(statements); if (!foundUseStrict) { - return ts.setTextRange(ts.createNodeArray([ + return ts.setTextRange(ts.createNodeArray(__spreadArrays([ startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) - ].concat(statements)), statements); + ], statements)), statements); } return statements; } @@ -66133,7 +66966,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 === 196 /* ParenthesizedExpression */) { + if (skipped.kind === 197 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -66167,10 +67000,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(205 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(205 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(206 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(206 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 198 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 199 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -66182,7 +67015,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 208 /* YieldExpression */) { + && operand.kind === 209 /* YieldExpression */) { return false; } return true; @@ -66270,22 +67103,20 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { + if (node.kind === 206 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0 /* Unknown */; + var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind : + 0 /* Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(206 /* ConditionalExpression */, 56 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(207 /* ConditionalExpression */, 56 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -66320,8 +67151,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: + case 211 /* ClassExpression */: + case 198 /* FunctionExpression */: needsParens = true; } } @@ -66337,9 +67168,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 192 /* CallExpression */: + case 193 /* CallExpression */: return ts.createParen(expression); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -66362,7 +67193,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 193 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 194 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -66400,7 +67231,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(205 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(206 /* BinaryExpression */, 27 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -66411,29 +67242,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 197 /* FunctionExpression */ || kind === 198 /* ArrowFunction */) { + if (kind === 198 /* FunctionExpression */ || kind === 199 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 189 /* ObjectLiteralExpression */ || leftmostExpressionKind === 197 /* FunctionExpression */) { + if (leftmostExpressionKind === 190 /* ObjectLiteralExpression */ || leftmostExpressionKind === 198 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 176 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 177 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -66441,9 +67272,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 168 /* TypeQuery */: - case 180 /* TypeOperator */: - case 177 /* InferType */: + case 169 /* TypeQuery */: + case 181 /* TypeOperator */: + case 178 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -66469,28 +67300,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: node = node.operand; continue; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: node = node.left; continue; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: node = node.condition; continue; - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: node = node.tag; continue; - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 213 /* AsExpression */: - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: - case 214 /* NonNullExpression */: - case 315 /* PartiallyEmittedExpression */: + case 214 /* AsExpression */: + case 192 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 215 /* NonNullExpression */: + case 317 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -66499,15 +67330,15 @@ var ts; } ts.getLeftmostExpression = getLeftmostExpression; function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 189 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 190 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 316 /* CommaListExpression */; + return node.kind === 206 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 318 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -66520,13 +67351,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 214 /* NonNullExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: + case 215 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -66551,7 +67382,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 214 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 215 /* NonNullExpression */) { node = node.expression; } return node; @@ -66559,11 +67390,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 196 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 195 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 213 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 214 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 315 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 197 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 196 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 214 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 215 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 317 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -66581,7 +67412,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 196 /* ParenthesizedExpression */ + return node.kind === 197 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -66606,6 +67437,60 @@ var ts; return emitNode && emitNode.externalHelpersModuleName; } ts.getExternalHelpersModuleName = getExternalHelpersModuleName; + function hasRecordedExternalHelpers(sourceFile) { + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = parseNode && parseNode.emitNode; + return !!emitNode && (!!emitNode.externalHelpersModuleName || !!emitNode.externalHelpers); + } + ts.hasRecordedExternalHelpers = hasRecordedExternalHelpers; + function createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault) { + if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + var namedBindings = void 0; + var moduleKind = ts.getEmitModuleKind(compilerOptions); + if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) { + // use named imports + var helpers = ts.getEmitHelpers(sourceFile); + if (helpers) { + var helperNames = []; + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; + if (!helper.scoped) { + var importName = helper.importName; + if (importName) { + ts.pushIfUnique(helperNames, importName); + } + } + } + if (ts.some(helperNames)) { + helperNames.sort(ts.compareStringsCaseSensitive); + // Alias the imports if the names are used somewhere in the file. + // NOTE: We don't need to care about global import collisions as this is a module. + namedBindings = ts.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name) + ? ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name)) + : ts.createImportSpecifier(ts.createIdentifier(name), getUnscopedHelperName(name)); })); + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = ts.getOrCreateEmitNode(parseNode); + emitNode.externalHelpers = true; + } + } + } + else { + // use a namespace import + var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar || hasImportDefault); + if (externalHelpersModuleName) { + namedBindings = ts.createNamespaceImport(externalHelpersModuleName); + } + } + if (namedBindings) { + var externalHelpersImportDeclaration = ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, namedBindings), ts.createLiteral(ts.externalHelpersModuleNameText)); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); + return externalHelpersImportDeclaration; + } + } + } + ts.createExternalHelpersImportDeclarationIfNeeded = createExternalHelpersImportDeclarationIfNeeded; function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault) { if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(node, compilerOptions)) { var externalHelpersModuleName = getExternalHelpersModuleName(node); @@ -66620,8 +67505,8 @@ var ts; if (!create) { var helpers = ts.getEmitHelpers(node); if (helpers) { - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; + for (var _i = 0, helpers_3 = helpers; _i < helpers_3.length; _i++) { + var helper = helpers_3[_i]; if (!helper.scoped) { create = true; break; @@ -66646,10 +67531,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 250 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 251 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 256 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 257 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -66768,7 +67653,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -66780,11 +67665,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -66816,12 +67701,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 153 /* Parameter */: + case 188 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 209 /* SpreadElement */: - case 278 /* SpreadAssignment */: + case 210 /* SpreadElement */: + case 279 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -66833,7 +67718,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 187 /* BindingElement */: + case 188 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -66845,7 +67730,7 @@ var ts; : propertyName; } break; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -66857,7 +67742,7 @@ var ts; : propertyName; } break; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -66880,13 +67765,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: + case 189 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -66926,11 +67811,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 187 /* ArrayBindingPattern */: + case 189 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 186 /* ObjectBindingPattern */: + case 190 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -67053,11 +67938,9 @@ var ts; function visitLexicalEnvironment(statements, visitor, context, start, ensureUseStrict) { context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); - if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); - } - var declarations = context.endLexicalEnvironment(); - return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); + if (ensureUseStrict) + statements = ts.ensureUseStrict(statements); // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier + return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment()); } ts.visitLexicalEnvironment = visitLexicalEnvironment; /** @@ -67091,278 +67974,278 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */) || kind === 179 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 149 /* LastToken */) || kind === 180 /* ThisType */) { return node; } switch (kind) { // Names case 73 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 152 /* Parameter */: + case 153 /* Parameter */: return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 153 /* Decorator */: + case 154 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 154 /* PropertySignature */: + case 155 /* PropertySignature */: return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too visitNode(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 156 /* MethodSignature */: + case 157 /* MethodSignature */: return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 158 /* Constructor */: + case 159 /* Constructor */: return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 159 /* GetAccessor */: + case 160 /* GetAccessor */: return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 161 /* CallSignature */: + case 162 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); // Types - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 166 /* FunctionType */: + case 167 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 167 /* ConstructorType */: + case 168 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 171 /* TupleType */: + case 172 /* TupleType */: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 172 /* OptionalType */: + case 173 /* OptionalType */: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 173 /* RestType */: + case 174 /* RestType */: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174 /* UnionType */: + case 175 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 175 /* IntersectionType */: + case 176 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 177 /* InferType */: + case 178 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 184 /* ImportType */: + case 185 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 182 /* MappedType */: + case 183 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 183 /* LiteralType */: + case 184 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 186 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 213 /* AsExpression */: + case 214 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 219 /* Block */: + case 220 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 229 /* ContinueStatement */: + case 230 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 230 /* BreakStatement */: + case 231 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 253 /* NamedImports */: + case 254 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 257 /* NamedExports */: + case 258 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 258 /* ExportSpecifier */: + case 259 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 261 /* JsxElement */: + case 262 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 263 /* JsxOpeningElement */: + case 264 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 272 /* CaseClause */: + case 273 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 279 /* EnumMember */: + case 280 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 285 /* SourceFile */: + case 286 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -67404,58 +68287,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 149 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 164 /* TypePredicate */ && kind <= 183 /* LiteralType */)) { + if ((kind >= 165 /* TypePredicate */ && kind <= 184 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 218 /* SemicolonClassElement */: - case 221 /* EmptyStatement */: - case 211 /* OmittedExpression */: - case 237 /* DebuggerStatement */: - case 314 /* NotEmittedStatement */: + case 219 /* SemicolonClassElement */: + case 222 /* EmptyStatement */: + case 212 /* OmittedExpression */: + case 238 /* DebuggerStatement */: + case 316 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 152 /* Parameter */: + case 153 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 153 /* Decorator */: + case 154 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 154 /* PropertySignature */: + case 155 /* PropertySignature */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67464,12 +68347,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 158 /* Constructor */: + case 159 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 159 /* GetAccessor */: + case 160 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67477,7 +68360,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67485,50 +68368,50 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 187 /* BindingElement */: + case 188 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 192 /* CallExpression */: + case 193 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 193 /* NewExpression */: + case 194 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -67536,123 +68419,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 196 /* ParenthesizedExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: + case 200 /* DeleteExpression */: + case 201 /* TypeOfExpression */: + case 202 /* VoidExpression */: + case 203 /* AwaitExpression */: + case 209 /* YieldExpression */: + case 210 /* SpreadElement */: + case 215 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 213 /* AsExpression */: + case 214 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 219 /* Block */: + case 220 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 223 /* IfStatement */: + case 224 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 224 /* DoStatement */: + case 225 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 225 /* WhileStatement */: - case 232 /* WithStatement */: + case 226 /* WhileStatement */: + case 233 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 226 /* ForStatement */: + case 227 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 232 /* ReturnStatement */: + case 236 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 236 /* TryStatement */: + case 237 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67661,7 +68544,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67669,140 +68552,140 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.members, cbNodes, result); break; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 251 /* ImportClause */: + case 252 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 254 /* NamedImports */: + case 258 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // Module references - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 261 /* JsxElement */: + case 262 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 272 /* CaseClause */: + case 273 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 275 /* CatchClause */: + case 276 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 279 /* EnumMember */: + case 280 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 285 /* SourceFile */: + case 286 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -67875,7 +68758,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 212 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 213 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -67948,19 +68831,20 @@ var ts; exit(); return sourceIndex; } + /* eslint-disable boolean-trivia, no-null/no-null */ function setSourceContent(sourceIndex, content) { enter(); if (content !== null) { if (!sourcesContent) sourcesContent = []; while (sourcesContent.length < sourceIndex) { - // tslint:disable-next-line:no-null-keyword boolean-trivia sourcesContent.push(null); } sourcesContent[sourceIndex] = content; } exit(); } + /* eslint-enable boolean-trivia, no-null/no-null */ function addName(name) { enter(); if (!nameToNameIndexMap) @@ -68163,12 +69047,11 @@ var ts; } } ts.tryGetSourceMappingURL = tryGetSourceMappingURL; + /* eslint-disable no-null/no-null */ function isStringOrNull(x) { - // tslint:disable-next-line:no-null-keyword return typeof x === "string" || x === null; } function isRawSourceMap(x) { - // tslint:disable-next-line:no-null-keyword return x !== null && typeof x === "object" && x.version === 3 @@ -68180,6 +69063,7 @@ var ts; && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString)); } ts.isRawSourceMap = isRawSourceMap; + /* eslint-enable no-null/no-null */ function tryParseRawSourceMap(text) { try { var parsed = JSON.parse(text); @@ -68548,7 +69432,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 285 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 286 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -68590,25 +69474,31 @@ var ts; var hasExportDefault = false; var exportEquals; var hasExportStarsToExportValues = false; - var hasImportStarOrImportDefault = false; + var hasImportStar = false; + var hasImportDefault = false; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); - hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); + if (!hasImportStar && getImportNeedsImportStarHelper(node)) { + hasImportStar = true; + } + if (!hasImportDefault && getImportNeedsImportDefaultHelper(node)) { + hasImportDefault = true; + } break; - case 249 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + case 250 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 261 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -68638,13 +69528,13 @@ var ts; } } break; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -68652,7 +69542,7 @@ var ts; } } break; - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -68672,7 +69562,7 @@ var ts; } } break; - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -68694,12 +69584,8 @@ var ts; break; } } - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault); - var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault); if (externalHelpersImportDeclaration) { - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); externalImports.unshift(externalHelpersImportDeclaration); } return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames, externalHelpersImportDeclaration: externalHelpersImportDeclaration }; @@ -68774,7 +69660,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 223 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -68838,7 +69724,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 155 /* PropertyDeclaration */ + return member.kind === 156 /* PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; @@ -69287,6 +70173,7 @@ var ts; } ts.restHelper = { name: "typescript:rest", + importName: "__rest", scoped: false, text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n };" }; @@ -69311,7 +70198,7 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), + return ts.createCall(ts.getUnscopedHelperName("__rest"), /*typeArguments*/ undefined, [ value, ts.setTextRange(ts.createArrayLiteral(propertyNames), location) @@ -69364,8 +70251,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(191 /* PropertyAccessExpression */); + context.enableSubstitution(192 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -69391,14 +70278,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 286 /* Bundle */) { + if (node.kind === 287 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288 /* InputFiles */) { + if (prepend.kind === 289 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -69449,16 +70336,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 246 /* ModuleBlock */: - case 219 /* Block */: + case 286 /* SourceFile */: + case 248 /* CaseBlock */: + case 247 /* ModuleBlock */: + case 220 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 241 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -69470,7 +70357,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 === 241 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 242 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -69513,10 +70400,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 256 /* ExportAssignment */: + case 257 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -69537,13 +70424,13 @@ var ts; return node; } switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -69563,11 +70450,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 256 /* ExportDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 251 /* ImportClause */ || - (node.kind === 249 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 260 /* ExternalModuleReference */)) { + if (node.kind === 257 /* ExportDeclaration */ || + node.kind === 251 /* ImportDeclaration */ || + node.kind === 252 /* ImportClause */ || + (node.kind === 250 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 261 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -69591,19 +70478,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: return visitConstructor(node); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 164 /* IndexSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 158 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 218 /* SemicolonClassElement */: + case 219 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -69641,14 +70528,15 @@ var ts; case 78 /* ConstKeyword */: case 126 /* DeclareKeyword */: case 134 /* ReadonlyKeyword */: - // TypeScript accessibility and readonly modifiers are elided. - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 169 /* TypeLiteral */: - case 164 /* TypePredicate */: - case 151 /* TypeParameter */: + // TypeScript accessibility and readonly modifiers are elided + // falls through + case 171 /* ArrayType */: + case 172 /* TupleType */: + case 173 /* OptionalType */: + case 174 /* RestType */: + case 170 /* TypeLiteral */: + case 165 /* TypePredicate */: + case 152 /* TypeParameter */: case 121 /* AnyKeyword */: case 144 /* UnknownKeyword */: case 124 /* BooleanKeyword */: @@ -69657,40 +70545,43 @@ var ts; case 133 /* NeverKeyword */: case 107 /* VoidKeyword */: case 140 /* SymbolKeyword */: - case 167 /* ConstructorType */: - case 166 /* FunctionType */: - case 168 /* TypeQuery */: - case 165 /* TypeReference */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 178 /* ParenthesizedType */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: + case 168 /* ConstructorType */: + case 167 /* FunctionType */: + case 169 /* TypeQuery */: + case 166 /* TypeReference */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: + case 177 /* ConditionalType */: + case 179 /* ParenthesizedType */: + case 180 /* ThisType */: + case 181 /* TypeOperator */: + case 182 /* IndexedAccessType */: + case 183 /* MappedType */: + case 184 /* LiteralType */: // TypeScript type nodes are elided. - case 163 /* IndexSignature */: + // falls through + case 164 /* IndexSignature */: // TypeScript index signatures are elided. - case 153 /* Decorator */: + // falls through + case 154 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 243 /* TypeAliasDeclaration */: + // falls through + case 244 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 155 /* PropertyDeclaration */: + case 156 /* 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 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 158 /* Constructor */: + case 159 /* Constructor */: return visitConstructor(node); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -69700,7 +70591,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -69710,35 +70601,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 159 /* GetAccessor */: + case 160 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 152 /* Parameter */: + case 153 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -69748,35 +70639,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return visitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -70080,7 +70971,7 @@ var ts; var members = []; var constructor = ts.getFirstConstructorWithBody(node); var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (parametersWithPropertyAssignments) { for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) { var parameter = parametersWithPropertyAssignments_1[_i]; @@ -70186,12 +71077,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -70344,7 +71235,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 155 /* PropertyDeclaration */ + ? member.kind === 156 /* 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`. ? ts.createVoidZero() @@ -70467,10 +71358,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 155 /* PropertyDeclaration */; + return kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */ + || kind === 156 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -70480,7 +71371,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 158 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -70491,12 +71382,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return true; } return false; @@ -70513,15 +71404,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 153 /* Parameter */: return serializeTypeNode(node.type); - case 160 /* SetAccessor */: - case 159 /* GetAccessor */: + case 161 /* SetAccessor */: + case 160 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 157 /* MethodDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 158 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -70558,7 +71449,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 159 /* GetAccessor */) { + if (container && node.kind === 160 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -70608,26 +71499,26 @@ var ts; case 97 /* NullKeyword */: case 133 /* NeverKeyword */: return ts.createVoidZero(); - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: return ts.createIdentifier("Function"); - case 170 /* ArrayType */: - case 171 /* TupleType */: + case 171 /* ArrayType */: + case 172 /* TupleType */: return ts.createIdentifier("Array"); - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: case 124 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); case 139 /* StringKeyword */: return ts.createIdentifier("String"); case 137 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 183 /* LiteralType */: + case 184 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: return ts.createIdentifier("String"); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); case 9 /* BigIntLiteral */: @@ -70646,26 +71537,26 @@ var ts; return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return serializeTypeReferenceNode(node); - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 176 /* IntersectionType */: + case 175 /* UnionType */: return serializeTypeList(node.types); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: if (node.operator === 134 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 168 /* TypeQuery */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 169 /* TypeLiteral */: + case 169 /* TypeQuery */: + case 182 /* IndexedAccessType */: + case 183 /* MappedType */: + case 170 /* TypeLiteral */: case 121 /* AnyKeyword */: case 144 /* UnknownKeyword */: - case 179 /* ThisType */: - case 184 /* ImportType */: + case 180 /* ThisType */: + case 185 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -70676,9 +71567,9 @@ var ts; // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var typeNode = types_18[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var typeNode = types_17[_i]; + while (typeNode.kind === 179 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 133 /* NeverKeyword */) { @@ -70793,7 +71684,7 @@ var ts; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. return name; - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -70927,7 +71818,7 @@ var ts; } function transformConstructorBody(body, constructor) { var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (!ts.some(parametersWithPropertyAssignments)) { return ts.visitFunctionBody(body, visitor, context); } @@ -71340,12 +72231,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 285 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 286 /* 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 === 244 /* EnumDeclaration */) { + if (node.kind === 245 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -71470,7 +72361,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 246 /* ModuleBlock */) { + if (body.kind === 247 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -71516,13 +72407,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 (body.kind !== 246 /* ModuleBlock */) { + if (body.kind !== 247 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 246 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -71563,7 +72454,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 252 /* NamespaceImport */) { + if (node.kind === 253 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -71795,16 +72686,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(73 /* Identifier */); - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); + context.enableSubstitution(278 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(245 /* ModuleDeclaration */); + context.enableEmitNotification(246 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 245 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 246 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 244 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 245 /* EnumDeclaration */; } /** * Hook for node emit. @@ -71865,9 +72756,9 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return substituteExpressionIdentifier(node); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -71905,9 +72796,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 !== 285 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 245 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 244 /* EnumDeclaration */); + if (container && container.kind !== 286 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 246 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 245 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -71957,18 +72848,19 @@ var ts; } } context.requestEmitHelper(ts.decorateHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray), location); } ts.decorateHelper = { name: "typescript:decorate", + importName: "__decorate", scoped: false, priority: 2, text: "\n var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n };" }; function createMetadataHelper(context, metadataKey, metadataValue) { context.requestEmitHelper(ts.metadataHelper); - return ts.createCall(ts.getHelperName("__metadata"), + return ts.createCall(ts.getUnscopedHelperName("__metadata"), /*typeArguments*/ undefined, [ ts.createLiteral(metadataKey), metadataValue @@ -71976,13 +72868,14 @@ var ts; } ts.metadataHelper = { name: "typescript:metadata", + importName: "__metadata", scoped: false, priority: 3, text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(ts.paramHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__param"), /*typeArguments*/ undefined, [ ts.createLiteral(parameterOffset), expression @@ -71990,6 +72883,7 @@ var ts; } ts.paramHelper = { name: "typescript:param", + importName: "__param", scoped: false, priority: 4, text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" @@ -72043,11 +72937,11 @@ var ts; if (!(node.transformFlags & 1048576 /* ContainsClassFields */)) return node; switch (node.kind) { - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return visitClassExpression(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); } return ts.visitEachChild(node, visitor, context); @@ -72059,20 +72953,20 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 158 /* MethodDeclaration */: // Visit the name of the member (if it's a computed property name). return ts.visitEachChild(node, classElementVisitor, context); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 218 /* SemicolonClassElement */: + case 219 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -72082,7 +72976,7 @@ var ts; var savedPendingStatements = pendingStatements; pendingStatements = []; var visitedNode = ts.visitEachChild(node, visitor, context); - var statement = ts.some(pendingStatements) ? [visitedNode].concat(pendingStatements) : + var statement = ts.some(pendingStatements) ? __spreadArrays([visitedNode], pendingStatements) : visitedNode; pendingStatements = savedPendingStatements; return statement; @@ -72252,7 +73146,7 @@ var ts; if (constructor && constructor.body) { var parameterPropertyDeclarationCount = 0; for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) { - if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]))) { + if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) { parameterPropertyDeclarationCount++; } else { @@ -72434,6 +73328,7 @@ var ts; var hasSuperElementAccess; /** A set of node IDs for generated super accessors (variable statements). */ var substitutedSuperAccessors = []; + var topLevel; // Save the previous transformation hooks. var previousOnEmitNode = context.onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; @@ -72445,10 +73340,23 @@ var ts; if (node.isDeclarationFile) { return node; } + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitor(node) { if ((node.transformFlags & 32 /* ContainsES2017 */) === 0) { return node; @@ -72457,26 +73365,32 @@ var ts; case 122 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return visitAwaitExpression(node); - case 157 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 240 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: - return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 241 /* FunctionDeclaration */: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 198 /* FunctionExpression */: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 199 /* ArrowFunction */: return visitArrowFunction(node); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 159 /* Constructor */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -72484,27 +73398,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 219 /* Block */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 232 /* WithStatement */: - case 234 /* LabeledStatement */: + case 220 /* Block */: + case 234 /* SwitchStatement */: + case 248 /* CaseBlock */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: + case 237 /* TryStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 224 /* IfStatement */: + case 233 /* WithStatement */: + case 235 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -72705,7 +73619,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 === 198 /* ArrowFunction */; + var isArrowFunction = node.kind === 199 /* 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 @@ -72728,7 +73642,7 @@ var ts; if (!isArrowFunction) { var statements = []; var statementOffset = ts.addPrologue(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); - statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); + statements.push(ts.createReturn(createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. @@ -72755,7 +73669,7 @@ var ts; result = block; } else { - var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); + var expression = createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); @@ -72796,17 +73710,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(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(193 /* CallExpression */); + context.enableSubstitution(191 /* PropertyAccessExpression */); + context.enableSubstitution(192 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(242 /* ClassDeclaration */); + context.enableEmitNotification(158 /* MethodDeclaration */); + context.enableEmitNotification(160 /* GetAccessor */); + context.enableEmitNotification(161 /* SetAccessor */); + context.enableEmitNotification(159 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(221 /* VariableStatement */); } } /** @@ -72854,11 +73768,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -72882,19 +73796,19 @@ var ts; ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 242 /* ClassDeclaration */ + || kind === 159 /* Constructor */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -72954,11 +73868,12 @@ var ts; ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; ts.awaiterHelper = { name: "typescript:awaiter", + importName: "__awaiter", scoped: false, priority: 5, text: "\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };" }; - function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { + function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression( /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), @@ -72968,9 +73883,9 @@ var ts; /*type*/ undefined, body); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; - return ts.createCall(ts.getHelperName("__awaiter"), + return ts.createCall(ts.getUnscopedHelperName("__awaiter"), /*typeArguments*/ undefined, [ - ts.createThis(), + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), generatorFunc @@ -73004,9 +73919,11 @@ var ts; context.onEmitNode = onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; + var exportedVariableStatement = false; var enabledSubstitutions; var enclosingFunctionFlags; var enclosingSuperContainerFlags = 0; + var topLevel; /** Keeps track of property names accessed on super (`super.x`) within async functions. */ var capturedSuperProperties; /** Whether the async function contains an element access on super (`super[x]`). */ @@ -73018,6 +73935,8 @@ var ts; if (node.isDeclarationFile) { return node; } + exportedVariableStatement = false; + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -73034,63 +73953,80 @@ var ts; } return node; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitorWorker(node, noDestructuringValue) { if ((node.transformFlags & 16 /* ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return visitAwaitExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return visitYieldExpression(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitReturnStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitLabeledStatement(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClause(node); - case 238 /* VariableDeclaration */: + case 221 /* VariableStatement */: + return visitVariableStatement(node); + case 239 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return visitVoidExpression(node); - case 158 /* Constructor */: - return visitConstructorDeclaration(node); - case 157 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - return visitGetAccessorDeclaration(node); - case 160 /* SetAccessor */: - return visitSetAccessorDeclaration(node); - case 240 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: - return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 159 /* Constructor */: + return doOutsideOfTopLevel(visitConstructorDeclaration, node); + case 158 /* MethodDeclaration */: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 160 /* GetAccessor */: + return doOutsideOfTopLevel(visitGetAccessorDeclaration, node); + case 161 /* SetAccessor */: + return doOutsideOfTopLevel(visitSetAccessorDeclaration, node); + case 241 /* FunctionDeclaration */: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 198 /* FunctionExpression */: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 199 /* ArrowFunction */: return visitArrowFunction(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return visitParameter(node); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return visitExpressionStatement(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -73123,7 +74059,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 228 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 229 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -73135,7 +74071,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 === 278 /* SpreadAssignment */) { + if (e.kind === 279 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -73144,7 +74080,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 276 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 277 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -73178,7 +74114,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 !== 189 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 190 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } var expression = objects[0]; @@ -73223,23 +74159,44 @@ var ts; var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { - block = ts.updateBlock(block, [ + block = ts.updateBlock(block, __spreadArrays([ ts.createVariableStatement(/*modifiers*/ undefined, visitedBindings) - ].concat(block.statements)); + ], block.statements)); } return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, /*type*/ undefined, /*initializer*/ undefined), block); } return ts.visitEachChild(node, visitor, context); } + function visitVariableStatement(node) { + if (ts.hasModifier(node, 1 /* Export */)) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = true; + var visited = ts.visitEachChild(node, visitor, context); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return ts.visitEachChild(node, visitor, context); + } /** * Visits a VariableDeclaration node with a binding pattern. * * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { + if (exportedVariableStatement) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = false; + var visited = visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ true); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ false); + } + 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 & 8192 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */); + return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, + /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); } @@ -73457,7 +74414,7 @@ var ts; /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))))); + /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !topLevel)); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); @@ -73523,17 +74480,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(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(193 /* CallExpression */); + context.enableSubstitution(191 /* PropertyAccessExpression */); + context.enableSubstitution(192 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(242 /* ClassDeclaration */); + context.enableEmitNotification(158 /* MethodDeclaration */); + context.enableEmitNotification(160 /* GetAccessor */); + context.enableEmitNotification(161 /* SetAccessor */); + context.enableEmitNotification(159 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(221 /* VariableStatement */); } } /** @@ -73581,11 +74538,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -73609,19 +74566,19 @@ var ts; ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 242 /* ClassDeclaration */ + || kind === 159 /* Constructor */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -73637,65 +74594,69 @@ var ts; ts.transformES2018 = transformES2018; ts.assignHelper = { name: "typescript:assign", + importName: "__assign", scoped: false, priority: 1, text: "\n var __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n };" }; function createAssignHelper(context, attributesSegments) { if (context.getCompilerOptions().target >= 2 /* ES2015 */) { - return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), - /*typeArguments*/ undefined, attributesSegments); + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } context.requestEmitHelper(ts.assignHelper); - return ts.createCall(ts.getHelperName("__assign"), + return ts.createCall(ts.getUnscopedHelperName("__assign"), /*typeArguments*/ undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; ts.awaitHelper = { name: "typescript:await", + importName: "__await", scoped: false, text: "\n var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }" }; function createAwaitHelper(context, expression) { context.requestEmitHelper(ts.awaitHelper); - return ts.createCall(ts.getHelperName("__await"), /*typeArguments*/ undefined, [expression]); + return ts.createCall(ts.getUnscopedHelperName("__await"), /*typeArguments*/ undefined, [expression]); } ts.asyncGeneratorHelper = { name: "typescript:asyncGenerator", + importName: "__asyncGenerator", scoped: false, text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n };" }; - function createAsyncGeneratorHelper(context, generatorFunc) { + function createAsyncGeneratorHelper(context, generatorFunc, hasLexicalThis) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */; - return ts.createCall(ts.getHelperName("__asyncGenerator"), + return ts.createCall(ts.getUnscopedHelperName("__asyncGenerator"), /*typeArguments*/ undefined, [ - ts.createThis(), + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), ts.createIdentifier("arguments"), generatorFunc ]); } ts.asyncDelegator = { name: "typescript:asyncDelegator", + importName: "__asyncDelegator", scoped: false, text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\n };" }; function createAsyncDelegatorHelper(context, expression, location) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncDelegator); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncDelegator"), /*typeArguments*/ undefined, [expression]), location); } ts.asyncValues = { name: "typescript:asyncValues", + importName: "__asyncValues", scoped: false, text: "\n var __asyncValues = (this && this.__asyncValues) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n };" }; function createAsyncValuesHelper(context, expression, location) { context.requestEmitHelper(ts.asyncValues); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncValues"), /*typeArguments*/ undefined, [expression]), location); } })(ts || (ts = {})); @@ -73715,7 +74676,7 @@ var ts; return node; } switch (node.kind) { - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -73784,13 +74745,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 261 /* JsxElement */: + case 262 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -73800,13 +74761,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return visitJsxExpression(node); - case 261 /* JsxElement */: + case 262 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -73881,7 +74842,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 271 /* JsxExpression */) { + else if (node.kind === 272 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -73975,7 +74936,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 261 /* JsxElement */) { + if (node.kind === 262 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -74281,7 +75242,7 @@ var ts; return node; } switch (node.kind) { - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74494,13 +75455,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 231 /* ReturnStatement */ + && node.kind === 232 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */))) + || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 220 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -74522,63 +75483,63 @@ var ts; switch (node.kind) { case 117 /* StaticKeyword */: return undefined; // elide static keyword - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return visitClassExpression(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return visitParameter(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return visitArrowFunction(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return visitFunctionExpression(node); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return visitVariableDeclaration(node); case 73 /* Identifier */: return visitIdentifier(node); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return visitCaseBlock(node); - case 219 /* Block */: + case 220 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitLabeledStatement(node); - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return visitExpressionStatement(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClause(node); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return visitNewExpression(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -74589,28 +75550,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return visitTemplateExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return visitYieldExpression(node); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return visitSpreadElement(node); case 99 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); case 101 /* ThisKeyword */: return visitThisKeyword(node); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return visitMetaProperty(node); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -74701,14 +75662,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 === 230 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 231 /* 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 === 230 /* BreakStatement */) { + if (node.kind === 231 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -74719,7 +75680,7 @@ var ts; } } else { - if (node.kind === 230 /* BreakStatement */) { + if (node.kind === 231 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -75115,11 +76076,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 231 /* ReturnStatement */) { + if (statement.kind === 232 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 223 /* IfStatement */) { + else if (statement.kind === 224 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -75127,7 +76088,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 219 /* Block */) { + else if (statement.kind === 220 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -75325,7 +76286,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 199 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, ts.createThis()); return true; } @@ -75346,22 +76307,22 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return statements; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 158 /* Constructor */: + case 159 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 198 /* 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 = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 95 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); @@ -75393,20 +76354,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 218 /* SemicolonClassElement */: + case 219 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 158 /* Constructor */: + case 159 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -75594,7 +76555,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 === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 241 /* FunctionDeclaration */ || node.kind === 198 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -75638,7 +76599,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 198 /* ArrowFunction */); + ts.Debug.assert(node.kind === 199 /* 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 @@ -75706,9 +76667,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -75727,9 +76688,9 @@ var ts; // expression. If we are in a state where we do not need the destructuring value, // we pass that information along to the children that care about it. switch (node.expression.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -75938,14 +76899,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -76133,7 +77094,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 150 /* ComputedPropertyName */) { + if (property.name.kind === 151 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -76254,11 +77215,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 226 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 227 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 228 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 224 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 225 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 227 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 228 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 229 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 225 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 226 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -76283,11 +77244,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 240 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -76686,20 +77647,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -76775,7 +77736,7 @@ var ts; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); - return ts.updateBlock(block, [statement].concat(transformedStatements)); + return ts.updateBlock(block, __spreadArrays([statement], transformedStatements)); } /** * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a @@ -76806,7 +77767,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 160 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -77043,7 +78004,7 @@ var ts; // [output] // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray(__spreadArrays([ts.createVoidZero()], node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), /*typeArguments*/ undefined, []); } return ts.visitEachChild(node, visitor, context); @@ -77207,13 +78168,16 @@ var ts; // Find original source text, since we need to emit the raw strings of the tagged template. // The raw strings contain the (escaped) strings of what the user wrote. // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), - // thus we need to remove those characters. - // First template piece starts with "`", others with "}" - // Last template piece ends with "`", others with "${" - var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; - text = text.substring(1, text.length - (isLast ? 1 : 2)); + var text = node.rawText; + if (text === undefined) { + text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), + // thus we need to remove those characters. + // First template piece starts with "`", others with "}" + // Last template piece ends with "`", others with "${" + var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; + text = text.substring(1, text.length - (isLast ? 1 : 2)); + } // Newline normalization: // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's // and LineTerminatorSequences are normalized to for both TV and TRV. @@ -77304,10 +78268,8 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ - && !isExpressionOfCall - ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") - : ts.createFileLevelUniqueName("_super"); + return hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") : + ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { if (node.keywordToken === 96 /* NewKeyword */ && node.name.escapedText === "target") { @@ -77353,13 +78315,13 @@ var ts; if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; context.enableSubstitution(101 /* ThisKeyword */); - context.enableEmitNotification(158 /* Constructor */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(198 /* ArrowFunction */); - context.enableEmitNotification(197 /* FunctionExpression */); - context.enableEmitNotification(240 /* FunctionDeclaration */); + context.enableEmitNotification(159 /* Constructor */); + context.enableEmitNotification(158 /* MethodDeclaration */); + context.enableEmitNotification(160 /* GetAccessor */); + context.enableEmitNotification(161 /* SetAccessor */); + context.enableEmitNotification(199 /* ArrowFunction */); + context.enableEmitNotification(198 /* FunctionExpression */); + context.enableEmitNotification(241 /* FunctionDeclaration */); } } /** @@ -77400,10 +78362,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 238 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 239 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -77485,11 +78447,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 222 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 223 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 192 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 193 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -77497,7 +78459,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 209 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 210 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -77507,7 +78469,7 @@ var ts; ts.transformES2015 = transformES2015; function createExtendsHelper(context, name) { context.requestEmitHelper(ts.extendsHelper); - return ts.createCall(ts.getHelperName("__extends"), + return ts.createCall(ts.getUnscopedHelperName("__extends"), /*typeArguments*/ undefined, [ name, ts.createFileLevelUniqueName("_super") @@ -77515,7 +78477,7 @@ var ts; } function createTemplateObjectHelper(context, cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); - return ts.createCall(ts.getHelperName("__makeTemplateObject"), + return ts.createCall(ts.getUnscopedHelperName("__makeTemplateObject"), /*typeArguments*/ undefined, [ cooked, raw @@ -77523,12 +78485,14 @@ var ts; } ts.extendsHelper = { name: "typescript:extends", + importName: "__extends", scoped: false, priority: 0, text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; ts.templateObjectHelper = { name: "typescript:makeTemplateObject", + importName: "__makeTemplateObject", scoped: false, priority: 0, text: "\n var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n };" @@ -77550,15 +78514,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(263 /* JsxOpeningElement */); - context.enableEmitNotification(264 /* JsxClosingElement */); - context.enableEmitNotification(262 /* JsxSelfClosingElement */); + context.enableEmitNotification(264 /* JsxOpeningElement */); + context.enableEmitNotification(265 /* JsxClosingElement */); + context.enableEmitNotification(263 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(276 /* PropertyAssignment */); + context.enableSubstitution(191 /* PropertyAccessExpression */); + context.enableSubstitution(277 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -77577,9 +78541,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 265 /* JsxClosingElement */: + case 263 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -77911,13 +78875,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 224 /* DoStatement */: + case 225 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return visitWhileStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return visitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -77930,24 +78894,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return visitFunctionExpression(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatement(node); - case 230 /* BreakStatement */: + case 231 /* BreakStatement */: return visitBreakStatement(node); - case 229 /* ContinueStatement */: + case 230 /* ContinueStatement */: return visitContinueStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 131072 /* ContainsYield */) { @@ -77968,21 +78932,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return visitConditionalExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return visitYieldExpression(node); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -77995,9 +78959,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -78225,7 +79189,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -78237,7 +79201,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -78463,13 +79427,13 @@ var ts; temp = declareLocal(); var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements); emitAssignment(temp, ts.createArrayLiteral(leadingElement - ? [leadingElement].concat(initialElements) : initialElements)); + ? __spreadArrays([leadingElement], initialElements) : initialElements)); leadingElement = undefined; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return temp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { var hasAssignedTemp = temp !== undefined; @@ -78478,7 +79442,7 @@ var ts; } emitAssignment(temp, hasAssignedTemp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); + : ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine)); leadingElement = undefined; expressions = []; } @@ -78613,35 +79577,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 219 /* Block */: + case 220 /* Block */: return transformAndEmitBlock(node); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return transformAndEmitIfStatement(node); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return transformAndEmitDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return transformAndEmitForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 229 /* ContinueStatement */: + case 230 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 230 /* BreakStatement */: + case 231 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return transformAndEmitWithStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -79071,7 +80035,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 273 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 274 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -79084,7 +80048,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 273 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -79257,11 +80221,10 @@ var ts; return node; } function cacheExpression(node) { - var temp; if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { return node; } - temp = ts.createTempVariable(hoistVariableDeclaration); + var temp = ts.createTempVariable(hoistVariableDeclaration); emitAssignment(temp, node, /*location*/ node); return temp; } @@ -80222,7 +81185,7 @@ var ts; ts.transformGenerators = transformGenerators; function createGeneratorHelper(context, body) { context.requestEmitHelper(ts.generatorHelper); - return ts.createCall(ts.getHelperName("__generator"), + return ts.createCall(ts.getUnscopedHelperName("__generator"), /*typeArguments*/ undefined, [ts.createThis(), body]); } // The __generator helper is used by down-level transformations to emulate the runtime @@ -80286,6 +81249,7 @@ var ts; // For examples of how these are used, see the comments in ./transformers/generators.ts ts.generatorHelper = { name: "typescript:generator", + importName: "__generator", scoped: false, priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" @@ -80313,11 +81277,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(206 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(204 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(205 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(278 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(286 /* 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. @@ -80415,14 +81379,14 @@ var ts; // define(moduleName?, ["module1", "module2"], function ... var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createExpressionStatement(ts.createCall(define, - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ + /*typeArguments*/ undefined, __spreadArrays((moduleName ? [moduleName] : []), [ // Add the dependency array argument: // // ["require", "exports", module1", "module2", ...] - ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : [ + ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : __spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), // Add the module body function argument: // // function (require, exports, module1, module2) ... @@ -80432,10 +81396,10 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ + /*typeParameters*/ undefined, __spreadArrays([ ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), + ], importAliasNames), /*type*/ undefined, transformAsynchronousModuleBody(node)) ]))) ]), @@ -80470,11 +81434,11 @@ var ts; ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ - ts.createArrayLiteral([ + /*typeArguments*/ undefined, __spreadArrays((moduleName ? [moduleName] : []), [ + ts.createArrayLiteral(__spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), ts.createIdentifier("factory") ]))) ]))) @@ -80502,10 +81466,10 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ + /*typeParameters*/ undefined, __spreadArrays([ ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), + ], importAliasNames), /*type*/ undefined, transformAsynchronousModuleBody(node)) ])) ]), @@ -80645,23 +81609,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return visitExportDeclaration(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitExportAssignment(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return visitClassDeclaration(node); - case 317 /* MergeDeclarationMarker */: + case 319 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 318 /* EndOfDeclarationMarker */: + case 320 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -80688,24 +81652,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -80820,7 +81784,7 @@ var ts; var promise = ts.createNew(ts.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getHelperName("__importStar")]); + return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getUnscopedHelperName("__importStar")]); } return promise; } @@ -80834,7 +81798,7 @@ var ts; var requireCall = ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - requireCall = ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); + requireCall = ts.createCall(ts.getUnscopedHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); } var func; if (languageVersion >= 2 /* ES2015 */) { @@ -80868,11 +81832,11 @@ var ts; } if (ts.getImportNeedsImportStarHelper(node)) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); } if (ts.getImportNeedsImportDefaultHelper(node)) { context.requestEmitHelper(ts.importDefaultHelper); - return ts.createCall(ts.getHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); } return innerExpr; } @@ -81183,7 +82147,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 221 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -81238,10 +82202,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 254 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -81440,7 +82404,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -81504,10 +82468,10 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return substituteBinaryExpression(node); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -81528,7 +82492,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 286 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -81603,7 +82567,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 /* PostfixUnaryExpression */ + var expression = node.kind === 205 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 /* PlusPlusToken */ ? 61 /* PlusEqualsToken */ : 62 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; @@ -81644,7 +82608,7 @@ var ts; function createExportStarHelper(context, module) { var compilerOptions = context.getCompilerOptions(); return compilerOptions.importHelpers - ? ts.createCall(ts.getHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]) + ? ts.createCall(ts.getUnscopedHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]) : ts.createCall(ts.createIdentifier("__export"), /*typeArguments*/ undefined, [module]); } // emit helper for dynamic import @@ -81656,12 +82620,14 @@ var ts; // emit helper for `import * as Name from "foo"` ts.importStarHelper = { name: "typescript:commonjsimportstar", + importName: "__importStar", scoped: false, text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};" }; // emit helper for `import Name from "foo"` ts.importDefaultHelper = { name: "typescript:commonjsimportdefault", + importName: "__importDefault", scoped: false, text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};" }; @@ -81679,15 +82645,17 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(278 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(206 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(204 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(205 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(216 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(286 /* 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. var noSubstitutionMap = []; // Set of nodes for which substitution rules should be ignored for each file. + var contextObjectMap = []; // The context object associated with a source file. var currentSourceFile; // The current file. var moduleInfo; // ExternalModuleInfo for the current file. var exportFunction; // The export function for the current file. @@ -81726,7 +82694,7 @@ var ts; // existing identifiers. exportFunction = ts.createUniqueName("exports"); exportFunctionsMap[id] = exportFunction; - contextObject = ts.createUniqueName("context"); + contextObject = contextObjectMap[id] = ts.createUniqueName("context"); // Add the body of the module. var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups); @@ -81904,7 +82872,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 256 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 257 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -81929,7 +82897,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 256 /* ExportDeclaration */) { + if (externalImport.kind !== 257 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -82007,19 +82975,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -82069,15 +83037,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -82253,7 +83221,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 === 285 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 286 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -82317,7 +83285,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 === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 221 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -82379,10 +83347,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 254 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -82562,43 +83530,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatement(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatement(node); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return visitWhileStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitLabeledStatement(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return visitWithStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return visitCaseBlock(node); - case 272 /* CaseClause */: + case 273 /* CaseClause */: return visitCaseClause(node); - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: return visitDefaultClause(node); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return visitTryStatement(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClause(node); - case 219 /* Block */: + case 220 /* Block */: return visitBlock(node); - case 317 /* MergeDeclarationMarker */: + case 319 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 318 /* EndOfDeclarationMarker */: + case 320 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -82845,7 +83813,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 285 /* SourceFile */; + return container !== undefined && container.kind === 286 /* SourceFile */; } else { return false; @@ -82878,12 +83846,13 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; exportFunction = exportFunctionsMap[id]; noSubstitution = noSubstitutionMap[id]; + contextObject = contextObjectMap[id]; if (noSubstitution) { delete noSubstitutionMap[id]; } @@ -82891,6 +83860,7 @@ var ts; currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; + contextObject = undefined; noSubstitution = undefined; } else { @@ -82926,7 +83896,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -82962,11 +83932,13 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return substituteBinaryExpression(node); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); + case 216 /* MetaProperty */: + return substituteMetaProperty(node); } return node; } @@ -83058,14 +84030,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 /* PostfixUnaryExpression */ + var expression = node.kind === 205 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(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 === 204 /* PostfixUnaryExpression */) { + if (node.kind === 205 /* PostfixUnaryExpression */) { expression = node.operator === 44 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -83075,6 +84047,12 @@ var ts; } return node; } + function substituteMetaProperty(node) { + if (ts.isImportMeta(node)) { + return ts.createPropertyAccess(contextObject, ts.createIdentifier("meta")); + } + return node; + } /** * Gets the exports of a name. * @@ -83087,7 +84065,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 286 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -83126,24 +84104,20 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(285 /* SourceFile */); + context.enableEmitNotification(286 /* SourceFile */); context.enableSubstitution(73 /* Identifier */); - var currentSourceFile; + var helperNameSubstitutions; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { return node; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); - if (externalHelpersModuleName) { + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(node, compilerOptions); + if (externalHelpersImportDeclaration) { var statements = []; var statementOffset = ts.addPrologue(statements, node.statements); - var tslibImport = ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); - ts.addEmitFlags(tslibImport, 67108864 /* NeverApplyImportHelper */); - ts.append(statements, tslibImport); + ts.append(statements, externalHelpersImportDeclaration); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } @@ -83155,10 +84129,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -83179,9 +84153,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { if (ts.isSourceFile(node)) { - currentSourceFile = node; + helperNameSubstitutions = ts.createMap(); previousOnEmitNode(hint, node, emitCallback); - currentSourceFile = undefined; + helperNameSubstitutions = undefined; } else { previousOnEmitNode(hint, node, emitCallback); @@ -83198,19 +84172,18 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (ts.isIdentifier(node) && hint === 1 /* Expression */) { - return substituteExpressionIdentifier(node); + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* HelperName */) { + return substituteHelperName(node); } return node; } - function substituteExpressionIdentifier(node) { - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { - var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); - if (externalHelpersModuleName) { - return ts.createPropertyAccess(externalHelpersModuleName, node); - } + function substituteHelperName(node) { + var name = ts.idText(node); + var substitution = helperNameSubstitutions.get(name); + if (!substitution) { + helperNameSubstitutions.set(name, substitution = ts.createFileLevelUniqueName(name)); } - return node; + return substitution; } } ts.transformES2015Module = transformES2015Module; @@ -83266,7 +84239,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 242 /* 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 : @@ -83295,7 +84268,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 242 /* 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 : @@ -83321,7 +84294,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node) && ts.hasModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8 /* Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -83342,7 +84315,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 === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 239 /* VariableDeclaration */ || node.kind === 188 /* 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 : @@ -83351,8 +84324,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 === 155 /* PropertyDeclaration */ || node.kind === 190 /* PropertyAccessExpression */ || node.kind === 154 /* PropertySignature */ || - (node.kind === 152 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 156 /* PropertyDeclaration */ || node.kind === 191 /* PropertyAccessExpression */ || node.kind === 155 /* PropertySignature */ || + (node.kind === 153 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -83361,7 +84334,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 === 241 /* ClassDeclaration */ || node.kind === 152 /* Parameter */) { + else if (node.parent.kind === 242 /* ClassDeclaration */ || node.kind === 153 /* 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 : @@ -83386,7 +84359,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 161 /* 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.hasModifier(node, 32 /* Static */)) { @@ -83425,26 +84398,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 162 /* ConstructSignature */: + case 163 /* 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 161 /* CallSignature */: + case 162 /* 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 163 /* IndexSignature */: + case 164 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -83452,7 +84425,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 242 /* 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 : @@ -83466,7 +84439,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 240 /* FunctionDeclaration */: + case 241 /* 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 : @@ -83491,30 +84464,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 158 /* Constructor */: + case 159 /* 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 162 /* ConstructSignature */: - case 167 /* ConstructorType */: + case 163 /* ConstructSignature */: + case 168 /* 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 161 /* CallSignature */: + case 162 /* 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 163 /* IndexSignature */: + case 164 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -83522,7 +84495,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 === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 242 /* 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 : @@ -83535,8 +84508,8 @@ 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 240 /* FunctionDeclaration */: - case 166 /* FunctionType */: + case 241 /* FunctionDeclaration */: + case 167 /* 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 : @@ -83550,39 +84523,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 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 182 /* MappedType */: + case 183 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 168 /* ConstructorType */: + case 163 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 161 /* CallSignature */: + case 162 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.hasModifier(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 === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 242 /* 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 166 /* FunctionType */: - case 240 /* FunctionDeclaration */: + case 167 /* FunctionType */: + case 241 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -83597,7 +84570,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + if (node.parent.parent.kind === 242 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 110 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -83648,7 +84621,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 152 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 153 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -83709,6 +84682,7 @@ var ts; var currentSourceFile; var refs; var libs; + var emittedImports; // must be declared in container so it can be `undefined` while transformer's first pass var resolver = context.getEmitResolver(); var options = context.getCompilerOptions(); var newLine = ts.getNewLineCharacter(options); @@ -83798,10 +84772,10 @@ var ts; return ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createNamedExports([]), /*moduleSpecifier*/ undefined); } function transformRoot(node) { - if (node.kind === 285 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 286 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { return node; } - if (node.kind === 286 /* Bundle */) { + if (node.kind === 287 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); @@ -83831,7 +84805,7 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288 /* InputFiles */) { + if (prepend.kind === 289 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -83871,9 +84845,9 @@ var ts; var statements = ts.visitNodes(node.statements, visitDeclarationStatements); var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); refs.forEach(referenceVisitor); - var emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { - combinedStatements = ts.setTextRange(ts.createNodeArray(combinedStatements.concat([createEmptyExports()])), combinedStatements); + combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [createEmptyExports()])), combinedStatements); } var updated = ts.updateSourceFileNode(node, combinedStatements, /*isDeclarationFile*/ true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences()); updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit; @@ -83915,6 +84889,15 @@ 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, host.getSourceFiles(), + /*preferences*/ undefined, host.redirectTargetsMap); + if (!ts.pathIsRelative(specifier)) { + // If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration + // via a non-relative name, emit a type reference directive to that non-relative name, rather than + // a relative path to the declaration file + recordTypeReferenceDirectivesIfNecessary([specifier]); + return; + } var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); if (ts.startsWith(fileName, "./") && ts.hasExtension(fileName)) { @@ -83955,7 +84938,7 @@ var ts; return name; } else { - if (name.kind === 186 /* ArrayBindingPattern */) { + if (name.kind === 187 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -83963,20 +84946,20 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 211 /* OmittedExpression */) { + if (elem.kind === 212 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); } } - function ensureParameter(p, modifierMask) { + function ensureParameter(p, modifierMask, type) { var oldDiag; if (!suppressNewDiagnosticContexts) { oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } var newParam = ts.updateParameter(p, - /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(56 /* QuestionToken */)) : undefined, ensureType(p, p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param + /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(56 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -84001,7 +84984,7 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 152 /* Parameter */ && + var shouldUseResolverType = node.kind === 153 /* Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { @@ -84010,7 +84993,7 @@ var ts; if (!ts.getParseTreeNode(node)) { return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(121 /* AnyKeyword */); } - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 161 /* 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 ts.createKeywordTypeNode(121 /* AnyKeyword */); @@ -84021,12 +85004,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 239 /* VariableDeclaration */ || node.kind === 188 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 152 /* Parameter */ - || node.kind === 155 /* PropertyDeclaration */ - || node.kind === 154 /* PropertySignature */) { + if (node.kind === 153 /* Parameter */ + || node.kind === 156 /* PropertyDeclaration */ + || node.kind === 155 /* 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)); @@ -84043,20 +85026,20 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 241 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 243 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 245 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 250 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: + case 256 /* ExportAssignment */: return false; } return false; @@ -84083,6 +85066,33 @@ var ts; } return ts.createNodeArray(newParams, params.hasTrailingComma); } + function updateAccessorParamsList(input, isPrivate) { + var newParams; + if (!isPrivate) { + var thisParameter = ts.getThisParameter(input); + if (thisParameter) { + newParams = [ensureParameter(thisParameter)]; + } + } + if (ts.isSetAccessorDeclaration(input)) { + var newValueParameter = void 0; + if (!isPrivate) { + var valueParameter = ts.getSetAccessorValueParameter(input); + if (valueParameter) { + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + newValueParameter = ensureParameter(valueParameter, /*modifierMask*/ undefined, accessorType); + } + } + if (!newValueParameter) { + newValueParameter = ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "value"); + } + newParams = ts.append(newParams, newValueParameter); + } + return ts.createNodeArray(newParams || ts.emptyArray); + } function ensureTypeParams(node, params) { return ts.hasModifier(node, 8 /* Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } @@ -84110,7 +85120,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 245 /* ModuleDeclaration */ && parent.kind !== 184 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 246 /* ModuleDeclaration */ && parent.kind !== 185 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -84130,7 +85140,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 261 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -84157,7 +85167,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 253 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -84249,6 +85259,11 @@ var ts; enclosingDeclaration = input; } var oldDiag = getSymbolAccessibilityDiagnostic; + // Setup diagnostic-related flags before first potential `cleanup` call, otherwise + // We'd see a TDZ violation at runtime + var canProduceDiagnostic = ts.canProduceDiagnostics(input); + var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 170 /* TypeLiteral */ || input.kind === 183 /* MappedType */) && input.parent.kind !== 244 /* TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { if (ts.hasModifier(input, 8 /* Private */)) { @@ -84257,76 +85272,87 @@ var ts; return cleanup(ts.createProperty(/*decorators*/ undefined, ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); } } - var canProdiceDiagnostic = ts.canProduceDiagnostics(input); - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input); } if (ts.isTypeQueryNode(input)) { checkEntityNameVisibility(input.exprName, enclosingDeclaration); } - var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 169 /* TypeLiteral */ || input.kind === 182 /* MappedType */) && input.parent.kind !== 243 /* TypeAliasDeclaration */); if (shouldEnterSuppressNewDiagnosticsContextContext) { // We stop making new diagnostic contexts within object literal types. Unless it's an object type on the RHS of a type alias declaration. Then we do. suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 212 /* ExpressionWithTypeArguments */: { + case 213 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 165 /* TypeReference */: { + case 166 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 158 /* Constructor */: { + case 159 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(158 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + var ctor = ts.createSignatureDeclaration(159 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), // TODO: GH#18217 isPrivate ? undefined : updateParamsList(input, input.parameters, 0 /* None */), /*type*/ undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 157 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(156 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 158 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(157 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 159 /* GetAccessor */: { + case 160 /* GetAccessor */: { + // For now, only emit class accessors as accessors if they were already declared in an ambient context. + if (input.flags & 4194304 /* Ambient */) { + var isPrivate = ts.hasModifier(input, 8 /* Private */); + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + return cleanup(ts.updateGetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, + /*body*/ undefined)); + } var newNode = ensureAccessor(input); return cleanup(newNode); } - case 160 /* SetAccessor */: { + case 161 /* SetAccessor */: { + // For now, only emit class accessors as accessors if they were already declared in an ambient context. + if (input.flags & 4194304 /* Ambient */) { + return cleanup(ts.updateSetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8 /* Private */)), + /*body*/ undefined)); + } var newNode = ensureAccessor(input); return cleanup(newNode); } - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return cleanup(ts.updateProperty(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 154 /* PropertySignature */: + case 155 /* PropertySignature */: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 156 /* MethodSignature */: { + case 157 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 161 /* CallSignature */: { + case 162 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 163 /* IndexSignature */: { + case 164 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(121 /* AnyKeyword */))); } - case 238 /* VariableDeclaration */: { + case 239 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -84334,13 +85360,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(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 151 /* TypeParameter */: { + case 152 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 176 /* ConditionalType */: { + case 177 /* 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); @@ -84352,13 +85378,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 166 /* FunctionType */: { + case 167 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 167 /* ConstructorType */: { + case 168 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 184 /* ImportType */: { + case 185 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -84368,13 +85394,13 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { - if (returnValue && canProdiceDiagnostic && ts.hasDynamicName(input)) { + if (returnValue && canProduceDiagnostic && ts.hasDynamicName(input)) { checkName(input); } if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; } - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } if (shouldEnterSuppressNewDiagnosticsContextContext) { @@ -84387,7 +85413,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 157 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 158 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -84397,7 +85423,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 256 /* ExportDeclaration */: { + case 257 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -84406,7 +85432,7 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 255 /* ExportAssignment */: { + case 256 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; @@ -84447,10 +85473,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249 /* ImportEqualsDeclaration */: { + case 250 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 250 /* ImportDeclaration */: { + case 251 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -84471,14 +85497,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 243 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 244 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 242 /* InterfaceDeclaration */: { + case 243 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 240 /* FunctionDeclaration */: { + case 241 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -84526,10 +85552,10 @@ var ts; return clean; } } - case 245 /* ModuleDeclaration */: { + case 246 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 246 /* ModuleBlock */) { + if (inner && inner.kind === 247 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; @@ -84545,7 +85571,7 @@ var ts; // 3. Some things are exported, some are not, and there's no marker - add an empty marker if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) { if (needsScopeFixMarker) { - lateStatements = ts.createNodeArray(lateStatements.concat([createEmptyExports()])); + lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [createEmptyExports()])); } else { lateStatements = ts.visitNodes(lateStatements, stripExportModifiers); @@ -84572,7 +85598,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 241 /* ClassDeclaration */: { + case 242 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -84643,10 +85669,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 220 /* VariableStatement */: { + case 221 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 244 /* EnumDeclaration */: { + case 245 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -84665,7 +85691,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 245 /* ModuleDeclaration */) { + if (input.kind === 246 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -84686,7 +85712,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 211 /* OmittedExpression */) { + if (e.kind === 212 /* OmittedExpression */) { return; } if (e.name) { @@ -84736,24 +85762,33 @@ var ts; function ensureModifierFlags(node) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 285 /* SourceFile */; + var parentIsFile = node.parent.kind === 286 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; } return maskModifierFlags(node, mask, additions); } - function ensureAccessor(node) { - var accessors = resolver.getAllAccessorDeclarations(node); - if (node.kind !== accessors.firstAccessor.kind) { - return; - } + function getTypeAnnotationFromAllAccessorDeclarations(node, accessors) { var accessorType = getTypeAnnotationFromAccessor(node); - if (!accessorType && accessors.secondAccessor) { + if (!accessorType && node !== accessors.firstAccessor) { + accessorType = getTypeAnnotationFromAccessor(accessors.firstAccessor); + // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message + getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.firstAccessor); + } + if (!accessorType && accessors.secondAccessor && node !== accessors.secondAccessor) { accessorType = getTypeAnnotationFromAccessor(accessors.secondAccessor); // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.secondAccessor); } + return accessorType; + } + function ensureAccessor(node) { + var accessors = resolver.getAllAccessorDeclarations(node); + if (node.kind !== accessors.firstAccessor.kind) { + return; + } + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(node, accessors); var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); if (leadingsSyntheticCommentRanges) { @@ -84764,7 +85799,7 @@ var ts; if (lines.length > 1) { var lastLines = lines.slice(1); var indentation_1 = ts.guessIndentation(lastLines); - text = [lines[0]].concat(ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); + text = __spreadArrays([lines[0]], ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); } ts.addSyntheticLeadingComment(prop, range.kind, text, range.hasTrailingNewLine); } @@ -84784,7 +85819,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 243 /* InterfaceDeclaration */) { return true; } return false; @@ -84809,7 +85844,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 159 /* GetAccessor */ + return accessor.kind === 160 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -84818,52 +85853,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return !ts.hasModifier(node, 8 /* Private */); - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 153 /* Parameter */: + case 239 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 220 /* VariableStatement */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 241 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 243 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 245 /* EnumDeclaration */: + case 221 /* VariableStatement */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: + case 256 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 238 /* VariableDeclaration */: - case 151 /* TypeParameter */: - case 212 /* ExpressionWithTypeArguments */: - case 165 /* TypeReference */: - case 176 /* ConditionalType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 184 /* ImportType */: + case 163 /* ConstructSignature */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 164 /* IndexSignature */: + case 239 /* VariableDeclaration */: + case 152 /* TypeParameter */: + case 213 /* ExpressionWithTypeArguments */: + case 166 /* TypeReference */: + case 177 /* ConditionalType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 185 /* ImportType */: return true; } return false; @@ -84992,7 +86027,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(319 /* Count */); + var enabledSyntaxKindFeatures = new Array(321 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -85199,7 +86234,7 @@ var ts; var statements; if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) { if (lexicalEnvironmentFunctionDeclarations) { - statements = lexicalEnvironmentFunctionDeclarations.slice(); + statements = __spreadArrays(lexicalEnvironmentFunctionDeclarations); } if (lexicalEnvironmentVariableDeclarations) { var statement = ts.createVariableStatement( @@ -85277,15 +86312,15 @@ var ts; * If an array, the full list of source files to emit. * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) { + if (forceDtsEmit === void 0) { forceDtsEmit = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { var prepends = host.getPrependNodes(); if (sourceFiles.length || prepends.length) { var bundle = ts.createBundle(sourceFiles, prepends); - var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); + var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle); if (result) { return result; } @@ -85295,7 +86330,7 @@ var ts; if (!onlyBuildInfo) { for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { var sourceFile = sourceFiles_1[_a]; - var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); + var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile); if (result) { return result; } @@ -85348,7 +86383,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 286 /* Bundle */) { + if (sourceFile.kind === 287 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -85406,6 +86441,8 @@ var ts; } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; function getOutputJSFileName(inputFileName, configFile, ignoreCase) { + if (configFile.options.emitDeclarationOnly) + return undefined; var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ? ".json" /* Json */ : @@ -85437,7 +86474,7 @@ var ts; addOutput(js); if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) continue; - if (configFile.options.sourceMap) { + if (js && configFile.options.sourceMap) { addOutput(js + ".map"); } if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { @@ -85466,6 +86503,11 @@ var ts; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase); if (jsFilePath) return jsFilePath; + if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + continue; + if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { + return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + } } var buildInfoPath = getOutputPathForBuildInfo(configFile.options); if (buildInfoPath) @@ -85475,7 +86517,7 @@ var ts; ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo) { + function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) { var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers; var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; @@ -85489,7 +86531,7 @@ var ts; var exportedModulesFromDeclarationEmit; // Emit each output file enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), forceDtsEmit, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -85627,7 +86669,7 @@ var ts; }); var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit; emitSkipped = emitSkipped || declBlocked; - if (!declBlocked || emitOnlyDtsFiles) { + 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, @@ -85635,12 +86677,8 @@ var ts; mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 285 /* SourceFile */) { - // Improved narrowing in master/3.6 makes this cast unnecessary, triggering a lint rule. - // But at the same time, the LKG (3.5) necessitates it because it doesn’t narrow. - // Once the LKG is updated to 3.6, this comment, the cast to `SourceFile`, and the - // tslint directive can be all be removed. - var sourceFile = declarationTransform.transformed[0]; // tslint:disable-line + if (forceDtsEmit && declarationTransform.transformed[0].kind === 286 /* SourceFile */) { + var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } } @@ -85662,8 +86700,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 286 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 285 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 287 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 286 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -85704,7 +86742,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 285 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 286 /* 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 @@ -85814,7 +86852,7 @@ var ts; }; function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) { var sourceFiles = bundle.sourceFiles.map(function (fileName) { - var sourceFile = ts.createNode(285 /* SourceFile */, 0, 0); + var sourceFile = ts.createNode(286 /* SourceFile */, 0, 0); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = ""; sourceFile.statements = ts.createNodeArray(); @@ -85826,7 +86864,7 @@ var ts; sourceFile.text = prologueInfo.text; sourceFile.end = prologueInfo.text.length; sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { - var statement = ts.createNode(222 /* ExpressionStatement */, directive.pos, directive.end); + var statement = ts.createNode(223 /* ExpressionStatement */, directive.pos, directive.end); statement.expression = ts.createNode(10 /* StringLiteral */, directive.expression.pos, directive.expression.end); statement.expression.text = directive.expression.text; return statement; @@ -85865,7 +86903,7 @@ var ts; var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); }); var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host); var emitHost = { - getPrependNodes: ts.memoize(function () { return prependNodes.concat([ownPrependInput]); }), + getPrependNodes: ts.memoize(function () { return __spreadArrays(prependNodes, [ownPrependInput]); }), getCanonicalFileName: host.getCanonicalFileName, getCommonSourceDirectory: function () { return ts.getNormalizedAbsolutePath(buildInfo.bundle.commonSourceDirectory, buildInfoDirectory); }, getCompilerOptions: function () { return config.options; }, @@ -85919,6 +86957,7 @@ var ts; useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: ts.returnUndefined, getSourceFileFromReference: ts.returnUndefined, + redirectTargetsMap: ts.createMultiMap() }; emitFiles(ts.notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers)); @@ -85999,9 +87038,9 @@ var ts; break; } switch (node.kind) { - case 285 /* SourceFile */: return printFile(node); - case 286 /* Bundle */: return printBundle(node); - case 287 /* UnparsedSource */: return printUnparsedSource(node); + case 286 /* SourceFile */: return printFile(node); + case 287 /* Bundle */: return printBundle(node); + case 288 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -86183,7 +87222,7 @@ var ts; } function setWriter(_writer, _sourceMapGenerator) { if (_writer && printerOptions.omitTrailingSemicolon) { - _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + _writer = ts.getTrailingSemicolonDeferringWriter(_writer); } writer = _writer; // TODO: GH#18217 sourceMapGenerator = _sourceMapGenerator; @@ -86237,12 +87276,12 @@ var ts; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 285 /* SourceFile */) { + if (!commentsDisabled && node.kind !== 286 /* SourceFile */) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 285 /* SourceFile */ && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 286 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through @@ -86279,272 +87318,272 @@ var ts; case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node); - case 287 /* UnparsedSource */: - case 281 /* UnparsedPrepend */: + case 288 /* UnparsedSource */: + case 282 /* UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 280 /* UnparsedPrologue */: + case 281 /* UnparsedPrologue */: return writeUnparsedNode(node); - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 283 /* UnparsedText */: + case 284 /* UnparsedInternalText */: return emitUnparsedTextLike(node); - case 284 /* UnparsedSyntheticReference */: + case 285 /* UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Identifiers case 73 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return emitQualifiedName(node); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return emitTypeParameter(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return emitParameter(node); - case 153 /* Decorator */: + case 154 /* Decorator */: return emitDecorator(node); // Type members - case 154 /* PropertySignature */: + case 155 /* PropertySignature */: return emitPropertySignature(node); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 156 /* MethodSignature */: + case 157 /* MethodSignature */: return emitMethodSignature(node); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 158 /* Constructor */: + case 159 /* Constructor */: return emitConstructor(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return emitAccessorDeclaration(node); - case 161 /* CallSignature */: + case 162 /* CallSignature */: return emitCallSignature(node); - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: return emitConstructSignature(node); - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: return emitIndexSignature(node); // Types - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return emitTypePredicate(node); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return emitTypeReference(node); - case 166 /* FunctionType */: + case 167 /* FunctionType */: return emitFunctionType(node); - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 167 /* ConstructorType */: + case 168 /* ConstructorType */: return emitConstructorType(node); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return emitTypeQuery(node); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return emitTypeLiteral(node); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return emitArrayType(node); - case 171 /* TupleType */: + case 172 /* TupleType */: return emitTupleType(node); - case 172 /* OptionalType */: + case 173 /* OptionalType */: return emitOptionalType(node); - case 174 /* UnionType */: + case 175 /* UnionType */: return emitUnionType(node); - case 175 /* IntersectionType */: + case 176 /* IntersectionType */: return emitIntersectionType(node); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return emitConditionalType(node); - case 177 /* InferType */: + case 178 /* InferType */: return emitInferType(node); - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return emitParenthesizedType(node); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 179 /* ThisType */: + case 180 /* ThisType */: return emitThisType(); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: return emitTypeOperator(node); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 182 /* MappedType */: + case 183 /* MappedType */: return emitMappedType(node); - case 183 /* LiteralType */: + case 184 /* LiteralType */: return emitLiteralType(node); - case 184 /* ImportType */: + case 185 /* ImportType */: return emitImportTypeNode(node); - case 290 /* JSDocAllType */: + case 291 /* JSDocAllType */: writePunctuation("*"); return; - case 291 /* JSDocUnknownType */: + case 292 /* JSDocUnknownType */: writePunctuation("?"); return; - case 292 /* JSDocNullableType */: + case 293 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 293 /* JSDocNonNullableType */: + case 294 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 294 /* JSDocOptionalType */: + case 295 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 173 /* RestType */: - case 296 /* JSDocVariadicType */: + case 174 /* RestType */: + case 297 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 186 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return emitBindingElement(node); // Misc - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return emitTemplateSpan(node); - case 218 /* SemicolonClassElement */: + case 219 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 219 /* Block */: + case 220 /* Block */: return emitBlock(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return emitVariableStatement(node); - case 221 /* EmptyStatement */: + case 222 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return emitExpressionStatement(node); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return emitIfStatement(node); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return emitDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return emitWhileStatement(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return emitForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return emitForInStatement(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return emitForOfStatement(node); - case 229 /* ContinueStatement */: + case 230 /* ContinueStatement */: return emitContinueStatement(node); - case 230 /* BreakStatement */: + case 231 /* BreakStatement */: return emitBreakStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return emitReturnStatement(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return emitWithStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return emitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return emitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return emitThrowStatement(node); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return emitTryStatement(node); - case 237 /* DebuggerStatement */: + case 238 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return emitClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return emitModuleBlock(node); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return emitCaseBlock(node); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return emitImportDeclaration(node); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return emitImportClause(node); - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return emitNamespaceImport(node); - case 253 /* NamedImports */: + case 254 /* NamedImports */: return emitNamedImports(node); - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return emitImportSpecifier(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return emitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return emitExportDeclaration(node); - case 257 /* NamedExports */: + case 258 /* NamedExports */: return emitNamedExports(node); - case 258 /* ExportSpecifier */: + case 259 /* ExportSpecifier */: return emitExportSpecifier(node); - case 259 /* MissingDeclaration */: + case 260 /* MissingDeclaration */: return; // Module references - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: + case 264 /* JsxOpeningElement */: + case 267 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 264 /* JsxClosingElement */: - case 267 /* JsxClosingFragment */: + case 265 /* JsxClosingElement */: + case 268 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return emitJsxAttribute(node); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return emitJsxAttributes(node); - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 272 /* CaseClause */: + case 273 /* CaseClause */: return emitCaseClause(node); - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: return emitDefaultClause(node); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: return emitHeritageClause(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 279 /* EnumMember */: + case 280 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: + case 314 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 308 /* JSDocThisTag */: - case 305 /* JSDocEnumTag */: + case 309 /* JSDocReturnTag */: + case 311 /* JSDocTypeTag */: + case 310 /* JSDocThisTag */: + case 307 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); - case 301 /* JSDocAugmentsTag */: + case 303 /* JSDocAugmentsTag */: return emitJSDocAugmentsTag(node); - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 311 /* JSDocTypedefTag */: + case 313 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 304 /* JSDocCallbackTag */: + case 306 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); - case 299 /* JSDocSignature */: + case 301 /* JSDocSignature */: return emitJSDocSignature(node); - case 298 /* JSDocTypeLiteral */: + case 300 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 303 /* JSDocClassTag */: - case 300 /* JSDocTag */: + case 305 /* JSDocClassTag */: + case 302 /* JSDocTag */: return emitJSDocSimpleTag(node); - case 297 /* JSDocComment */: + case 299 /* JSDocComment */: return emitJSDoc(node); // Transformation nodes (ignored) } @@ -86581,71 +87620,71 @@ var ts; writeTokenNode(node, writeKeyword); return; // Expressions - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return emitCallExpression(node); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return emitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return emitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return emitArrowFunction(node); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return emitDeleteExpression(node); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return emitVoidExpression(node); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return emitAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return emitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return emitConditionalExpression(node); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return emitTemplateExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return emitYieldExpression(node); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return emitSpreadExpression(node); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return emitClassExpression(node); - case 211 /* OmittedExpression */: + case 212 /* OmittedExpression */: return; - case 213 /* AsExpression */: + case 214 /* AsExpression */: return emitAsExpression(node); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: return emitNonNullExpression(node); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 261 /* JsxElement */: + case 262 /* JsxElement */: return emitJsxElement(node); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: return emitCommaList(node); } } @@ -86673,8 +87712,8 @@ var ts; var helpers = getSortedEmitHelpers(sourceFile); if (!helpers) continue; - for (var _c = 0, helpers_3 = helpers; _c < helpers_3.length; _c++) { - var helper = helpers_3[_c]; + for (var _c = 0, helpers_4 = helpers; _c < helpers_4.length; _c++) { + var helper = helpers_4[_c]; if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) { bundledHelpers.set(helper.name, true); (result || (result = [])).push(helper.name); @@ -86685,7 +87724,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 286 /* Bundle */ ? node : undefined; + var bundle = node.kind === 287 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -86694,12 +87733,12 @@ var ts; for (var i = 0; i < numNodes; i++) { var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node; var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile; - var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.hasRecordedExternalHelpers(sourceFile)); var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit; var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode); if (helpers) { - for (var _a = 0, helpers_4 = helpers; _a < helpers_4.length; _a++) { - var helper = helpers_4[_a]; + for (var _a = 0, helpers_5 = helpers; _a < helpers_5.length; _a++) { + var helper = helpers_5[_a]; if (!helper.scoped) { // Skip the helper if it can be skipped and the noEmitHelpers compiler // option is set, or if it can be imported and the importHelpers compiler @@ -86785,7 +87824,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 282 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 283 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -86854,7 +87893,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 295 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 296 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -86916,7 +87955,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 159 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 160 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -87323,7 +88362,7 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 203 /* PrefixUnaryExpression */ + return operand.kind === 204 /* PrefixUnaryExpression */ && ((node.operator === 38 /* PlusToken */ && (operand.operator === 38 /* PlusToken */ || operand.operator === 44 /* PlusPlusToken */)) || (node.operator === 39 /* MinusToken */ && (operand.operator === 39 /* MinusToken */ || operand.operator === 45 /* MinusMinusToken */))); } @@ -87452,7 +88491,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); emitTokenWithComment(84 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 223 /* IfStatement */) { + if (node.elseStatement.kind === 224 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -87478,7 +88517,7 @@ var ts; writeLineOrSpace(node); } emitWhileClause(node, node.statement.end); - writePunctuation(";"); + writeTrailingSemicolon(); } function emitWhileStatement(node) { emitWhileClause(node, node.pos); @@ -87515,7 +88554,7 @@ var ts; emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(148 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(149 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -87523,7 +88562,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 240 /* VariableDeclarationList */) { emit(node); } else { @@ -87638,7 +88677,7 @@ var ts; writeKeyword("function"); emit(node.asteriskToken); writeSpace(); - emitIdentifierName(node.name); // TODO: GH#18217 + emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } function emitBlockCallback(_hint, body) { @@ -87818,7 +88857,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 245 /* ModuleDeclaration */) { + while (body.kind === 246 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -88139,7 +89178,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 309 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 311 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -88173,7 +89212,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 290 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -88192,7 +89231,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 298 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 300 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -88326,8 +89365,8 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } - for (var _d = 0, types_19 = types; _d < types_19.length; _d++) { - var directive = types_19[_d]; + for (var _d = 0, types_18 = types; _d < types_18.length; _d++) { + var directive = types_18[_d]; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) @@ -88970,7 +90009,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 197 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -89035,81 +90074,81 @@ var ts; if (!node) return; switch (node.kind) { - case 219 /* Block */: + case 220 /* Block */: ts.forEach(node.statements, generateNames); break; - case 234 /* LabeledStatement */: - case 232 /* WithStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 235 /* LabeledStatement */: + case 233 /* WithStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: generateNames(node.statement); break; - case 223 /* IfStatement */: + case 224 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 227 /* ForStatement */: + case 229 /* ForOfStatement */: + case 228 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 236 /* TryStatement */: + case 237 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 275 /* CatchClause */: + case 276 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: generateNames(node.declarationList); break; - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: + case 239 /* VariableDeclaration */: + case 153 /* Parameter */: + case 188 /* BindingElement */: + case 242 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: generateNames(node.importClause); break; - case 251 /* ImportClause */: + case 252 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 253 /* NamedImports */: + case 254 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -89118,12 +90157,12 @@ var ts; if (!node) return; switch (node.kind) { - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -89181,7 +90220,7 @@ var ts; if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (local && local.flags & (67220415 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { + if (local && local.flags & (111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { return false; } } @@ -89305,23 +90344,23 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 255 /* ExportAssignment */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 256 /* ExportAssignment */: return generateNameForExportDefault(); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return generateNameForClassExpression(); - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -89368,7 +90407,7 @@ var ts; hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 314 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 316 /* 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 */; @@ -89392,7 +90431,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 240 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -89649,7 +90688,7 @@ var ts; 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 !== 314 /* NotEmittedStatement */ + if (node.kind !== 316 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -89662,7 +90701,7 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 314 /* NotEmittedStatement */ + if (node.kind !== 316 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); @@ -90030,6 +91069,9 @@ var ts; var createFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile); var createFilePathWatcher = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher; var createDirectoryWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory); + if (watchLogLevel === WatchLogLevel.Verbose && ts.sysLog === ts.noop) { + ts.sysLog = function (s) { return log(s); }; + } return { watchFile: function (host, file, callback, pollingInterval, detailInfo1, detailInfo2) { return createFileWatcher(host, file, callback, pollingInterval, /*passThrough*/ undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo); @@ -90385,7 +91427,7 @@ var ts; } ts.changeCompilerHostLikeToUseCache = changeCompilerHostLikeToUseCache; function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { - var diagnostics = program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (ts.getEmitDeclarations(program.getCompilerOptions())) { ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } @@ -90574,8 +91616,8 @@ var ts; } var resolutions = []; var cache = ts.createMap(); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name = names_1[_i]; + for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { + var name = names_2[_i]; var result = void 0; if (cache.has(name)) { result = cache.get(name); @@ -90662,7 +91704,7 @@ var ts; } ts.isProgramUptoDate = isProgramUptoDate; function getConfigFileParsingDiagnostics(configFileParseResult) { - return configFileParseResult.options.configFile ? configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : + return configFileParseResult.options.configFile ? __spreadArrays(configFileParseResult.options.configFile.parseDiagnostics, configFileParseResult.errors) : configFileParseResult.errors; } ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; @@ -90692,7 +91734,6 @@ var ts; var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217 var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; var oldProgram = createProgramOptions.oldProgram; - var program; var processingDefaultLibFiles; var processingOtherFiles; var files; @@ -90701,6 +91742,8 @@ var ts; var noDiagnosticsTypeChecker; var classifiableNames; var ambientModuleNameToUnmodifiedFileName = ts.createMap(); + // Todo:: Use this to report why file was included in --extendedDiagnostics + var refFileMap; var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -90736,7 +91779,7 @@ var ts; var resolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference).map(function (resolved) { + resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).map(function (resolved) { // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName. if (!resolved || resolved.extension !== undefined) { return resolved; @@ -90753,7 +91796,7 @@ var ts; } var resolveTypeReferenceDirectiveNamesWorker; if (host.resolveTypeReferenceDirectives) { - resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference); }; + resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); }; } else { var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 @@ -90783,7 +91826,10 @@ var ts; var projectReferenceRedirects; var mapFromFileToProjectReferenceRedirects; var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); - var structuralIsReused = tryReuseStructureFromOldProgram(); + // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks + // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. + var structuralIsReused; + structuralIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const if (structuralIsReused !== 2 /* Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -90870,12 +91916,13 @@ var ts; } // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; - program = { + var program = { getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFileByPath: getSourceFileByPath, getSourceFiles: function () { return files; }, getMissingFilePaths: function () { return missingFilePaths; }, + getRefFileMap: function () { return refFileMap; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, getOptionsDiagnostics: getOptionsDiagnostics, @@ -91307,6 +92354,7 @@ var ts; return oldProgram.structureIsReused = 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); + refFileMap = oldProgram.getRefFileMap(); // update fileName -> file mapping for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) { var newSourceFile = newSourceFiles_1[_f]; @@ -91329,7 +92377,7 @@ var ts; return oldProgram.structureIsReused = 2 /* Completely */; } function getEmitHost(writeFileCallback) { - return __assign({ getPrependNodes: getPrependNodes, + return __assign(__assign({ getPrependNodes: getPrependNodes, getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { // Use local caches @@ -91340,7 +92388,7 @@ var ts; return false; // Before falling back to the host return host.fileExists(f); - } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); } }); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); }, redirectTargetsMap: redirectTargetsMap }); } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!options.out && !options.outFile); @@ -91396,15 +92444,15 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.has(toPath(emitFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) { var declarationDiagnostics = []; - if (!emitOnlyDtsFiles) { + if (!forceDtsEmit) { if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; } @@ -91412,7 +92460,7 @@ var ts; // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we // get any preEmit diagnostics, not just the ones if (options.noEmitOnError) { - var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (diagnostics.length === 0 && ts.getEmitDeclarations(program.getCompilerOptions())) { declarationDiagnostics = program.getDeclarationDiagnostics(/*sourceFile*/ undefined, cancellationToken); } @@ -91436,7 +92484,8 @@ var ts; // checked is to not pass the file to getEmitResolver. var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, + /*onlyBuildInfo*/ false, forceDtsEmit); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -91578,22 +92627,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 152 /* Parameter */: - case 155 /* PropertyDeclaration */: + case 153 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 238 /* VariableDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: + case 239 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -91601,41 +92650,41 @@ var ts; } } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 110 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 213 /* AsExpression */: + case 214 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -91648,28 +92697,28 @@ 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 241 /* ClassDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // falls through - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 220 /* VariableStatement */); + return checkModifiers(parent.modifiers, parent.kind === 221 /* VariableStatement */); } break; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { @@ -91681,18 +92730,19 @@ var ts; return; } break; - case 152 /* Parameter */: + case 153 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 213 /* ExpressionWithTypeArguments */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 195 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -91883,7 +92933,7 @@ var ts; } function collectDynamicImportOrRequireCalls(file) { var r = /import|require/g; - while (r.exec(file.text) !== null) { + while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null var node = getNodeAtPosition(file, r.lastIndex); if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { imports = ts.append(imports, node.arguments[0]); @@ -91964,24 +93014,18 @@ var ts; } } /** This has side effects through `findSourceFile`. */ - function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId); }, // TODO: GH#18217 + function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, // TODO: GH#18217 function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined - ? ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(args)) : ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(args))); - }, refFile); + return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args))); + }, refFile && refFile.file); } - function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile) { + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { var redirect = Object.create(redirectTarget); @@ -92004,7 +93048,7 @@ var ts; return redirect; } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId) { + function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) { var originalFileName = fileName; if (filesByName.has(path)) { var file_1 = filesByName.get(path); @@ -92021,7 +93065,7 @@ var ts; var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory); var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory); if (checkedAbsolutePath !== inputAbsolutePath) { - reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile); } } // If the file was previously found via a node_modules search, but is now being processed as a root file, @@ -92045,6 +93089,7 @@ var ts; processImportedModules(file_1); } } + addFileToRefFileMap(file_1 || undefined, refFile); return file_1 || undefined; } var redirectedPath; @@ -92066,14 +93111,7 @@ var ts; } } // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }, shouldCreateNewSourceFile); + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { return fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); }, shouldCreateNewSourceFile); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); @@ -92104,7 +93142,7 @@ var ts; // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case var existingFile = filesByNameIgnoreCase.get(pathLowerCase); if (existingFile) { - reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile); } else { filesByNameIgnoreCase.set(pathLowerCase, file); @@ -92127,8 +93165,18 @@ var ts; processingOtherFiles.push(file); } } + addFileToRefFileMap(file, refFile); return file; } + function addFileToRefFileMap(file, refFile) { + if (refFile && file) { + (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, { + kind: refFile.kind, + index: refFile.index, + file: refFile.file.path + }); + } + } function addFileToFilesByName(file, path, redirectedPath) { if (redirectedPath) { filesByName.set(redirectedPath, file); @@ -92217,9 +93265,17 @@ var ts; return projectReferenceRedirects.get(projectReferencePath) || undefined; } function processReferencedFiles(file, isDefaultLib) { - ts.forEach(file.referencedFiles, function (ref) { + ts.forEach(file.referencedFiles, function (ref, index) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); - processSourceFile(referencedFileName, isDefaultLib, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, + /*ignoreNoDefaultLib*/ false, + /*packageId*/ undefined, { + kind: ts.RefFileKind.ReferenceFile, + index: index, + file: file, + pos: ref.pos, + end: ref.end + }); }); } function processTypeReferenceDirectives(file) { @@ -92235,10 +93291,16 @@ var ts; // store resolved type directive on the file var fileName = ref.fileName.toLocaleLowerCase(); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); - processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); + processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { + kind: ts.RefFileKind.TypeReferenceDirective, + index: i, + file: file, + pos: ref.pos, + end: ref.end + }); } } - function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { + function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) { // If we already found this library as a primary reference - nothing to do var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { @@ -92250,7 +93312,7 @@ var ts; currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); // TODO: GH#18217 } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -92260,8 +93322,7 @@ var ts; if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, // TODO: GH#18217 - ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); } } // don't overwrite previous resolution result @@ -92269,14 +93330,14 @@ var ts; } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); } } if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--; } else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); @@ -92294,20 +93355,20 @@ var ts; var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts"); var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; - fileProcessingDiagnostics.add(createDiagnostic(file, libReference.pos, libReference.end, message, libName, suggestion)); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion)); } }); } - function createDiagnostic(refFile, refPos, refEnd, message) { + function createRefFileDiagnostic(refFile, message) { var args = []; - for (var _i = 4; _i < arguments.length; _i++) { - args[_i - 4] = arguments[_i]; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; } - if (refFile === undefined || refPos === undefined || refEnd === undefined) { - return ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)); + if (!refFile) { + return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)); } else { - return ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, message].concat(args)); + return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args)); } } function getCanonicalFileName(fileName) { @@ -92354,7 +93415,15 @@ var ts; else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, file, pos, file.imports[i].end, resolution.packageId); + findSourceFile(resolvedFileName, path, + /*isDefaultLib*/ false, + /*ignoreNoDefaultLib*/ false, { + kind: ts.RefFileKind.Import, + index: i, + file: file, + pos: pos, + end: file.imports[i].end + }, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -92373,12 +93442,15 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + var rootPaths; for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { var sourceFile = sourceFiles_2[_i]; if (!sourceFile.isDeclarationFile) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory)); + if (!rootPaths) + rootPaths = ts.arrayToSet(rootNames, toPath); + addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory); allFilesBelongToPath = false; } } @@ -92472,17 +93544,20 @@ var ts; else if (options.incremental && !options.outFile && !options.out && !options.configFilePath) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified)); } + if (options.noEmit && ts.isIncrementalCompilation(options)) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", options.incremental ? "incremental" : "composite"); + } verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { - var rootPaths = rootNames.map(toPath); + var rootPaths = ts.arrayToSet(rootNames, toPath); for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { var file = files_3[_i]; // Ignore file that is not emitted if (!ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) continue; - if (rootPaths.indexOf(file.path) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || "")); + if (!rootPaths.has(file.path)) { + addProgramDiagnosticAtRefPath(file, rootPaths, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || ""); } } } @@ -92664,6 +93739,39 @@ var ts; } } } + function addProgramDiagnosticAtRefPath(file, rootPaths, message) { + var _a, _b; + var args = []; + for (var _i = 3; _i < arguments.length; _i++) { + args[_i - 3] = arguments[_i]; + } + var refPaths = refFileMap && refFileMap.get(file.path); + var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) || + ts.elementAt(refPaths, 0); + if (refPathToReportErrorOn) { + var refFile = ts.Debug.assertDefined(getSourceFileByPath(refPathToReportErrorOn.file)); + var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index; + var pos = void 0, end = void 0; + switch (kind) { + case ts.RefFileKind.Import: + pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos); + end = refFile.imports[index].end; + break; + case ts.RefFileKind.ReferenceFile: + (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end); + break; + case ts.RefFileKind.TypeReferenceDirective: + (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end); + break; + default: + return ts.Debug.assertNever(kind); + } + programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args))); + } + else { + programDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); + } + } function verifyProjectReferences() { var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { @@ -92767,7 +93875,7 @@ var ts; } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { - _compilerOptionsObjectLiteralSyntax = null; // tslint:disable-line:no-null-keyword + _compilerOptionsObjectLiteralSyntax = null; // eslint-disable-line no-null/no-null var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); if (jsonObjectLiteral) { for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) { @@ -92923,9 +94031,9 @@ var ts; /*@internal*/ var ts; (function (ts) { - function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers) { + function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit); return { outputFiles: outputFiles, emitSkipped: emitResult.emitSkipped, exportedModulesFromDeclarationEmit: emitResult.exportedModulesFromDeclarationEmit }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); @@ -93171,11 +94279,19 @@ var ts; } } else { - var emitOutput = ts.getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken); - if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { - latestSignature = computeHash(emitOutput.outputFiles[0].text); + var emitOutput_1 = ts.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; + 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(firstDts_1.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { - updateExportedModules(sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache); + updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); } } else { @@ -93381,6 +94497,11 @@ var ts; /*@internal*/ var ts; (function (ts) { + var BuilderFileEmit; + (function (BuilderFileEmit) { + BuilderFileEmit[BuilderFileEmit["DtsOnly"] = 0] = "DtsOnly"; + BuilderFileEmit[BuilderFileEmit["Full"] = 1] = "Full"; + })(BuilderFileEmit = ts.BuilderFileEmit || (ts.BuilderFileEmit = {})); function hasSameKeys(map1, map2) { // Has same size and every key is present in both maps return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); @@ -93418,7 +94539,8 @@ var ts; ts.copyEntries(changedFilesSet, state.changedFilesSet); } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; + state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice(); + state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind); state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; } } @@ -93464,7 +94586,7 @@ var ts; }); if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - addToAffectedFilesPendingEmit(state, newProgram.getSourceFiles().map(function (f) { return f.path; })); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.path, 1 /* Full */); }); ts.Debug.assert(state.seenAffectedFiles === undefined); state.seenAffectedFiles = ts.createMap(); } @@ -93492,7 +94614,7 @@ var ts; } function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); } /** * Releases program and other related not needed properties @@ -93518,7 +94640,8 @@ var ts; newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState); newState.program = state.program; newState.compilerOptions = state.compilerOptions; - newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit; + newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); + newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind); newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles); newState.programEmitComplete = state.programEmitComplete; @@ -93550,7 +94673,6 @@ var ts; handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash); return affectedFile; } - seenAffectedFiles.set(affectedFile.path, true); affectedFilesIndex++; } // Remove the changed file from the change set @@ -93596,13 +94718,18 @@ var ts; var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap()); for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) { var affectedFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]); - if (affectedFile && !seenEmittedFiles.has(affectedFile.path)) { - // emit this file - state.affectedFilesPendingEmitIndex = i; - return affectedFile; + if (affectedFile) { + var seenKind = seenEmittedFiles.get(affectedFile.path); + var emitKind = ts.Debug.assertDefined(ts.Debug.assertDefined(state.affectedFilesPendingEmitKind).get(affectedFile.path)); + if (seenKind === undefined || seenKind < emitKind) { + // emit this file + state.affectedFilesPendingEmitIndex = i; + return { affectedFile: affectedFile, emitKind: emitKind }; + } } } state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; state.affectedFilesPendingEmitIndex = undefined; } return undefined; @@ -93646,7 +94773,7 @@ var ts; ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.assertDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, [path]); + addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); } } } @@ -93740,7 +94867,7 @@ var ts; * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly */ - function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit) { + function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) { if (isBuildInfoEmit) { state.emittedBuildInfo = true; } @@ -93750,6 +94877,9 @@ var ts; } else { state.seenAffectedFiles.set(affected.path, true); + if (emitKind !== undefined) { + (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, emitKind); + } if (isPendingEmit) { state.affectedFilesPendingEmitIndex++; } @@ -93761,8 +94891,15 @@ var ts; /** * Returns the result with affected file */ - function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); + function toAffectedFileResult(state, result, affected) { + doneWithAffectedFile(state, affected); + return { result: result, affected: affected }; + } + /** + * Returns the result with affected file + */ + function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } /** @@ -93887,7 +95024,7 @@ var ts; } function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? relativeToBuildInfo(file.path) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.path) : undefined }); } var BuilderProgramKind; (function (BuilderProgramKind) { @@ -93985,22 +95122,24 @@ var ts; */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var emitKind = 1 /* Full */; var isPendingEmitFile = false; if (!affected) { if (!state.compilerOptions.out && !state.compilerOptions.outFile) { - affected = getNextAffectedFilePendingEmit(state); - if (!affected) { + var pendingAffectedFile = getNextAffectedFilePendingEmit(state); + if (!pendingAffectedFile) { if (state.emittedBuildInfo) { return undefined; } var affected_1 = ts.Debug.assertDefined(state.program); - return toAffectedFileResult(state, + return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } + (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind); isPendingEmitFile = true; } else { @@ -94013,10 +95152,10 @@ var ts; affected = program; } } - return toAffectedFileResult(state, + return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers), affected, isPendingEmitFile); + ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); } /** * Emits the JavaScript and declaration files. @@ -94072,7 +95211,7 @@ var ts; } // Add file to affected file pending emit to handle for later emit time if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - addToAffectedFilesPendingEmit(state, [affected.path]); + addToAffectedFilesPendingEmit(state, affected.path, 1 /* Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -94104,7 +95243,7 @@ var ts; } // When semantic builder asks for diagnostics of the whole program, // ensure that all the affected files are handled - // tslint:disable-next-line no-empty + // eslint-disable-next-line no-empty while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) { } var diagnostics; @@ -94116,8 +95255,14 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; - function addToAffectedFilesPendingEmit(state, affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit); + function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) { + if (!state.affectedFilesPendingEmit) + state.affectedFilesPendingEmit = []; + if (!state.affectedFilesPendingEmitKind) + state.affectedFilesPendingEmitKind = ts.createMap(); + var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit); + state.affectedFilesPendingEmit.push(affectedFilePendingEmit); + state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind); // affectedFilesPendingEmitIndex === undefined // - means the emit state.affectedFilesPendingEmit was undefined before adding current affected files // so start from 0 as array would be affectedFilesPendingEmit @@ -94153,7 +95298,7 @@ var ts; compilerOptions: convertFromReusableCompilerOptions(program.options, toAbsolutePath), referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), - semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return ts.isString(value) ? value : value[0]; }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), + 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]; }), hasReusableDiagnostic: true }; return { @@ -94279,15 +95424,27 @@ var ts; // ignore "/user", "c:/users" or "c:/folderAtRoot" return false; } - if (dirPath.charCodeAt(0) !== 47 /* slash */ && - dirPath.substr(rootLength, nextDirectorySeparator).search(/users/i) === -1) { + var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + if (isNonDirectorySeparatorRoot && + dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths + pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart + nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1); + if (nextDirectorySeparator === -1) { + // ignore "//vda1cs4850/c$/folderAtRoot" + return false; + } + pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1); + } + if (isNonDirectorySeparatorRoot && + pathPartForUserCheck.search(/users\//i) !== 0) { // Paths like c:/folderAtRoot/subFolder are allowed return true; } for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) { searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1; if (searchIndex === 0) { - // Folder isnt at expected minimun levels + // Folder isnt at expected minimum levels return false; } } @@ -94452,8 +95609,8 @@ var ts; !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path : !!redirectedReference; var seenNamesInFile = ts.createMap(); - for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name = names_2[_i]; + for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { + var name = names_3[_i]; var resolution = resolutionsInFile.get(name); // Resolution is valid if it is present and not invalidated if (!seenNamesInFile.has(name) && @@ -94533,7 +95690,7 @@ var ts; if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { // Ensure failed look up is normalized path failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); - ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); // tslint:disable-line + ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); var subDirectoryInRoot = failedLookupLocationPath.indexOf(ts.directorySeparator, rootPath.length + 1); if (subDirectoryInRoot !== -1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution @@ -94929,8 +96086,9 @@ var ts; function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, - ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? + 2 /* JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, oldImportSpecifier) { @@ -94959,7 +96117,7 @@ var ts; return [ambient]; var info = getInfo(importingSourceFile.path, host); var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); - var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.fileName, info.getCanonicalFileName, host, redirectTargetsMap); + var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.originalFileName, info.getCanonicalFileName, host, redirectTargetsMap); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); var global = ts.mapDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }); return global.length ? global : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifier(moduleFileName, info, compilerOptions, preferences); }); @@ -94975,7 +96133,7 @@ var ts; var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; var ending = _b.ending, relativePreference = _b.relativePreference; var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; - var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); if (!baseUrl || relativePreference === 0 /* Relative */) { return relativePath; @@ -95050,7 +96208,7 @@ var ts; */ function getAllModulePaths(files, importingFileName, importedFileName, getCanonicalFileName, host, redirectTargetsMap) { var redirects = redirectTargetsMap.get(importedFileName); - var importedFileNames = redirects ? redirects.concat([importedFileName]) : [importedFileName]; + var importedFileNames = redirects ? __spreadArrays(redirects, [importedFileName]) : [importedFileName]; var cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); var links = discoverProbableSymlinks(files, getCanonicalFileName, cwd); @@ -95101,14 +96259,16 @@ var ts; } } } - function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) { + function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) { var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName); if (normalizedTargetPath === undefined) { return undefined; } var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName); var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath; - return ts.removeFileExtension(relativePath); + return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs + ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) + : ts.removeFileExtension(relativePath); } function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; @@ -95540,7 +96700,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); if (result) { result.version = computeHash.call(host, result.text); } @@ -95554,7 +96714,9 @@ var ts; function createProgramHost(system, createProgram) { var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); }); var host = system; - host; // tslint:disable-line no-unused-expression (TODO: `host` is unused!) + // TODO: `host` is unused! + // eslint-disable-next-line no-unused-expressions + host; return { useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; }, getNewLine: function () { return system.newLine; }, @@ -95588,7 +96750,7 @@ var ts; result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); }); }; return result; } @@ -95730,7 +96892,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - return getVersionedSourceFileByPath.apply(void 0, [fileName, toPath(fileName)].concat(args)); + return getVersionedSourceFileByPath.apply(void 0, __spreadArrays([fileName, toPath(fileName)], args)); }; compilerHost.getSourceFileByPath = getVersionedSourceFileByPath; compilerHost.getNewLine = function () { return newLine; }; @@ -95758,10 +96920,22 @@ var ts; /*logChangesWhenResolvingModule*/ false); // Resolve module using host module resolution strategy if provided otherwise use resolution cache to resolve module names compilerHost.resolveModuleNames = host.resolveModuleNames ? - (function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveModuleNames.apply(host, args); + }) : (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }); compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ? - (function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveTypeReferenceDirectives.apply(host, args); + }) : (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; builderProgram = readBuilderProgram(compilerOptions, compilerHost); @@ -95987,13 +97161,19 @@ var ts; reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); switch (reloadLevel) { case ts.ConfigFileProgramReloadLevel.Partial: - return reloadFileNamesFromConfigFile(); + ts.perfLogger.logStartUpdateProgram("PartialConfigReload"); + reloadFileNamesFromConfigFile(); + break; case ts.ConfigFileProgramReloadLevel.Full: - return reloadConfigFile(); + ts.perfLogger.logStartUpdateProgram("FullConfigReload"); + reloadConfigFile(); + break; default: + ts.perfLogger.logStartUpdateProgram("SynchronizeProgram"); synchronizeProgram(); - return; + break; } + ts.perfLogger.logStopUpdateProgram("Done"); } function reloadFileNamesFromConfigFile() { writeLog("Reloading new file names and options"); @@ -96177,6 +97357,16 @@ var ts; function isDeclarationFile(fileName) { return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */); } + /*@internal*/ + function isCircularBuildOrder(buildOrder) { + return !!buildOrder && !!buildOrder.buildOrder; + } + ts.isCircularBuildOrder = isCircularBuildOrder; + /*@internal*/ + function getBuildOrderFromAnyBuildOrder(anyBuildOrder) { + return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder; + } + ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ @@ -96338,11 +97528,14 @@ var ts; var permanentMarks = ts.createMap(); var circularityReportStack = []; var buildOrder; + var circularDiagnostics; for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { var root = roots_1[_i]; visit(root); } - return buildOrder || ts.emptyArray; + return circularDiagnostics ? + { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } : + buildOrder || ts.emptyArray; function visit(configFileName, inCircularContext) { var projPath = toResolvedConfigFilePath(state, configFileName); // Already visited @@ -96351,8 +97544,7 @@ var ts; // Circular if (temporaryMarks.has(projPath)) { if (!inCircularContext) { - // TODO:: Do we report this as error? - reportStatus(state, ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")); + (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n"))); } return; } @@ -96372,12 +97564,35 @@ var ts; } } function getBuildOrder(state) { - return state.buildOrder || - (state.buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }))); + return state.buildOrder || createStateBuildOrder(state); + } + function createStateBuildOrder(state) { + var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); })); + // Clear all to ResolvedConfigFilePaths cache to start fresh + state.resolvedConfigFilePaths.clear(); + var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); }); + var noopOnDelete = { onDeleteValue: ts.noop }; + // Config file cache + ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete); + // Remove watches for the program no longer in the solution + if (state.watch) { + ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher }); + ts.mutateMapSkippingNewValues(state.allWatchedWildcardDirectories, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcherOf); } }); + ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } }); + } + return state.buildOrder = buildOrder; } function getBuildOrderFor(state, project, onlyReferences) { var resolvedProject = project && resolveProjectName(state, project); var buildOrderFromState = getBuildOrder(state); + if (isCircularBuildOrder(buildOrderFromState)) + return buildOrderFromState; if (resolvedProject) { var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject); var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; }); @@ -96385,6 +97600,7 @@ var ts; return undefined; } var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState; + ts.Debug.assert(!isCircularBuildOrder(buildOrder)); ts.Debug.assert(!onlyReferences || resolvedProject !== undefined); ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject); return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder; @@ -96401,7 +97617,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); }), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, getSourceFileWithCache = _a.getSourceFileWithCache, readFileWithCache = _a.readFileWithCache; state.readFileWithCache = readFileWithCache; compilerHost.getSourceFile = getSourceFileWithCache; @@ -96456,7 +97672,7 @@ var ts; reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode); } enableCache(state); - var buildOrder = getBuildOrder(state); + var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state)); buildOrder.forEach(function (configFileName) { return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None); }); @@ -96628,7 +97844,7 @@ var ts; } function getSyntaxDiagnostics(cancellationToken) { ts.Debug.assertDefined(program); - handleDiagnostics(program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); + handleDiagnostics(__spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); } function getSemanticDiagnostics(cancellationToken) { handleDiagnostics(ts.Debug.assertDefined(program).getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic"); @@ -96796,6 +98012,8 @@ var ts; function getNextInvalidatedProject(state, buildOrder, reportQueue) { if (!state.projectPendingBuild.size) return undefined; + if (isCircularBuildOrder(buildOrder)) + return undefined; if (state.currentInvalidatedProject) { // Only if same buildOrder the currentInvalidated project can be sent again return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ? @@ -96852,8 +98070,11 @@ var ts; if (status.type === ts.UpToDateStatusType.UpstreamBlocked) { reportAndStoreErrors(state, projectPath, config.errors); projectPendingBuild.delete(projectPath); - if (options.verbose) - reportStatus(state, ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + if (options.verbose) { + reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built : + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + } continue; } if (status.type === ts.UpToDateStatusType.ContainerOnly) { @@ -97024,10 +98245,12 @@ var ts; continue; } // An upstream project is blocked - if (refStatus.type === ts.UpToDateStatusType.Unbuildable) { + if (refStatus.type === ts.UpToDateStatusType.Unbuildable || + refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) { return { type: ts.UpToDateStatusType.UpstreamBlocked, - upstreamProjectName: ref.path + upstreamProjectName: ref.path, + upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked }; } // If the upstream project is out of date, then so are we (someone shouldn't have asked, though?) @@ -97251,16 +98474,22 @@ var ts; disableCache(state); reportErrorSummary(state, buildOrder); startWatching(state, buildOrder); - return errorProjects ? - successfulProjects ? - ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : - ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : - ts.ExitStatus.Success; + return isCircularBuildOrder(buildOrder) ? + ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped : + errorProjects ? + successfulProjects ? + ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : + ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : + ts.ExitStatus.Success; } function clean(state, project, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; + if (isCircularBuildOrder(buildOrder)) { + reportErrors(state, buildOrder.circularDiagnostics); + return ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped; + } var options = state.options, host = state.host; var filesToDelete = options.dry ? [] : undefined; for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) { @@ -97403,8 +98632,8 @@ var ts; if (!state.watchAllProjectsPending) return; state.watchAllProjectsPending = false; - for (var _i = 0, buildOrder_2 = buildOrder; _i < buildOrder_2.length; _i++) { - var resolved = buildOrder_2[_i]; + for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) { + var resolved = _a[_i]; var resolvedPath = toResolvedConfigFilePath(state, resolved); // Watch this file watchConfigFile(state, resolved, resolvedPath); @@ -97436,6 +98665,7 @@ var ts; }, invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); }, buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); }, + getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); }, }; } function relName(state, path) { @@ -97446,7 +98676,7 @@ var ts; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } - state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args))); + state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); } function reportWatchStatus(state, message) { var args = []; @@ -97454,7 +98684,7 @@ var ts; args[_i - 2] = arguments[_i]; } if (state.hostWithWatch.onWatchStatusChange) { - state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)), state.host.getNewLine(), state.baseCompilerOptions); + state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)), state.host.getNewLine(), state.baseCompilerOptions); } } function reportErrors(_a, errors) { @@ -97472,23 +98702,33 @@ var ts; reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]); } function reportErrorSummary(state, buildOrder) { - if (!state.needsSummary || (!state.watch && !state.host.reportErrorSummary)) + if (!state.needsSummary) return; state.needsSummary = false; + var canReportSummary = state.watch || !!state.host.reportErrorSummary; var diagnostics = state.diagnostics; - // Report errors from the other projects - buildOrder.forEach(function (project) { - var projectPath = toResolvedConfigFilePath(state, project); - if (!state.projectErrorsReported.has(projectPath)) { - reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); - } - }); var totalErrors = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + if (isCircularBuildOrder(buildOrder)) { + reportBuildQueue(state, buildOrder.buildOrder); + reportErrors(state, buildOrder.circularDiagnostics); + if (canReportSummary) + totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics); + } + else { + // Report errors from the other projects + buildOrder.forEach(function (project) { + var projectPath = toResolvedConfigFilePath(state, project); + if (!state.projectErrorsReported.has(projectPath)) { + reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); + } + }); + if (canReportSummary) + diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + } if (state.watch) { reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors); } - else { + else if (state.host.reportErrorSummary) { state.host.reportErrorSummary(totalErrors); } } @@ -97521,13 +98761,16 @@ var ts; case ts.UpToDateStatusType.UpstreamOutOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.UpstreamBlocked: - return reportStatus(state, ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); + return reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built : + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.Unbuildable: return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason); case ts.UpToDateStatusType.TsVersionOutputOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relName(state, configFileName), status.version, ts.version); case ts.UpToDateStatusType.ContainerOnly: // Don't report status on "solution" projects + // falls through case ts.UpToDateStatusType.ComputingUpstream: // Should never leak from getUptoDateStatusWorker break; @@ -97549,7 +98792,6 @@ var ts; (function (ts) { var server; (function (server) { - // tslint:disable variable-name server.ActionSet = "action::set"; server.ActionInvalidate = "action::invalidate"; server.ActionPackageInstalled = "action::packageInstalled"; @@ -98201,37 +99443,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 275 /* CatchClause */: - case 268 /* JsxAttribute */: + case 153 /* Parameter */: + case 188 /* BindingElement */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 276 /* CatchClause */: + case 269 /* JsxAttribute */: return 1 /* Value */; - case 151 /* TypeParameter */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 169 /* TypeLiteral */: + case 152 /* TypeParameter */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 170 /* TypeLiteral */: return 2 /* Type */; - case 311 /* JSDocTypedefTag */: + case 313 /* 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 279 /* EnumMember */: - case 241 /* ClassDeclaration */: + case 280 /* EnumMember */: + case 242 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -98241,26 +99483,26 @@ var ts; else { return 4 /* Namespace */; } - case 244 /* EnumDeclaration */: - case 253 /* NamedImports */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 245 /* EnumDeclaration */: + case 254 /* NamedImports */: + case 255 /* ImportSpecifier */: + case 250 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: + case 256 /* ExportAssignment */: + case 257 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 285 /* SourceFile */: + case 286 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 255 /* ExportAssignment */ || node.parent.kind === 260 /* ExternalModuleReference */) { + else if (node.parent.kind === 256 /* ExportAssignment */ || node.parent.kind === 261 /* ExternalModuleReference */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -98292,11 +99534,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 149 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 249 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 150 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 250 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 150 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -98308,27 +99550,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 149 /* QualifiedName */) { - while (root.parent && root.parent.kind === 149 /* QualifiedName */) { + if (root.parent.kind === 150 /* QualifiedName */) { + while (root.parent && root.parent.kind === 150 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 165 /* TypeReference */ && !isLastClause; + return root.parent.kind === 166 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 190 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 190 /* PropertyAccessExpression */) { + if (root.parent.kind === 191 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 191 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 212 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 274 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 213 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 275 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 241 /* ClassDeclaration */ && root.parent.parent.token === 110 /* ImplementsKeyword */) || - (decl.kind === 242 /* InterfaceDeclaration */ && root.parent.parent.token === 87 /* ExtendsKeyword */); + return (decl.kind === 242 /* ClassDeclaration */ && root.parent.parent.token === 110 /* ImplementsKeyword */) || + (decl.kind === 243 /* InterfaceDeclaration */ && root.parent.parent.token === 87 /* ExtendsKeyword */); } return false; } @@ -98339,15 +99581,15 @@ var ts; switch (node.kind) { case 101 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 179 /* ThisType */: + case 180 /* ThisType */: return true; } switch (node.parent.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return true; - case 184 /* ImportType */: + case 185 /* ImportType */: return !node.parent.isTypeOf; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -98374,7 +99616,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 234 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 235 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -98406,15 +99648,15 @@ var ts; } ts.isTagName = isTagName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 150 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 191 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 245 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 246 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -98424,22 +99666,22 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 279 /* EnumMember */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 245 /* ModuleDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 277 /* PropertyAssignment */: + case 280 /* EnumMember */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 246 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return true; - case 183 /* LiteralType */: - return node.parent.parent.kind === 181 /* IndexedAccessType */; + case 184 /* LiteralType */: + return node.parent.parent.kind === 182 /* IndexedAccessType */; default: return false; } @@ -98463,17 +99705,17 @@ var ts; return undefined; } switch (node.kind) { - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 286 /* SourceFile */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 246 /* ModuleDeclaration */: return node; } } @@ -98481,48 +99723,53 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return "class" /* classElement */; - case 242 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 243 /* TypeAliasDeclaration */: - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 243 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 244 /* TypeAliasDeclaration */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 244 /* EnumDeclaration */: return "enum" /* enumElement */; - case 238 /* VariableDeclaration */: + case 245 /* EnumDeclaration */: return "enum" /* enumElement */; + case 239 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: return "function" /* functionElement */; - case 159 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 160 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 161 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 277 /* PropertyAssignment */: + var initializer = node.initializer; + return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 278 /* ShorthandPropertyAssignment */: + case 279 /* SpreadAssignment */: return "property" /* memberVariableElement */; - case 163 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 162 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 161 /* CallSignature */: return "call" /* callSignatureElement */; - case 158 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 151 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 279 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 152 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 164 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 163 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 162 /* CallSignature */: return "call" /* callSignatureElement */; + case 159 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 152 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 280 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 153 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 250 /* ImportEqualsDeclaration */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: + case 253 /* NamespaceImport */: return "alias" /* alias */; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { @@ -98570,7 +99817,7 @@ var ts; return true; case 73 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 152 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 153 /* Parameter */; default: return false; } @@ -98635,42 +99882,42 @@ var ts; return false; } switch (n.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 185 /* ObjectBindingPattern */: - case 169 /* TypeLiteral */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 247 /* CaseBlock */: - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 190 /* ObjectLiteralExpression */: + case 186 /* ObjectBindingPattern */: + case 170 /* TypeLiteral */: + case 220 /* Block */: + case 247 /* ModuleBlock */: + case 248 /* CaseBlock */: + case 254 /* NamedImports */: + case 258 /* NamedExports */: return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 193 /* NewExpression */: + case 194 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 192 /* CallExpression */: - case 196 /* ParenthesizedExpression */: - case 178 /* ParenthesizedType */: + case 193 /* CallExpression */: + case 197 /* ParenthesizedExpression */: + case 179 /* ParenthesizedType */: return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 198 /* ArrowFunction */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 163 /* ConstructSignature */: + case 162 /* CallSignature */: + case 199 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -98680,65 +99927,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 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 223 /* IfStatement */: + case 224 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 188 /* ArrayLiteralExpression */: - case 186 /* ArrayBindingPattern */: - case 191 /* ElementAccessExpression */: - case 150 /* ComputedPropertyName */: - case 171 /* TupleType */: + case 189 /* ArrayLiteralExpression */: + case 187 /* ArrayBindingPattern */: + case 192 /* ElementAccessExpression */: + case 151 /* ComputedPropertyName */: + case 172 /* TupleType */: return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 226 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 224 /* DoStatement */: + case 225 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; return hasChildOfKind(n, 108 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 200 /* TypeOfExpression */: - case 199 /* DeleteExpression */: - case 201 /* VoidExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: + case 201 /* TypeOfExpression */: + case 200 /* DeleteExpression */: + case 202 /* VoidExpression */: + case 209 /* YieldExpression */: + case 210 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -98917,7 +100164,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 285 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 286 /* 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. @@ -98987,17 +100234,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 272 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 272 /* JsxExpression */) { return true; } //
|
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 264 /* JsxClosingElement */) { + if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 265 /* JsxClosingElement */) { return true; } return false; @@ -99116,12 +100363,14 @@ var ts; nTypeArguments++; break; case 37 /* EqualsGreaterThanToken */: + // falls through case 73 /* Identifier */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 103 /* TrueKeyword */: case 88 /* FalseKeyword */: + // falls through case 105 /* TypeOfKeyword */: case 87 /* ExtendsKeyword */: case 130 /* KeyOfKeyword */: @@ -99183,10 +100432,10 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 165 /* TypeReference */ || node.kind === 192 /* CallExpression */) { + if (node.kind === 166 /* TypeReference */ || node.kind === 193 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 241 /* ClassDeclaration */ || node.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 242 /* ClassDeclaration */ || node.kind === 243 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -99231,18 +100480,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 188 /* ArrayLiteralExpression */ || - node.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 189 /* ArrayLiteralExpression */ || + node.kind === 190 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 205 /* BinaryExpression */ && + if (node.parent.kind === 206 /* BinaryExpression */ && node.parent.left === node && node.parent.operatorToken.kind === 60 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 228 /* ForOfStatement */ && + if (node.parent.kind === 229 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -99250,7 +100499,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 276 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 277 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -99346,7 +100595,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 150 /* ComputedPropertyName */ + return name.kind === 151 /* 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.getTextOfIdentifierOrLiteral(name); @@ -99511,7 +100760,7 @@ var ts; /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 152 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 153 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -99973,15 +101222,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 193 /* NewExpression */: + case 194 /* NewExpression */: return checker.getContextualType(parent); - case 205 /* BinaryExpression */: { + case 206 /* 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 272 /* CaseClause */: + case 273 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -100023,8 +101272,8 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: + case 208 /* TemplateExpression */: + case 195 /* TaggedTemplateExpression */: return true; default: return false; @@ -100064,19 +101313,19 @@ var ts; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; function syntaxUsuallyHasTrailingSemicolon(kind) { - return kind === 220 /* VariableStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 224 /* DoStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 230 /* BreakStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 155 /* PropertyDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */; + return kind === 221 /* VariableStatement */ + || kind === 223 /* ExpressionStatement */ + || kind === 225 /* DoStatement */ + || kind === 230 /* ContinueStatement */ + || kind === 231 /* BreakStatement */ + || kind === 232 /* ReturnStatement */ + || kind === 236 /* ThrowStatement */ + || kind === 238 /* DebuggerStatement */ + || kind === 156 /* PropertyDeclaration */ + || kind === 244 /* TypeAliasDeclaration */ + || kind === 251 /* ImportDeclaration */ + || kind === 250 /* ImportEqualsDeclaration */ + || kind === 257 /* ExportDeclaration */; } ts.syntaxUsuallyHasTrailingSemicolon = syntaxUsuallyHasTrailingSemicolon; function probablyUsesSemicolons(sourceFile) { @@ -100110,6 +101359,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier() { var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false); function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { @@ -100542,10 +101792,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 241 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -100738,6 +101988,11 @@ var ts; return; } } + else if (kind === 2 /* SingleLineCommentTrivia */) { + if (tryClassifyTripleSlashComment(start, width)) { + return; + } + } // Simple comment. Just add as is. pushCommentRange(start, width); } @@ -100758,18 +102013,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 306 /* JSDocParameterTag */: + case 308 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 309 /* JSDocTypeTag */: + case 311 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 307 /* JSDocReturnTag */: + case 309 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -100798,6 +102053,70 @@ var ts; } } } + function tryClassifyTripleSlashComment(start, width) { + var tripleSlashXMLCommentRegEx = /^(\/\/\/\s*)(<)(?:(\S+)((?:[^/]|\/[^>])*)(\/>)?)?/im; + var attributeRegex = /(\S+)(\s*)(=)(\s*)('[^']+'|"[^"]+")/img; + var text = sourceFile.text.substr(start, width); + var match = tripleSlashXMLCommentRegEx.exec(text); + if (!match) { + return false; + } + // Limiting classification to exactly the elements and attributes + // defined in `ts.commentPragmas` would be excessive, but we can avoid + // some obvious false positives (e.g. in XML-like doc comments) by + // checking the element name. + // eslint-disable-next-line no-in-operator + if (!match[3] || !(match[3] in ts.commentPragmas)) { + return false; + } + var pos = start; + pushCommentRange(pos, match[1].length); // /// + pos += match[1].length; + pushClassification(pos, match[2].length, 10 /* punctuation */); // < + pos += match[2].length; + pushClassification(pos, match[3].length, 21 /* jsxSelfClosingTagName */); // element name + pos += match[3].length; + var attrText = match[4]; + var attrPos = pos; + while (true) { + var attrMatch = attributeRegex.exec(attrText); + if (!attrMatch) { + break; + } + var newAttrPos = pos + attrMatch.index; + if (newAttrPos > attrPos) { + pushCommentRange(attrPos, newAttrPos - attrPos); + attrPos = newAttrPos; + } + pushClassification(attrPos, attrMatch[1].length, 22 /* jsxAttribute */); // attribute name + attrPos += attrMatch[1].length; + if (attrMatch[2].length) { + pushCommentRange(attrPos, attrMatch[2].length); // whitespace + attrPos += attrMatch[2].length; + } + pushClassification(attrPos, attrMatch[3].length, 5 /* operator */); // = + attrPos += attrMatch[3].length; + if (attrMatch[4].length) { + pushCommentRange(attrPos, attrMatch[4].length); // whitespace + attrPos += attrMatch[4].length; + } + pushClassification(attrPos, attrMatch[5].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value + attrPos += attrMatch[5].length; + } + pos += match[4].length; + if (pos > attrPos) { + pushCommentRange(attrPos, pos - attrPos); + } + if (match[5]) { + pushClassification(pos, match[5].length, 10 /* punctuation */); // /> + pos += match[5].length; + } + var end = start + width; + if (pos < end) { + pushCommentRange(pos, end - pos); + } + return true; + } function processJSDocTemplateTag(tag) { for (var _i = 0, _a = tag.getChildren(); _i < _a.length; _i++) { var child = _a[_i]; @@ -100856,22 +102175,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 263 /* JsxOpeningElement */: + case 264 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -100900,17 +102219,17 @@ var ts; var parent = token.parent; if (tokenKind === 60 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 238 /* VariableDeclaration */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 152 /* Parameter */ || - parent.kind === 268 /* JsxAttribute */) { + if (parent.kind === 239 /* VariableDeclaration */ || + parent.kind === 156 /* PropertyDeclaration */ || + parent.kind === 153 /* Parameter */ || + parent.kind === 269 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 205 /* BinaryExpression */ || - parent.kind === 203 /* PrefixUnaryExpression */ || - parent.kind === 204 /* PostfixUnaryExpression */ || - parent.kind === 206 /* ConditionalExpression */) { + if (parent.kind === 206 /* BinaryExpression */ || + parent.kind === 204 /* PrefixUnaryExpression */ || + parent.kind === 205 /* PostfixUnaryExpression */ || + parent.kind === 207 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -100924,7 +102243,7 @@ var ts; } else if (tokenKind === 10 /* StringLiteral */) { // TODO: GH#18217 - return token.parent.kind === 268 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 269 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -100940,32 +102259,32 @@ var ts; else if (tokenKind === 73 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 152 /* Parameter */: + case 153 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -101088,11 +102407,11 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { var parent = node.parent; switch (parent.kind) { - case 183 /* LiteralType */: + case 184 /* LiteralType */: switch (parent.parent.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent)), isNewIdentifier: false }; - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -101100,9 +102419,9 @@ var ts; // } // let x: Foo["/*completion position*/"] return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(parent.parent.objectType)); - case 184 /* ImportType */: + case 185 /* ImportType */: return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 174 /* UnionType */: { + case 175 /* UnionType */: { if (!ts.isTypeReferenceNode(parent.parent.parent)) return undefined; var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(parent.parent, parent); @@ -101112,7 +102431,7 @@ var ts; default: return undefined; } - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -101129,7 +102448,7 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(parent.parent)); } return fromContextualType(); - case 191 /* ElementAccessExpression */: { + case 192 /* ElementAccessExpression */: { var _a = parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { // Get all names of properties on the expression @@ -101142,8 +102461,8 @@ var ts; } return undefined; } - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* 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 @@ -101152,9 +102471,9 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 260 /* ExternalModuleReference */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: + case 261 /* 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*/"); @@ -101198,11 +102517,8 @@ var ts; if (!type) return ts.emptyArray; type = ts.skipConstraint(type); - return type.isUnion() - ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) - : type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) - ? [type] - : ts.emptyArray; + return type.isUnion() ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) : + type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; } function nameAndKind(name, kind, extension) { return { name: name, kind: kind, extension: extension }; @@ -101259,7 +102575,7 @@ var ts; return ts.containsPath(rootDirectory, scriptDirectory, basePath, ignoreCase) ? scriptDirectory.substr(rootDirectory.length) : undefined; }); // TODO: GH#18217 // Now find a path for each potential directory that is to be merged with the one containing the script - return ts.deduplicate(rootDirs.map(function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }).concat([scriptDirectory]), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); + return ts.deduplicate(__spreadArrays(rootDirs.map(function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }), [scriptDirectory]), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptDirectory, extensionOptions, compilerOptions, host, exclude) { var basePath = compilerOptions.project || host.getCurrentDirectory(); @@ -101466,7 +102782,7 @@ var ts; var name = trimPrefixAndSuffix(dir); return name === undefined ? undefined : directoryResult(name); }); - return matches.concat(directories); + return __spreadArrays(matches, directories); function trimPrefixAndSuffix(path) { var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix); return inner === undefined ? undefined : removeLeadingDirectorySeparator(inner); @@ -101667,10 +102983,12 @@ var ts; var SortText; (function (SortText) { SortText["LocationPriority"] = "0"; - SortText["SuggestedClassMembers"] = "1"; - SortText["GlobalsOrKeywords"] = "2"; - SortText["AutoImportSuggestions"] = "3"; - SortText["JavascriptIdentifiers"] = "4"; + SortText["OptionalMember"] = "1"; + SortText["MemberDeclaredBySpreadAssignment"] = "2"; + SortText["SuggestedClassMembers"] = "3"; + SortText["GlobalsOrKeywords"] = "4"; + SortText["AutoImportSuggestions"] = "5"; + SortText["JavascriptIdentifiers"] = "6"; })(SortText = Completions.SortText || (Completions.SortText = {})); var SymbolOriginInfoKind; (function (SymbolOriginInfoKind) { @@ -101678,6 +102996,7 @@ var ts; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 1] = "SymbolMemberNoExport"; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 2] = "SymbolMemberExport"; SymbolOriginInfoKind[SymbolOriginInfoKind["Export"] = 3] = "Export"; + SymbolOriginInfoKind[SymbolOriginInfoKind["Promise"] = 4] = "Promise"; })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {})); function originIsSymbolMember(origin) { return origin.kind === 2 /* SymbolMemberExport */ || origin.kind === 1 /* SymbolMemberNoExport */; @@ -101685,6 +103004,9 @@ var ts; function originIsExport(origin) { return origin.kind === 2 /* SymbolMemberExport */ || origin.kind === 3 /* Export */; } + function originIsPromise(origin) { + return origin.kind === 4 /* Promise */; + } var KeywordCompletionFilters; (function (KeywordCompletionFilters) { KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None"; @@ -101845,6 +103167,13 @@ var ts; replacementSpan = ts.createTextSpanFromNode(isJsxInitializer, sourceFile); } } + if (origin && originIsPromise(origin) && propertyAccessToConvert) { + if (insertText === undefined) + insertText = name; + var awaitText = "(await " + propertyAccessToConvert.expression.getText() + ")"; + insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : awaitText + "." + insertText; + replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); + } if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) { return undefined; } @@ -102075,11 +103404,11 @@ var ts; return ts.getContextualTypeFromParent(previousToken, checker); case 60 /* EqualsToken */: switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; @@ -102089,16 +103418,16 @@ var ts; case 75 /* CaseKeyword */: return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 18 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 261 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 262 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); - return argInfo + return argInfo ? // At `,`, treat this as the next argument after the comma. - ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) - : ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) + checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) : + ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) ? // completion at `x ===/**/` should be for the right side - ? checker.getTypeAtLocation(parent.left) - : checker.getContextualType(previousToken); + checker.getTypeAtLocation(parent.left) : + checker.getContextualType(previousToken); } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { @@ -102108,7 +103437,7 @@ 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 === 285 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 286 /* SourceFile */; }); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { var typeChecker = program.getTypeChecker(); @@ -102159,11 +103488,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 290 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 312 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 314 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -102213,7 +103542,7 @@ var ts; if (contextToken.kind === 24 /* DotToken */) { isRightOfDot = true; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; if (node.end === contextToken.pos && @@ -102225,14 +103554,14 @@ var ts; return undefined; } break; - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: node = parent.left; break; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: node = parent.name; break; - case 184 /* ImportType */: - case 215 /* MetaProperty */: + case 185 /* ImportType */: + case 216 /* MetaProperty */: node = parent; break; default: @@ -102245,7 +103574,7 @@ var ts; // // If the tagname is a property access expression, we will then walk up to the top most of property access expression. // Then, try to get a JSX container and its associated attributes type. - if (parent && parent.kind === 190 /* PropertyAccessExpression */) { + if (parent && parent.kind === 191 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } @@ -102253,38 +103582,38 @@ var ts; if (currentToken.parent === location) { switch (currentToken.kind) { case 30 /* GreaterThanToken */: - if (currentToken.parent.kind === 261 /* JsxElement */ || currentToken.parent.kind === 263 /* JsxOpeningElement */) { + if (currentToken.parent.kind === 262 /* JsxElement */ || currentToken.parent.kind === 264 /* JsxOpeningElement */) { location = currentToken; } break; case 42 /* SlashToken */: - if (currentToken.parent.kind === 262 /* JsxSelfClosingElement */) { + if (currentToken.parent.kind === 263 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: if (contextToken.kind === 42 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: - case 263 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 262 /* JsxElement */: + case 264 /* JsxOpeningElement */: if (contextToken.kind === 28 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: switch (previousToken.kind) { case 60 /* EqualsToken */: isJsxInitializer = true; @@ -102359,11 +103688,11 @@ var ts; }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 311 /* JSDocTypedefTag */: + case 308 /* JSDocParameterTag */: + case 314 /* JSDocPropertyTag */: + case 309 /* JSDocReturnTag */: + case 311 /* JSDocTypeTag */: + case 313 /* JSDocTypedefTag */: return true; default: return false; @@ -102407,8 +103736,8 @@ 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 !== 285 /* SourceFile */ && d.kind !== 245 /* ModuleDeclaration */ && d.kind !== 244 /* EnumDeclaration */; })) { - addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); + symbol.declarations.some(function (d) { return d.kind !== 286 /* SourceFile */ && d.kind !== 246 /* ModuleDeclaration */ && d.kind !== 245 /* EnumDeclaration */; })) { + addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node), !!(node.flags & 16384 /* AwaitContext */)); } return; } @@ -102420,11 +103749,12 @@ var ts; return; } if (!isTypeLocation) { - addTypeProperties(typeChecker.getTypeAtLocation(node)); + addTypeProperties(typeChecker.getTypeAtLocation(node), !!(node.flags & 16384 /* AwaitContext */)); } } - function addTypeProperties(type) { + function addTypeProperties(type, insertAwait) { isNewIdentifierLocation = !!type.getStringIndexType(); + var propertyAccess = node.kind === 185 /* 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 @@ -102436,13 +103766,24 @@ var ts; else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 184 /* ImportType */ ? node : node.parent, type, symbol)) { + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) { addPropertySymbol(symbol); } } } + if (insertAwait && preferences.includeCompletionsWithInsertText) { + var promiseType = typeChecker.getPromisedTypeOfPromise(type); + if (promiseType) { + for (var _b = 0, _c = promiseType.getApparentProperties(); _b < _c.length; _b++) { + var symbol = _c[_b]; + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, promiseType, symbol)) { + addPropertySymbol(symbol, /* insertAwait */ true); + } + } + } + } } - function addPropertySymbol(symbol) { + function addPropertySymbol(symbol, insertAwait) { // For a computed property with an accessible name like `Symbol.iterator`, // we'll add a completion for the *name* `Symbol` instead of for the property. // If this is e.g. [Symbol.iterator], add a completion for `Symbol`. @@ -102459,12 +103800,19 @@ var ts; !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) ? { kind: 1 /* SymbolMemberNoExport */ } : { kind: 2 /* SymbolMemberExport */, moduleSymbol: moduleSymbol, isDefaultExport: false }; } else if (preferences.includeCompletionsWithInsertText) { + addPromiseSymbolOriginInfo(symbol); symbols.push(symbol); } } else { + addPromiseSymbolOriginInfo(symbol); symbols.push(symbol); } + function addPromiseSymbolOriginInfo(symbol) { + if (insertAwait && preferences.includeCompletionsWithInsertText && !symbolToOriginInfoMap[ts.getSymbolId(symbol)]) { + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 4 /* Promise */ }; + } + } } /** Given 'a.b.c', returns 'a'. */ function getLeftMostName(e) { @@ -102497,6 +103845,7 @@ var ts; if (!attrsType) return 0 /* Continue */; symbols = filterJsxAttributes(getPropertiesForObjectExpression(attrsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties); + setSortTextToOptionalMember(); completionKind = 3 /* MemberLike */; isNewIdentifierLocation = false; return 1 /* Success */; @@ -102540,7 +103889,7 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; isInSnippetScope = isSnippetScope(scopeNode); var isTypeOnly = isTypeOnlyCompletion(); - var symbolMeanings = (isTypeOnly ? 0 /* None */ : 67220415 /* Value */) | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; + var symbolMeanings = (isTypeOnly ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { var symbol = symbols_2[_i]; @@ -102550,7 +103899,7 @@ var ts; } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 285 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 286 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType) { for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) { @@ -102584,10 +103933,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 285 /* SourceFile */: - case 207 /* TemplateExpression */: - case 271 /* JsxExpression */: - case 219 /* Block */: + case 286 /* SourceFile */: + case 208 /* TemplateExpression */: + case 272 /* JsxExpression */: + case 220 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -102617,7 +103966,7 @@ var ts; } } // expressions are value space (which includes the value namespaces) - return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 67220415 /* Value */); + return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */); }); } function isTypeAssertion() { @@ -102633,27 +103982,27 @@ var ts; function isContextTokenValueLocation(contextToken) { return contextToken && contextToken.kind === 105 /* TypeOfKeyword */ && - (contextToken.parent.kind === 168 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + (contextToken.parent.kind === 169 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { case 57 /* ColonToken */: - return parentKind === 155 /* PropertyDeclaration */ || - parentKind === 154 /* PropertySignature */ || - parentKind === 152 /* Parameter */ || - parentKind === 238 /* VariableDeclaration */ || + return parentKind === 156 /* PropertyDeclaration */ || + parentKind === 155 /* PropertySignature */ || + parentKind === 153 /* Parameter */ || + parentKind === 239 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); case 60 /* EqualsToken */: - return parentKind === 243 /* TypeAliasDeclaration */; + return parentKind === 244 /* TypeAliasDeclaration */; case 120 /* AsKeyword */: - return parentKind === 213 /* AsExpression */; + return parentKind === 214 /* AsExpression */; case 28 /* LessThanToken */: - return parentKind === 165 /* TypeReference */ || - parentKind === 195 /* TypeAssertionExpression */; + return parentKind === 166 /* TypeReference */ || + parentKind === 196 /* TypeAssertionExpression */; case 87 /* ExtendsKeyword */: - return parentKind === 151 /* TypeParameter */; + return parentKind === 152 /* TypeParameter */; } } return false; @@ -102662,7 +104011,7 @@ var ts; function symbolCanBeReferencedAtTypeLocation(symbol, seenModules) { if (seenModules === void 0) { seenModules = ts.createMap(); } var sym = ts.skipAlias(symbol.exportSymbol || symbol, typeChecker); - return !!(sym.flags & 67897832 /* Type */) || + 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); }); @@ -102683,7 +104032,7 @@ var ts; if (resolvedModuleSymbol !== moduleSymbol && // 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`. - ts.some(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) { + ts.every(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) { symbols.push(resolvedModuleSymbol); symbolToSortTextMap[ts.getSymbolId(resolvedModuleSymbol)] = SortText.AutoImportSuggestions; symbolToOriginInfoMap[ts.getSymbolId(resolvedModuleSymbol)] = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: false }; @@ -102762,11 +104111,11 @@ var ts; return true; } if (contextToken.kind === 30 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 263 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 264 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 264 /* JsxClosingElement */ || contextToken.parent.kind === 262 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 261 /* JsxElement */; + if (contextToken.parent.kind === 265 /* JsxClosingElement */ || contextToken.parent.kind === 263 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 262 /* JsxElement */; } } return false; @@ -102777,40 +104126,40 @@ var ts; // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(previousToken)) { case 27 /* CommaToken */: - return containingNodeKind === 192 /* CallExpression */ // func( a, | - || containingNodeKind === 158 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 193 /* NewExpression */ // new C(a, | - || containingNodeKind === 188 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 205 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 166 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 193 /* CallExpression */ // func( a, | + || containingNodeKind === 159 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 194 /* NewExpression */ // new C(a, | + || containingNodeKind === 189 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 206 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 167 /* FunctionType */; // var x: (s: string, list| case 20 /* OpenParenToken */: - return containingNodeKind === 192 /* CallExpression */ // func( | - || containingNodeKind === 158 /* Constructor */ // constructor( | - || containingNodeKind === 193 /* NewExpression */ // new C(a| - || containingNodeKind === 196 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 178 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 193 /* CallExpression */ // func( | + || containingNodeKind === 159 /* Constructor */ // constructor( | + || containingNodeKind === 194 /* NewExpression */ // new C(a| + || containingNodeKind === 197 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 179 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 22 /* OpenBracketToken */: - return containingNodeKind === 188 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 163 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 150 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + return containingNodeKind === 189 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 164 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 151 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 131 /* ModuleKeyword */: // module | case 132 /* NamespaceKeyword */: // namespace | return true; case 24 /* DotToken */: - return containingNodeKind === 245 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 246 /* ModuleDeclaration */; // module A.| case 18 /* OpenBraceToken */: - return containingNodeKind === 241 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 242 /* ClassDeclaration */; // class A{ | case 60 /* EqualsToken */: - return containingNodeKind === 238 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 205 /* BinaryExpression */; // x = a| + return containingNodeKind === 239 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 206 /* BinaryExpression */; // x = a| case 15 /* TemplateHead */: - return containingNodeKind === 207 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 208 /* TemplateExpression */; // `aa ${| case 16 /* TemplateMiddle */: - return containingNodeKind === 217 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 218 /* TemplateSpan */; // `aa ${10} dd ${| case 116 /* PublicKeyword */: case 114 /* PrivateKeyword */: case 115 /* ProtectedKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 156 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -102837,7 +104186,7 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 189 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 190 /* ObjectLiteralExpression */) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2 /* Fail */; @@ -102846,7 +104195,7 @@ var ts; existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 185 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 186 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -102857,12 +104206,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 === 228 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 152 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 229 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 153 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 157 /* MethodDeclaration */ || rootDeclaration.parent.kind === 160 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 158 /* MethodDeclaration */ || rootDeclaration.parent.kind === 161 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -102879,6 +104228,7 @@ var ts; // Add filtered items to the completion list symbols = filterObjectMembersList(typeMembers, ts.Debug.assertDefined(existingMembers)); } + setSortTextToOptionalMember(); return 1 /* Success */; } /** @@ -102904,7 +104254,7 @@ var ts; return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 253 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 254 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -102932,7 +104282,7 @@ var ts; // If you're in an interface you don't want to repeat things from super-interface. So just stop here. if (!ts.isClassLike(decl)) return 1 /* Success */; - var classElement = contextToken.parent; + var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getModifierFlags(classElement) : 0 /* None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier if (contextToken.kind === 73 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { @@ -103026,11 +104376,11 @@ var ts; case 29 /* LessThanSlashToken */: case 42 /* SlashToken */: case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 269 /* JsxAttributes */: - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 262 /* JsxSelfClosingElement */ || parent.kind === 263 /* JsxOpeningElement */)) { + case 191 /* PropertyAccessExpression */: + case 270 /* JsxAttributes */: + case 269 /* JsxAttribute */: + case 271 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 263 /* JsxSelfClosingElement */ || parent.kind === 264 /* JsxOpeningElement */)) { if (contextToken.kind === 30 /* GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); if (!parent.typeArguments || (precedingToken && precedingToken.kind === 42 /* SlashToken */)) @@ -103038,7 +104388,7 @@ var ts; } return parent; } - else if (parent.kind === 268 /* JsxAttribute */) { + else if (parent.kind === 269 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103050,7 +104400,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 === 268 /* JsxAttribute */) || (parent.kind === 270 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 269 /* JsxAttribute */) || (parent.kind === 271 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103060,8 +104410,8 @@ var ts; break; case 19 /* CloseBraceToken */: if (parent && - parent.kind === 271 /* JsxExpression */ && - parent.parent && parent.parent.kind === 268 /* JsxAttribute */) { + parent.kind === 272 /* JsxExpression */ && + parent.parent && parent.parent.kind === 269 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103069,7 +104419,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 270 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 271 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103089,49 +104439,49 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 27 /* CommaToken */: - return containingNodeKind === 238 /* VariableDeclaration */ || - containingNodeKind === 239 /* VariableDeclarationList */ || - containingNodeKind === 220 /* VariableStatement */ || - containingNodeKind === 244 /* EnumDeclaration */ || // enum a { foo, | + return containingNodeKind === 239 /* VariableDeclaration */ || + containingNodeKind === 240 /* VariableDeclarationList */ || + containingNodeKind === 221 /* VariableStatement */ || + containingNodeKind === 245 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 24 /* DotToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 187 /* ArrayBindingPattern */; // var [.| case 57 /* ColonToken */: - return containingNodeKind === 187 /* BindingElement */; // var {x :html| + return containingNodeKind === 188 /* BindingElement */; // var {x :html| case 22 /* OpenBracketToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 187 /* ArrayBindingPattern */; // var [x| case 20 /* OpenParenToken */: - return containingNodeKind === 275 /* CatchClause */ || + return containingNodeKind === 276 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 18 /* OpenBraceToken */: - return containingNodeKind === 244 /* EnumDeclaration */; // enum a { | + return containingNodeKind === 245 /* EnumDeclaration */; // enum a { | case 28 /* LessThanToken */: - return containingNodeKind === 241 /* ClassDeclaration */ || // class A< | - containingNodeKind === 210 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 243 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 242 /* ClassDeclaration */ || // class A< | + containingNodeKind === 211 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 243 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 244 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); case 117 /* StaticKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + return containingNodeKind === 156 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 25 /* DotDotDotToken */: - return containingNodeKind === 152 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 186 /* ArrayBindingPattern */); // var [...z| + return containingNodeKind === 153 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 187 /* ArrayBindingPattern */); // var [...z| case 116 /* PublicKeyword */: case 114 /* PrivateKeyword */: case 115 /* ProtectedKeyword */: - return containingNodeKind === 152 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + return containingNodeKind === 153 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); case 120 /* AsKeyword */: - return containingNodeKind === 254 /* ImportSpecifier */ || - containingNodeKind === 258 /* ExportSpecifier */ || - containingNodeKind === 252 /* NamespaceImport */; + return containingNodeKind === 255 /* ImportSpecifier */ || + containingNodeKind === 259 /* ExportSpecifier */ || + containingNodeKind === 253 /* NamespaceImport */; case 127 /* GetKeyword */: case 138 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); @@ -103192,7 +104542,7 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 158 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 159 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -103211,16 +104561,18 @@ var ts; if (existingMembers.length === 0) { return contextualMemberSymbols; } + var membersDeclaredBySpreadAssignment = ts.createMap(); var existingMemberNames = ts.createUnderscoreEscapedMap(); 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 !== 276 /* PropertyAssignment */ && - m.kind !== 277 /* ShorthandPropertyAssignment */ && - m.kind !== 187 /* BindingElement */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 277 /* PropertyAssignment */ && + m.kind !== 278 /* ShorthandPropertyAssignment */ && + m.kind !== 188 /* BindingElement */ && + m.kind !== 158 /* MethodDeclaration */ && + m.kind !== 160 /* GetAccessor */ && + m.kind !== 161 /* SetAccessor */ && + m.kind !== 279 /* SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -103228,7 +104580,10 @@ var ts; continue; } var existingName = void 0; - if (ts.isBindingElement(m) && m.propertyName) { + if (ts.isSpreadAssignment(m)) { + setMembersDeclaredBySpreadAssignment(m, membersDeclaredBySpreadAssignment); + } + else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list if (m.propertyName.kind === 73 /* Identifier */) { existingName = m.propertyName.escapedText; @@ -103243,7 +104598,40 @@ var ts; } existingMemberNames.set(existingName, true); // TODO: GH#18217 } - return contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + var filteredSymbols = contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; + } + function setMembersDeclaredBySpreadAssignment(declaration, membersDeclaredBySpreadAssignment) { + var expression = declaration.expression; + var symbol = typeChecker.getSymbolAtLocation(expression); + var type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, expression); + var properties = type && type.properties; + if (properties) { + properties.forEach(function (property) { + membersDeclaredBySpreadAssignment.set(property.name, true); + }); + } + } + // Set SortText to OptionalMember if it is an optinoal member + function setSortTextToOptionalMember() { + symbols.forEach(function (m) { + if (m.flags & 16777216 /* Optional */) { + symbolToSortTextMap[ts.getSymbolId(m)] = symbolToSortTextMap[ts.getSymbolId(m)] || SortText.OptionalMember; + } + }); + } + // Set SortText to MemberDeclaredBySpreadAssignment if it is fulfilled by spread assignment + function setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, contextualMemberSymbols) { + if (membersDeclaredBySpreadAssignment.size === 0) { + return; + } + for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) { + var contextualMemberSymbol = contextualMemberSymbols_1[_i]; + if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) { + symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = SortText.MemberDeclaredBySpreadAssignment; + } + } } /** * Filters out completion suggestions for class elements. @@ -103255,10 +104643,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 !== 155 /* PropertyDeclaration */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 156 /* PropertyDeclaration */ && + m.kind !== 158 /* MethodDeclaration */ && + m.kind !== 160 /* GetAccessor */ && + m.kind !== 161 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -103292,17 +104680,23 @@ var ts; */ function filterJsxAttributes(symbols, attributes) { var seenNames = ts.createUnderscoreEscapedMap(); + var membersDeclaredBySpreadAssignment = ts.createMap(); for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) { var attr = attributes_1[_i]; // If this is the current item we are editing right now, do not filter it out if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 268 /* JsxAttribute */) { + if (attr.kind === 269 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } + else if (ts.isJsxSpreadAttribute(attr)) { + setMembersDeclaredBySpreadAssignment(attr, membersDeclaredBySpreadAssignment); + } } - return symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + var filteredSymbols = symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; } function isCurrentlyEditingNode(node) { return node.getStart(sourceFile) <= position && position <= node.getEnd(); @@ -103342,7 +104736,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 74 /* FirstKeyword */; i <= 148 /* LastKeyword */; i++) { + for (var i = 74 /* FirstKeyword */; i <= 149 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -103476,7 +104870,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 313 /* SyntaxList */: + case 315 /* 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); @@ -103671,7 +105065,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 285 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 286 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -103703,16 +105097,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 233 /* SwitchStatement */: - if (statement.kind === 229 /* ContinueStatement */) { + case 234 /* SwitchStatement */: + if (statement.kind === 230 /* ContinueStatement */) { return false; } // falls through - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 226 /* WhileStatement */: + case 225 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -103728,35 +105122,37 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 219 /* Block */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 247 /* ModuleBlock */: + case 286 /* SourceFile */: + case 220 /* Block */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { - return declaration.members.concat([declaration]); + return __spreadArrays(declaration.members, [declaration]); } else { return container.statements; } - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + return __spreadArrays(container.parameters, (ts.isClassLike(container.parent) ? container.parent.members : [])); + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 170 /* TypeLiteral */: var nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & 28 /* AccessibilityModifier */) { + if (modifierFlag & (28 /* AccessibilityModifier */ | 64 /* Readonly */)) { var constructor = ts.find(container.members, ts.isConstructorDeclaration); if (constructor) { - return nodes.concat(constructor.parameters); + return __spreadArrays(nodes, constructor.parameters); } } else if (modifierFlag & 128 /* Abstract */) { - return nodes.concat([container]); + return __spreadArrays(nodes, [container]); } return nodes; default: @@ -103778,7 +105174,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 90 /* ForKeyword */, 108 /* WhileKeyword */, 83 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 224 /* DoStatement */) { + if (loopNode.kind === 225 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 108 /* WhileKeyword */)) { @@ -103798,13 +105194,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -104171,10 +105567,10 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 238 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 239 /* VariableDeclaration */) { var name = parent.name; if (name.kind === 73 /* Identifier */) { directImports.push(name); @@ -104187,20 +105583,20 @@ var ts; break; case 73 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 253 /* 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 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -104210,7 +105606,7 @@ var ts; directImports.push(direct); } break; - case 184 /* ImportType */: + case 185 /* ImportType */: directImports.push(direct); break; default: @@ -104227,7 +105623,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 285 /* SourceFile */ || sourceFileLike.kind === 245 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 286 /* SourceFile */ || sourceFileLike.kind === 246 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -104282,7 +105678,7 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 249 /* ImportEqualsDeclaration */) { + if (decl.kind === 250 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } @@ -104292,7 +105688,7 @@ var ts; handleNamespaceImportLike(decl); return; } - if (decl.kind === 184 /* ImportType */) { + if (decl.kind === 185 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -104307,17 +105703,17 @@ var ts; if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 256 /* ExportDeclaration */) { + if (decl.kind === 257 /* ExportDeclaration */) { searchForNamedImport(decl.exportClause); return; } var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 253 /* NamedImports */: + case 254 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -104367,7 +105763,7 @@ var ts; } } else { - var localSymbol = element.kind === 258 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 259 /* 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); @@ -104396,7 +105792,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 === 285 /* SourceFile */) { + if (searchSourceFile.kind === 286 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -104444,7 +105840,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 === 285 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 286 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -104459,15 +105855,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: { + case 257 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 249 /* ImportEqualsDeclaration */: { + case 250 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -104481,7 +105877,7 @@ var ts; /** * Given a local reference, we might notice that it's an import/export and recursively search for references of that. * If at an import, look locally for the symbol it imports. - * If an an export, look for all imports of it. + * If at an export, look for all imports of it. * This doesn't handle export specifiers; that is done in `getReferencesAtExportSpecifier`. * @param comingFromExport If we are doing a search for all exports, don't bother looking backwards for the imported symbol, since that's the reason we're here. */ @@ -104491,7 +105887,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 190 /* PropertyAccessExpression */) { + if (parent.kind === 191 /* 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) @@ -104613,10 +106009,10 @@ var ts; // If a reference is a class expression, the exported node would be its parent. // If a reference is a variable declaration, the exported node would be the variable statement. function getExportNode(parent, node) { - if (parent.kind === 238 /* VariableDeclaration */) { - var p = parent; - return p.name !== node ? undefined : - p.parent.kind === 275 /* CatchClause */ ? undefined : p.parent.parent.kind === 220 /* VariableStatement */ ? p.parent.parent : undefined; + var declaration = ts.isVariableDeclaration(parent) ? parent : ts.isBindingElement(parent) ? ts.walkUpBindingElementsAndPatterns(parent) : undefined; + if (declaration) { + return parent.name !== node ? undefined : + ts.isCatchClause(declaration.parent) ? undefined : ts.isVariableStatement(declaration.parent.parent) ? declaration.parent.parent : undefined; } else { return parent; @@ -104625,13 +106021,13 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 254 /* ImportSpecifier */: + case 255 /* 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 251 /* ImportClause */: - case 252 /* NamespaceImport */: + case 252 /* ImportClause */: + case 253 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return true; default: @@ -104664,21 +106060,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 193 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 285 /* SourceFile */) { + if (parent.kind === 286 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 246 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 247 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 246 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 260 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 261 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -104780,7 +106176,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -104788,27 +106184,27 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 187 /* BindingElement */: + case 188 /* BindingElement */: return getContextNode(node.parent.parent); - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return node.parent.parent.parent; - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 259 /* ExportSpecifier */: + case 253 /* NamespaceImport */: return node.parent.parent; - case 251 /* ImportClause */: + case 252 /* ImportClause */: return node.parent; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 228 /* ForInStatement */: return { start: node.initializer, end: node.expression }; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -104852,13 +106248,13 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* 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 === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 278 /* ShorthandPropertyAssignment */) { var result_1 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); return result_1; @@ -104943,16 +106339,16 @@ var ts; return { displayParts: displayParts, kind: symbolKind }; } function toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixText) { - return __assign({}, entryToDocumentSpan(entry), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker))); + return __assign(__assign({}, entryToDocumentSpan(entry)), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker))); } FindAllReferences.toRenameLocation = toRenameLocation; function toReferenceEntry(entry) { var documentSpan = entryToDocumentSpan(entry); if (entry.kind === 0 /* Span */) { - return __assign({}, documentSpan, { isWriteAccess: false, isDefinition: false }); + return __assign(__assign({}, documentSpan), { isWriteAccess: false, isDefinition: false }); } var kind = entry.kind, node = entry.node; - return __assign({}, documentSpan, { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 81 /* DefaultKeyword */ + return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 81 /* DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); } @@ -104996,10 +106392,10 @@ var ts; var documentSpan = entryToDocumentSpan(entry); if (entry.kind !== 0 /* Span */) { var node = entry.node; - return __assign({}, documentSpan, implementationKindDisplayParts(node, checker)); + return __assign(__assign({}, documentSpan), implementationKindDisplayParts(node, checker)); } else { - return __assign({}, documentSpan, { kind: "" /* unknown */, displayParts: [] }); + return __assign(__assign({}, documentSpan), { kind: "" /* unknown */, displayParts: [] }); } } function implementationKindDisplayParts(node, checker) { @@ -105007,13 +106403,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 190 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 210 /* ClassExpression */) { + else if (node.kind === 211 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] @@ -105068,46 +106464,46 @@ var ts; if (!!(decl.flags & 4194304 /* Ambient */)) return true; switch (decl.kind) { - case 205 /* BinaryExpression */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 206 /* BinaryExpression */: + case 188 /* BindingElement */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: case 81 /* DefaultKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 258 /* ExportSpecifier */: - case 251 /* ImportClause */: // default import - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 242 /* InterfaceDeclaration */: - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: - case 268 /* JsxAttribute */: - case 245 /* ModuleDeclaration */: - case 248 /* NamespaceExportDeclaration */: - case 252 /* NamespaceImport */: - case 152 /* Parameter */: - case 277 /* ShorthandPropertyAssignment */: - case 243 /* TypeAliasDeclaration */: - case 151 /* TypeParameter */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 259 /* ExportSpecifier */: + case 252 /* ImportClause */: // default import + case 250 /* ImportEqualsDeclaration */: + case 255 /* ImportSpecifier */: + case 243 /* InterfaceDeclaration */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 269 /* JsxAttribute */: + case 246 /* ModuleDeclaration */: + case 249 /* NamespaceExportDeclaration */: + case 253 /* NamespaceImport */: + case 153 /* Parameter */: + case 278 /* ShorthandPropertyAssignment */: + case 244 /* TypeAliasDeclaration */: + case 152 /* TypeParameter */: return true; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return !!decl.body; - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: + case 239 /* VariableDeclaration */: + case 156 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 156 /* MethodSignature */: - case 154 /* PropertySignature */: - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: + case 157 /* MethodSignature */: + case 155 /* PropertySignature */: + case 314 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -105267,10 +106663,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 285 /* SourceFile */: + case 286 /* 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 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(FindAllReferences.nodeEntry(decl.name)); } @@ -105287,21 +106683,32 @@ var ts; var sourceFile = decl.getSourceFile(); if (sourceFilesSet.has(sourceFile.fileName)) { // At `module.exports = ...`, reference node is `module` - var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) - ? decl.left.expression - : ts.isExportAssignment(decl) - ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 86 /* ExportKeyword */, sourceFile)) - : ts.getNameOfDeclaration(decl) || decl; + var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : + ts.isExportAssignment(decl) ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 86 /* ExportKeyword */, sourceFile)) : + ts.getNameOfDeclaration(decl) || decl; references.push(FindAllReferences.nodeEntry(node)); } } } return references.length ? [{ definition: { type: 0 /* Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; } + /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ + function isReadonlyTypeOperator(node) { + return node.kind === 134 /* ReadonlyKeyword */ + && ts.isTypeOperatorNode(node.parent) + && node.parent.operator === 134 /* ReadonlyKeyword */; + } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { if (ts.isTypeKeyword(node.kind)) { - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + // A modifier readonly (like on a property declaration) is not special; + // a readonly type keyword (like `readonly string[]`) is. + if (node.kind === 134 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + return undefined; + } + // Likewise, when we *are* looking for a special keyword, make sure we + // *don’t* include readonly member modifiers. + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 134 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } // Labels if (ts.isJumpStatementTarget(node)) { @@ -105600,7 +107007,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 === 197 /* FunctionExpression */ || valueDeclaration.kind === 210 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 198 /* FunctionExpression */ || valueDeclaration.kind === 211 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -105610,7 +107017,7 @@ var ts; if (flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.find(declarations, function (d) { return ts.hasModifier(d, 8 /* Private */); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 241 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 242 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -105639,7 +107046,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 286 /* 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; @@ -105660,7 +107067,7 @@ var ts; } Core.isSymbolReferencedInFile = isSymbolReferencedInFile; function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) { - var symbol = ts.isParameterPropertyDeclaration(definition.parent) + var symbol = ts.isParameterPropertyDeclaration(definition.parent, definition.parent.parent) ? ts.first(checker.getSymbolsOfParameterPropertyDeclaration(definition.parent, definition.text)) : checker.getSymbolAtLocation(definition); if (!symbol) @@ -105762,11 +107169,13 @@ var ts; return false; } } - function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { + function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken, filter) { var references = ts.flatMap(sourceFiles, function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, ts.tokenToString(keywordKind), sourceFile), function (referenceLocation) { - return referenceLocation.kind === keywordKind ? FindAllReferences.nodeEntry(referenceLocation) : undefined; + if (referenceLocation.kind === keywordKind && (!filter || filter(referenceLocation))) { + return FindAllReferences.nodeEntry(referenceLocation); + } }); }); return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; @@ -105940,7 +107349,7 @@ var ts; } } function addReference(referenceLocation, relatedSymbol, state) { - var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; + var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator var addRef = state.referenceAdder(symbol); if (state.options.implementations) { addImplementationReferences(referenceLocation, addRef, state); @@ -106003,14 +107412,14 @@ var ts; for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var ctrKeyword = ts.findChildOfKind(decl, 125 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 158 /* Constructor */ && !!ctrKeyword); + ts.Debug.assert(decl.kind === 159 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 157 /* MethodDeclaration */) { + if (decl && decl.kind === 158 /* MethodDeclaration */) { var body = decl.body; if (body) { forEachDescendantOfKind(body, 101 /* ThisKeyword */, function (thisKeyword) { @@ -106034,7 +107443,7 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 158 /* Constructor */); + ts.Debug.assert(decl.kind === 159 /* Constructor */); var body = decl.body; if (body) { forEachDescendantOfKind(body, 99 /* SuperKeyword */, function (node) { @@ -106064,7 +107473,7 @@ var ts; if (refNode.kind !== 73 /* Identifier */) { return; } - if (refNode.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 278 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -106084,7 +107493,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 219 /* Block */) { + if (body.kind === 220 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -106112,13 +107521,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 188 /* ArrayLiteralExpression */: + case 199 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 190 /* ObjectLiteralExpression */: + case 211 /* ClassExpression */: + case 189 /* ArrayLiteralExpression */: return true; default: return false; @@ -106171,13 +107580,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -106198,41 +107607,41 @@ var ts; return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 73 /* Identifier */ && node.parent.kind === 152 /* Parameter */ && node.parent.name === node; + return node.kind === 73 /* Identifier */ && node.parent.kind === 153 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 198 /* 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 === 285 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 286 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -106240,19 +107649,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 242 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 285 /* SourceFile */: - return container.kind === 285 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 286 /* SourceFile */: + return container.kind === 286 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -106329,7 +107738,7 @@ var ts; var res = fromRoot(symbol); if (res) return res; - if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) { // For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property). var paramProps = checker.getSymbolsOfParameterPropertyDeclaration(ts.cast(symbol.valueDeclaration, ts.isParameter), symbol.name); ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] @@ -106371,7 +107780,7 @@ var ts; }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 187 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 188 /* BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -106421,11 +107830,10 @@ var ts; } Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations; function isImplementation(node) { - return !!(node.flags & 4194304 /* Ambient */) - ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) - : (ts.isVariableLike(node) ? ts.hasInitializer(node) - : ts.isFunctionLikeDeclaration(node) ? !!node.body - : ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); + return !!(node.flags & 4194304 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : + (ts.isVariableLike(node) ? ts.hasInitializer(node) : + ts.isFunctionLikeDeclaration(node) ? !!node.body : + ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); } function getReferenceEntriesForShorthandPropertyAssignment(node, checker, addReference) { var refSymbol = checker.getSymbolAtLocation(node); @@ -106728,9 +108136,9 @@ var ts; return [sigInfo]; } else { - var defs = getDefinitionFromSymbol(typeChecker, symbol, node) || ts.emptyArray; + var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 99 /* SuperKeyword */ ? [sigInfo].concat(defs) : defs.concat([sigInfo]); + return node.kind === 99 /* SuperKeyword */ ? __spreadArrays([sigInfo], defs) : __spreadArrays(defs, [sigInfo]); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -106738,7 +108146,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 278 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -106898,28 +108306,32 @@ var ts; return true; } switch (declaration.kind) { - case 251 /* ImportClause */: - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportClause */: + case 250 /* ImportEqualsDeclaration */: return true; - case 254 /* ImportSpecifier */: - return declaration.parent.kind === 253 /* NamedImports */; + case 255 /* ImportSpecifier */: + return declaration.parent.kind === 254 /* NamedImports */; default: return false; } } - function getDefinitionFromSymbol(typeChecker, symbol, node) { - return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(symbol.declarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); + function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) { + // There are cases when you extend a function by adding properties to it afterwards, + // we want to strip those extra properties. + // For deduping purposes, we also want to exclude any declarationNodes if provided. + var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); }) || undefined; + return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); function getConstructSignatureDefinition() { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (symbol.flags & 32 /* Class */ && (ts.isNewExpressionTarget(node) || node.kind === 125 /* ConstructorKeyword */)) { - var cls = ts.find(symbol.declarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); + if (symbol.flags & 32 /* Class */ && !(symbol.flags & 16 /* Function */) && (ts.isNewExpressionTarget(node) || node.kind === 125 /* ConstructorKeyword */)) { + var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } } function getCallSignatureDefinition() { return ts.isCallOrNewExpressionTarget(node) || ts.isNameOfFunctionDeclaration(node) - ? getSignatureDefinition(symbol.declarations, /*selectConstructors*/ false) + ? getSignatureDefinition(filteredDeclarations, /*selectConstructors*/ false) : undefined; } function getSignatureDefinition(signatureDeclarations, selectConstructors) { @@ -106927,8 +108339,12 @@ var ts; return undefined; } var declarations = signatureDeclarations.filter(selectConstructors ? ts.isConstructorDeclaration : ts.isFunctionLike); + var declarationsWithBody = declarations.filter(function (d) { return !!d.body; }); + // declarations defined on the global scope can be defined on multiple files. Get all of them. return declarations.length - ? [createDefinitionInfo(ts.find(declarations, function (d) { return !!d.body; }) || ts.last(declarations), typeChecker, symbol, node)] + ? declarationsWithBody.length !== 0 + ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); }) + : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)] : undefined; } } @@ -106981,9 +108397,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 159 /* Constructor */: + case 168 /* ConstructorType */: + case 163 /* ConstructSignature */: return true; default: return false; @@ -107101,11 +108517,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: + case 314 /* JSDocPropertyTag */: return [declaration]; - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -107126,16 +108542,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 301 /* JSDocAugmentsTag */: + case 303 /* JSDocAugmentsTag */: return withNode(tag.class); - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 309 /* JSDocTypeTag */: + case 311 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 314 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -107322,23 +108738,23 @@ var ts; } function getCommentOwnerInfoWorker(commentOwner) { switch (commentOwner.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 156 /* MethodSignature */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 157 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer); - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 154 /* PropertySignature */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 243 /* TypeAliasDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 155 /* PropertySignature */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 244 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 220 /* VariableStatement */: { + case 221 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -107346,14 +108762,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 285 /* SourceFile */: + case 286 /* SourceFile */: return "quit"; - case 245 /* ModuleDeclaration */: + case 246 /* 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 === 245 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 205 /* BinaryExpression */: { + return commentOwner.parent.kind === 246 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 206 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; @@ -107372,14 +108788,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 196 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 197 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return rightHandSide.parameters; - case 210 /* ClassExpression */: { + case 211 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -107441,9 +108857,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 251 /* ImportClause */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportClause */: + case 255 /* ImportSpecifier */: + case 250 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -107453,7 +108869,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 150 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 151 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -107470,7 +108886,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 === 150 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 151 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -107514,6 +108930,7 @@ var ts; (function (ts) { var NavigationBar; (function (NavigationBar) { + var _a; /** * Matches all whitespace characters in a string. Eg: * @@ -107528,6 +108945,11 @@ var ts; * does not match. */ var whiteSpaceRegex = /\s+/g; + /** + * Maximum amount of characters to return + * The amount was choosen arbitrarily. + */ + var maxLength = 150; // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. var curCancellationToken; var curSourceFile; @@ -107538,13 +108960,15 @@ var ts; */ var parentsStack = []; var parent; + var trackedEs5ClassesStack = []; + var trackedEs5Classes; // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. var emptyChildItemArray = []; function getNavigationBarItems(sourceFile, cancellationToken) { curCancellationToken = cancellationToken; curSourceFile = sourceFile; try { - return ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); + return ts.map(primaryNavBarMenuItems(rootNavigationBarNode(sourceFile)), convertToPrimaryNavBarMenuItem); } finally { reset(); @@ -107570,7 +108994,7 @@ var ts; emptyChildItemArray = []; } function nodeText(node) { - return node.getText(curSourceFile); + return cleanText(node.getText(curSourceFile)); } function navigationBarNodeKind(n) { return n.node.kind; @@ -107595,28 +109019,55 @@ var ts; ts.Debug.assert(!parent && !parentsStack.length); return root; } - function addLeafNode(node) { - pushChild(parent, emptyNavigationBarNode(node)); + function addLeafNode(node, name) { + pushChild(parent, emptyNavigationBarNode(node, name)); } - function emptyNavigationBarNode(node) { + function emptyNavigationBarNode(node, name) { return { node: node, - name: ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined, + name: name || (ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined), additionalNodes: undefined, parent: parent, children: undefined, indent: parent.indent + 1 }; } + function addTrackedEs5Class(name) { + if (!trackedEs5Classes) { + trackedEs5Classes = ts.createMap(); + } + trackedEs5Classes.set(name, true); + } + function endNestedNodes(depth) { + for (var i = 0; i < depth; i++) + endNode(); + } + function startNestedNodes(targetNode, entityName) { + var names = []; + while (!ts.isIdentifier(entityName)) { + var name = entityName.name; + entityName = entityName.expression; + if (name.escapedText === "prototype") + continue; + names.push(name); + } + names.push(entityName); + for (var i = names.length - 1; i > 0; i--) { + var name = names[i]; + startNode(targetNode, name); + } + return [names.length - 1, names[0]]; + } /** * Add a new level of NavigationBarNodes. * This pushes to the stack, so you must call `endNode` when you are done adding to this node. */ - function startNode(node) { - var navNode = emptyNavigationBarNode(node); + function startNode(node, name) { + var navNode = emptyNavigationBarNode(node, name); pushChild(parent, navNode); // Save the old parent parentsStack.push(parent); + trackedEs5ClassesStack.push(trackedEs5Classes); parent = navNode; } /** Call after calling `startNode` and adding children to it. */ @@ -107626,46 +109077,48 @@ var ts; sortChildren(parent.children); } parent = parentsStack.pop(); + trackedEs5Classes = trackedEs5ClassesStack.pop(); } - function addNodeWithRecursiveChild(node, child) { - startNode(node); + function addNodeWithRecursiveChild(node, child, name) { + startNode(node, name); addChildrenRecursively(child); endNode(); } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ function addChildrenRecursively(node) { + var _a; curCancellationToken.throwIfCancellationRequested(); if (!node || ts.isToken(node)) { return; } switch (node.kind) { - case 158 /* Constructor */: + case 159 /* 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); // Parameter properties are children of the class, not the constructor. - for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { - var param = _a[_i]; - if (ts.isParameterPropertyDeclaration(param)) { + for (var _i = 0, _b = ctr.parameters; _i < _b.length; _i++) { + var param = _b[_i]; + if (ts.isParameterPropertyDeclaration(param, ctr)) { addLeafNode(param); } } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 157 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 251 /* ImportClause */: + case 252 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -107677,90 +109130,168 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 253 /* NamespaceImport */) { addLeafNode(namedBindings); } else { - for (var _b = 0, _c = namedBindings.elements; _b < _c.length; _b++) { - var element = _c[_b]; + for (var _c = 0, _d = namedBindings.elements; _c < _d.length; _c++) { + var element = _d[_c]; addLeafNode(element); } } } break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: - var _d = node, name = _d.name, initializer = _d.initializer; + case 278 /* ShorthandPropertyAssignment */: + addNodeWithRecursiveChild(node, node.name); + break; + case 279 /* 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 188 /* BindingElement */: + case 277 /* PropertyAssignment */: + case 239 /* VariableDeclaration */: + var _e = node, name = _e.name, initializer = _e.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); } else if (initializer && isFunctionOrClassExpression(initializer)) { - if (initializer.name) { - // Don't add a node for the VariableDeclaration, just for the initializer. - addChildrenRecursively(initializer); - } - else { - // Add a node for the VariableDeclaration, but not for the initializer. - startNode(node); - ts.forEachChild(initializer, addChildrenRecursively); - endNode(); - } + // Add a node for the VariableDeclaration, but not for the initializer. + startNode(node); + ts.forEachChild(initializer, addChildrenRecursively); + endNode(); } else { addNodeWithRecursiveChild(node, initializer); } break; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + var nameNode = node.name; + // If we see a function declaration track as a possible ES5 class + if (nameNode && ts.isIdentifier(nameNode)) { + addTrackedEs5Class(nameNode.text); + } + addNodeWithRecursiveChild(node, node.body); + break; + case 199 /* ArrowFunction */: + case 198 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: startNode(node); - for (var _e = 0, _f = node.members; _e < _f.length; _e++) { - var member = _f[_e]; + for (var _f = 0, _g = node.members; _f < _g.length; _f++) { + var member = _g[_f]; if (!isComputedProperty(member)) { addLeafNode(member); } } endNode(); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: startNode(node); - for (var _g = 0, _h = node.members; _g < _h.length; _g++) { - var member = _h[_g]; + for (var _h = 0, _j = node.members; _h < _j.length; _h++) { + var member = _j[_h]; addChildrenRecursively(member); } endNode(); break; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 258 /* ExportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 163 /* IndexSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 243 /* TypeAliasDeclaration */: + case 259 /* ExportSpecifier */: + case 250 /* ImportEqualsDeclaration */: + case 164 /* IndexSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 244 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 205 /* BinaryExpression */: { + case 193 /* CallExpression */: + case 206 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: case 2 /* ModuleExports */: - case 3 /* PrototypeProperty */: - case 6 /* Prototype */: addNodeWithRecursiveChild(node, node.right); return; + case 6 /* Prototype */: + case 3 /* PrototypeProperty */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var prototypeAccess = special === 3 /* PrototypeProperty */ ? + assignmentTarget.expression : + assignmentTarget; + var depth = 0; + var className = void 0; + // If we see a prototype assignment, start tracking the target as a class + // This is only done for simple classes not nested assignments. + if (ts.isIdentifier(prototypeAccess.expression)) { + addTrackedEs5Class(prototypeAccess.expression.text); + className = prototypeAccess.expression; + } + else { + _a = startNestedNodes(binaryExpression, prototypeAccess.expression), depth = _a[0], className = _a[1]; + } + if (special === 6 /* Prototype */) { + if (ts.isObjectLiteralExpression(binaryExpression.right)) { + if (binaryExpression.right.properties.length > 0) { + startNode(binaryExpression, className); + ts.forEachChild(binaryExpression.right, addChildrenRecursively); + endNode(); + } + } + } + else if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, className); + } + else { + startNode(binaryExpression, className); + addNodeWithRecursiveChild(node, binaryExpression.right, assignmentTarget.name); + endNode(); + } + endNestedNodes(depth); + return; + } + case 7 /* ObjectDefinePropertyValue */: + case 9 /* ObjectDefinePrototypeProperty */: { + var defineCall = node; + var className = special === 7 /* ObjectDefinePropertyValue */ ? + defineCall.arguments[0] : + defineCall.arguments[0].expression; + var memberName = defineCall.arguments[1]; + var _k = startNestedNodes(node, className), depth = _k[0], classNameIdentifier = _k[1]; + startNode(node, classNameIdentifier); + startNode(node, ts.setTextRange(ts.createIdentifier(memberName.text), memberName)); + addChildrenRecursively(node.arguments[2]); + endNode(); + endNode(); + endNestedNodes(depth); + return; + } + case 5 /* Property */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var targetFunction = assignmentTarget.expression; + if (ts.isIdentifier(targetFunction) && assignmentTarget.name.escapedText !== "prototype" && + trackedEs5Classes && trackedEs5Classes.has(targetFunction.text)) { + if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, targetFunction); + } + else { + startNode(binaryExpression, targetFunction); + addNodeWithRecursiveChild(binaryExpression.left, binaryExpression.right, assignmentTarget.name); + endNode(); + } + return; + } + break; + } case 4 /* ThisProperty */: - case 5 /* Property */: case 0 /* None */: - case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: break; default: ts.Debug.assertNever(special); @@ -107783,8 +109314,8 @@ var ts; /** Merge declarations of the same kind. */ function mergeChildren(children, node) { var nameToItems = ts.createMap(); - ts.filterMutate(children, function (child) { - var declName = ts.getNameOfDeclaration(child.node); + ts.filterMutate(children, function (child, index) { + var declName = child.name || ts.getNameOfDeclaration(child.node); var name = declName && nodeText(declName); if (!name) { // Anonymous items are never merged. @@ -107798,7 +109329,7 @@ var ts; if (itemsWithSameName instanceof Array) { for (var _i = 0, itemsWithSameName_1 = itemsWithSameName; _i < itemsWithSameName_1.length; _i++) { var itemWithSameName = itemsWithSameName_1[_i]; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } } @@ -107807,7 +109338,7 @@ var ts; } else { var itemWithSameName = itemsWithSameName; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } nameToItems.set(name, [itemWithSameName, child]); @@ -107815,7 +109346,100 @@ var ts; } }); } - function tryMerge(a, b, parent) { + var isEs5ClassMember = (_a = {}, + _a[5 /* Property */] = true, + _a[3 /* PrototypeProperty */] = true, + _a[7 /* ObjectDefinePropertyValue */] = true, + _a[9 /* ObjectDefinePrototypeProperty */] = true, + _a[0 /* None */] = false, + _a[1 /* ExportsProperty */] = false, + _a[2 /* ModuleExports */] = false, + _a[8 /* ObjectDefinePropertyExports */] = false, + _a[6 /* Prototype */] = true, + _a[4 /* ThisProperty */] = false, + _a); + function tryMergeEs5Class(a, b, bIndex, parent) { + function isPossibleConstructor(node) { + return ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node) || ts.isVariableDeclaration(node); + } + var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? + ts.getAssignmentDeclarationKind(b.node) : + 0 /* None */; + var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? + ts.getAssignmentDeclarationKind(a.node) : + 0 /* None */; + // We treat this as an es5 class and merge the nodes in in one of several cases + if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements + || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member + || (isPossibleConstructor(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & ctor function + || (ts.isClassDeclaration(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // class (generated) & member + || (ts.isClassDeclaration(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & class (generated) + || (ts.isClassDeclaration(a.node) && isPossibleConstructor(b.node)) // class (generated) & ctor + || (ts.isClassDeclaration(b.node) && isPossibleConstructor(a.node)) // ctor & class (generated) + ) { + var lastANode = a.additionalNodes && ts.lastOrUndefined(a.additionalNodes) || a.node; + if ((!ts.isClassDeclaration(a.node) && !ts.isClassDeclaration(b.node)) // If neither outline node is a class + || isPossibleConstructor(a.node) || isPossibleConstructor(b.node) // If either function is a constructor function + ) { + var ctorFunction = isPossibleConstructor(a.node) ? a.node : + isPossibleConstructor(b.node) ? b.node : + undefined; + if (ctorFunction !== undefined) { + var ctorNode = ts.setTextRange(ts.createConstructor(/* decorators */ undefined, /* modifiers */ undefined, [], /* body */ undefined), ctorFunction); + var ctor = emptyNavigationBarNode(ctorNode); + ctor.indent = a.indent + 1; + ctor.children = a.node === ctorFunction ? a.children : b.children; + a.children = a.node === ctorFunction ? ts.concatenate([ctor], b.children || [b]) : ts.concatenate(a.children || [a], [ctor]); + } + else { + if (a.children || b.children) { + a.children = ts.concatenate(a.children || [a], b.children || [b]); + if (a.children) { + mergeChildren(a.children, a); + sortChildren(a.children); + } + } + } + lastANode = a.node = ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), a.node); + } + else { + a.children = ts.concatenate(a.children, b.children); + if (a.children) { + mergeChildren(a.children, a); + } + } + var bNode = b.node; + // We merge if the outline node previous to b (bIndex - 1) is already part of the current class + // We do this so that statements between class members that do not generate outline nodes do not split up the class outline: + // Ex This should produce one outline node C: + // function C() {}; a = 1; C.prototype.m = function () {} + // Ex This will produce 3 outline nodes: C, a, C + // function C() {}; let a = 1; C.prototype.m = function () {} + if (parent.children[bIndex - 1].node.end === lastANode.end) { + ts.setTextRange(lastANode, { pos: lastANode.pos, end: bNode.end }); + } + else { + if (!a.additionalNodes) + a.additionalNodes = []; + a.additionalNodes.push(ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), b.node)); + } + return true; + } + return bAssignmentDeclarationKind === 0 /* None */ ? false : true; + } + function tryMerge(a, b, bIndex, parent) { + // const v = false as boolean; + if (tryMergeEs5Class(a, b, bIndex, parent)) { + return true; + } if (shouldReallyMerge(a.node, b.node, parent)) { merge(a, b); return true; @@ -107828,12 +109452,12 @@ var ts; return false; } switch (a.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -107849,7 +109473,7 @@ var ts; // 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 !== 245 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 246 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -107879,7 +109503,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 245 /* ModuleDeclaration */) { + if (node.kind === 246 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -107887,35 +109511,35 @@ var ts; return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 } switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 211 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 245 /* ModuleDeclaration */) { - return getModuleName(node); + if (node.kind === 246 /* ModuleDeclaration */) { + return cleanText(getModuleName(node)); } if (name) { - var text = nodeText(name); + var text = ts.isIdentifier(name) ? name.text : nodeText(name); if (text.length > 0) { - return text; + return cleanText(text); } } switch (node.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 199 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -107923,24 +109547,27 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 158 /* Constructor */: + case 159 /* Constructor */: return "constructor"; - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: return "new()"; - case 161 /* CallSignature */: + case 162 /* CallSignature */: return "()"; - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: return "[]"; default: return ""; } } - /** Flattens the NavNode tree to a list, keeping only the top-level items. */ - function topLevelItems(root) { - var topLevel = []; + /** Flattens the NavNode tree to a list of items to appear in the primary navbar menu. */ + function primaryNavBarMenuItems(root) { + // The primary (middle) navbar menu displays the general code navigation hierarchy, similar to the navtree. + // The secondary (right) navbar menu displays the child items of whichever primary item is selected. + // Some less interesting items without their own child navigation items (e.g. a local variable declaration) only show up in the secondary menu. + var primaryNavBarMenuItems = []; function recur(item) { - if (isTopLevel(item)) { - topLevel.push(item); + if (shouldAppearInPrimaryNavBarMenu(item)) { + primaryNavBarMenuItems.push(item); if (item.children) { for (var _i = 0, _a = item.children; _i < _a.length; _i++) { var child = _a[_i]; @@ -107950,28 +109577,28 @@ var ts; } } recur(root); - return topLevel; - function isTopLevel(item) { + return primaryNavBarMenuItems; + /** Determines if a node should appear in the primary navbar menu. */ + function shouldAppearInPrimaryNavBarMenu(item) { + // Items with children should always appear in the primary navbar menu. + if (item.children) { + return true; + } + // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 285 /* SourceFile */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 245 /* EnumDeclaration */: + case 243 /* InterfaceDeclaration */: + case 246 /* ModuleDeclaration */: + case 286 /* SourceFile */: + case 244 /* TypeAliasDeclaration */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: return true; - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 238 /* VariableDeclaration */: - return hasSomeImportantChild(item); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -107981,21 +109608,15 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: + case 247 /* ModuleBlock */: + case 286 /* SourceFile */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: return true; default: - return hasSomeImportantChild(item); + return false; } } - function hasSomeImportantChild(item) { - return ts.some(item.children, function (child) { - var childKind = navigationBarNodeKind(child); - return childKind !== 238 /* VariableDeclaration */ && childKind !== 187 /* BindingElement */; - }); - } } } function convertToTree(n) { @@ -108008,18 +109629,18 @@ var ts; childItems: ts.map(n.children, convertToTree) }; } - function convertToTopLevelItem(n) { + function convertToPrimaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), kindModifiers: getModifiers(n.node), spans: getSpans(n), - childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, + childItems: ts.map(n.children, convertToSecondaryNavBarMenuItem) || emptyChildItemArray, indent: n.indent, bolded: false, grayed: false }; - function convertToChildItem(n) { + function convertToSecondaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), @@ -108050,7 +109671,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 246 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -108064,13 +109685,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 150 /* ComputedPropertyName */; + return !member.name || member.name.kind === 151 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 285 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 286 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 238 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 239 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -108078,11 +109699,11 @@ var ts; function getFunctionOrClassName(node) { var parent = node.parent; if (node.name && ts.getFullWidth(node.name) > 0) { - return ts.declarationNameToString(node.name); + return cleanText(ts.declarationNameToString(node.name)); } // See if it is a var initializer. If so, use the var name. else if (ts.isVariableDeclaration(parent)) { - return ts.declarationNameToString(parent.name); + return cleanText(ts.declarationNameToString(parent.name)); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 60 /* EqualsToken */) { @@ -108102,7 +109723,11 @@ var ts; else if (ts.isCallExpression(parent)) { var name = getCalledExpressionName(parent.expression); if (name !== undefined) { - var args = ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", "); + name = cleanText(name); + if (name.length > maxLength) { + return name + " callback"; + } + var args = cleanText(ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", ")); return name + "(" + args + ") callback"; } } @@ -108123,14 +109748,24 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: + case 199 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 211 /* ClassExpression */: return true; default: return false; } } + function cleanText(text) { + // Truncate to maximum amount of characters as we don't want to do a big replace operation. + text = text.length > maxLength ? text.substring(0, maxLength) + "..." : text; + // Replaces ECMAScript line terminators and removes the trailing `\` from each line: + // \n - Line Feed + // \r - Carriage Return + // \u2028 - Line separator + // \u2029 - Paragraph separator + return text.replace(/\\?(\r?\n|\r|\u2028|\u2029)/g, ""); + } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); /* @internal */ @@ -108590,7 +110225,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 219 /* Block */: + case 220 /* Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -108598,16 +110233,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 224 /* DoStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 275 /* CatchClause */: + case 225 /* DoStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 227 /* ForStatement */: + case 224 /* IfStatement */: + case 226 /* WhileStatement */: + case 233 /* WithStatement */: + case 276 /* CatchClause */: return spanForNode(n.parent); - case 236 /* TryStatement */: + case 237 /* TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { @@ -108622,24 +110257,24 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return spanForNode(n.parent); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 247 /* CaseBlock */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 248 /* CaseBlock */: return spanForNode(n); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 261 /* JsxElement */: + case 262 /* JsxElement */: return spanForJSXElement(n); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return spanForJSXFragment(n); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); } function spanForJSXElement(node) { @@ -108681,7 +110316,7 @@ var ts; ? ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) : ts.findChildOfKind(body, 18 /* OpenBraceToken */, sourceFile); var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 198 /* ArrowFunction */); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 199 /* ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } @@ -109525,7 +111160,7 @@ var ts; return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 150 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 151 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -109614,7 +111249,7 @@ var ts; if (node.getStart(sourceFile) > pos) { break outer; } - if (positionShouldSnapToNode(pos, node, nextNode)) { + 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 // of things that should be considered independently. @@ -109623,7 +111258,7 @@ var ts; // // Dive in without pushing a selection range. if (ts.isBlock(node) - || ts.isTemplateSpan(node) || ts.isTemplateHead(node) + || ts.isTemplateSpan(node) || ts.isTemplateHead(node) || ts.isTemplateTail(node) || prevNode && ts.isTemplateHead(prevNode) || ts.isVariableDeclarationList(node) && ts.isVariableStatement(parentNode) || ts.isSyntaxList(node) && ts.isVariableDeclarationList(parentNode) @@ -109686,12 +111321,11 @@ var ts; * count too, unless that position belongs to the next node. In effect, makes * selections able to snap to preceding tokens when the cursor is on the tail * end of them with only whitespace ahead. + * @param sourceFile The source file containing the nodes. * @param pos The position to check. * @param node The candidate node to snap to. - * @param nextNode The next sibling node in the tree. - * @param sourceFile The source file containing the nodes. */ - function positionShouldSnapToNode(pos, node, nextNode) { + function positionShouldSnapToNode(sourceFile, pos, node) { // Can’t use 'ts.positionBelongsToNode()' here because it cleverly accounts // for missing nodes, which can’t really be considered when deciding what // to select. @@ -109700,9 +111334,8 @@ var ts; return true; } var nodeEnd = node.getEnd(); - var nextNodeStart = nextNode && nextNode.getStart(); if (nodeEnd === pos) { - return pos !== nextNodeStart; + return ts.getTouchingPropertyName(sourceFile, pos).pos < node.end; } return false; } @@ -109744,7 +111377,7 @@ var ts; var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; return kind === 22 /* OpenBracketToken */ || - kind === 151 /* TypeParameter */ || + kind === 152 /* TypeParameter */ || kind === 23 /* CloseBracketToken */; }); return [ @@ -109851,7 +111484,7 @@ var ts; } function createSyntaxList(children) { ts.Debug.assertGreaterThanOrEqual(children.length, 1); - var syntaxList = ts.createNode(313 /* SyntaxList */, children[0].pos, ts.last(children).end); + var syntaxList = ts.createNode(315 /* SyntaxList */, children[0].pos, ts.last(children).end); syntaxList._children = children; return syntaxList; } @@ -109860,14 +111493,14 @@ var ts; return kind === 18 /* OpenBraceToken */ || kind === 22 /* OpenBracketToken */ || kind === 20 /* OpenParenToken */ - || kind === 263 /* JsxOpeningElement */; + || kind === 264 /* JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; return kind === 19 /* CloseBraceToken */ || kind === 23 /* CloseBracketToken */ || kind === 21 /* CloseParenToken */ - || kind === 264 /* JsxClosingElement */; + || kind === 265 /* JsxClosingElement */; } })(SmartSelectionRange = ts.SmartSelectionRange || (ts.SmartSelectionRange = {})); })(ts || (ts = {})); @@ -110072,10 +111705,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 194 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 195 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 207 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 208 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -110142,17 +111775,17 @@ var ts; return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 197 /* ParenthesizedExpression */: + case 158 /* MethodDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* 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 205 /* BinaryExpression */: { + case 206 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; @@ -110223,11 +111856,11 @@ var ts; // not enough to put us in the substitution expression; we should consider ourselves part of // the *next* span's expression by offsetting the index (argIndex = (spanIndex + 1) + 1). // - // tslint:disable no-double-space + /* eslint-disable no-double-space */ // Example: f `# abcd $#{# 1 + 1# }# efghi ${ #"#hello"# } # ` // ^ ^ ^ ^ ^ ^ ^ ^ ^ // Case: 1 1 3 2 1 3 2 2 1 - // tslint:enable no-double-space + /* eslint-enable no-double-space */ ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); if (ts.isTemplateLiteralToken(node)) { if (ts.isInsideTemplateLiteral(node, position, sourceFile)) { @@ -110276,7 +111909,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 === 207 /* TemplateExpression */) { + if (template.kind === 208 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -110341,14 +111974,14 @@ var ts; var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); var tags = symbol.getJsDocTags(); - var prefixDisplayParts = typeSymbolDisplay.concat([ts.punctuationPart(28 /* LessThanToken */)]); + var prefixDisplayParts = __spreadArrays(typeSymbolDisplay, [ts.punctuationPart(28 /* LessThanToken */)]); return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(30 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]; function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) { var _a = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile), isVariadic = _a.isVariadic, parameters = _a.parameters, prefix = _a.prefix, suffix = _a.suffix; - var prefixDisplayParts = callTargetDisplayParts.concat(prefix); - var suffixDisplayParts = suffix.concat(returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker)); + var prefixDisplayParts = __spreadArrays(callTargetDisplayParts, prefix); + var suffixDisplayParts = __spreadArrays(suffix, returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker)); var documentation = candidateSignature.getDocumentationComment(checker); var tags = candidateSignature.getJsDocTags(); return { isVariadic: isVariadic, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; @@ -110372,10 +112005,10 @@ var ts; var parameters = (typeParameters || ts.emptyArray).map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var parameterParts = ts.mapToDisplayParts(function (writer) { var thisParameter = candidateSignature.thisParameter ? [checker.symbolToParameterDeclaration(candidateSignature.thisParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags)] : []; - var params = ts.createNodeArray(thisParameter.concat(checker.getExpandedParameters(candidateSignature).map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); + var params = ts.createNodeArray(__spreadArrays(thisParameter, checker.getExpandedParameters(candidateSignature).map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(28 /* LessThanToken */)], suffix: [ts.punctuationPart(30 /* GreaterThanToken */)].concat(parameterParts) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(28 /* LessThanToken */)], suffix: __spreadArrays([ts.punctuationPart(30 /* GreaterThanToken */)], parameterParts) }; } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { var isVariadic = checker.hasEffectiveRestParameter(candidateSignature); @@ -110387,7 +112020,7 @@ var ts; } }); var parameters = checker.getExpandedParameters(candidateSignature).map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }); - return { isVariadic: isVariadic, parameters: parameters, prefix: typeParameterParts.concat([ts.punctuationPart(20 /* OpenParenToken */)]), suffix: [ts.punctuationPart(21 /* CloseParenToken */)] }; + return { isVariadic: isVariadic, parameters: parameters, prefix: __spreadArrays(typeParameterParts, [ts.punctuationPart(20 /* OpenParenToken */)]), suffix: [ts.punctuationPart(21 /* CloseParenToken */)] }; } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { @@ -110588,7 +112221,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: var decl = ts.getDeclarationOfExpando(node); if (decl) { var symbol_1 = decl.symbol; @@ -110598,7 +112231,7 @@ var ts; } } // falls through if no diagnostic was created - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: var symbol = node.symbol; if (symbol.members && (symbol.members.size > 0)) { diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); @@ -110631,11 +112264,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 222 /* ExpressionStatement */: { + case 223 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -110652,12 +112285,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 252 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 253 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -110715,11 +112348,11 @@ var ts; // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg) { switch (arg.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); - /* falls through */ + // falls through case 97 /* NullKeyword */: case 73 /* Identifier */: // identifier includes undefined return true; @@ -110744,7 +112377,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 211 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -110832,11 +112465,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 263 /* JsxOpeningElement */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: return location.kind === 73 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -110879,7 +112512,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 190 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 191 /* 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)) { @@ -110899,7 +112532,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 193 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 99 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 194 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 99 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -110954,7 +112587,7 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 125 /* ConstructorKeyword */ && location.parent.kind === 158 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 125 /* ConstructorKeyword */ && location.parent.kind === 159 /* 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 @@ -110962,21 +112595,21 @@ var ts; return declaration === (location.kind === 125 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 158 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 159 /* 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 === 158 /* Constructor */) { + if (functionDeclaration_1.kind === 159 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 161 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 162 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -110986,7 +112619,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 211 /* 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 @@ -111030,7 +112663,7 @@ var ts; } if (symbolFlags & 1536 /* Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 245 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 246 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 73 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 132 /* NamespaceKeyword */ : 131 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -111051,7 +112684,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 151 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 152 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -111059,16 +112692,16 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 162 /* ConstructSignature */) { + if (declaration.kind === 163 /* ConstructSignature */) { displayParts.push(ts.keywordPart(96 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 161 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 162 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 243 /* TypeAliasDeclaration */) { + else if (declaration.kind === 244 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path @@ -111085,7 +112718,7 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 279 /* EnumMember */) { + if (declaration.kind === 280 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -111115,17 +112748,17 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(132 /* NamespaceKeyword */)); break; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 60 /* EqualsToken */ : 81 /* DefaultKeyword */)); break; - case 258 /* ExportSpecifier */: + case 259 /* ExportSpecifier */: displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); break; default: @@ -111134,7 +112767,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 249 /* ImportEqualsDeclaration */) { + if (declaration.kind === 250 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -111212,10 +112845,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 === 285 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 286 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 205 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 206 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -111328,16 +112961,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 197 /* FunctionExpression */) { + if (declaration.kind === 198 /* FunctionExpression */) { return true; } - if (declaration.kind !== 238 /* VariableDeclaration */ && declaration.kind !== 240 /* FunctionDeclaration */) { + if (declaration.kind !== 239 /* VariableDeclaration */ && declaration.kind !== 241 /* 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 === 285 /* SourceFile */ || parent.kind === 246 /* ModuleBlock */) { + if (parent.kind === 286 /* SourceFile */ || parent.kind === 247 /* ModuleBlock */) { return false; } } @@ -111360,32 +112993,24 @@ var ts; */ function transpileModule(input, transpileOptions) { var diagnostics = []; - var options = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : ts.getDefaultCompilerOptions(); - options.isolatedModules = true; + var options = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : {}; + // mix in default options + var defaultOptions = ts.getDefaultCompilerOptions(); + for (var key in defaultOptions) { + if (ts.hasProperty(defaultOptions, key) && options[key] === undefined) { + options[key] = defaultOptions[key]; + } + } + for (var _i = 0, transpileOptionValueCompilerOptions_1 = ts.transpileOptionValueCompilerOptions; _i < transpileOptionValueCompilerOptions_1.length; _i++) { + var option = transpileOptionValueCompilerOptions_1[_i]; + options[option.name] = option.transpileOptionValue; + } // transpileModule does not write anything to disk so there is no need to verify that there are no conflicts between input and output paths. options.suppressOutputPathCheck = true; // Filename can be non-ts file. options.allowNonTsExtensions = true; - // We are not returning a sourceFile for lib file when asked by the program, - // so pass --noLib to avoid reporting a file not found error. - options.noLib = true; - // Clear out other settings that would not be used in transpiling this module - options.lib = undefined; - options.types = undefined; - options.noEmit = undefined; - options.noEmitOnError = undefined; - options.paths = undefined; - options.rootDirs = undefined; - options.declaration = undefined; - options.composite = undefined; - options.declarationDir = undefined; - options.out = undefined; - options.outFile = undefined; - // We are not doing a full typecheck, we are not resolving the whole context, - // so pass --noResolve to avoid reporting missing file errors. - options.noResolve = true; // if jsx is specified then treat file as .tsx - var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); + var inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts"); var sourceFile = ts.createSourceFile(inputFileName, input, options.target); // TODO: GH#18217 if (transpileOptions.moduleName) { sourceFile.moduleName = transpileOptions.moduleName; @@ -111642,10 +113267,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 268 /* JsxAttribute */: - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 269 /* JsxAttribute */: + case 264 /* JsxOpeningElement */: + case 265 /* JsxClosingElement */: + case 263 /* 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 === 73 /* Identifier */; } @@ -111669,17 +113294,12 @@ var ts; ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) - ? 1 /* RescanGreaterThanToken */ - : shouldRescanSlashToken(n) - ? 2 /* RescanSlashToken */ - : shouldRescanTemplateToken(n) - ? 3 /* RescanTemplateToken */ - : shouldRescanJsxIdentifier(n) - ? 4 /* RescanJsxIdentifier */ - : shouldRescanJsxText(n) - ? 5 /* RescanJsxText */ - : 0 /* Scan */; + var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : + shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : + shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : + shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : + shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : + 0 /* Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -111822,7 +113442,7 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 148 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 149 /* LastToken */; token++) { allTokens.push(token); } function anyTokenExcept() { @@ -111833,10 +113453,10 @@ var ts; return { tokens: allTokens.filter(function (t) { return !tokens.some(function (t2) { return t2 === t; }); }), isSpecific: false }; } var anyToken = { tokens: allTokens, isSpecific: false }; - var anyTokenIncludingMultilineComments = tokenRangeFrom(allTokens.concat([3 /* MultiLineCommentTrivia */])); - var keywords = tokenRangeFromRange(74 /* FirstKeyword */, 148 /* LastKeyword */); + var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArrays(allTokens, [3 /* MultiLineCommentTrivia */])); + var keywords = tokenRangeFromRange(74 /* FirstKeyword */, 149 /* LastKeyword */); var binaryOperators = tokenRangeFromRange(28 /* FirstBinaryOperator */, 72 /* LastBinaryOperator */); - var binaryKeywordOperators = [94 /* InKeyword */, 95 /* InstanceOfKeyword */, 148 /* OfKeyword */, 120 /* AsKeyword */, 129 /* IsKeyword */]; + var binaryKeywordOperators = [94 /* InKeyword */, 95 /* InstanceOfKeyword */, 149 /* OfKeyword */, 120 /* AsKeyword */, 129 /* IsKeyword */]; var unaryPrefixOperators = [44 /* PlusPlusToken */, 45 /* MinusMinusToken */, 53 /* TildeToken */, 52 /* ExclamationToken */]; var unaryPrefixExpressions = [ 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 73 /* Identifier */, 20 /* OpenParenToken */, @@ -111847,7 +113467,7 @@ var ts; var unaryPredecrementExpressions = [73 /* Identifier */, 20 /* OpenParenToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */]; var unaryPostdecrementExpressions = [73 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 96 /* NewKeyword */]; var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = [73 /* Identifier */].concat(ts.typeKeywords); + var typeNames = __spreadArrays([73 /* Identifier */], ts.typeKeywords); // Place a space before open brace in a function declaration // TypeScript: Function can have return types, which can be made of tons of different token kinds var functionOpenBraceLeftTokenRange = anyTokenIncludingMultilineComments; @@ -112085,7 +113705,7 @@ var ts; // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. rule("SpaceAfterTryFinally", [104 /* TryKeyword */, 89 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), ]; - return highPriorityCommonRules.concat(userConfigurableRules, lowPriorityCommonRules); + return __spreadArrays(highPriorityCommonRules, userConfigurableRules, lowPriorityCommonRules); } formatting.getAllRules = getAllRules; /** @@ -112139,45 +113759,50 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 226 /* ForStatement */; + return context.contextNode.kind === 227 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 176 /* ConditionalType */: - case 213 /* AsExpression */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 164 /* TypePredicate */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 206 /* BinaryExpression */: + case 207 /* ConditionalExpression */: + case 177 /* ConditionalType */: + case 214 /* AsExpression */: + case 259 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 165 /* TypePredicate */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 187 /* BindingElement */: + case 188 /* BindingElement */: // equals in type X = ... - case 243 /* TypeAliasDeclaration */: + // falls through + case 244 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 249 /* ImportEqualsDeclaration */: - // equal in let a = 0; - case 238 /* VariableDeclaration */: - // equal in p = 0; - case 152 /* Parameter */: - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + // falls through + case 250 /* ImportEqualsDeclaration */: + // equal in let a = 0 + // falls through + case 239 /* VariableDeclaration */: + // equal in p = 0 + // falls through + case 153 /* Parameter */: + case 280 /* EnumMember */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 151 /* TypeParameter */: + // falls through + case 152 /* TypeParameter */: return context.currentTokenSpan.kind === 94 /* InKeyword */ || context.nextTokenSpan.kind === 94 /* InKeyword */ || context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 228 /* ForOfStatement */: - return context.currentTokenSpan.kind === 148 /* OfKeyword */ || context.nextTokenSpan.kind === 148 /* OfKeyword */; + case 229 /* ForOfStatement */: + return context.currentTokenSpan.kind === 149 /* OfKeyword */ || context.nextTokenSpan.kind === 149 /* OfKeyword */; } return false; } @@ -112189,22 +113814,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 155 /* PropertyDeclaration */ || - contextKind === 154 /* PropertySignature */ || - contextKind === 152 /* Parameter */ || - contextKind === 238 /* VariableDeclaration */ || + return contextKind === 156 /* PropertyDeclaration */ || + contextKind === 155 /* PropertySignature */ || + contextKind === 153 /* Parameter */ || + contextKind === 239 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 206 /* ConditionalExpression */ || - context.contextNode.kind === 176 /* ConditionalType */; + return context.contextNode.kind === 207 /* ConditionalExpression */ || + context.contextNode.kind === 177 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 185 /* ObjectBindingPattern */ || - context.contextNode.kind === 182 /* MappedType */ || + return context.contextNode.kind === 186 /* ObjectBindingPattern */ || + context.contextNode.kind === 183 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -112230,31 +113855,34 @@ var ts; return true; } switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 189 /* ObjectLiteralExpression */: - case 246 /* ModuleBlock */: + case 220 /* Block */: + case 248 /* CaseBlock */: + case 190 /* ObjectLiteralExpression */: + case 247 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + // falls through + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 161 /* CallSignature */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 198 /* ArrowFunction */: + // falls through + case 162 /* CallSignature */: + case 198 /* FunctionExpression */: + case 159 /* Constructor */: + case 199 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 242 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + // falls through + case 243 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -112263,40 +113891,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 240 /* FunctionDeclaration */ || context.contextNode.kind === 197 /* FunctionExpression */; + return context.contextNode.kind === 241 /* FunctionDeclaration */ || context.contextNode.kind === 198 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 169 /* TypeLiteral */: - case 245 /* ModuleDeclaration */: - case 256 /* ExportDeclaration */: - case 257 /* NamedExports */: - case 250 /* ImportDeclaration */: - case 253 /* NamedImports */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 170 /* TypeLiteral */: + case 246 /* ModuleDeclaration */: + case 257 /* ExportDeclaration */: + case 258 /* NamedExports */: + case 251 /* ImportDeclaration */: + case 254 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 275 /* CatchClause */: - case 246 /* ModuleBlock */: - case 233 /* SwitchStatement */: + case 242 /* ClassDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 276 /* CatchClause */: + case 247 /* ModuleBlock */: + case 234 /* SwitchStatement */: return true; - case 219 /* Block */: { + case 220 /* 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 !== 198 /* ArrowFunction */ && blockParent.kind !== 197 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 199 /* ArrowFunction */ && blockParent.kind !== 198 /* FunctionExpression */) { return true; } } @@ -112305,31 +113933,32 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 232 /* WithStatement */: + case 224 /* IfStatement */: + case 234 /* SwitchStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 226 /* WhileStatement */: + case 237 /* TryStatement */: + case 225 /* DoStatement */: + case 233 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 275 /* CatchClause */: + // falls through + case 276 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 189 /* ObjectLiteralExpression */; + return context.contextNode.kind === 190 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 192 /* CallExpression */; + return context.contextNode.kind === 193 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 193 /* NewExpression */; + return context.contextNode.kind === 194 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -112341,28 +113970,28 @@ var ts; return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 198 /* ArrowFunction */; + return context.contextNode.kind === 199 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 184 /* ImportType */; + return context.contextNode.kind === 185 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 261 /* JsxElement */ && context.contextNode.kind !== 265 /* JsxFragment */; + return context.contextNode.kind !== 262 /* JsxElement */ && context.contextNode.kind !== 266 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 271 /* JsxExpression */ || context.contextNode.kind === 270 /* JsxSpreadAttribute */; + return context.contextNode.kind === 272 /* JsxExpression */ || context.contextNode.kind === 271 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 268 /* JsxAttribute */; + return context.nextTokenParent.kind === 269 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 268 /* JsxAttribute */; + return context.contextNode.kind === 269 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 262 /* JsxSelfClosingElement */; + return context.contextNode.kind === 263 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -112377,45 +114006,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 153 /* Decorator */; + return node.kind === 154 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 239 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 240 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 245 /* ModuleDeclaration */; + return context.contextNode.kind === 246 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 169 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 170 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 162 /* ConstructSignature */; + return context.contextNode.kind === 163 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { if (token.kind !== 28 /* LessThanToken */ && token.kind !== 30 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 165 /* TypeReference */: - case 195 /* TypeAssertionExpression */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: + case 166 /* TypeReference */: + case 196 /* TypeAssertionExpression */: + case 244 /* TypeAliasDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 213 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -112426,16 +114055,16 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 195 /* TypeAssertionExpression */; + return context.contextNode.kind === 196 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 107 /* VoidKeyword */ && context.currentTokenParent.kind === 201 /* VoidExpression */; + return context.currentTokenSpan.kind === 107 /* VoidKeyword */ && context.currentTokenParent.kind === 202 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 208 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 209 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 214 /* NonNullExpression */; + return context.contextNode.kind === 215 /* NonNullExpression */; } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -112486,12 +114115,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 148 /* LastKeyword */ && column <= 148 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 149 /* LastKeyword */ && column <= 149 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 148 /* LastToken */ + 1; + var mapRowLength = 149 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; @@ -112517,11 +114146,11 @@ var ts; // In order to insert a rule to the end of sub-bucket (3), we get the index by adding // the values in the bitmap segments 3rd, 2nd, and 1st. function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) { - var position = rule.action === 1 /* Ignore */ - ? specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny - : rule.context !== formatting.anyContext - ? specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny - : specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; + var position = rule.action === 1 /* Ignore */ ? + specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny : + rule.context !== formatting.anyContext ? + specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny : + specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; var state = constructionState[rulesBucketIndex] || 0; rules.splice(getInsertionIndex(state, position), 0, rule); constructionState[rulesBucketIndex] = increaseInsertionIndex(state, position); @@ -112669,17 +114298,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 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 246 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 285 /* SourceFile */: - case 219 /* Block */: - case 246 /* ModuleBlock */: + return !!body && body.kind === 247 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 286 /* SourceFile */: + case 220 /* Block */: + case 247 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -112904,19 +114533,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 241 /* ClassDeclaration */: return 77 /* ClassKeyword */; - case 242 /* InterfaceDeclaration */: return 111 /* InterfaceKeyword */; - case 240 /* FunctionDeclaration */: return 91 /* FunctionKeyword */; - case 244 /* EnumDeclaration */: return 244 /* EnumDeclaration */; - case 159 /* GetAccessor */: return 127 /* GetKeyword */; - case 160 /* SetAccessor */: return 138 /* SetKeyword */; - case 157 /* MethodDeclaration */: + case 242 /* ClassDeclaration */: return 77 /* ClassKeyword */; + case 243 /* InterfaceDeclaration */: return 111 /* InterfaceKeyword */; + case 241 /* FunctionDeclaration */: return 91 /* FunctionKeyword */; + case 245 /* EnumDeclaration */: return 245 /* EnumDeclaration */; + case 160 /* GetAccessor */: return 127 /* GetKeyword */; + case 161 /* SetAccessor */: return 138 /* SetKeyword */; + case 158 /* MethodDeclaration */: if (node.asteriskToken) { return 40 /* AsteriskToken */; } // falls through - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 153 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -112973,15 +114602,15 @@ var ts; case 42 /* SlashToken */: case 30 /* GreaterThanToken */: switch (container.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 265 /* JsxClosingElement */: + case 263 /* JsxSelfClosingElement */: return false; } break; case 22 /* OpenBracketToken */: case 23 /* CloseBracketToken */: - if (container.kind !== 182 /* MappedType */) { + if (container.kind !== 183 /* MappedType */) { return false; } break; @@ -113073,7 +114702,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 153 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 154 /* 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 */) { @@ -113081,7 +114710,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 188 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 189 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -113464,8 +115093,7 @@ var ts; /** * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. */ - function getRangeOfEnclosingComment(sourceFile, position, precedingToken, // tslint:disable-line:no-null-keyword - tokenAtPosition) { + function getRangeOfEnclosingComment(sourceFile, position, precedingToken, tokenAtPosition) { if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position); } var jsdoc = ts.findAncestor(tokenAtPosition, ts.isJSDoc); if (jsdoc) @@ -113474,6 +115102,7 @@ var ts; if (tokenStart <= position && position < tokenAtPosition.getEnd()) { return undefined; } + // eslint-disable-next-line no-null/no-null precedingToken = precedingToken === null ? undefined : precedingToken === undefined ? ts.findPrecedingToken(position, sourceFile) : precedingToken; // Between two consecutive tokens, all comments are either trailing on the former // or leading on the latter (and none are in both lists). @@ -113499,12 +115128,12 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 198 /* ArrowFunction */: + case 159 /* Constructor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 199 /* ArrowFunction */: if (node.typeParameters === list) { return 28 /* LessThanToken */; } @@ -113512,8 +115141,8 @@ var ts; return 20 /* OpenParenToken */; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: if (node.typeArguments === list) { return 28 /* LessThanToken */; } @@ -113521,12 +115150,12 @@ var ts; return 20 /* OpenParenToken */; } break; - case 165 /* TypeReference */: + case 166 /* TypeReference */: if (node.typeArguments === list) { return 28 /* LessThanToken */; } break; - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return 18 /* OpenBraceToken */; } return 0 /* Unknown */; @@ -113624,7 +115253,8 @@ var ts; return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); - var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); // tslint:disable-line:no-null-keyword + // eslint-disable-next-line no-null/no-null + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } @@ -113643,7 +115273,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 205 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 206 /* 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 */) { @@ -113797,7 +115427,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 === 285 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 286 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -113845,7 +115475,7 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 223 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 224 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 84 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -113880,40 +115510,40 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return getList(node.typeArguments); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return getList(node.properties); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return getList(node.elements); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return getList(node.members); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 159 /* Constructor */: + case 168 /* ConstructorType */: + case 163 /* ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 312 /* JSDocTemplateTag */: return getList(node.typeParameters); - case 193 /* NewExpression */: - case 192 /* CallExpression */: + case 194 /* NewExpression */: + case 193 /* CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return getList(node.declarations); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 254 /* NamedImports */: + case 258 /* NamedExports */: return getList(node.elements); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -113936,7 +115566,7 @@ var ts; return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 239 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 240 /* VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens return -1 /* Unknown */; } @@ -114009,83 +115639,87 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 222 /* ExpressionStatement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 188 /* ArrayLiteralExpression */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 182 /* MappedType */: - case 171 /* TupleType */: - case 247 /* CaseBlock */: - case 273 /* DefaultClause */: - case 272 /* CaseClause */: - case 196 /* ParenthesizedExpression */: - case 190 /* PropertyAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 220 /* VariableStatement */: - case 255 /* ExportAssignment */: - case 231 /* ReturnStatement */: - case 206 /* ConditionalExpression */: - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: - case 262 /* JsxSelfClosingElement */: - case 271 /* JsxExpression */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 152 /* Parameter */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 178 /* ParenthesizedType */: - case 194 /* TaggedTemplateExpression */: - case 202 /* AwaitExpression */: - case 257 /* NamedExports */: - case 253 /* NamedImports */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 155 /* PropertyDeclaration */: + case 223 /* ExpressionStatement */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 189 /* ArrayLiteralExpression */: + case 220 /* Block */: + case 247 /* ModuleBlock */: + case 190 /* ObjectLiteralExpression */: + case 170 /* TypeLiteral */: + case 183 /* MappedType */: + case 172 /* TupleType */: + case 248 /* CaseBlock */: + case 274 /* DefaultClause */: + case 273 /* CaseClause */: + case 197 /* ParenthesizedExpression */: + case 191 /* PropertyAccessExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 221 /* VariableStatement */: + case 256 /* ExportAssignment */: + case 232 /* ReturnStatement */: + case 207 /* ConditionalExpression */: + case 187 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 264 /* JsxOpeningElement */: + case 267 /* JsxOpeningFragment */: + case 263 /* JsxSelfClosingElement */: + case 272 /* JsxExpression */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 153 /* Parameter */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 179 /* ParenthesizedType */: + case 195 /* TaggedTemplateExpression */: + case 203 /* AwaitExpression */: + case 258 /* NamedExports */: + case 254 /* NamedImports */: + case 259 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 156 /* PropertyDeclaration */: return true; - case 238 /* VariableDeclaration */: - case 276 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 189 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 239 /* VariableDeclaration */: + case 277 /* PropertyAssignment */: + case 206 /* BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 190 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - return true; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return childKind !== 219 /* Block */; - case 256 /* ExportDeclaration */: - return childKind !== 257 /* NamedExports */; - case 250 /* ImportDeclaration */: - return childKind !== 251 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 253 /* NamedImports */); - case 261 /* JsxElement */: - return childKind !== 264 /* JsxClosingElement */; - case 265 /* JsxFragment */: - return childKind !== 267 /* JsxClosingFragment */; - case 175 /* IntersectionType */: - case 174 /* UnionType */: - if (childKind === 169 /* TypeLiteral */) { + if (parent.kind !== 206 /* BinaryExpression */) { + return true; + } + break; + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 227 /* ForStatement */: + case 224 /* IfStatement */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 199 /* ArrowFunction */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + return childKind !== 220 /* Block */; + case 257 /* ExportDeclaration */: + return childKind !== 258 /* NamedExports */; + case 251 /* ImportDeclaration */: + return childKind !== 252 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 254 /* NamedImports */); + case 262 /* JsxElement */: + return childKind !== 265 /* JsxClosingElement */; + case 266 /* JsxFragment */: + return childKind !== 268 /* JsxClosingFragment */; + case 176 /* IntersectionType */: + case 175 /* UnionType */: + if (childKind === 170 /* TypeLiteral */) { return false; } // falls through @@ -114096,11 +115730,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: - return parent.kind !== 219 /* Block */; + case 232 /* ReturnStatement */: + case 236 /* ThrowStatement */: + case 230 /* ContinueStatement */: + case 231 /* BreakStatement */: + return parent.kind !== 220 /* Block */; default: return false; } @@ -114242,7 +115876,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 === 189 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 190 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -114407,7 +116041,7 @@ var ts; } } else { - endNode = node.kind !== 238 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 239 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; @@ -114439,7 +116073,7 @@ var ts; ChangeTracker.prototype.insertNodeAtConstructorStart = function (sourceFile, ctr, newStatement) { var firstStatement = ts.firstOrUndefined(ctr.body.statements); if (!firstStatement || !ctr.body.multiLine) { - this.replaceConstructorBody(sourceFile, ctr, [newStatement].concat(ctr.body.statements)); + this.replaceConstructorBody(sourceFile, ctr, __spreadArrays([newStatement], ctr.body.statements)); } else { this.insertNodeBefore(sourceFile, firstStatement, newStatement); @@ -114448,7 +116082,7 @@ var ts; ChangeTracker.prototype.insertNodeAtConstructorEnd = function (sourceFile, ctr, newStatement) { var lastStatement = ts.lastOrUndefined(ctr.body.statements); if (!lastStatement || !ctr.body.multiLine) { - this.replaceConstructorBody(sourceFile, ctr, ctr.body.statements.concat([newStatement])); + this.replaceConstructorBody(sourceFile, ctr, __spreadArrays(ctr.body.statements, [newStatement])); } else { this.insertNodeAfter(sourceFile, lastStatement, newStatement); @@ -114481,7 +116115,7 @@ var ts; if (getMembersOrProperties(cls).length === 0) { if (ts.addToSeen(this.classesWithNodesInsertedAtStart, ts.getNodeId(cls), { node: cls, sourceFile: sourceFile })) { // For `class C {\n}`, don't add the trailing "\n" - var shouldSuffix = ts.positionsAreOnSameLine.apply(void 0, getClassOrObjectBraceEnds(cls, sourceFile).concat([sourceFile])); // TODO: GH#4130 remove 'as any' + var shouldSuffix = ts.positionsAreOnSameLine.apply(void 0, __spreadArrays(getClassOrObjectBraceEnds(cls, sourceFile), [sourceFile])); // TODO: GH#4130 remove 'as any' return { prefix: this.newLineCharacter, suffix: comma + (shouldSuffix ? this.newLineCharacter : "") }; } else { @@ -114520,22 +116154,22 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptions = function (sourceFile, after) { var options = this.getInsertNodeAfterOptionsWorker(after); - return __assign({}, options, { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); + return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 246 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: case 10 /* StringLiteral */: case 73 /* Identifier */: return { prefix: ", " }; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; case 86 /* ExportKeyword */: return { prefix: " " }; - case 152 /* Parameter */: + case 153 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -114544,7 +116178,7 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 198 /* ArrowFunction */) { + if (node.kind === 199 /* ArrowFunction */) { var arrow = ts.findChildOfKind(node, 37 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { @@ -114558,14 +116192,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 219 /* Block */) { + if (node.body.kind !== 220 /* Block */) { // `() => 0` => `function f() { return 0; }` this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(98 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(26 /* SemicolonToken */), ts.createToken(19 /* CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 197 /* FunctionExpression */ ? 91 /* FunctionKeyword */ : 77 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 198 /* FunctionExpression */ ? 91 /* FunctionKeyword */ : 77 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -114838,7 +116472,7 @@ var ts; var omitTrailingSemicolon = !!sourceFile && !ts.probablyUsesSemicolons(sourceFile); var writer = createWriter(newLineCharacter, omitTrailingSemicolon); var newLine = newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; - ts.createPrinter({ newLine: newLine, neverAsciiEscape: true, omitTrailingSemicolon: omitTrailingSemicolon }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + ts.createPrinter({ newLine: newLine, neverAsciiEscape: true }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -115090,14 +116724,14 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 150 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 151 /* 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 152 /* Parameter */: { + case 153 /* Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && @@ -115112,14 +116746,14 @@ var ts; } break; } - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: deleteNode(changes, sourceFile, node, // For first import, leave header comment in place node === sourceFile.imports[0].parent ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined); break; - case 187 /* BindingElement */: + case 188 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 186 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 187 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -115127,13 +116761,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -115142,7 +116776,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; default: @@ -115189,13 +116823,13 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 250 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 251 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 275 /* CatchClause */) { + if (parent.kind === 276 /* 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; @@ -115206,14 +116840,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 228 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); break; - case 226 /* ForStatement */: + case 227 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: deleteNode(changes, sourceFile, gp); break; default: @@ -115374,7 +117008,7 @@ var ts; }); function makeChange(changeTracker, sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); })); + var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); }), "Expected to find an assertion expression"); var replacement = ts.isAsExpression(assertion) ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(144 /* UnknownKeyword */)) : ts.createTypeAssertion(ts.createKeywordTypeNode(144 /* UnknownKeyword */), assertion.expression); @@ -115393,7 +117027,7 @@ var ts; ts.Diagnostics.This_expression_is_not_callable.code, ts.Diagnostics.This_expression_is_not_constructable.code, ]; - var errorCodes = [ + var errorCodes = __spreadArrays([ ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type.code, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type.code, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type.code, @@ -115409,13 +117043,13 @@ var ts; ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator.code, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code, propertyAccessCode - ].concat(callableConstructableErrorCodes); + ], callableConstructableErrorCodes); codefix.registerCodeFix({ fixIds: [fixId], errorCodes: errorCodes, getCodeActions: function (context) { var sourceFile = context.sourceFile, errorCode = context.errorCode, span = context.span, cancellationToken = context.cancellationToken, program = context.program; - var expression = getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program); if (!expression) { return; } @@ -115429,27 +117063,38 @@ var ts; getAllCodeActions: function (context) { var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; var checker = context.program.getTypeChecker(); + var fixedDeclarations = ts.createMap(); return codefix.codeFixAll(context, errorCodes, function (t, diagnostic) { - var expression = getAwaitableExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); if (!expression) { return; } var trackChanges = function (cb) { return (cb(t), []); }; - return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges) - || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges); + return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations) + || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations); }); }, }); - function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges) { - var sourceFile = context.sourceFile; - var awaitableInitializer = findAwaitableInitializer(expression, sourceFile, checker); - if (awaitableInitializer) { - var initializerChanges = trackChanges(function (t) { return makeChange(t, errorCode, sourceFile, checker, awaitableInitializer); }); - return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, [ts.Diagnostics.Add_await_to_initializer_for_0, expression.getText(sourceFile)]); + function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; + var awaitableInitializers = findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker); + if (awaitableInitializers) { + var initializerChanges = trackChanges(function (t) { + ts.forEach(awaitableInitializers.initializers, function (_a) { + var expression = _a.expression; + return makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + }); + if (fixedDeclarations && awaitableInitializers.needsSecondPassForFixAll) { + makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + } + }); + return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, awaitableInitializers.initializers.length === 1 + ? [ts.Diagnostics.Add_await_to_initializer_for_0, awaitableInitializers.initializers[0].declarationSymbol.name] + : ts.Diagnostics.Add_await_to_initializers); } } - function getUseSiteFix(context, expression, errorCode, checker, trackChanges) { - var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression); }); + function getUseSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression, fixedDeclarations); }); return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_await, fixId, ts.Diagnostics.Fix_all_expressions_possibly_missing_await); } function isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) { @@ -115463,7 +117108,7 @@ var ts; ts.some(relatedInformation, function (related) { return related.code === ts.Diagnostics.Did_you_forget_to_use_await.code; }); }); } - function getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program) { + function getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program) { var token = ts.getTokenAtPosition(sourceFile, span.start); // Checker has already done work to determine that await might be possible, and has attached // related info to the node, so start by finding the expression that exactly matches up @@ -115476,64 +117121,146 @@ var ts; }); return expression && isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) - && isInsideAwaitableBody(expression) - ? expression - : undefined; + && isInsideAwaitableBody(expression) ? expression : undefined; } - function findAwaitableInitializer(expression, sourceFile, checker) { - if (!ts.isIdentifier(expression)) { + function findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker) { + var identifiers = getIdentifiersFromErrorSpanExpression(expression, checker); + if (!identifiers) { return; } - var symbol = checker.getSymbolAtLocation(expression); - if (!symbol) { - return; + var isCompleteFix = identifiers.isCompleteFix; + var initializers; + var _loop_11 = 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, 221 /* VariableStatement */); + if (!declaration || !variableStatement || + declaration.type || + !declaration.initializer || + variableStatement.getSourceFile() !== sourceFile || + ts.hasModifier(variableStatement, 1 /* Export */) || + !variableName || + !isInsideAwaitableBody(declaration.initializer)) { + isCompleteFix = false; + return "continue"; + } + var diagnostics = program.getSemanticDiagnostics(sourceFile, cancellationToken); + var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (reference) { + return identifier !== reference && !symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker); + }); + if (isUsedElsewhere) { + isCompleteFix = false; + return "continue"; + } + (initializers || (initializers = [])).push({ + expression: declaration.initializer, + declarationSymbol: symbol, + }); + }; + for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { + var identifier = _a[_i]; + _loop_11(identifier); } - var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); - var variableName = ts.tryCast(declaration && declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 220 /* VariableStatement */); - if (!declaration || !variableStatement || - declaration.type || - !declaration.initializer || - variableStatement.getSourceFile() !== sourceFile || - ts.hasModifier(variableStatement, 1 /* Export */) || - !variableName || - !isInsideAwaitableBody(declaration.initializer)) { - return; + return initializers && { + initializers: initializers, + needsSecondPassForFixAll: !isCompleteFix, + }; + } + function getIdentifiersFromErrorSpanExpression(expression, checker) { + if (ts.isPropertyAccessExpression(expression.parent) && ts.isIdentifier(expression.parent.expression)) { + return { identifiers: [expression.parent.expression], isCompleteFix: true }; } - var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (identifier) { - return identifier !== expression; - }); - if (isUsedElsewhere) { - return; + if (ts.isIdentifier(expression)) { + return { identifiers: [expression], isCompleteFix: true }; + } + if (ts.isBinaryExpression(expression)) { + var sides = void 0; + var isCompleteFix = true; + for (var _i = 0, _a = [expression.left, expression.right]; _i < _a.length; _i++) { + var side = _a[_i]; + var type = checker.getTypeAtLocation(side); + if (checker.getPromisedTypeOfPromise(type)) { + if (!ts.isIdentifier(side)) { + isCompleteFix = false; + continue; + } + (sides || (sides = [])).push(side); + } + } + return sides && { identifiers: sides, isCompleteFix: isCompleteFix }; } - return declaration.initializer; + } + function symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker) { + var errorNode = ts.isPropertyAccessExpression(reference.parent) ? reference.parent.name : + ts.isBinaryExpression(reference.parent) ? reference.parent : + reference; + var diagnostic = ts.find(diagnostics, function (diagnostic) { + return diagnostic.start === errorNode.getStart(sourceFile) && + diagnostic.start + diagnostic.length === errorNode.getEnd(); + }); + return diagnostic && ts.contains(errorCodes, diagnostic.code) || + // A Promise is usually not correct in a binary expression (it’s not valid + // in an arithmetic expression and an equality comparison seems unusual), + // but if the other side of the binary expression has an error, the side + // is typed `any` which will squash the error that would identify this + // Promise as an invalid operand. So if the whole binary expression is + // typed `any` as a result, there is a strong likelihood that this Promise + // is accidentally missing `await`. + checker.getTypeAtLocation(errorNode).flags & 1 /* Any */; } function isInsideAwaitableBody(node) { return node.kind & 16384 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 240 /* FunctionDeclaration */ || - ancestor.parent.kind === 197 /* FunctionExpression */ || - ancestor.parent.kind === 198 /* ArrowFunction */ || - ancestor.parent.kind === 157 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 241 /* FunctionDeclaration */ || + ancestor.parent.kind === 198 /* FunctionExpression */ || + ancestor.parent.kind === 199 /* ArrowFunction */ || + ancestor.parent.kind === 158 /* MethodDeclaration */); }); } - function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite) { + function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { if (ts.isBinaryExpression(insertionSite)) { - var left = insertionSite.left, right = insertionSite.right; - var leftType = checker.getTypeAtLocation(left); - var rightType = checker.getTypeAtLocation(right); - var newLeft = checker.getPromisedTypeOfPromise(leftType) ? ts.createAwait(left) : left; - var newRight = checker.getPromisedTypeOfPromise(rightType) ? ts.createAwait(right) : right; - changeTracker.replaceNode(sourceFile, left, newLeft); - changeTracker.replaceNode(sourceFile, right, newRight); + for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) { + var side = _a[_i]; + if (fixedDeclarations && ts.isIdentifier(side)) { + var symbol = checker.getSymbolAtLocation(side); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + continue; + } + } + var type = checker.getTypeAtLocation(side); + var newNode = checker.getPromisedTypeOfPromise(type) ? ts.createAwait(side) : side; + changeTracker.replaceNode(sourceFile, side, newNode); + } } else if (errorCode === propertyAccessCode && ts.isPropertyAccessExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite.parent.expression)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.expression); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite.parent.expression, ts.createParen(ts.createAwait(insertionSite.parent.expression))); } else if (ts.contains(callableConstructableErrorCodes, errorCode) && ts.isCallOrNewExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite)) { + var symbol = checker.getSymbolAtLocation(insertionSite); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createParen(ts.createAwait(insertionSite))); } else { + if (fixedDeclarations && ts.isVariableDeclaration(insertionSite.parent) && ts.isIdentifier(insertionSite.parent.name)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.name); + if (symbol && !ts.addToSeen(fixedDeclarations, ts.getSymbolId(symbol))) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createAwait(insertionSite)); } } @@ -115602,10 +117329,10 @@ var ts; function isPossiblyPartOfDestructuring(node) { switch (node.kind) { case 73 /* Identifier */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return true; default: return false; @@ -115620,7 +117347,7 @@ var ts; function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { case 73 /* Identifier */: - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: case 27 /* CommaToken */: return true; default: @@ -115761,33 +117488,33 @@ var ts; } } else { - var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl)); // If not defined, shouldn't have been an error to fix - ts.Debug.assert(!decl.type); // If defined, shouldn't have been an error to fix. + var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl), "A JSDocType for this declaration should exist"); // If not defined, shouldn't have been an error to fix + ts.Debug.assert(!decl.type, "The JSDocType decl should have a type"); // If defined, shouldn't have been an error to fix. changes.tryInsertTypeAnnotation(sourceFile, decl, transformJSDocType(jsdocType)); } } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 238 /* VariableDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 239 /* VariableDeclaration */ || + node.kind === 155 /* PropertySignature */ || + node.kind === 156 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 291 /* JSDocAllType */: + case 292 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 294 /* JSDocOptionalType */: + case 295 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 293 /* JSDocNonNullableType */: + case 294 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 292 /* JSDocNullableType */: + case 293 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 296 /* JSDocVariadicType */: + case 297 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); // TODO: GH#18217 @@ -115809,7 +117536,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 296 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 297 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); var dotdotdot = isRest ? ts.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -116041,13 +117768,8 @@ var ts; if (!ts.isIdentifier(parameterDeclaration.name)) { return; } - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - var parameterInferences = InferFromReference.inferTypeForParametersFromReferences(references, containingFunction, program, cancellationToken) || - containingFunction.parameters.map(function (p) { return ({ - declaration: p, - type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() - }); }); - ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length); + var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken); + ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length, "Parameter count and inference count should match"); if (ts.isInJSFile(containingFunction)) { annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } @@ -116066,14 +117788,11 @@ var ts; } } function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - if (!references) { - return; - } - var thisInference = InferFromReference.inferTypeForThisFromReferences(references, program, cancellationToken); - if (!thisInference) { + var references = getFunctionReferences(containingFunction, sourceFile, program, cancellationToken); + if (!references || !references.length) { return; } + var thisInference = inferTypeFromReferences(program, references, cancellationToken).thisParameter(); var typeNode = ts.getTypeNodeIfAccessible(thisInference, containingFunction, program, host); if (!typeNode) { return; @@ -116108,7 +117827,7 @@ var ts; function annotate(changes, sourceFile, declaration, type, program, host) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 154 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 155 /* PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -116148,14 +117867,14 @@ var ts; oldTags[i] = merged; return !!merged; }); }); - var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray((oldTags || ts.emptyArray).concat(unmergedNewTags))); - var jsDocNode = parent.kind === 198 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; + var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray(__spreadArrays((oldTags || ts.emptyArray), unmergedNewTags))); + var jsDocNode = parent.kind === 199 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; jsDocNode.jsDoc = parent.jsDoc; jsDocNode.jsDocCache = parent.jsDocCache; changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag); } function getJsDocNodeForArrowFunction(signature) { - if (signature.parent.kind === 155 /* PropertyDeclaration */) { + if (signature.parent.kind === 156 /* PropertyDeclaration */) { return signature.parent; } return signature.parent.parent; @@ -116165,14 +117884,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 306 /* JSDocParameterTag */: { + case 308 /* JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.createJSDocParamTag(newParam.name, newParam.isBracketed, newParam.typeExpression, oldParam.comment) : undefined; } - case 307 /* JSDocReturnTag */: + case 309 /* JSDocReturnTag */: return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); } } @@ -116184,25 +117903,31 @@ var ts; } function inferTypeForVariableFromUsage(token, program, cancellationToken) { var references = getReferences(token, program, cancellationToken); - var checker = program.getTypeChecker(); - var types = InferFromReference.inferTypesFromReferences(references, checker, cancellationToken); - return InferFromReference.unifyFromContext(types, checker); + return inferTypeFromReferences(program, references, cancellationToken).single(); + } + function inferTypeForParametersFromUsage(func, sourceFile, program, cancellationToken) { + var references = getFunctionReferences(func, sourceFile, program, cancellationToken); + return references && inferTypeFromReferences(program, references, cancellationToken).parameters(func) || + func.parameters.map(function (p) { return ({ + declaration: p, + type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() + }); }); } - function inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken) { + function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: searchToken = ts.findChildOfKind(containingFunction, 125 /* ConstructorKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 198 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: searchToken = containingFunction.name; break; } @@ -116211,54 +117936,51 @@ var ts; } return getReferences(searchToken, program, cancellationToken); } - var InferFromReference; - (function (InferFromReference) { - function inferTypesFromReferences(references, checker, cancellationToken) { - var usageContext = {}; - for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { - var reference = references_2[_i]; - cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); - } - return inferFromContext(usageContext, checker); + function inferTypeFromReferences(program, references, cancellationToken) { + var checker = program.getTypeChecker(); + return { + single: single, + parameters: parameters, + thisParameter: thisParameter, + }; + function single() { + return unifyFromUsage(inferTypesFromReferencesSingle(references)); } - InferFromReference.inferTypesFromReferences = inferTypesFromReferences; - function inferTypeForParametersFromReferences(references, declaration, program, cancellationToken) { - if (references === undefined || references.length === 0 || !declaration.parameters) { + function parameters(declaration) { + if (references.length === 0 || !declaration.parameters) { return undefined; } - var checker = program.getTypeChecker(); - var usageContext = {}; - for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { - var reference = references_3[_i]; + var usage = {}; + for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { + var reference = references_2[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - var callContexts = (usageContext.constructContexts || []).concat(usageContext.callContexts || []); + var calls = __spreadArrays(usage.constructs || [], usage.calls || []); return declaration.parameters.map(function (parameter, parameterIndex) { var types = []; var isRest = ts.isRestParameter(parameter); var isOptional = false; - for (var _i = 0, callContexts_1 = callContexts; _i < callContexts_1.length; _i++) { - var callContext = callContexts_1[_i]; - if (callContext.argumentTypes.length <= parameterIndex) { + for (var _i = 0, calls_1 = calls; _i < calls_1.length; _i++) { + var call = calls_1[_i]; + if (call.argumentTypes.length <= parameterIndex) { isOptional = ts.isInJSFile(declaration); types.push(checker.getUndefinedType()); } else if (isRest) { - for (var i = parameterIndex; i < callContext.argumentTypes.length; i++) { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + for (var i = parameterIndex; i < call.argumentTypes.length; i++) { + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[i])); } } else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex])); } } if (ts.isIdentifier(parameter.name)) { - var inferred = inferTypesFromReferences(getReferences(parameter.name, program, cancellationToken), checker, cancellationToken); + var inferred = inferTypesFromReferencesSingle(getReferences(parameter.name, program, cancellationToken)); types.push.apply(types, (isRest ? ts.mapDefined(inferred, checker.getElementTypeOfArrayType) : inferred)); } - var type = unifyFromContext(types, checker); + var type = unifyFromUsage(types); return { type: isRest ? checker.createArrayType(type) : type, isOptional: isOptional && !isRest, @@ -116266,112 +117988,119 @@ var ts; }; }); } - InferFromReference.inferTypeForParametersFromReferences = inferTypeForParametersFromReferences; - function inferTypeForThisFromReferences(references, program, cancellationToken) { - if (references.length === 0) { - return undefined; + function thisParameter() { + var usage = {}; + for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { + var reference = references_3[_i]; + cancellationToken.throwIfCancellationRequested(); + calculateUsageOfNode(reference, usage); } - var checker = program.getTypeChecker(); - var usageContext = {}; + return unifyFromUsage(usage.candidateThisTypes || ts.emptyArray); + } + function inferTypesFromReferencesSingle(references) { + var usage = {}; for (var _i = 0, references_4 = references; _i < references_4.length; _i++) { var reference = references_4[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - return unifyFromContext(usageContext.candidateThisTypes || ts.emptyArray, checker); + return inferFromUsage(usage); } - InferFromReference.inferTypeForThisFromReferences = inferTypeForThisFromReferences; - function inferTypeFromContext(node, checker, usageContext) { + function calculateUsageOfNode(node, usage) { while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } switch (node.parent.kind) { - case 204 /* PostfixUnaryExpression */: - usageContext.isNumber = true; + case 205 /* PostfixUnaryExpression */: + usage.isNumber = true; break; - case 203 /* PrefixUnaryExpression */: - inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); + case 204 /* PrefixUnaryExpression */: + inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 205 /* BinaryExpression */: - inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); + case 206 /* BinaryExpression */: + inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); + case 273 /* CaseClause */: + case 274 /* DefaultClause */: + inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: if (node.parent.expression === node) { - inferTypeFromCallExpressionContext(node.parent, checker, usageContext); + inferTypeFromCallExpression(node.parent, usage); } else { - inferTypeFromContextualType(node, checker, usageContext); + inferTypeFromContextualType(node, usage); } break; - case 190 /* PropertyAccessExpression */: - inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); + case 191 /* PropertyAccessExpression */: + inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 191 /* ElementAccessExpression */: - inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); + case 192 /* ElementAccessExpression */: + inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - inferTypeFromPropertyAssignment(node.parent, checker, usageContext); + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: + inferTypeFromPropertyAssignment(node.parent, usage); break; - case 155 /* PropertyDeclaration */: - inferTypeFromPropertyDeclaration(node.parent, checker, usageContext); + case 156 /* PropertyDeclaration */: + inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 238 /* VariableDeclaration */: { + case 239 /* 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. - addCandidateType(usageContext, checker.getTypeAtLocation(initializer)); + addCandidateType(usage, checker.getTypeAtLocation(initializer)); } break; } } // falls through default: - return inferTypeFromContextualType(node, checker, usageContext); + return inferTypeFromContextualType(node, usage); } } - function inferTypeFromContextualType(node, checker, usageContext) { + function inferTypeFromContextualType(node, usage) { if (ts.isExpressionNode(node)) { - addCandidateType(usageContext, checker.getContextualType(node)); + addCandidateType(usage, checker.getContextualType(node)); } } - function inferTypeFromPrefixUnaryExpressionContext(node, usageContext) { + function inferTypeFromPrefixUnaryExpression(node, usage) { switch (node.operator) { case 44 /* PlusPlusToken */: case 45 /* MinusMinusToken */: case 39 /* MinusToken */: case 53 /* TildeToken */: - usageContext.isNumber = true; + usage.isNumber = true; break; case 38 /* PlusToken */: - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; break; // case SyntaxKind.ExclamationToken: // no inferences here; } } - function inferTypeFromBinaryExpressionContext(node, parent, checker, usageContext) { + function inferTypeFromBinaryExpression(node, parent, usage) { switch (parent.operatorToken.kind) { // ExponentiationOperator case 41 /* AsteriskAsteriskToken */: // MultiplicativeOperator + // falls through case 40 /* AsteriskToken */: case 42 /* SlashToken */: case 43 /* PercentToken */: // ShiftOperator + // falls through case 46 /* LessThanLessThanToken */: case 47 /* GreaterThanGreaterThanToken */: case 48 /* GreaterThanGreaterThanGreaterThanToken */: // BitwiseOperator + // falls through case 49 /* AmpersandToken */: case 50 /* BarToken */: case 51 /* CaretToken */: // CompoundAssignmentOperator + // falls through case 62 /* MinusEqualsToken */: case 64 /* AsteriskAsteriskEqualsToken */: case 63 /* AsteriskEqualsToken */: @@ -116384,34 +118113,36 @@ var ts; case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: case 68 /* GreaterThanGreaterThanEqualsToken */: // AdditiveOperator + // falls through case 39 /* MinusToken */: // RelationalOperator + // falls through case 28 /* LessThanToken */: case 31 /* LessThanEqualsToken */: case 30 /* GreaterThanToken */: case 32 /* GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (operandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, operandType); + addCandidateType(usage, operandType); } else { - usageContext.isNumber = true; + usage.isNumber = true; } break; case 61 /* PlusEqualsToken */: case 38 /* PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (otherOperandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, otherOperandType); + addCandidateType(usage, otherOperandType); } else if (otherOperandType.flags & 296 /* NumberLike */) { - usageContext.isNumber = true; + usage.isNumber = true; } else if (otherOperandType.flags & 132 /* StringLike */) { - usageContext.isString = true; + usage.isString = true; } else { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; } break; // AssignmentOperators @@ -116420,20 +118151,20 @@ var ts; case 35 /* EqualsEqualsEqualsToken */: case 36 /* ExclamationEqualsEqualsToken */: case 34 /* ExclamationEqualsToken */: - addCandidateType(usageContext, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); + addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; case 94 /* InKeyword */: if (node === parent.left) { - usageContext.isString = true; + usage.isString = true; } break; // LogicalOperator case 55 /* BarBarToken */: if (node === parent.left && - (node.parent.parent.kind === 238 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 239 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType - addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); + addCandidateType(usage, checker.getTypeAtLocation(parent.right)); } break; case 54 /* AmpersandAmpersandToken */: @@ -116443,65 +118174,62 @@ var ts; break; } } - function inferTypeFromSwitchStatementLabelContext(parent, checker, usageContext) { - addCandidateType(usageContext, checker.getTypeAtLocation(parent.parent.parent.expression)); + function inferTypeFromSwitchStatementLabel(parent, usage) { + addCandidateType(usage, checker.getTypeAtLocation(parent.parent.parent.expression)); } - function inferTypeFromCallExpressionContext(parent, checker, usageContext) { - var callContext = { + function inferTypeFromCallExpression(parent, usage) { + var call = { argumentTypes: [], returnType: {} }; if (parent.arguments) { for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { var argument = _a[_i]; - callContext.argumentTypes.push(checker.getTypeAtLocation(argument)); + call.argumentTypes.push(checker.getTypeAtLocation(argument)); } } - inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 192 /* CallExpression */) { - (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); + calculateUsageOfNode(parent, call.returnType); + if (parent.kind === 193 /* CallExpression */) { + (usage.calls || (usage.calls = [])).push(call); } else { - (usageContext.constructContexts || (usageContext.constructContexts = [])).push(callContext); + (usage.constructs || (usage.constructs = [])).push(call); } } - function inferTypeFromPropertyAccessExpressionContext(parent, checker, usageContext) { + function inferTypeFromPropertyAccessExpression(parent, usage) { var name = ts.escapeLeadingUnderscores(parent.name.text); - if (!usageContext.properties) { - usageContext.properties = ts.createUnderscoreEscapedMap(); + if (!usage.properties) { + usage.properties = ts.createUnderscoreEscapedMap(); } - var propertyUsageContext = usageContext.properties.get(name) || {}; - inferTypeFromContext(parent, checker, propertyUsageContext); - usageContext.properties.set(name, propertyUsageContext); + var propertyUsage = usage.properties.get(name) || {}; + calculateUsageOfNode(parent, propertyUsage); + usage.properties.set(name, propertyUsage); } - function inferTypeFromPropertyElementExpressionContext(parent, node, checker, usageContext) { + function inferTypeFromPropertyElementExpression(parent, node, usage) { if (node === parent.argumentExpression) { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; return; } else { var indexType = checker.getTypeAtLocation(parent.argumentExpression); - var indexUsageContext = {}; - inferTypeFromContext(parent, checker, indexUsageContext); + var indexUsage = {}; + calculateUsageOfNode(parent, indexUsage); if (indexType.flags & 296 /* NumberLike */) { - usageContext.numberIndexContext = indexUsageContext; + usage.numberIndex = indexUsage; } else { - usageContext.stringIndexContext = indexUsageContext; + usage.stringIndex = indexUsage; } } } - function inferTypeFromPropertyAssignment(assignment, checker, usageContext) { - var objectLiteral = ts.isShorthandPropertyAssignment(assignment) ? - assignment.parent : - assignment.parent.parent; - var nodeWithRealType = ts.isVariableDeclaration(objectLiteral.parent) ? - objectLiteral.parent : - objectLiteral; - addCandidateThisType(usageContext, checker.getTypeAtLocation(nodeWithRealType)); + function inferTypeFromPropertyAssignment(assignment, usage) { + var nodeWithRealType = ts.isVariableDeclaration(assignment.parent.parent) ? + assignment.parent.parent : + assignment.parent; + addCandidateThisType(usage, checker.getTypeAtLocation(nodeWithRealType)); } - function inferTypeFromPropertyDeclaration(declaration, checker, usageContext) { - addCandidateThisType(usageContext, checker.getTypeAtLocation(declaration.parent)); + function inferTypeFromPropertyDeclaration(declaration, usage) { + addCandidateThisType(usage, checker.getTypeAtLocation(declaration.parent)); } function removeLowPriorityInferences(inferences, priorities) { var toRemove = []; @@ -116510,14 +118238,14 @@ var ts; for (var _a = 0, priorities_1 = priorities; _a < priorities_1.length; _a++) { var _b = priorities_1[_a], high = _b.high, low = _b.low; if (high(i)) { - ts.Debug.assert(!low(i)); + ts.Debug.assert(!low(i), "Priority can't have both low and high"); toRemove.push(low); } } } return inferences.filter(function (i) { return toRemove.every(function (f) { return !f(i); }); }); } - function unifyFromContext(inferences, checker, fallback) { + function unifyFromUsage(inferences, fallback) { if (fallback === void 0) { fallback = checker.getAnyType(); } if (!inferences.length) return fallback; @@ -116543,12 +118271,11 @@ var ts; var anons = good.filter(function (i) { return checker.getObjectFlags(i) & 16 /* Anonymous */; }); if (anons.length) { good = good.filter(function (i) { return !(checker.getObjectFlags(i) & 16 /* Anonymous */); }); - good.push(unifyAnonymousTypes(anons, checker)); + good.push(unifyAnonymousTypes(anons)); } return checker.getWidenedType(checker.getUnionType(good)); } - InferFromReference.unifyFromContext = unifyFromContext; - function unifyAnonymousTypes(anons, checker) { + function unifyAnonymousTypes(anons) { if (anons.length === 1) { return anons[0]; } @@ -116584,74 +118311,74 @@ var ts; }); return checker.createAnonymousType(anons[0].symbol, members, calls, constructs, stringIndices.length ? checker.createIndexInfo(checker.getUnionType(stringIndices), stringIndexReadonly) : undefined, numberIndices.length ? checker.createIndexInfo(checker.getUnionType(numberIndices), numberIndexReadonly) : undefined); } - function inferFromContext(usageContext, checker) { + function inferFromUsage(usage) { var types = []; - if (usageContext.isNumber) { + if (usage.isNumber) { types.push(checker.getNumberType()); } - if (usageContext.isString) { + if (usage.isString) { types.push(checker.getStringType()); } - if (usageContext.isNumberOrString) { + if (usage.isNumberOrString) { types.push(checker.getUnionType([checker.getStringType(), checker.getNumberType()])); } - types.push.apply(types, (usageContext.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); - if (usageContext.properties && hasCallContext(usageContext.properties.get("then"))) { - var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); // TODO: GH#18217 - var types_1 = paramType.getCallSignatures().map(function (c) { return c.getReturnType(); }); + types.push.apply(types, (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); + if (usage.properties && hasCalls(usage.properties.get("then"))) { + var paramType = getParameterTypeFromCalls(0, usage.properties.get("then").calls, /*isRestParameter*/ false); // TODO: GH#18217 + var types_1 = paramType.getCallSignatures().map(function (sig) { return sig.getReturnType(); }); types_1.push(checker.createPromiseType(types_1.length ? checker.getUnionType(types_1, 2 /* Subtype */) : checker.getAnyType())); } - else if (usageContext.properties && hasCallContext(usageContext.properties.get("push"))) { - types.push(checker.createArrayType(getParameterTypeFromCallContexts(0, usageContext.properties.get("push").callContexts, /*isRestParameter*/ false, checker))); + else if (usage.properties && hasCalls(usage.properties.get("push"))) { + types.push(checker.createArrayType(getParameterTypeFromCalls(0, usage.properties.get("push").calls, /*isRestParameter*/ false))); } - if (usageContext.numberIndexContext) { - types.push(checker.createArrayType(recur(usageContext.numberIndexContext))); + if (usage.numberIndex) { + types.push(checker.createArrayType(recur(usage.numberIndex))); } - else if (usageContext.properties || usageContext.callContexts || usageContext.constructContexts || usageContext.stringIndexContext) { + else if (usage.properties || usage.calls || usage.constructs || usage.stringIndex) { var members_1 = ts.createUnderscoreEscapedMap(); var callSignatures = []; var constructSignatures = []; var stringIndexInfo = void 0; - if (usageContext.properties) { - usageContext.properties.forEach(function (context, name) { + if (usage.properties) { + usage.properties.forEach(function (u, name) { var symbol = checker.createSymbol(4 /* Property */, name); - symbol.type = recur(context); + symbol.type = recur(u); members_1.set(name, symbol); }); } - if (usageContext.callContexts) { - for (var _i = 0, _a = usageContext.callContexts; _i < _a.length; _i++) { - var callContext = _a[_i]; - callSignatures.push(getSignatureFromCallContext(callContext, checker)); + if (usage.calls) { + for (var _i = 0, _a = usage.calls; _i < _a.length; _i++) { + var call = _a[_i]; + callSignatures.push(getSignatureFromCall(call)); } } - if (usageContext.constructContexts) { - for (var _b = 0, _c = usageContext.constructContexts; _b < _c.length; _b++) { - var constructContext = _c[_b]; - constructSignatures.push(getSignatureFromCallContext(constructContext, checker)); + if (usage.constructs) { + for (var _b = 0, _c = usage.constructs; _b < _c.length; _b++) { + var construct = _c[_b]; + constructSignatures.push(getSignatureFromCall(construct)); } } - if (usageContext.stringIndexContext) { - stringIndexInfo = checker.createIndexInfo(recur(usageContext.stringIndexContext), /*isReadonly*/ false); + if (usage.stringIndex) { + stringIndexInfo = checker.createIndexInfo(recur(usage.stringIndex), /*isReadonly*/ false); } types.push(checker.createAnonymousType(/*symbol*/ undefined, members_1, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined)); // TODO: GH#18217 } return types; - function recur(innerContext) { - return unifyFromContext(inferFromContext(innerContext, checker), checker); + function recur(innerUsage) { + return unifyFromUsage(inferFromUsage(innerUsage)); } } - function getParameterTypeFromCallContexts(parameterIndex, callContexts, isRestParameter, checker) { + function getParameterTypeFromCalls(parameterIndex, calls, isRestParameter) { var types = []; - if (callContexts) { - for (var _i = 0, callContexts_2 = callContexts; _i < callContexts_2.length; _i++) { - var callContext = callContexts_2[_i]; - if (callContext.argumentTypes.length > parameterIndex) { + if (calls) { + for (var _i = 0, calls_2 = calls; _i < calls_2.length; _i++) { + var call = calls_2[_i]; + if (call.argumentTypes.length > parameterIndex) { if (isRestParameter) { - types = ts.concatenate(types, ts.map(callContext.argumentTypes.slice(parameterIndex), function (a) { return checker.getBaseTypeOfLiteralType(a); })); + types = ts.concatenate(types, ts.map(call.argumentTypes.slice(parameterIndex), function (a) { return checker.getBaseTypeOfLiteralType(a); })); } else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex])); } } } @@ -116662,31 +118389,31 @@ var ts; } return undefined; } - function getSignatureFromCallContext(callContext, checker) { + function getSignatureFromCall(call) { var parameters = []; - for (var i = 0; i < callContext.argumentTypes.length; i++) { + for (var i = 0; i < call.argumentTypes.length; i++) { var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); - symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(call.argumentTypes[i])); parameters.push(symbol); } - var returnType = unifyFromContext(inferFromContext(callContext.returnType, checker), checker, checker.getVoidType()); + var returnType = unifyFromUsage(inferFromUsage(call.returnType), checker.getVoidType()); // TODO: GH#18217 - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, call.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); } - function addCandidateType(context, type) { + function addCandidateType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateTypes || (context.candidateTypes = [])).push(type); + (usage.candidateTypes || (usage.candidateTypes = [])).push(type); } } - function addCandidateThisType(context, type) { + function addCandidateThisType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateThisTypes || (context.candidateThisTypes = [])).push(type); + (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); } } - function hasCallContext(usageContext) { - return !!usageContext && !!usageContext.callContexts; + function hasCalls(usage) { + return !!usage && !!usage.calls; } - })(InferFromReference || (InferFromReference = {})); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -116715,12 +118442,12 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: precedingNode = ctorDeclaration; changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { @@ -116775,7 +118502,7 @@ var ts; return; } // 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 === 222 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 223 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { @@ -116783,7 +118510,7 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 197 /* FunctionExpression */: { + case 198 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 122 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, @@ -116791,12 +118518,12 @@ var ts; ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 198 /* ArrowFunction */: { + case 199 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 219 /* Block */) { + if (arrowFunctionBody.kind === 220 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] @@ -116824,7 +118551,7 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 197 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 198 /* FunctionExpression */) { return undefined; } if (node.name.kind !== 73 /* Identifier */) { @@ -116913,7 +118640,7 @@ var ts; var newNodes = transformExpression(node, transformer, node); changes.replaceNodeWithNodes(sourceFile, nodeToReplace, newNodes); } - var _loop_11 = function (statement) { + var _loop_12 = function (statement) { ts.forEachChild(statement, function visit(node) { if (ts.isCallExpression(node)) { startTransformation(node, statement); @@ -116925,7 +118652,7 @@ var ts; }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var statement = returnStatements_1[_i]; - _loop_11(statement); + _loop_12(statement); } } function getReturnStatementsWithPromiseHandlers(body) { @@ -117244,8 +118971,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: { var funcBody = func.body; // Arrow functions with block bodies { } will enter this control flow if (ts.isBlock(funcBody)) { @@ -117357,6 +119084,7 @@ var ts; name = getMapEntryOrDefault(funcNode); } // return undefined argName when arg is null or undefined + // eslint-disable-next-line no-in-operator if (!name || "identifier" in name && name.identifier.text === "undefined") { return undefined; } @@ -117448,10 +119176,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -117477,7 +119205,7 @@ var ts; forEachExportReference(sourceFile, function (node) { var _a = node.name, text = _a.text, originalKeywordKind = _a.originalKeywordKind; if (!res.has(text) && (originalKeywordKind !== undefined && ts.isNonContextualKeyword(originalKeywordKind) - || checker.resolveName(node.name.text, node, 67220415 /* Value */, /*excludeGlobals*/ true))) { + || checker.resolveName(node.name.text, node, 111551 /* Value */, /*excludeGlobals*/ true))) { // Unconditionally add an underscore in case `text` is a keyword. res.set(text, makeUniqueName("_" + text, identifiers)); } @@ -117504,20 +119232,20 @@ var ts; } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 222 /* ExpressionStatement */: { + case 223 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 192 /* CallExpression */: { + case 193 /* 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 205 /* BinaryExpression */: { + case 206 /* BinaryExpression */: { var operatorToken = expression.operatorToken; return operatorToken.kind === 60 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } @@ -117559,8 +119287,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: { + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -117572,7 +119300,7 @@ var ts; // `const a = require("b").c` --> `import { c as a } from "./b"; return [makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]; default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid syntax form " + name.kind); } } function convertAssignment(sourceFile, checker, assignment, changes, exports) { @@ -117611,18 +119339,19 @@ var ts; function tryChangeModuleExportsObject(object) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 277 /* ShorthandPropertyAssignment */: - case 278 /* SpreadAssignment */: + // falls through + case 278 /* ShorthandPropertyAssignment */: + case 279 /* SpreadAssignment */: return undefined; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(86 /* ExportKeyword */)], prop); default: - ts.Debug.assertNever(prop); + ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); } }); return statements && [statements, false]; @@ -117651,12 +119380,10 @@ var ts; var moduleSpecifier = reExported.text; var moduleSymbol = checker.getSymbolAtLocation(reExported); var exports = moduleSymbol ? moduleSymbol.exports : ts.emptyUnderscoreEscapedMap; - return exports.has("export=") - ? [[reExportDefault(moduleSpecifier)], true] - : !exports.has("default") - ? [[reExportStar(moduleSpecifier)], false] + return exports.has("export=") ? [[reExportDefault(moduleSpecifier)], true] : + !exports.has("default") ? [[reExportStar(moduleSpecifier)], false] : // If there's some non-default export, must include both `export *` and `export default`. - : exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; + exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; } function reExportStar(moduleSpecifier) { return makeExportDeclaration(/*exportClause*/ undefined, moduleSpecifier); @@ -117685,7 +119412,7 @@ var ts; function convertExportsDotXEquals_replaceNode(name, exported) { var modifiers = [ts.createToken(86 /* ExportKeyword */)]; switch (exported.kind) { - case 197 /* FunctionExpression */: { + case 198 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -117693,10 +119420,10 @@ var ts; } } // falls through - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -117714,18 +119441,20 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: { + case 186 /* 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 + // (TODO: GH#18217) + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion : makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text); - }); // tslint:disable-line no-unnecessary-type-assertion (TODO: GH#18217) + }); if (importSpecifiers) { return [ts.makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, quotePreference)]; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 186 /* ArrayBindingPattern */: { + case 187 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -117739,7 +119468,7 @@ var ts; case 73 /* Identifier */: return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, quotePreference); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid name kind " + name.kind); } } /** @@ -117761,7 +119490,7 @@ var ts; var parent = use.parent; if (ts.isPropertyAccessExpression(parent)) { var expression = parent.expression, propertyName = parent.name.text; - ts.Debug.assert(expression === use); // Else shouldn't have been in `collectIdentifiers` + 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); @@ -117808,11 +119537,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return parent.name !== node; - case 187 /* BindingElement */: + case 188 /* BindingElement */: return parent.propertyName !== node; - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -117887,8 +119616,10 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var errorCodes = [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, - ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code]; + var errorCodes = [ + ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, + ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code + ]; var fixId = "fixClassIncorrectlyImplementsInterface"; // TODO: share a group with fixClassDoesntImplementInheritedAbstractMember? codefix.registerCodeFix({ errorCodes: errorCodes, @@ -117915,7 +119646,7 @@ var ts; }, }); function getClass(sourceFile, pos) { - return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos))); + return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); @@ -118013,7 +119744,7 @@ var ts; ts.pushIfUnique(entry.namedImports, symbolName); } else { - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add to Existing) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; } break; @@ -118026,7 +119757,7 @@ var ts; } switch (importKind) { case 1 /* Default */: - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add new) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; break; case 0 /* Named */: @@ -118034,14 +119765,14 @@ var ts; break; case 3 /* Equals */: case 2 /* Namespace */: - ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName); + ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); entry.namespaceLikeImport = { importKind: importKind, name: symbolName }; break; } break; } default: - ts.Debug.assertNever(fix); + ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); } }); return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { @@ -118078,10 +119809,11 @@ var ts; ImportKind[ImportKind["Default"] = 1] = "Default"; ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; ImportKind[ImportKind["Equals"] = 3] = "Equals"; + ImportKind[ImportKind["ConstEquals"] = 4] = "ConstEquals"; })(ImportKind || (ImportKind = {})); function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) { - var exportInfos = getAllReExportingModules(exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles()); - ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; })); + var exportInfos = getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles()); + 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 for completions. var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, position, exportInfos, host, preferences)).moduleSpecifier; var fix = ts.first(getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences)); @@ -118092,14 +119824,14 @@ var ts; var description = _a.description, changes = _a.changes, commands = _a.commands; return { description: description, changes: changes, commands: commands }; } - function getAllReExportingModules(exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, compilerOptions, checker, allSourceFiles) { + function getAllReExportingModules(importingFile, exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, compilerOptions, checker, allSourceFiles) { var result = []; forEachExternalModule(checker, allSourceFiles, function (moduleSymbol, moduleFile) { // Don't import from a re-export when looking "up" like to `./index` or `../index`. if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(sourceFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) { return; } - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + var defaultInfo = getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions); if (defaultInfo && defaultInfo.name === symbolName && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol) { result.push({ moduleSymbol: moduleSymbol, importKind: defaultInfo.kind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker) }); } @@ -118113,7 +119845,7 @@ var ts; return result; } function isTypeOnlySymbol(s, checker) { - return !(ts.skipAlias(s, checker).flags & 67220415 /* Value */); + return !(ts.skipAlias(s, checker).flags & 111551 /* Value */); } function getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences) { var checker = program.getTypeChecker(); @@ -118122,7 +119854,7 @@ var ts; var addToExisting = tryAddToExistingImport(existingImports); // Don't bother providing an action to add a new import if we can add to an existing one. var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences); - return (useNamespace ? [useNamespace] : ts.emptyArray).concat(addImport); + return __spreadArrays((useNamespace ? [useNamespace] : ts.emptyArray), addImport); } function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) { // It is possible that multiple import statements with the same specifier exist in the file. @@ -118151,21 +119883,21 @@ var ts; function tryAddToExistingImport(existingImports) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind !== 250 /* ImportDeclaration */) + if (declaration.kind !== 251 /* ImportDeclaration */) return undefined; var importClause = declaration.importClause; if (!importClause) return undefined; var name = importClause.name, namedBindings = importClause.namedBindings; - return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 253 /* NamedImports */) + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 254 /* NamedImports */) ? { kind: 2 /* AddToExisting */, importClause: importClause, importKind: importKind } : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 250 /* ImportDeclaration */) { + if (declaration.kind === 251 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 252 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 253 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -118176,7 +119908,7 @@ var ts; // Can't use an es6 import for a type in JS. return exportedSymbolIsTypeOnly && ts.isSourceFileJS(sourceFile) ? ts.emptyArray : ts.mapDefined(sourceFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 250 /* ImportDeclaration */ || i.kind === 249 /* ImportEqualsDeclaration */) + return (i.kind === 251 /* ImportDeclaration */ || i.kind === 250 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } @@ -118187,7 +119919,7 @@ var ts; return ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences, program.redirectTargetsMap) .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.assertDefined(position) } : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; + return exportedSymbolIsTypeOnly && isJs ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position, "position should be defined") } : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; }); }); // Sort to keep the shortest paths first @@ -118199,9 +119931,9 @@ var ts; } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 250 /* ImportDeclaration */ + var expression = declaration.kind === 251 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 260 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 261 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; return expression && ts.isStringLiteral(expression) ? { kind: 3 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; @@ -118211,7 +119943,7 @@ 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) : undefined; - return info && __assign({}, info, { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); + return info && __assign(__assign({}, info), { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); } function getFixesInfoForUMDImport(_a, token) { var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences; @@ -118221,7 +119953,7 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; + var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(sourceFile, program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; var fixes = getFixForImport(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, program, sourceFile, host, preferences); return { fixes: fixes, symbolName: symbolName }; } @@ -118233,10 +119965,10 @@ var ts; // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. var parent = token.parent; return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) - ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 67220415 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } - function getUmdImportKind(compilerOptions) { + function getUmdImportKind(importingFile, compilerOptions) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { return 1 /* Default */; @@ -118247,6 +119979,9 @@ var ts; case ts.ModuleKind.AMD: case ts.ModuleKind.CommonJS: case ts.ModuleKind.UMD: + if (ts.isInJSFile(importingFile)) { + return ts.isExternalModule(importingFile) ? 2 /* Namespace */ : 4 /* ConstEquals */; + } return 3 /* Equals */; case ts.ModuleKind.System: case ts.ModuleKind.ES2015: @@ -118255,7 +119990,7 @@ var ts; // Fall back to the `import * as ns` style import. return 2 /* Namespace */; default: - return ts.Debug.assertNever(moduleKind); + return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind); } } function getFixesInfoForNonUMDImport(_a, symbolToken) { @@ -118268,7 +120003,7 @@ var ts; ? checker.getJsxNamespace(sourceFile) : symbolToken.text; // "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 */); + ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here"); var fixes = ts.arrayFrom(ts.flatMapIterator(getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), program, sourceFile, host, preferences); @@ -118285,7 +120020,7 @@ var ts; } forEachExternalModuleToImportFrom(checker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { cancellationToken.throwIfCancellationRequested(); - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, program.getCompilerOptions()); + var defaultInfo = getDefaultLikeExportInfo(sourceFile, moduleSymbol, checker, program.getCompilerOptions()); if (defaultInfo && defaultInfo.name === symbolName && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { addSymbol(moduleSymbol, defaultInfo.symbol, defaultInfo.kind); } @@ -118297,20 +120032,41 @@ var ts; }); return originalSymbolToExportInfos; } - function getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions) { - var exported = getDefaultLikeExportWorker(moduleSymbol, checker); + function getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions) { + var exported = getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions); if (!exported) return undefined; var symbol = exported.symbol, kind = exported.kind; var info = getDefaultExportInfoWorker(symbol, moduleSymbol, checker, compilerOptions); return info && __assign({ symbol: symbol, kind: kind }, info); } - function getDefaultLikeExportWorker(moduleSymbol, checker) { + function getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions) { 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: 3 /* Equals */ }; + return exportEquals === moduleSymbol ? undefined : { symbol: exportEquals, kind: getExportEqualsImportKind(importingFile, compilerOptions, checker) }; + } + function getExportEqualsImportKind(importingFile, compilerOptions, checker) { + if (ts.getAllowSyntheticDefaultImports(compilerOptions) && ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { + return 1 /* Default */; + } + if (ts.isInJSFile(importingFile)) { + return ts.isExternalModule(importingFile) ? 1 /* Default */ : 4 /* ConstEquals */; + } + for (var _i = 0, _a = importingFile.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (ts.isImportEqualsDeclaration(statement)) { + return 3 /* Equals */; + } + if (ts.isImportDeclaration(statement) && statement.importClause && statement.importClause.name) { + var moduleSymbol = checker.getImmediateAliasedSymbol(statement.importClause.symbol); + if (moduleSymbol && moduleSymbol.name !== "default" /* Default */) { + return 1 /* Default */; + } + } + } + return 3 /* Equals */; } function getDefaultExportInfoWorker(defaultExport, moduleSymbol, checker, compilerOptions) { var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); @@ -118321,7 +120077,7 @@ var ts; return { symbolForMeaning: defaultExport, name: name }; if (defaultExport.flags & 2097152 /* Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); - return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent), checker, compilerOptions); + return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent, "Alias targets of default exports must have a parent"), checker, compilerOptions); } if (defaultExport.escapedName !== "default" /* Default */ && defaultExport.escapedName !== "export=" /* ExportEquals */) { @@ -118337,7 +120093,7 @@ var ts; } } else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.text === "default" /* Default */); + ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); return declaration.propertyName && declaration.propertyName.text; } }); @@ -118371,12 +120127,12 @@ var ts; return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; } default: - return ts.Debug.assertNever(fix); + return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind); } } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports) { if (defaultImport) { - ts.Debug.assert(!clause.name); + ts.Debug.assert(!clause.name, "Default imports can't have names"); changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), ts.createIdentifier(defaultImport), { suffix: ", " }); } if (namedImports.length) { @@ -118394,7 +120150,7 @@ var ts; changes.replaceNode(sourceFile, clause.namedBindings, namedImports_1); } else { - changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name), namedImports_1); + changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name, "Named import specifiers must have names"), namedImports_1); } } } @@ -118419,11 +120175,17 @@ var ts; ts.insertImport(changes, sourceFile, ts.makeImport(defaultImport === undefined ? undefined : ts.createIdentifier(defaultImport), namedImports.map(function (n) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(n)); }), moduleSpecifier, quotePreference)); } if (namespaceLikeImport) { - ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ - ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) - : ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); + ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) : + namespaceLikeImport.importKind === 4 /* ConstEquals */ ? createConstEqualsRequireDeclaration(namespaceLikeImport.name, quotedModuleSpecifier) : + ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); } } + function createConstEqualsRequireDeclaration(name, quotedModuleSpecifier) { + return ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.createIdentifier(name), + /*type*/ undefined, ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, [quotedModuleSpecifier])) + ], 2 /* Const */)); + } function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); @@ -118531,12 +120293,12 @@ var ts; var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 73 /* Identifier */); + ts.Debug.assert(node.kind === 73 /* Identifier */, "Expected an identifier for spelling (property access)"); var containingType = checker.getTypeAtLocation(node.parent.expression); suggestion = checker.getSuggestionForNonexistentProperty(node, containingType); } else if (ts.isImportSpecifier(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 73 /* Identifier */); + ts.Debug.assert(node.kind === 73 /* Identifier */, "Expected an identifier for spelling (import)"); var importDeclaration = ts.findAncestor(node, ts.isImportDeclaration); var resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration); if (resolvedSourceFile && resolvedSourceFile.symbol) { @@ -118565,10 +120327,10 @@ var ts; flags |= 1920 /* Namespace */; } if (meaning & 2 /* Type */) { - flags |= 67897832 /* Type */; + flags |= 788968 /* Type */; } if (meaning & 1 /* Value */) { - flags |= 67220415 /* Value */; + flags |= 111551 /* Value */; } return flags; } @@ -118639,7 +120401,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, classDeclaration) { var supers = getAllSupers(classDeclaration, checker); - var _loop_12 = function (info) { + var _loop_13 = function (info) { // If some superclass added this property, don't add it again. if (supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -118666,7 +120428,7 @@ var ts; }; for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { var info = infos_1[_i]; - _loop_12(info); + _loop_13(info); } }); })); @@ -118727,7 +120489,7 @@ var ts; } function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 210 /* ClassExpression */) { + if (classDeclaration.kind === 211 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -118753,7 +120515,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 205 /* BinaryExpression */) { + if (token.parent.parent.kind === 206 /* 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))); @@ -118816,7 +120578,7 @@ var ts; } function addMethodDeclaration(context, changeTracker, declSourceFile, typeDecl, token, callExpression, makeStatic, inJs, preferences) { var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences, typeDecl); - var containingMethodDeclaration = ts.getAncestor(callExpression, 157 /* MethodDeclaration */); + var containingMethodDeclaration = ts.getAncestor(callExpression, 158 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === typeDecl) { changeTracker.insertNodeAfter(declSourceFile, containingMethodDeclaration, methodDeclaration); } @@ -119063,7 +120825,7 @@ var ts; }); function getNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 125 /* ConstructorKeyword */); + ts.Debug.assert(token.kind === 125 /* ConstructorKeyword */, "token should be at the constructor keyword"); return token.parent; } function doChange(changes, sourceFile, ctr) { @@ -119107,6 +120869,43 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixID = "fixEnableJsxFlag"; + var errorCodes = [ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) { + return doChange(changeTracker, configFile); + }); + return [ + codefix.createCodeFixActionNoFixId(fixID, changes, ts.Diagnostics.Enable_the_jsx_flag_in_your_configuration_file) + ]; + }, + fixIds: [fixID], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + doChange(changes, configFile); + }); + } + }); + function doChange(changeTracker, configFile) { + codefix.setJsonCompilerOptionValue(changeTracker, configFile, "jsx", ts.createStringLiteral("react")); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -119316,7 +121115,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); } function deleteTypeParameters(changes, sourceFile, token) { - changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters)); + changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. function tryGetFullImport(token) { @@ -119326,7 +121125,7 @@ var ts; if (token.kind !== 18 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; var decl = token.parent.parent; - if (decl.kind === 152 /* Parameter */) { + if (decl.kind === 153 /* Parameter */) { tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); } else { @@ -119337,7 +121136,7 @@ var ts; function tryDeleteFullVariableStatement(sourceFile, token, changes) { var declarationList = ts.tryCast(token.parent, ts.isVariableDeclarationList); if (declarationList && declarationList.getChildren(sourceFile)[0] === token) { - changes.delete(sourceFile, declarationList.parent.kind === 220 /* VariableStatement */ ? declarationList.parent : declarationList); + changes.delete(sourceFile, declarationList.parent.kind === 221 /* VariableStatement */ ? declarationList.parent : declarationList); return true; } return false; @@ -119355,14 +121154,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 152 /* Parameter */: - case 151 /* TypeParameter */: + case 153 /* Parameter */: + case 152 /* TypeParameter */: return true; - case 238 /* VariableDeclaration */: { + case 239 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 228 /* ForInStatement */: return true; } } @@ -119409,26 +121208,26 @@ var ts; function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: // Don't remove a parameter if this overrides something. var symbol = checker.getSymbolAtLocation(parent.name); if (ts.isMemberSymbolInBaseType(symbol, checker)) return false; // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: + case 159 /* Constructor */: + case 241 /* FunctionDeclaration */: return true; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 198 /* FunctionExpression */: + case 199 /* 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. var parameters = parent.parameters; var index = parameters.indexOf(p); - ts.Debug.assert(index !== -1); + ts.Debug.assert(index !== -1, "The parameter should already be in the list"); return isFixAll ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 73 /* Identifier */ && !p.symbol.isReferenced; }) : index === parameters.length - 1; } - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -119464,11 +121263,11 @@ var ts; function doChange(changes, sourceFile, start, length) { var token = ts.getTokenAtPosition(sourceFile, start); var statement = ts.findAncestor(token, ts.isStatement); - ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); + ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile), "token and statement should start at the same point"); 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 223 /* IfStatement */: + case 224 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -119479,15 +121278,15 @@ var ts; return; } // falls through - case 225 /* WhileStatement */: - case 226 /* ForStatement */: + case 226 /* WhileStatement */: + case 227 /* ForStatement */: changes.delete(sourceFile, container); return; } } if (ts.isBlock(statement.parent)) { var end_3 = start + length; - var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; })); + var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; }), "Some statement should be last"); changes.deleteNodeRange(sourceFile, statement, lastStatement); } else { @@ -119553,7 +121352,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 === 292 /* JSDocNullableType */) { + if (typeNode.kind === 293 /* 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)); @@ -119573,7 +121372,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 292 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 293 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -119590,22 +121389,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 213 /* AsExpression */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 240 /* FunctionDeclaration */: - case 159 /* GetAccessor */: - case 163 /* IndexSignature */: - case 182 /* MappedType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 195 /* TypeAssertionExpression */: - case 238 /* VariableDeclaration */: + case 214 /* AsExpression */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 241 /* FunctionDeclaration */: + case 160 /* GetAccessor */: + case 164 /* IndexSignature */: + case 183 /* MappedType */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 153 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 161 /* SetAccessor */: + case 244 /* TypeAliasDeclaration */: + case 196 /* TypeAssertionExpression */: + case 239 /* VariableDeclaration */: return true; default: return false; @@ -119634,12 +121433,15 @@ var ts; return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_async_modifier_to_containing_function, fixId, ts.Diagnostics.Add_all_missing_async_modifiers)]; }, fixIds: [fixId], - getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var nodes = getNodes(diag.file, diag.start); - if (!nodes) - return; - doChange(changes, context.sourceFile, nodes); - }); }, + getAllCodeActions: function (context) { + var seen = ts.createMap(); + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var nodes = getNodes(diag.file, diag.start); + if (!nodes || !ts.addToSeen(seen, ts.getNodeId(nodes.insertBefore))) + return; + doChange(changes, context.sourceFile, nodes); + }); + }, }); function getReturnType(expr) { if (expr.type) { @@ -119659,14 +121461,14 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: insertBefore = ts.findChildOfKind(containingFunction, 91 /* FunctionKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -119793,18 +121595,40 @@ var ts; var modifiers = visibilityModifier ? ts.createNodeArray([visibilityModifier]) : undefined; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var optional = !!(symbol.flags & 16777216 /* Optional */); + var ambient = !!(enclosingDeclaration.flags & 4194304 /* Ambient */); switch (declaration.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 154 /* PropertySignature */: - case 155 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 156 /* PropertyDeclaration */: var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); out(ts.createProperty( /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 156 /* MethodSignature */: - case 157 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: { + var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); + var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); + var orderedAccessors = allAccessors.secondAccessor + ? [allAccessors.firstAccessor, allAccessors.secondAccessor] + : [allAccessors.firstAccessor]; + for (var _i = 0, orderedAccessors_1 = orderedAccessors; _i < orderedAccessors_1.length; _i++) { + var accessor = orderedAccessors_1[_i]; + if (ts.isGetAccessorDeclaration(accessor)) { + out(ts.createGetAccessor( + /*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : createStubbedMethodBody(preferences))); + } + else { + ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter"); + var parameter = ts.getSetAccessorValueParameter(accessor); + var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined; + out(ts.createSetAccessor( + /*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : createStubbedMethodBody(preferences))); + } + } + break; + } + case 157 /* MethodSignature */: + case 158 /* 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 @@ -119817,23 +121641,25 @@ var ts; break; } if (declarations.length === 1) { - ts.Debug.assert(signatures.length === 1); + ts.Debug.assert(signatures.length === 1, "One declaration implies one signature"); var signature = signatures[0]; - outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); + outputMethod(signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(preferences)); break; } - for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { - var signature = signatures_1[_i]; + for (var _a = 0, signatures_1 = signatures; _a < signatures_1.length; _a++) { + var signature = signatures_1[_a]; // Need to ensure nodes are fresh each time so they can have different positions. outputMethod(signature, ts.getSynthesizedDeepClones(modifiers, /*includeTrivia*/ false), ts.getSynthesizedDeepClone(name, /*includeTrivia*/ false)); } - if (declarations.length > signatures.length) { - var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); - outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); - } - else { - ts.Debug.assert(declarations.length === signatures.length); - out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); + if (!ambient) { + if (declarations.length > signatures.length) { + var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); + outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); + } + else { + ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); + out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); + } } break; } @@ -119845,7 +121671,7 @@ var ts; } function signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body) { var program = context.program; - var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 157 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); + var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 158 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } @@ -119866,8 +121692,7 @@ var ts; return checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, /*flags*/ undefined, tracker); }); var names = ts.map(args, function (arg) { - return ts.isIdentifier(arg) ? arg.text : - ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; + return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; }); var contextualType = checker.getContextualType(call); var returnType = (inJs || !contextualType) ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); @@ -120021,7 +121846,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 192 /* CallExpression */ : 193 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 193 /* CallExpression */ : 194 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -120261,6 +122086,39 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "useBigintLiteral"; + var errorCodes = [ + ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span); }); + if (changes.length > 0) { + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_to_a_bigint_numeric_literal, fixId, ts.Diagnostics.Convert_all_to_bigint_numeric_literals)]; + } + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag); }); + }, + }); + function makeChange(changeTracker, sourceFile, span) { + var numericLiteral = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), ts.isNumericLiteral); + if (!numericLiteral) { + return; + } + // We use .getText to overcome parser inaccuracies: https://github.com/microsoft/TypeScript/issues/33298 + var newText = numericLiteral.getText(sourceFile) + "n"; + changeTracker.replaceNode(sourceFile, numericLiteral, ts.createBigIntLiteral(newText)); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -120282,8 +122140,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 93 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 184 /* ImportType */); + ts.Debug.assert(token.kind === 93 /* ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 185 /* ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -120336,7 +122194,7 @@ var ts; var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(134 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); - var intersectionType = ts.createIntersectionTypeNode(ts.getAllSuperTypeNodes(container).concat([ + var intersectionType = ts.createIntersectionTypeNode(__spreadArrays(ts.getAllSuperTypeNodes(container), [ mappedIntersectionType ], (otherMembers.length ? [ts.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); changes.replaceNode(sourceFile, container, createTypeAliasFromInterface(container, intersectionType)); @@ -120388,6 +122246,40 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "fixConvertConstToLet"; + var errorCodes = [ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, span = context.span, program = context.program; + var variableStatement = getVariableStatement(sourceFile, span.start, program); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, variableStatement); }); + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_const_to_let, fixId, ts.Diagnostics.Convert_const_to_let)]; + }, + fixIds: [fixId] + }); + function getVariableStatement(sourceFile, pos, program) { + var token = ts.getTokenAtPosition(sourceFile, pos); + var checker = program.getTypeChecker(); + var symbol = checker.getSymbolAtLocation(token); + if (symbol) { + return symbol.valueDeclaration.parent.parent; + } + } + function doChange(changes, sourceFile, variableStatement) { + if (!variableStatement) { + return; + } + var start = variableStatement.getStart(); + changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 5 }, "let"); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var refactor; (function (refactor) { @@ -120404,8 +122296,8 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context)), t, context.cancellationToken); }); + ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context), "context must have info"), t, context.cancellationToken); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; }, }); @@ -120425,16 +122317,16 @@ var ts; return undefined; } switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: { + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 246 /* ModuleDeclaration */: { var node = exportNode; return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } - case 220 /* VariableStatement */: { + case 221 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -120443,7 +122335,7 @@ var ts; var decl = ts.first(vs.declarationList.declarations); if (!decl.initializer) return undefined; - ts.Debug.assert(!wasDefault); + 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; } default: @@ -120457,40 +122349,40 @@ 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.assertDefined(ts.findModifier(exportNode, 81 /* DefaultKeyword */))); + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 81 /* DefaultKeyword */), "Should find a default keyword in modifier list")); } else { - var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 86 /* ExportKeyword */)); + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 86 /* ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(81 /* DefaultKeyword */)); break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: // If 'x' isn't used in this file, `export const x = 0;` --> `export default 0;` if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile)) { // We checked in `getInfo` that an initializer exists. - changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer))); + changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer, "Initializer was previously known to be present"))); break; } // falls through - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 246 /* ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.createExportDefault(ts.createIdentifier(exportName.text))); break; default: - ts.Debug.assertNever(exportNode); + ts.Debug.assertNever(exportNode, "Unexpected exportNode kind " + exportNode.kind); } } } function changeImports(program, _a, changes, cancellationToken) { var wasDefault = _a.wasDefault, exportName = _a.exportName, exportingModuleSymbol = _a.exportingModuleSymbol; var checker = program.getTypeChecker(); - var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName)); + var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName), "Export name should resolve to a symbol"); ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) { var importingSourceFile = ref.getSourceFile(); if (wasDefault) { @@ -120504,27 +122396,27 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: { + case 255 /* ImportSpecifier */: + case 259 /* 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 251 /* ImportClause */: { + case 252 /* ImportClause */: { var clause = parent; - ts.Debug.assert(clause.name === ref); + ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); var namedBindings = clause.namedBindings; if (!namedBindings) { // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); } - else if (namedBindings.kind === 252 /* NamespaceImport */) { + else if (namedBindings.kind === 253 /* 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 */; @@ -120545,11 +122437,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); break; - case 254 /* ImportSpecifier */: { + case 255 /* ImportSpecifier */: { // `import { foo } from "./a";` --> `import foo from "./a";` // `import { foo as bar } from "./a";` --> `import bar from "./a";` var defaultImport = ts.createIdentifier(parent.name.text); @@ -120562,7 +122454,7 @@ var ts; } break; } - case 258 /* ExportSpecifier */: { + case 259 /* 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";` @@ -120571,7 +122463,7 @@ var ts; break; } default: - ts.Debug.assertNever(parent); + ts.Debug.assertNever(parent, "Unexpected parent kind " + parent.kind); } } function makeImportSpecifier(propertyName, name) { @@ -120595,13 +122487,13 @@ var ts; var i = getImportToConvert(context); if (!i) return ts.emptyArray; - var description = i.kind === 252 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; - var actionName = i.kind === 252 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + var description = i.kind === 253 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 253 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); + ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context), "Context must provide an import to convert")); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; } }); @@ -120618,7 +122510,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 252 /* NamespaceImport */) { + if (toConvert.kind === 253 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -120639,7 +122531,7 @@ var ts; if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { conflictingNames.set(exportName, true); } - ts.Debug.assert(parent.expression === id); + ts.Debug.assert(parent.expression === id, "Parent expression should match id"); nodesToReplace.push(parent); } }); @@ -120678,7 +122570,7 @@ var ts; }); var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; var neededNamedImports = []; - var _loop_13 = function (element) { + var _loop_14 = function (element) { var propertyName = (element.propertyName || element.name).text; ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); @@ -120697,7 +122589,7 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_13(element); + _loop_14(element); } changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); if (neededNamedImports.length) { @@ -120818,6 +122710,7 @@ var ts; Messages.cannotExtractRange = createMessage("Cannot extract range."); Messages.cannotExtractImport = createMessage("Cannot extract import statement."); Messages.cannotExtractSuper = createMessage("Cannot extract super call."); + Messages.cannotExtractJSDoc = createMessage("Cannot extract JSDoc."); Messages.cannotExtractEmpty = createMessage("Cannot extract empty range."); Messages.expressionExpected = createMessage("expression expected."); Messages.uselessConstantType = createMessage("No reason to extract constant of type."); @@ -120909,6 +122802,9 @@ 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)] }; @@ -120961,20 +122857,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 155 /* PropertyDeclaration */) { + if (current.kind === 156 /* PropertyDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 152 /* Parameter */) { + else if (current.kind === 153 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 158 /* Constructor */) { + if (ctorOrMethod.kind === 159 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 157 /* MethodDeclaration */) { + else if (current.kind === 158 /* MethodDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -120992,9 +122888,9 @@ var ts; PermittedJumps[PermittedJumps["Return"] = 4] = "Return"; })(PermittedJumps || (PermittedJumps = {})); // We believe it's true because the node is from the (unmodified) tree. - ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (1)"); // For understanding how skipTrivia functioned: - ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (2)"); if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck))) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)]; } @@ -121017,7 +122913,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 238 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 239 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasModifier(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`! @@ -121029,13 +122925,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; case 99 /* 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 === 192 /* CallExpression */) { + if (node.parent.kind === 193 /* 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)) { @@ -121050,8 +122946,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -121063,20 +122959,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 223 /* IfStatement */: + case 224 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 236 /* TryStatement */: + case 237 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 219 /* Block */: - if (node.parent && node.parent.kind === 236 /* TryStatement */ && node.parent.finallyBlock === node) { + case 220 /* Block */: + if (node.parent && node.parent.kind === 237 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 272 /* CaseClause */: + case 273 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -121088,19 +122984,19 @@ var ts; break; } switch (node.kind) { - case 179 /* ThisType */: + case 180 /* ThisType */: case 101 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 234 /* LabeledStatement */: { + case 235 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: { + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -121109,20 +123005,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 230 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 231 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -121176,7 +123072,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 === 152 /* Parameter */) { + if (current.kind === 153 /* 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; } @@ -121187,7 +123083,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 285 /* SourceFile */) { + if (current.kind === 286 /* SourceFile */) { return scopes; } } @@ -121277,32 +123173,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: return "constructor"; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return "arrow function"; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return "method '" + scope.name.getText() + "'"; - case 159 /* GetAccessor */: + case 160 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: - throw ts.Debug.assertNever(scope); + throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 241 /* ClassDeclaration */ + return scope.kind === 242 /* 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 === 246 /* ModuleBlock */ + return scope.kind === 247 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -121406,8 +123302,8 @@ var ts; if (exposedVariableDeclarations.length && !writes) { // No need to mix declarations and writes. // How could any variables be exposed if there's a return statement? - ts.Debug.assert(!returnValueProperty); - ts.Debug.assert(!(range.facts & RangeFacts.HasReturn)); + ts.Debug.assert(!returnValueProperty, "Expected no returnValueProperty"); + ts.Debug.assert(!(range.facts & RangeFacts.HasReturn), "Expected RangeFacts.HasReturn flag to be unset"); if (exposedVariableDeclarations.length === 1) { // Declaring exactly one variable: let x = newFunction(); var variableDeclaration = exposedVariableDeclarations[0]; @@ -121475,7 +123371,7 @@ var ts; if (assignments.length === 1) { // We would only have introduced a return value property if there had been // other assignments to make. - ts.Debug.assert(!returnValueProperty); + ts.Debug.assert(!returnValueProperty, "Shouldn't have returnValueProperty here"); newNodes.push(ts.createStatement(ts.createAssignment(assignments[0].name, call))); if (range.facts & RangeFacts.HasReturn) { newNodes.push(ts.createReturn()); @@ -121532,6 +123428,7 @@ var ts; * Stores either a list of changes that should be applied to extract a range or a list of errors */ function extractConstantInScope(node, scope, _a, rangeFacts, context) { + var _b; var substitutions = _a.substitutions; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable @@ -121542,10 +123439,11 @@ var ts; ? undefined : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(node, substitutions); + (_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer); ts.suppressLeadingAndTrailingTrivia(initializer); var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); if (ts.isClassLike(scope)) { - ts.Debug.assert(!isJS); // See CannotExtractToJSClass + ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass var modifiers = []; modifiers.push(ts.createToken(114 /* PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { @@ -121580,7 +123478,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 222 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 223 /* 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.createVariableStatement( @@ -121599,7 +123497,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 222 /* ExpressionStatement */) { + if (node.parent.kind === 223 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -121613,6 +123511,63 @@ var ts; var renameFilename = node.getSourceFile().fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, localNameText, /*isDeclaredBeforeUse*/ true); return { renameFilename: renameFilename, renameLocation: renameLocation, edits: edits }; + function transformFunctionInitializerAndType(variableType, initializer) { + // If no contextual type exists there is nothing to transfer to the function signature + if (variableType === undefined) + return { variableType: variableType, initializer: initializer }; + // Only do this for function expressions and arrow functions that are not generic + if (!ts.isFunctionExpression(initializer) && !ts.isArrowFunction(initializer) || !!initializer.typeParameters) + return { variableType: variableType, initializer: initializer }; + var functionType = checker.getTypeAtLocation(node); + var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* Call */)); + // If no function signature, maybe there was an error, do nothing + if (!functionSignature) + return { variableType: variableType, initializer: initializer }; + // If the function signature has generic type parameters we don't attempt to move the parameters + if (!!functionSignature.getTypeParameters()) + return { variableType: variableType, initializer: initializer }; + // We add parameter types if needed + var parameters = []; + var hasAny = false; + for (var _i = 0, _a = initializer.parameters; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.type) { + parameters.push(p); + } + else { + var paramType = checker.getTypeAtLocation(p); + if (paramType === checker.getAnyType()) + hasAny = true; + parameters.push(ts.updateParameter(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NoTruncation */), p.initializer)); + } + } + // If a parameter was inferred as any we skip adding function parameters at all. + // Turning an implicit any (which under common settings is a error) to an explicit + // is probably actually a worse refactor outcome. + if (hasAny) + return { variableType: variableType, initializer: initializer }; + variableType = undefined; + if (ts.isArrowFunction(initializer)) { + initializer = ts.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); + } + else { + if (functionSignature && !!functionSignature.thisParameter) { + var firstParameter = ts.firstOrUndefined(parameters); + // If the function signature has a this parameter and if the first defined parameter is not the this parameter, we must add it + // Note: If this parameter was already there, it would have been previously updated with the type if not type was present + if ((!firstParameter || (ts.isIdentifier(firstParameter.name) && firstParameter.name.escapedText !== "this"))) { + var thisType = checker.getTypeOfSymbolAtLocation(functionSignature.thisParameter, node); + parameters.splice(0, 0, ts.createParameter( + /* decorators */ undefined, + /* modifiers */ undefined, + /* dotDotDotToken */ undefined, "this", + /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NoTruncation */))); + } + } + initializer = ts.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.body); + } + return { variableType: variableType, initializer: initializer }; + } } function getContainingVariableDeclarationIfInList(node, scope) { var prevNode; @@ -121686,7 +123641,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 231 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 232 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -121749,7 +123704,7 @@ var ts; } function getNodeToInsertPropertyBefore(maxPos, scope) { var members = scope.members; - ts.Debug.assert(members.length > 0); // There must be at least one child, since we extracted from one. + ts.Debug.assert(members.length > 0, "Found no members"); // There must be at least one child, since we extracted from one. var prevMember; var allProperties = true; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { @@ -121791,11 +123746,11 @@ var ts; } if (!prevStatement && ts.isCaseClause(curr)) { // We must have been in the expression of the case clause. - ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent)); + ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent), "Grandparent isn't a switch statement"); return curr.parent.parent; } // There must be at least one statement since we started in one. - return ts.Debug.assertDefined(prevStatement); + return ts.Debug.assertDefined(prevStatement, "prevStatement failed to get set"); } ts.Debug.assert(curr !== scope, "Didn't encounter a block-like before encountering scope"); } @@ -121864,7 +123819,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 240 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 241 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -121917,7 +123872,7 @@ var ts; // If we didn't get through all the scopes, then there were some that weren't in our // parent chain (impossible at time of writing). A conservative solution would be to // copy allTypeParameterUsages into all remaining scopes. - ts.Debug.assert(i_1 === scopes.length); + ts.Debug.assert(i_1 === scopes.length, "Should have iterated all scopes"); } // If there are any declarations in the extracted block that are used in the same enclosing // lexical scope, we can't move the extraction "up" as those declarations will become unreachable @@ -121927,7 +123882,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_14 = function (i) { + var _loop_15 = 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 @@ -121949,7 +123904,7 @@ var ts; } }); // If an expression was extracted, then there shouldn't have been any variable declarations. - ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0); + ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0, "No variable declarations expected if something was extracted"); if (hasWrite && !isReadonlyArray(targetRange.range)) { var diag = ts.createDiagnosticForNode(targetRange.range, Messages.cannotWriteInExpression); functionErrorsPerScope[i].push(diag); @@ -121967,7 +123922,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_14(i); + _loop_15(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -122180,30 +124135,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 279 /* EnumMember */: + case 280 /* EnumMember */: return false; } switch (node.kind) { case 10 /* StringLiteral */: - return parent.kind !== 250 /* ImportDeclaration */ && - parent.kind !== 254 /* ImportSpecifier */; - case 209 /* SpreadElement */: - case 185 /* ObjectBindingPattern */: - case 187 /* BindingElement */: + return parent.kind !== 251 /* ImportDeclaration */ && + parent.kind !== 255 /* ImportSpecifier */; + case 210 /* SpreadElement */: + case 186 /* ObjectBindingPattern */: + case 188 /* BindingElement */: return false; case 73 /* Identifier */: - return parent.kind !== 187 /* BindingElement */ && - parent.kind !== 254 /* ImportSpecifier */ && - parent.kind !== 258 /* ExportSpecifier */; + return parent.kind !== 188 /* BindingElement */ && + parent.kind !== 255 /* ImportSpecifier */ && + parent.kind !== 259 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 219 /* Block */: - case 285 /* SourceFile */: - case 246 /* ModuleBlock */: - case 272 /* CaseClause */: + case 220 /* Block */: + case 286 /* SourceFile */: + case 247 /* ModuleBlock */: + case 273 /* CaseClause */: return true; default: return false; @@ -122219,6 +124174,7 @@ var ts; (function (refactor) { var refactorName = "Extract type"; var extractToTypeAlias = "Extract to type alias"; + var extractToInterface = "Extract to interface"; var extractToTypeDef = "Extract to typedef"; refactor.registerRefactor(refactorName, { getAvailableActions: function (context) { @@ -122228,22 +124184,34 @@ var ts; return [{ name: refactorName, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_type), - actions: [info.isJS ? { + actions: info.isJS ? [{ name: extractToTypeDef, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_typedef) - } : { + }] : ts.append([{ name: extractToTypeAlias, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_type_alias) - }] + }], info.typeElements && { + name: extractToInterface, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_interface) + }) }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === extractToTypeAlias || actionName === extractToTypeDef); var file = context.file; - var info = ts.Debug.assertDefined(getRangeToExtract(context)); - ts.Debug.assert(actionName === extractToTypeAlias && !info.isJS || actionName === extractToTypeDef && info.isJS); + var info = ts.Debug.assertDefined(getRangeToExtract(context), "Expected to find a range to extract"); var name = ts.getUniqueName("NewType", file); - var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { return info.isJS ? - doTypedefChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters) : - doTypeAliasChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters); }); + var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { + switch (actionName) { + case extractToTypeAlias: + ts.Debug.assert(!info.isJS, "Invalid actionName/JS combo"); + return doTypeAliasChange(changes, file, name, info); + case extractToTypeDef: + ts.Debug.assert(info.isJS, "Invalid actionName/JS combo"); + return doTypedefChange(changes, file, name, info); + case extractToInterface: + ts.Debug.assert(!info.isJS && !!info.typeElements, "Invalid actionName/JS combo"); + return doInterfaceChange(changes, file, name, info); + default: + ts.Debug.fail("Unexpected action name"); + } + }); var renameFilename = file.fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, name, /*preferLastLocation*/ false); return { edits: edits, renameFilename: renameFilename, renameLocation: renameLocation }; @@ -122258,11 +124226,36 @@ var ts; if (!selection || !ts.isTypeNode(selection)) return undefined; var checker = context.program.getTypeChecker(); - var firstStatement = ts.Debug.assertDefined(isJS ? ts.findAncestor(selection, isStatementAndHasJSDoc) : ts.findAncestor(selection, ts.isStatement)); + var firstStatement = ts.Debug.assertDefined(isJS ? ts.findAncestor(selection, isStatementAndHasJSDoc) : ts.findAncestor(selection, ts.isStatement), "Should find a statement"); var typeParameters = collectTypeParameters(checker, selection, firstStatement, file); if (!typeParameters) return undefined; - return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters }; + var typeElements = flattenTypeLiteralNodeReference(checker, selection); + return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters, typeElements: typeElements }; + } + function flattenTypeLiteralNodeReference(checker, node) { + if (!node) + return undefined; + if (ts.isIntersectionTypeNode(node)) { + var result = []; + var seen_1 = ts.createMap(); + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var type = _a[_i]; + var flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type); + if (!flattenedTypeMembers || !flattenedTypeMembers.every(function (type) { return type.name && ts.addToSeen(seen_1, ts.getNameFromPropertyName(type.name)); })) { + return undefined; + } + ts.addRange(result, flattenedTypeMembers); + } + return result; + } + else if (ts.isParenthesizedTypeNode(node)) { + return flattenTypeLiteralNodeReference(checker, node.type); + } + else if (ts.isTypeLiteralNode(node)) { + return node.members; + } + return undefined; } function isStatementAndHasJSDoc(n) { return ts.isStatement(n) && ts.hasJSDocNodes(n); @@ -122299,7 +124292,7 @@ var ts; } else if (ts.isTypeQueryNode(node)) { if (ts.isIdentifier(node.exprName)) { - var symbol = checker.resolveName(node.exprName.text, node.exprName, 67220415 /* Value */, /* excludeGlobals */ false); + 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)) { return true; } @@ -122313,15 +124306,26 @@ var ts; return ts.forEachChild(node, visitor); } } - function doTypeAliasChange(changes, file, name, firstStatement, selection, typeParameters) { + function doTypeAliasChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; var newTypeNode = ts.createTypeAliasDeclaration( /* decorators */ undefined, /* modifiers */ undefined, name, typeParameters.map(function (id) { return ts.updateTypeParameterDeclaration(id, id.name, id.constraint, /* defaultType */ undefined); }), selection); changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); } - function doTypedefChange(changes, file, name, firstStatement, selection, typeParameters) { - var node = ts.createNode(311 /* JSDocTypedefTag */); + function doInterfaceChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters, typeElements = info.typeElements; + var newTypeNode = ts.createInterfaceDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, name, typeParameters, + /* heritageClauses */ undefined, typeElements); + changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); + changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); + } + function doTypedefChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; + var node = ts.createNode(313 /* JSDocTypedefTag */); node.tagName = ts.createIdentifier("typedef"); // TODO: jsdoc factory https://github.com/Microsoft/TypeScript/pull/29539 node.fullName = ts.createIdentifier(name); node.name = node.fullName; @@ -122329,10 +124333,10 @@ var ts; var templates = []; ts.forEach(typeParameters, function (typeParameter) { var constraint = ts.getEffectiveConstraintOfTypeParameter(typeParameter); - var template = ts.createNode(310 /* JSDocTemplateTag */); + var template = ts.createNode(312 /* JSDocTemplateTag */); template.tagName = ts.createIdentifier("template"); template.constraint = constraint && ts.cast(constraint, ts.isJSDocTypeExpression); - var parameter = ts.createNode(151 /* TypeParameter */); + var parameter = ts.createNode(152 /* TypeParameter */); parameter.name = typeParameter.name; template.typeParameters = ts.createNodeArray([parameter]); templates.push(template); @@ -122413,7 +124417,7 @@ var ts; return ts.isIdentifier(name) || ts.isStringLiteral(name); } function isAcceptedDeclaration(node) { - return ts.isParameterPropertyDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); + return ts.isParameterPropertyDeclaration(node, node.parent) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); } function createPropertyName(name, originalName) { return ts.isIdentifier(originalName) ? ts.createIdentifier(name) : ts.createLiteral(name); @@ -122446,7 +124450,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasReadonlyModifier(declaration), type: ts.getTypeAnnotationNode(declaration), - container: declaration.kind === 152 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 153 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -122492,11 +124496,9 @@ var ts; } } function insertAccessor(changeTracker, file, accessor, declaration, container) { - ts.isParameterPropertyDeclaration(declaration) - ? changeTracker.insertNodeAtClassStart(file, container, accessor) - : ts.isPropertyAssignment(declaration) - ? changeTracker.insertNodeAfterComma(file, declaration, accessor) - : changeTracker.insertNodeAfter(file, declaration, accessor); + ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.insertNodeAtClassStart(file, container, accessor) : + ts.isPropertyAssignment(declaration) ? changeTracker.insertNodeAfterComma(file, declaration, accessor) : + changeTracker.insertNodeAfter(file, declaration, accessor); } function updateReadonlyPropertyInitializerStatementConstructor(changeTracker, file, constructor, fieldName, originalName) { if (!constructor.body) @@ -122534,7 +124536,7 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Wrong refactor invoked"); var statements = ts.Debug.assertDefined(getStatementsToMove(context)); var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; @@ -122591,11 +124593,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return true; - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -122630,7 +124632,7 @@ var ts; deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker); deleteMovedStatements(oldFile, toMove.ranges, changes); updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName); - return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference).concat(addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); + return __spreadArrays(getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference), addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); } function deleteMovedStatements(sourceFile, moved, changes) { for (var _i = 0, moved_1 = moved; _i < moved_1.length; _i++) { @@ -122648,10 +124650,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_15 = function (sourceFile) { + var _loop_16 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_16 = function (statement) { + var _loop_17 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -122673,25 +124675,25 @@ var ts; }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_16(statement); + _loop_17(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_15(sourceFile); + _loop_16(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 252 /* NamespaceImport */ ? + case 251 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 253 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return node.name; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { @@ -122719,20 +124721,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function moduleSpecifierFromImport(i) { - return (i.kind === 250 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 249 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 251 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 250 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -122774,7 +124776,7 @@ var ts; return ts.makeImportIfNecessary(defaultImport, specifiers, path, quotePreference); } else { - ts.Debug.assert(!defaultImport); // If there's a default export, it should have been an es6 module. + ts.Debug.assert(!defaultImport, "No default import should exist"); // If there's a default export, it should have been an es6 module. var bindingElements = imports.map(function (i) { return ts.createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, i); }); return bindingElements.length ? makeVariableStatement(ts.createObjectBindingPattern(bindingElements), /*type*/ undefined, createRequireCall(ts.createLiteral(path))) @@ -122802,19 +124804,19 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: - ts.Debug.assertNever(importDecl); + ts.Debug.assertNever(importDecl, "Unexpected import decl kind " + importDecl.kind); } } function deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused) { @@ -122823,7 +124825,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 252 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 253 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -122833,9 +124835,9 @@ var ts; } if (namedBindings) { if (namedBindingsUnused) { - changes.delete(sourceFile, namedBindings); + changes.replaceNode(sourceFile, importDecl.importClause, ts.updateImportClause(importDecl.importClause, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 253 /* NamedImports */) { + else if (namedBindings.kind === 254 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -122853,9 +124855,9 @@ var ts; changes.delete(sourceFile, name); } break; - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: break; - case 185 /* ObjectBindingPattern */: + case 186 /* 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); } @@ -122929,7 +124931,7 @@ var ts; for (var _i = 0, toMove_1 = toMove; _i < toMove_1.length; _i++) { var statement = toMove_1[_i]; forEachTopLevelDeclaration(statement, function (decl) { - movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol)); + movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol, "Need a symbol here")); }); } for (var _a = 0, toMove_2 = toMove; _a < toMove_2.length; _a++) { @@ -122982,13 +124984,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: + case 250 /* ImportEqualsDeclaration */: + case 255 /* ImportSpecifier */: + case 252 /* ImportClause */: return true; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -123000,7 +125002,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 250 /* ImportDeclaration */: { + case 251 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -123010,18 +125012,18 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 238 /* VariableDeclaration */: { + case 239 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } default: - return ts.Debug.assertNever(i); + return ts.Debug.assertNever(i, "Unexpected import kind " + i.kind); } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 253 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -123033,9 +125035,9 @@ var ts; switch (name.kind) { case 73 /* Identifier */: return keep(name) ? name : undefined; - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: return name; - case 185 /* ObjectBindingPattern */: { + case 186 /* 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.createObjectBindingPattern(newElements) : undefined; @@ -123087,18 +125089,18 @@ var ts; return ts.isVariableDeclaration(node) ? node.parent.parent.parent : node.parent; } function isTopLevelDeclarationStatement(node) { - ts.Debug.assert(ts.isSourceFile(node.parent)); + ts.Debug.assert(ts.isSourceFile(node.parent), "Node parent should be a SourceFile"); return isNonVariableTopLevelDeclaration(node) || ts.isVariableStatement(node); } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 250 /* ImportEqualsDeclaration */: return true; default: return false; @@ -123106,17 +125108,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 250 /* ImportEqualsDeclaration */: return cb(statement); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 222 /* ExpressionStatement */: { + case 223 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -123128,11 +125130,11 @@ var ts; switch (name.kind) { case 73 /* Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); } } function nameOfTopLevelDeclaration(d) { @@ -123140,9 +125142,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return d.parent.parent; - case 187 /* BindingElement */: + case 188 /* BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -123175,48 +125177,48 @@ var ts; function addEs6Export(d) { var modifiers = ts.concatenate([ts.createModifier(86 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(d); + return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); } } function addCommonjsExport(decl) { - return [decl].concat(getNamesToExportInCommonJS(decl).map(createExportAssignment)); + return __spreadArrays([decl], getNamesToExportInCommonJS(decl).map(createExportAssignment)); } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 250 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 222 /* ExpressionStatement */: - return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` + case 223 /* 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); + return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); } } /** Creates `exports.x = x;` */ @@ -123344,7 +125346,7 @@ var ts; }]; } function getEditsForAction(context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Unexpected action name"); var file = context.file, startPosition = context.startPosition, program = context.program, cancellationToken = context.cancellationToken, host = context.host; var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker()); if (!functionDeclaration || !cancellationToken) @@ -123376,7 +125378,7 @@ var ts; function getGroupedReferences(functionDeclaration, program, cancellationToken) { var functionNames = getFunctionNames(functionDeclaration); var classNames = ts.isConstructorDeclaration(functionDeclaration) ? getClassNames(functionDeclaration) : []; - var names = ts.deduplicate(functionNames.concat(classNames), ts.equateValues); + var names = ts.deduplicate(__spreadArrays(functionNames, classNames), ts.equateValues); var checker = program.getTypeChecker(); var references = ts.flatMap(names, /*mapfn*/ function (/*mapfn*/ name) { return ts.FindAllReferences.getReferenceEntriesForNode(-1, name, program, program.getSourceFiles(), cancellationToken); }); var groupedReferences = groupReferences(references); @@ -123483,15 +125485,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -123501,7 +125503,7 @@ var ts; } break; // x["foo"](...) - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -123520,14 +125522,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -123569,11 +125571,11 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return isSingleImplementation(functionDeclaration, checker); - case 158 /* Constructor */: + case 159 /* Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -123581,8 +125583,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -123753,7 +125755,7 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; @@ -123761,7 +125763,7 @@ var ts; // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 81 /* DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -123772,30 +125774,30 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* 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.assertDefined(ts.findModifier(functionDeclaration, 81 /* DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return [functionDeclaration.name]; - case 158 /* Constructor */: + case 159 /* Constructor */: var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 125 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 210 /* ClassExpression */) { + if (functionDeclaration.parent.kind === 211 /* ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return [functionDeclaration.parent.name]; - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; default: - return ts.Debug.assertNever(functionDeclaration); + return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind " + functionDeclaration.kind); } } })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); @@ -123824,7 +125826,7 @@ var ts; this.kind = kind; } NodeObject.prototype.assertHasRealPosition = function (message) { - // tslint:disable-next-line:debug-assert + // eslint-disable-next-line debug-assert ts.Debug.assert(!ts.positionIsSynthesized(this.pos) && !ts.positionIsSynthesized(this.end), message || "Node must have a real position for this operation"); }; NodeObject.prototype.getSourceFile = function () { @@ -123881,8 +125883,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 289 /* FirstJSDocNode */ || kid.kind > 312 /* LastJSDocNode */; }); - return child.kind < 149 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 290 /* FirstJSDocNode */ || kid.kind > 314 /* LastJSDocNode */; }); + return child.kind < 150 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -123893,7 +125895,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 149 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 150 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -123951,7 +125953,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(313 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(315 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { @@ -124286,10 +126288,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -124309,31 +126311,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 169 /* TypeLiteral */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 245 /* EnumDeclaration */: + case 246 /* ModuleDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 259 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 252 /* ImportClause */: + case 253 /* NamespaceImport */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 170 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 152 /* Parameter */: + case 153 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // falls through - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: { + case 239 /* VariableDeclaration */: + case 188 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -124344,19 +126346,19 @@ var ts; } } // falls through - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 280 /* EnumMember */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: addDeclaration(node); break; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -124368,7 +126370,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 253 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -124377,7 +126379,7 @@ var ts; } } break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -124574,7 +126576,7 @@ var ts; return sourceFile; } ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; - ts.disableIncrementalParsing = false; + ts.disableIncrementalParsing = false; // eslint-disable-line prefer-const function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { // If we were given a text change range, and our version or open-ness changed, then // incrementally parse this file. @@ -124703,7 +126705,11 @@ var ts; function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { - throw new Error("Could not find sourceFile: '" + fileName + "' in " + (program && JSON.stringify(program.getSourceFiles().map(function (f) { return f.fileName; }))) + "."); + var error = new Error("Could not find source file: '" + fileName + "'."); + // We've been having trouble debugging this, so attach sidecar data for the tsserver log. + // See https://github.com/microsoft/TypeScript/issues/30180. + error.ProgramFiles = program.getSourceFiles().map(function (f) { return f.fileName; }); + throw error; } return sourceFile; } @@ -124772,11 +126778,21 @@ var ts; compilerHost.trace = function (message) { return host.trace(message); }; } if (host.resolveModuleNames) { - compilerHost.resolveModuleNames = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }; + compilerHost.resolveModuleNames = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveModuleNames.apply(host, args); + }; } if (host.resolveTypeReferenceDirectives) { - compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { - return host.resolveTypeReferenceDirectives(typeReferenceDirectiveNames, containingFile, redirectedReference); + compilerHost.resolveTypeReferenceDirectives = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveTypeReferenceDirectives.apply(host, args); }; } var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); @@ -124914,7 +126930,7 @@ var ts; } // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); - return semanticDiagnostics.concat(declarationDiagnostics); + return __spreadArrays(semanticDiagnostics, declarationDiagnostics); } function getSuggestionDiagnostics(fileName) { synchronizeHostData(); @@ -124922,12 +126938,12 @@ var ts; } function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); + return __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken)); } function getCompletionsAtPosition(fileName, position, options) { if (options === void 0) { options = ts.emptyOptions; } // Convert from deprecated options names to new names - var fullPreferences = __assign({}, ts.identity(options), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); + var fullPreferences = __assign(__assign({}, ts.identity(options)), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); synchronizeHostData(); return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter); } @@ -124985,12 +127001,12 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node); - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 191 /* PropertyAccessExpression */: + case 150 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); case 101 /* ThisKeyword */: - case 179 /* ThisType */: + case 180 /* ThisType */: case 99 /* SuperKeyword */: return true; default: @@ -125017,13 +127033,13 @@ var ts; } /// References and Occurrences function getOccurrencesAtPosition(fileName, position) { - return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */, isDefinition: false }, highlightSpan.isInString && { isInString: true }, highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); + return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */, isDefinition: false }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); } function getDocumentHighlights(fileName, position, filesToSearch) { var normalizedFileName = ts.normalizePath(fileName); ts.Debug.assert(filesToSearch.some(function (f) { return ts.normalizePath(f) === normalizedFileName; })); synchronizeHostData(); - var sourceFilesToSearch = filesToSearch.map(getValidSourceFile); + var sourceFilesToSearch = ts.mapDefined(filesToSearch, function (fileName) { return program.getSourceFile(fileName); }); var sourceFile = getValidSourceFile(fileName); return ts.DocumentHighlights.getDocumentHighlights(program, cancellationToken, sourceFile, position, sourceFilesToSearch); } @@ -125093,15 +127109,15 @@ var ts; return undefined; } switch (node.kind) { - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 191 /* PropertyAccessExpression */: + case 150 /* QualifiedName */: case 10 /* StringLiteral */: case 88 /* FalseKeyword */: case 103 /* TrueKeyword */: case 97 /* NullKeyword */: case 99 /* SuperKeyword */: case 101 /* ThisKeyword */: - case 179 /* ThisType */: + case 180 /* ThisType */: case 73 /* Identifier */: break; // Cant create the text span @@ -125118,7 +127134,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 === 245 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 246 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -125570,7 +127586,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 260 /* ExternalModuleReference */ || + node.parent.kind === 261 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -125587,13 +127603,13 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 150 /* ComputedPropertyName */) { + if (node.parent.kind === 151 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through case 73 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 189 /* ObjectLiteralExpression */ || node.parent.parent.kind === 269 /* JsxAttributes */) && + (node.parent.parent.kind === 190 /* ObjectLiteralExpression */ || node.parent.parent.kind === 270 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -125635,7 +127651,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 191 /* ElementAccessExpression */ && + node.parent.kind === 192 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -125715,114 +127731,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 239 /* VariableDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return spanInVariableDeclaration(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return spanInParameterDeclaration(node); - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 159 /* Constructor */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 219 /* Block */: + case 220 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return spanInBlock(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return spanInBlock(node.block); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 224 /* DoStatement */: + case 225 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 237 /* DebuggerStatement */: + case 238 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 223 /* IfStatement */: + case 224 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return spanInForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 236 /* TryStatement */: + case 237 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 187 /* BindingElement */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 188 /* BindingElement */: // span on complete node return textSpan(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 153 /* Decorator */: + case 154 /* Decorator */: return spanInNodeArray(parent.decorators); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: return undefined; // Tokens: case 26 /* SemicolonToken */: @@ -125852,7 +127868,7 @@ var ts; case 76 /* CatchKeyword */: case 89 /* FinallyKeyword */: return spanInNextNode(node); - case 148 /* OfKeyword */: + case 149 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -125865,13 +127881,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 === 73 /* Identifier */ || - node.kind === 209 /* SpreadElement */ || - node.kind === 276 /* PropertyAssignment */ || - node.kind === 277 /* ShorthandPropertyAssignment */) && + node.kind === 210 /* SpreadElement */ || + node.kind === 277 /* PropertyAssignment */ || + node.kind === 278 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 205 /* BinaryExpression */) { + if (node.kind === 206 /* 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 @@ -125893,22 +127909,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 224 /* DoStatement */: + case 225 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 153 /* Decorator */: + case 154 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 227 /* ForStatement */: + case 229 /* ForOfStatement */: return textSpan(node); - case 205 /* BinaryExpression */: + case 206 /* 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 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -125917,21 +127933,21 @@ var ts; } } switch (node.parent.kind) { - case 276 /* PropertyAssignment */: + case 277 /* 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 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: { + case 239 /* VariableDeclaration */: + case 153 /* 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)) { @@ -125939,7 +127955,7 @@ var ts; } break; } - case 205 /* BinaryExpression */: { + case 206 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -125969,7 +127985,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 227 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 228 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -125981,7 +127997,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 228 /* ForOfStatement */) { + parent.parent.kind === 229 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -126022,7 +128038,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 241 /* ClassDeclaration */ && functionDeclaration.kind !== 158 /* Constructor */); + (functionDeclaration.parent.kind === 242 /* ClassDeclaration */ && functionDeclaration.kind !== 159 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -126045,26 +128061,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } - // falls through // Set on parent if on same line otherwise on first statement - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 227 /* ForInStatement */: + // falls through + case 226 /* WhileStatement */: + case 224 /* IfStatement */: + case 228 /* 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 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 227 /* ForStatement */: + case 229 /* 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 === 239 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 240 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -126089,21 +128105,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 212 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 187 /* BindingElement */) { + if (bindingPattern.parent.kind === 188 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 186 /* ArrayBindingPattern */ && node.kind !== 185 /* ObjectBindingPattern */); - var elements = node.kind === 188 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 187 /* ArrayBindingPattern */ && node.kind !== 186 /* ObjectBindingPattern */); + var elements = node.kind === 189 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 212 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -126111,18 +128127,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 === 205 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 206 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -126130,25 +128146,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 246 /* ModuleBlock */: + case 247 /* 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 244 /* EnumDeclaration */: - case 241 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 242 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 219 /* Block */: + case 220 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 275 /* CatchClause */: + case 276 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -126156,7 +128172,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 185 /* ObjectBindingPattern */: + case 186 /* 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); @@ -126172,7 +128188,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 186 /* ArrayBindingPattern */: + case 187 /* 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); @@ -126187,12 +128203,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 224 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 192 /* CallExpression */ || - node.parent.kind === 193 /* NewExpression */) { + if (node.parent.kind === 225 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 193 /* CallExpression */ || + node.parent.kind === 194 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 196 /* ParenthesizedExpression */) { + if (node.parent.kind === 197 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -126201,21 +128217,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 196 /* ParenthesizedExpression */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 159 /* Constructor */: + case 226 /* WhileStatement */: + case 225 /* DoStatement */: + case 227 /* ForStatement */: + case 229 /* ForOfStatement */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 197 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -126225,20 +128241,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ || - node.parent.kind === 152 /* Parameter */) { + node.parent.kind === 277 /* PropertyAssignment */ || + node.parent.kind === 153 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 195 /* TypeAssertionExpression */) { + if (node.parent.kind === 196 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 224 /* DoStatement */) { + if (node.parent.kind === 225 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -126246,7 +128262,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.kind === 229 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -126291,10 +128307,9 @@ var ts; // limitations under the License. // /* @internal */ -var debugObjectHost = (function () { return this; })(); +var debugObjectHost = (function () { return this; })(); // eslint-disable-line prefer-const // We need to use 'null' to interface with the managed side. -/* tslint:disable:no-null-keyword */ -/* tslint:disable:no-in-operator */ +/* eslint-disable no-in-operator */ /* @internal */ var ts; (function (ts) { @@ -126316,9 +128331,11 @@ var ts; ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + /* eslint-disable no-null/no-null */ if (encoded === null) { return null; // TODO: GH#18217 } + /* eslint-enable no-null/no-null */ var decoded = JSON.parse(encoded); // TODO: GH#18217 return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); }; @@ -126389,6 +128406,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); + // eslint-disable-next-line no-null/no-null if (settingsJson === null || settingsJson === "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } @@ -126417,6 +128435,7 @@ var ts; return this.shimHost.getScriptVersion(fileName); }; LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { + /* eslint-disable no-null/no-null */ var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); if (diagnosticMessagesJson === null || diagnosticMessagesJson === "") { return null; @@ -126428,6 +128447,7 @@ var ts; this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); return null; } + /* eslint-enable no-null/no-null */ }; LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { var hostCancellationToken = this.shimHost.getCancellationToken(); @@ -126571,13 +128591,13 @@ var ts; LanguageServiceShimObject.prototype.dispose = function (dummy) { this.logger.log("dispose()"); this.languageService.dispose(); - this.languageService = null; + this.languageService = null; // eslint-disable-line no-null/no-null // force a GC if (debugObjectHost && debugObjectHost.CollectGarbage) { debugObjectHost.CollectGarbage(); this.logger.log("CollectGarbage()"); } - this.logger = null; + this.logger = null; // eslint-disable-line no-null/no-null _super.prototype.dispose.call(this, dummy); }; /// REFRESH @@ -126585,13 +128605,14 @@ var ts; * Update the list of scripts known to the compiler */ LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); + this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; } // eslint-disable-line no-null/no-null + ); }; LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { var _this = this; this.forwardJSONCall("cleanupSemanticCache()", function () { _this.languageService.cleanupSemanticCache(); - return null; + return null; // eslint-disable-line no-null/no-null }); }; LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { @@ -126962,7 +128983,7 @@ var ts; typeAcquisition: configFile.typeAcquisition, files: configFile.fileNames, raw: configFile.raw, - errors: realizeDiagnostics(result.parseDiagnostics.concat(configFile.errors), "\r\n") + errors: realizeDiagnostics(__spreadArrays(result.parseDiagnostics, configFile.errors), "\r\n") }; }); }; @@ -127049,8 +129070,7 @@ var ts; module.exports = ts; } })(ts || (ts = {})); -/* tslint:enable:no-in-operator */ -/* tslint:enable:no-null */ +/* eslint-enable no-in-operator */ /// TODO: this is used by VS, clean this up on both sides of the interface /* @internal */ var TypeScript; @@ -127186,11 +129206,13 @@ var ts; } }; ThrottledOperations.run = function (self, operationId, cb) { + ts.perfLogger.logStartScheduledOperation(operationId); self.pendingTimeouts.delete(operationId); if (self.logger) { self.logger.info("Running: " + operationId); } cb(); + ts.perfLogger.logStopScheduledOperation(); }; return ThrottledOperations; }()); @@ -127210,6 +129232,7 @@ var ts; }; GcTimer.run = function (self) { self.timerId = undefined; + ts.perfLogger.logStartScheduledOperation("GC collect"); var log = self.logger.hasLevel(server.LogLevel.requestTime); var before = log && self.host.getMemoryUsage(); // TODO: GH#18217 self.host.gc(); // TODO: GH#18217 @@ -127217,6 +129240,7 @@ var ts; var after = self.host.getMemoryUsage(); // TODO: GH#18217 self.logger.perftrc("GC::before " + before + ", after " + after); } + ts.perfLogger.logStopScheduledOperation(); }; return GcTimer; }()); @@ -127265,7 +129289,7 @@ var ts; WatchType["MissingGeneratedFile"] = "Missing generated file"; })(WatchType = ts.WatchType || (ts.WatchType = {})); })(ts || (ts = {})); -// tslint:disable no-unnecessary-qualifier +/* eslint-disable @typescript-eslint/no-unnecessary-qualifier */ /** * Declaration module describing the TypeScript Server protocol */ @@ -127868,14 +129892,14 @@ var ts; ts.assign(this.formatSettings, formatSettings); } else { - this.formatSettings = __assign({}, this.formatSettings, formatSettings); + this.formatSettings = __assign(__assign({}, this.formatSettings), formatSettings); } } if (preferences) { if (!this.preferences) { this.preferences = ts.emptyOptions; } - this.preferences = __assign({}, this.preferences, preferences); + this.preferences = __assign(__assign({}, this.preferences), preferences); } }; ScriptInfo.prototype.getLatestVersion = function () { @@ -128253,7 +130277,7 @@ var ts; return this.typingsCache.isKnownTypesPackageName(name); }; Project.prototype.installPackage = function (options) { - return this.typingsCache.installPackage(__assign({}, options, { projectName: this.projectName, projectRootPath: this.toPath(this.currentDirectory) })); + return this.typingsCache.installPackage(__assign(__assign({}, options), { projectName: this.projectName, projectRootPath: this.toPath(this.currentDirectory) })); }; Object.defineProperty(Project.prototype, "typingsCache", { get: function () { @@ -128499,7 +130523,7 @@ var ts; // Nothing to filter out, so just return as-is return newTypeAcquisition; } - return __assign({}, newTypeAcquisition, { include: this.removeExistingTypings(newTypeAcquisition.include) }); + return __assign(__assign({}, newTypeAcquisition), { include: this.removeExistingTypings(newTypeAcquisition.include) }); }; Project.prototype.getExternalFiles = function () { var _this = this; @@ -128737,6 +130761,7 @@ var ts; * @returns: true if set of files in the project stays the same and false - otherwise. */ Project.prototype.updateGraph = function () { + ts.perfLogger.logStartUpdateGraph(); this.resolutionCache.startRecordingFilesWithChangedResolutions(); var hasNewProgram = this.updateGraphWorker(); var hasAddedorRemovedFiles = this.hasAddedorRemovedFiles; @@ -128767,6 +130792,7 @@ var ts; if (hasNewProgram) { this.projectProgramVersion++; } + ts.perfLogger.logStopUpdateGraph(); return !hasNewProgram; }; /*@internal*/ @@ -128867,9 +130893,12 @@ var ts; }, function (removed) { return _this.detachScriptInfoFromProject(removed); }); var elapsed = ts.timestamp() - start; this.writeLog("Finishing updateGraphWorker: Project: " + this.getProjectName() + " Version: " + this.getProjectVersion() + " structureChanged: " + hasNewProgram + " Elapsed: " + elapsed + "ms"); - if (this.program !== oldProgram) { + if (this.hasAddedorRemovedFiles) { this.print(); } + else if (this.program !== oldProgram) { + this.writeLog("Different program with same set of files:: oldProgram.structureIsReused:: " + (oldProgram && oldProgram.structureIsReused)); + } return hasNewProgram; }; Project.prototype.detachScriptInfoFromProject = function (uncheckedFileName, noRemoveResolution) { @@ -129056,7 +131085,7 @@ var ts; } // Search our peer node_modules, then any globally-specified probe paths // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/ - var searchPaths = [ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")].concat(this.projectService.pluginProbeLocations); + var searchPaths = __spreadArrays([ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")], this.projectService.pluginProbeLocations); if (this.projectService.globalPlugins) { var _loop_1 = function (globalPluginName) { // Skip empty names from odd commandline parses @@ -129104,7 +131133,7 @@ var ts; Project.prototype.enableProxy = function (pluginModuleFactory, configEntry) { try { if (typeof pluginModuleFactory !== "function") { - this.projectService.logger.info("Skipped loading plugin " + configEntry.name + " because it did expose a proper factory function"); + this.projectService.logger.info("Skipped loading plugin " + configEntry.name + " because it did not expose a proper factory function"); return; } var info = { @@ -129118,6 +131147,7 @@ var ts; var newLS = pluginModule.create(info); for (var _i = 0, _a = Object.keys(this.languageService); _i < _a.length; _i++) { var k = _a[_i]; + // eslint-disable-next-line no-in-operator if (!(k in newLS)) { this.projectService.logger.info("Plugin activation warning: Missing proxied method " + k + " in created LS. Patching."); newLS[k] = this.languageService[k]; @@ -129338,7 +131368,7 @@ var ts; } // Search our peer node_modules, then any globally-specified probe paths // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/ - var searchPaths = [ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")].concat(this.projectService.pluginProbeLocations); + var searchPaths = __spreadArrays([ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")], this.projectService.pluginProbeLocations); if (this.projectService.allowLocalPluginLoads) { var local = ts.getDirectoryPath(this.canonicalConfigFilePath); this.projectService.logger.info("Local plugin loading enabled; adding " + local + " to search paths"); @@ -129489,7 +131519,6 @@ var ts; server.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; /*@internal*/ server.maxFileSize = 4 * 1024 * 1024; - // tslint:disable variable-name server.ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground"; server.ProjectLoadingStartEvent = "projectLoadingStart"; server.ProjectLoadingFinishEvent = "projectLoadingFinish"; @@ -130059,7 +132088,7 @@ var ts; }; ProjectService.prototype.getPreferences = function (file) { var info = this.getScriptInfoForNormalizedPath(file); - return __assign({}, this.hostConfiguration.preferences, info && info.getPreferences()); + return __assign(__assign({}, this.hostConfiguration.preferences), info && info.getPreferences()); }; ProjectService.prototype.getHostFormatCodeOptions = function () { return this.hostConfiguration.formatCodeOptions; @@ -130823,7 +132852,7 @@ var ts; } project.enablePluginsWithOptions(compilerOptions, this.currentPluginConfigOverrides); var filesToAdd = parsedCommandLine.fileNames.concat(project.getExternalFiles()); - this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave); // TODO: GH#18217 + this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave); }; ProjectService.prototype.updateNonInferredProjectFiles = function (project, files, propertyReader) { var projectRootFilesMap = project.getRootFilesMap(); @@ -131374,12 +133403,12 @@ var ts; this.logger.info("Host information " + args.hostInfo); } if (args.formatOptions) { - this.hostConfiguration.formatCodeOptions = __assign({}, this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); + this.hostConfiguration.formatCodeOptions = __assign(__assign({}, this.hostConfiguration.formatCodeOptions), convertFormatOptions(args.formatOptions)); this.logger.info("Format host information updated"); } if (args.preferences) { var lazyConfiguredProjectsFromExternalProject = this.hostConfiguration.preferences.lazyConfiguredProjectsFromExternalProject; - this.hostConfiguration.preferences = __assign({}, this.hostConfiguration.preferences, args.preferences); + this.hostConfiguration.preferences = __assign(__assign({}, this.hostConfiguration.preferences), args.preferences); if (lazyConfiguredProjectsFromExternalProject && !this.hostConfiguration.preferences.lazyConfiguredProjectsFromExternalProject) { // Load configured projects for external projects that are pending reload this.configuredProjects.forEach(function (project) { @@ -131581,6 +133610,7 @@ var ts; var configFileName; var configFileErrors; var project = this.findExternalProjectContainingOpenScriptInfo(info); + var defaultConfigProject; if (!project && !this.syntaxOnly) { // Checking syntaxOnly is an optimization configFileName = this.getConfigFileNameForFile(info); if (configFileName) { @@ -131601,6 +133631,7 @@ var ts; // Ensure project is ready to check if it contains opened script info updateProjectIfDirty(project); } + defaultConfigProject = project; } } // Project we have at this point is going to be updated since its either found through @@ -131617,12 +133648,12 @@ var ts; this.assignOrphanScriptInfoToInferredProject(info, this.openFiles.get(info.path)); } ts.Debug.assert(!info.isOrphan()); - return { configFileName: configFileName, configFileErrors: configFileErrors }; + return { configFileName: configFileName, configFileErrors: configFileErrors, defaultConfigProject: defaultConfigProject }; }; - ProjectService.prototype.cleanupAfterOpeningFile = function () { + ProjectService.prototype.cleanupAfterOpeningFile = function (toRetainConfigProjects) { // This was postponed from closeOpenFile to after opening next file, // so that we can reuse the project if we need to right away - this.removeOrphanConfiguredProjects(); + this.removeOrphanConfiguredProjects(toRetainConfigProjects); // Remove orphan inferred projects now that we have reused projects // We need to create a duplicate because we cant guarantee order after removal for (var _i = 0, _a = this.inferredProjects.slice(); _i < _a.length; _i++) { @@ -131636,25 +133667,33 @@ var ts; // It was then postponed to cleanup these script infos so that they can be reused if // the file from that old project is reopened because of opening file from here. this.removeOrphanScriptInfos(); - this.printProjects(); }; ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent, projectRootPath) { var info = this.getOrCreateOpenScriptInfo(fileName, fileContent, scriptKind, hasMixedContent, projectRootPath); - var result = this.assignProjectToOpenedScriptInfo(info); - this.cleanupAfterOpeningFile(); + var _a = this.assignProjectToOpenedScriptInfo(info), defaultConfigProject = _a.defaultConfigProject, result = __rest(_a, ["defaultConfigProject"]); + this.cleanupAfterOpeningFile(defaultConfigProject); this.telemetryOnOpenFile(info); + this.printProjects(); return result; }; - ProjectService.prototype.removeOrphanConfiguredProjects = function () { + ProjectService.prototype.removeOrphanConfiguredProjects = function (toRetainConfiguredProjects) { var _this = this; var toRemoveConfiguredProjects = ts.cloneMap(this.configuredProjects); + if (toRetainConfiguredProjects) { + if (ts.isArray(toRetainConfiguredProjects)) { + toRetainConfiguredProjects.forEach(retainConfiguredProject); + } + else { + retainConfiguredProject(toRetainConfiguredProjects); + } + } // Do not remove configured projects that are used as original projects of other this.inferredProjects.forEach(markOriginalProjectsAsUsed); this.externalProjects.forEach(markOriginalProjectsAsUsed); this.configuredProjects.forEach(function (project) { // If project has open ref (there are more than zero references from external project/open file), keep it alive as well as any project it references if (project.hasOpenRef()) { - toRemoveConfiguredProjects.delete(project.canonicalConfigFilePath); + retainConfiguredProject(project); markOriginalProjectsAsUsed(project); } else { @@ -131663,7 +133702,7 @@ var ts; if (ref) { var refProject = _this.configuredProjects.get(ref.sourceFile.path); if (refProject && refProject.hasOpenRef()) { - toRemoveConfiguredProjects.delete(project.canonicalConfigFilePath); + retainConfiguredProject(project); } } }); @@ -131676,6 +133715,9 @@ var ts; project.originalConfiguredProjects.forEach(function (_value, configuredProjectPath) { return toRemoveConfiguredProjects.delete(configuredProjectPath); }); } } + function retainConfiguredProject(project) { + toRemoveConfiguredProjects.delete(project.canonicalConfigFilePath); + } }; ProjectService.prototype.removeOrphanScriptInfos = function () { var _this = this; @@ -131803,18 +133845,24 @@ var ts; } } // All the script infos now exist, so ok to go update projects for open files + var defaultConfigProjects; if (openScriptInfos) { - openScriptInfos.forEach(function (info) { return _this.assignProjectToOpenedScriptInfo(info); }); + defaultConfigProjects = ts.mapDefined(openScriptInfos, function (info) { return _this.assignProjectToOpenedScriptInfo(info).defaultConfigProject; }); } // While closing files there could be open files that needed assigning new inferred projects, do it now if (assignOrphanScriptInfosToInferredProject) { this.assignOrphanScriptInfosToInferredProject(); } - // Cleanup projects - this.cleanupAfterOpeningFile(); - // Telemetry - ts.forEach(openScriptInfos, function (info) { return _this.telemetryOnOpenFile(info); }); - this.printProjects(); + if (openScriptInfos) { + // Cleanup projects + this.cleanupAfterOpeningFile(defaultConfigProjects); + // Telemetry + openScriptInfos.forEach(function (info) { return _this.telemetryOnOpenFile(info); }); + this.printProjects(); + } + else if (ts.length(closedFiles)) { + this.printProjects(); + } }; /* @internal */ ProjectService.prototype.applyChangesToFile = function (scriptInfo, changes) { @@ -132186,6 +134234,9 @@ var ts; } return false; } + function dtsChangeCanAffectEmit(compilationSettings) { + return ts.getEmitDeclarations(compilationSettings) || !!compilationSettings.emitDecoratorMetadata; + } function formatDiag(fileName, project, diag) { var scriptInfo = project.getScriptInfoForNormalizedPath(fileName); // TODO: GH#18217 return { @@ -132238,12 +134289,12 @@ var ts; relatedInformation: ts.map(diag.relatedInformation, formatRelatedInformation), }; return includeFileName - ? __assign({}, common, { fileName: diag.file && diag.file.fileName }) : common; + ? __assign(__assign({}, common), { fileName: diag.file && diag.file.fileName }) : common; } function allEditsBeforePos(edits, pos) { return edits.every(function (edit) { return ts.textSpanEnd(edit.span) < pos; }); } - server.CommandNames = server.protocol.CommandTypes; // tslint:disable-line variable-name + server.CommandNames = server.protocol.CommandTypes; function formatMessage(msg, logger, byteLength, newLine) { var verboseLogging = logger.hasLevel(server.LogLevel.verbose); var json = JSON.stringify(msg); @@ -132402,7 +134453,7 @@ var ts; var _loop_8 = function (outputReferencedSymbol) { var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(outputReferencedSymbol.definition)); var definition = mappedDefinitionFile === undefined ? - outputReferencedSymbol.definition : __assign({}, outputReferencedSymbol.definition, { textSpan: ts.createTextSpan(mappedDefinitionFile.pos, outputReferencedSymbol.definition.textSpan.length), fileName: mappedDefinitionFile.fileName, contextSpan: getMappedContextSpan(outputReferencedSymbol.definition, project) }); + outputReferencedSymbol.definition : __assign(__assign({}, outputReferencedSymbol.definition), { textSpan: ts.createTextSpan(mappedDefinitionFile.pos, outputReferencedSymbol.definition.textSpan.length), fileName: mappedDefinitionFile.fileName, contextSpan: getMappedContextSpan(outputReferencedSymbol.definition, project) }); var symbolToAddTo = ts.find(outputs, function (o) { return ts.documentSpansEqual(o.definition, definition); }); if (!symbolToAddTo) { symbolToAddTo = { definition: definition, references: [] }; @@ -132532,8 +134583,8 @@ var ts; } var Session = /** @class */ (function () { function Session(opts) { - var _this = this; var _a; + var _this = this; this.changeSeq = 0; this.handlers = ts.createMapFromTemplate((_a = {}, _a[server.CommandNames.Status] = function () { @@ -133000,9 +135051,10 @@ var ts; msg += "\n\nFile text of " + fileRequest.file + ":" + server.indent(text) + "\n"; } } - catch (_b) { } // tslint:disable-line no-empty + catch (_b) { } // eslint-disable-line no-empty } - if (err.message && err.message.indexOf("Could not find sourceFile:") !== -1) { + if (err.ProgramFiles) { + msg += "\n\nProgram files: " + JSON.stringify(err.ProgramFiles) + "\n"; msg += "\n\nProjects::\n"; var counter_1 = 0; var addProjectInfo = function (project) { @@ -133025,7 +135077,9 @@ var ts; } return; } - this.host.write(formatMessage(msg, this.logger, this.byteLength, this.host.newLine)); + var msgText = formatMessage(msg, this.logger, this.byteLength, this.host.newLine); + ts.perfLogger.logEvent("Response message size: " + msgText.length); + this.host.write(msgText); }; Session.prototype.event = function (body, eventName) { this.send(toEvent(eventName, body)); @@ -133244,7 +135298,7 @@ var ts; Session.prototype.mapDefinitionInfoLocations = function (definitions, project) { return definitions.map(function (info) { var newDocumentSpan = getMappedDocumentSpan(info, project); - return !newDocumentSpan ? info : __assign({}, newDocumentSpan, { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }); + return !newDocumentSpan ? info : __assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }); }); }; Session.prototype.getDefinitionAndBoundSpan = function (args, simplifiedResult) { @@ -133289,7 +135343,7 @@ var ts; Session.mapToOriginalLocation = function (def) { if (def.originalFileName) { ts.Debug.assert(def.originalTextSpan !== undefined, "originalTextSpan should be present if originalFileName is"); - return __assign({}, def, { fileName: def.originalFileName, textSpan: def.originalTextSpan, targetFileName: def.fileName, targetTextSpan: def.textSpan, contextSpan: def.originalContextSpan, targetContextSpan: def.contextSpan }); + return __assign(__assign({}, def), { fileName: def.originalFileName, textSpan: def.originalTextSpan, targetFileName: def.fileName, targetTextSpan: def.textSpan, contextSpan: def.originalContextSpan, targetContextSpan: def.contextSpan }); } return def; }; @@ -133306,7 +135360,7 @@ var ts; Session.prototype.toFileSpanWithContext = function (fileName, textSpan, contextSpan, project) { var fileSpan = this.toFileSpan(fileName, textSpan, project); var context = contextSpan && this.toFileSpan(fileName, contextSpan, project); - return context ? __assign({}, fileSpan, { contextStart: context.start, contextEnd: context.end }) : + return context ? __assign(__assign({}, fileSpan), { contextStart: context.start, contextEnd: context.end }) : fileSpan; }; Session.prototype.getTypeDefinition = function (args) { @@ -133318,7 +135372,7 @@ var ts; Session.prototype.mapImplementationLocations = function (implementations, project) { return implementations.map(function (info) { var newDocumentSpan = getMappedDocumentSpan(info, project); - return !newDocumentSpan ? info : __assign({}, newDocumentSpan, { kind: info.kind, displayParts: info.displayParts }); + return !newDocumentSpan ? info : __assign(__assign({}, newDocumentSpan), { kind: info.kind, displayParts: info.displayParts }); }); }; Session.prototype.getImplementation = function (args, simplifiedResult) { @@ -133341,7 +135395,7 @@ var ts; occurrences.map(function (occurrence) { var fileName = occurrence.fileName, isWriteAccess = occurrence.isWriteAccess, textSpan = occurrence.textSpan, isInString = occurrence.isInString, contextSpan = occurrence.contextSpan; var scriptInfo = project.getScriptInfo(fileName); - return __assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo), { file: fileName, isWriteAccess: isWriteAccess }, (isInString ? { isInString: isInString } : undefined)); + return __assign(__assign(__assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo)), { file: fileName, isWriteAccess: isWriteAccess }), (isInString ? { isInString: isInString } : undefined)); }) : server.emptyArray; }; @@ -133390,7 +135444,7 @@ var ts; file: fileName, highlightSpans: highlightSpans.map(function (_a) { var textSpan = _a.textSpan, kind = _a.kind, contextSpan = _a.contextSpan; - return (__assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo), { kind: kind })); + return (__assign(__assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo)), { kind: kind })); }) }; }); @@ -133485,7 +135539,7 @@ var ts; if (!group_1) map.set(fileName, group_1 = { file: fileName, locs: [] }); var scriptInfo = ts.Debug.assertDefined(this.projectService.getScriptInfo(fileName)); - group_1.locs.push(__assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo), prefixSuffixText)); + group_1.locs.push(__assign(__assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo)), prefixSuffixText)); } return ts.arrayFrom(map.values()); }; @@ -133511,7 +135565,7 @@ var ts; var span = toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo); var lineSpan = scriptInfo.lineToTextSpan(span.start.line - 1); var lineText = scriptInfo.getSnapshot().getText(lineSpan.start, ts.textSpanEnd(lineSpan)).replace(/\r|\n/g, ""); - return __assign({ file: fileName }, span, { lineText: lineText, + return __assign(__assign({ file: fileName }, span), { lineText: lineText, isWriteAccess: isWriteAccess, isDefinition: isDefinition }); }); @@ -133713,7 +135767,7 @@ var ts; var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; var scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file); var position = this.getPosition(args, scriptInfo); - var completions = project.getLanguageService().getCompletionsAtPosition(file, position, __assign({}, server.convertUserPreferences(this.getPreferences(file)), { triggerCharacter: args.triggerCharacter, includeExternalModuleExports: args.includeExternalModuleExports, includeInsertTextCompletions: args.includeInsertTextCompletions })); + var completions = project.getLanguageService().getCompletionsAtPosition(file, position, __assign(__assign({}, server.convertUserPreferences(this.getPreferences(file))), { triggerCharacter: args.triggerCharacter, includeExternalModuleExports: args.includeExternalModuleExports, includeInsertTextCompletions: args.includeInsertTextCompletions })); if (completions === undefined) return undefined; if (kind === "completions-full" /* CompletionsFull */) @@ -133732,7 +135786,7 @@ var ts; entries.metadata = completions.metadata; return entries; } - var res = __assign({}, completions, { entries: entries }); + var res = __assign(__assign({}, completions), { entries: entries }); return res; }; Session.prototype.getCompletionEntryDetails = function (args, simplifiedResult) { @@ -133746,7 +135800,7 @@ var ts; return project.getLanguageService().getCompletionEntryDetails(file, position, name, formattingOptions, source, _this.getPreferences(file)); }); return simplifiedResult - ? result.map(function (details) { return (__assign({}, details, { codeActions: ts.map(details.codeActions, function (action) { return _this.mapCodeAction(action); }) })); }) + ? result.map(function (details) { return (__assign(__assign({}, details), { codeActions: ts.map(details.codeActions, function (action) { return _this.mapCodeAction(action); }) })); }) : result; }; Session.prototype.getCompileOnSaveAffectedFileList = function (args) { @@ -133757,15 +135811,19 @@ var ts; return server.emptyArray; } return combineProjectOutput(info, function (path) { return _this.projectService.getScriptInfoForPath(path); }, projects, function (project, info) { - var result; - if (project.compileOnSaveEnabled && project.languageServiceEnabled && !project.isOrphan() && !project.getCompilationSettings().noEmit) { - result = { - projectFileName: project.getProjectName(), - fileNames: project.getCompileOnSaveAffectedFileList(info), - projectUsesOutFile: !!project.getCompilationSettings().outFile || !!project.getCompilationSettings().out - }; + if (!project.compileOnSaveEnabled || !project.languageServiceEnabled || project.isOrphan()) { + return undefined; } - return result; + var compilationSettings = project.getCompilationSettings(); + if (!!compilationSettings.noEmit || ts.fileExtensionIs(info.fileName, ".d.ts" /* Dts */) && !dtsChangeCanAffectEmit(compilationSettings)) { + // avoid triggering emit when a change is made in a .d.ts when declaration emit and decorator metadata emit are disabled + return undefined; + } + return { + projectFileName: project.getProjectName(), + fileNames: project.getCompileOnSaveAffectedFileList(info), + projectUsesOutFile: !!compilationSettings.outFile || !!compilationSettings.out + }; }); }; Session.prototype.emitFile = function (args) { @@ -134156,7 +136214,7 @@ var ts; } } } - var sortedFiles = highPriorityFiles.concat(mediumPriorityFiles, lowPriorityFiles, veryLowPriorityFiles); + var sortedFiles = __spreadArrays(highPriorityFiles, mediumPriorityFiles, lowPriorityFiles, veryLowPriorityFiles); var checkList = sortedFiles.map(function (fileName) { return ({ fileName: fileName, project: project }); }); // Project level error analysis runs on background files too, therefore // doesn't require the file to be opened @@ -134246,6 +136304,7 @@ var ts; try { request = JSON.parse(message); relevantFile = request.arguments && request.arguments.file ? request.arguments : undefined; + ts.perfLogger.logStartCommand("" + request.command, message.substring(0, 100)); var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired; if (this.logger.hasLevel(server.LogLevel.requestTime)) { var elapsedTime = hrTimeToMilliseconds(this.hrtime(start)).toFixed(4); @@ -134256,6 +136315,8 @@ var ts; this.logger.perftrc(request.seq + "::" + request.command + ": async elapsed time (in milliseconds) " + elapsedTime); } } + // Note: Log before writing the response, else the editor can complete its activity before the server does + ts.perfLogger.logStopCommand("" + request.command, "Success"); if (response) { this.doOutput(response, request.command, request.seq, /*success*/ true); } @@ -134266,10 +136327,12 @@ var ts; catch (err) { if (err instanceof ts.OperationCanceledException) { // Handle cancellation exceptions + ts.perfLogger.logStopCommand("" + (request && request.command), "Canceled: " + err); this.doOutput({ canceled: true }, request.command, request.seq, /*success*/ true); return; } this.logErrorWorker(err, message, relevantFile); + ts.perfLogger.logStopCommand("" + (request && request.command), "Error: " + err); this.doOutput( /*info*/ undefined, request ? request.command : server.CommandNames.Unknown, request ? request.seq : 0, /*success*/ false, "Error processing request. " + err.message + "\n" + err.stack); @@ -134299,7 +136362,7 @@ var ts; function toProtocolTextSpanWithContext(span, contextSpan, scriptInfo) { var textSpan = toProcolTextSpan(span, scriptInfo); var contextTextSpan = contextSpan && toProcolTextSpan(contextSpan, scriptInfo); - return contextTextSpan ? __assign({}, textSpan, { contextStart: contextTextSpan.start, contextEnd: contextTextSpan.end }) : + return contextTextSpan ? __assign(__assign({}, textSpan), { contextStart: contextTextSpan.start, contextEnd: contextTextSpan.end }) : textSpan; } function convertTextChangeToCodeEdit(change, scriptInfo) { diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 7a2559bbc2242..e1a04fe461c42 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "3.6"; + const versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ const version: string; } @@ -65,17 +65,17 @@ declare namespace ts { } } declare namespace ts { - type Path = string & { + export type Path = string & { __pathBrand: any; }; - interface TextRange { + export interface TextRange { pos: number; end: number; } - type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; - type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | 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.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | 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 | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; - type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; - enum SyntaxKind { + export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; + export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | 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.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | 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 | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.TagKeyword | SyntaxKind.OfKeyword; + export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; + export enum SyntaxKind { Unknown = 0, EndOfFileToken = 1, SingleLineCommentTrivia = 2, @@ -225,178 +225,180 @@ declare namespace ts { FromKeyword = 145, GlobalKeyword = 146, BigIntKeyword = 147, - OfKeyword = 148, - QualifiedName = 149, - ComputedPropertyName = 150, - TypeParameter = 151, - Parameter = 152, - Decorator = 153, - PropertySignature = 154, - PropertyDeclaration = 155, - MethodSignature = 156, - MethodDeclaration = 157, - Constructor = 158, - GetAccessor = 159, - SetAccessor = 160, - CallSignature = 161, - ConstructSignature = 162, - IndexSignature = 163, - TypePredicate = 164, - TypeReference = 165, - FunctionType = 166, - ConstructorType = 167, - TypeQuery = 168, - TypeLiteral = 169, - ArrayType = 170, - TupleType = 171, - OptionalType = 172, - RestType = 173, - UnionType = 174, - IntersectionType = 175, - ConditionalType = 176, - InferType = 177, - ParenthesizedType = 178, - ThisType = 179, - TypeOperator = 180, - IndexedAccessType = 181, - MappedType = 182, - LiteralType = 183, - ImportType = 184, - ObjectBindingPattern = 185, - ArrayBindingPattern = 186, - BindingElement = 187, - ArrayLiteralExpression = 188, - ObjectLiteralExpression = 189, - PropertyAccessExpression = 190, - ElementAccessExpression = 191, - CallExpression = 192, - NewExpression = 193, - TaggedTemplateExpression = 194, - TypeAssertionExpression = 195, - ParenthesizedExpression = 196, - FunctionExpression = 197, - ArrowFunction = 198, - DeleteExpression = 199, - TypeOfExpression = 200, - VoidExpression = 201, - AwaitExpression = 202, - PrefixUnaryExpression = 203, - PostfixUnaryExpression = 204, - BinaryExpression = 205, - ConditionalExpression = 206, - TemplateExpression = 207, - YieldExpression = 208, - SpreadElement = 209, - ClassExpression = 210, - OmittedExpression = 211, - ExpressionWithTypeArguments = 212, - AsExpression = 213, - NonNullExpression = 214, - MetaProperty = 215, - SyntheticExpression = 216, - TemplateSpan = 217, - SemicolonClassElement = 218, - Block = 219, - VariableStatement = 220, - EmptyStatement = 221, - ExpressionStatement = 222, - IfStatement = 223, - DoStatement = 224, - WhileStatement = 225, - ForStatement = 226, - ForInStatement = 227, - ForOfStatement = 228, - ContinueStatement = 229, - BreakStatement = 230, - ReturnStatement = 231, - WithStatement = 232, - SwitchStatement = 233, - LabeledStatement = 234, - ThrowStatement = 235, - TryStatement = 236, - DebuggerStatement = 237, - VariableDeclaration = 238, - VariableDeclarationList = 239, - FunctionDeclaration = 240, - ClassDeclaration = 241, - InterfaceDeclaration = 242, - TypeAliasDeclaration = 243, - EnumDeclaration = 244, - ModuleDeclaration = 245, - ModuleBlock = 246, - CaseBlock = 247, - NamespaceExportDeclaration = 248, - ImportEqualsDeclaration = 249, - ImportDeclaration = 250, - ImportClause = 251, - NamespaceImport = 252, - NamedImports = 253, - ImportSpecifier = 254, - ExportAssignment = 255, - ExportDeclaration = 256, - NamedExports = 257, - ExportSpecifier = 258, - MissingDeclaration = 259, - ExternalModuleReference = 260, - JsxElement = 261, - JsxSelfClosingElement = 262, - JsxOpeningElement = 263, - JsxClosingElement = 264, - JsxFragment = 265, - JsxOpeningFragment = 266, - JsxClosingFragment = 267, - JsxAttribute = 268, - JsxAttributes = 269, - JsxSpreadAttribute = 270, - JsxExpression = 271, - CaseClause = 272, - DefaultClause = 273, - HeritageClause = 274, - CatchClause = 275, - PropertyAssignment = 276, - ShorthandPropertyAssignment = 277, - SpreadAssignment = 278, - EnumMember = 279, - UnparsedPrologue = 280, - UnparsedPrepend = 281, - UnparsedText = 282, - UnparsedInternalText = 283, - UnparsedSyntheticReference = 284, - SourceFile = 285, - Bundle = 286, - UnparsedSource = 287, - InputFiles = 288, - JSDocTypeExpression = 289, - JSDocAllType = 290, - JSDocUnknownType = 291, - JSDocNullableType = 292, - JSDocNonNullableType = 293, - JSDocOptionalType = 294, - JSDocFunctionType = 295, - JSDocVariadicType = 296, - JSDocComment = 297, - JSDocTypeLiteral = 298, - JSDocSignature = 299, - JSDocTag = 300, - JSDocAugmentsTag = 301, - JSDocAuthorTag = 302, - JSDocClassTag = 303, - JSDocCallbackTag = 304, - JSDocEnumTag = 305, - JSDocParameterTag = 306, - JSDocReturnTag = 307, - JSDocThisTag = 308, - JSDocTypeTag = 309, - JSDocTemplateTag = 310, - JSDocTypedefTag = 311, - JSDocPropertyTag = 312, - SyntaxList = 313, - NotEmittedStatement = 314, - PartiallyEmittedExpression = 315, - CommaListExpression = 316, - MergeDeclarationMarker = 317, - EndOfDeclarationMarker = 318, - Count = 319, + TagKeyword = 148, + OfKeyword = 149, + QualifiedName = 150, + ComputedPropertyName = 151, + TypeParameter = 152, + Parameter = 153, + Decorator = 154, + PropertySignature = 155, + PropertyDeclaration = 156, + MethodSignature = 157, + MethodDeclaration = 158, + Constructor = 159, + GetAccessor = 160, + SetAccessor = 161, + CallSignature = 162, + ConstructSignature = 163, + IndexSignature = 164, + TypePredicate = 165, + TypeReference = 166, + FunctionType = 167, + ConstructorType = 168, + TypeQuery = 169, + TypeLiteral = 170, + ArrayType = 171, + TupleType = 172, + OptionalType = 173, + RestType = 174, + UnionType = 175, + IntersectionType = 176, + ConditionalType = 177, + InferType = 178, + ParenthesizedType = 179, + ThisType = 180, + TypeOperator = 181, + IndexedAccessType = 182, + MappedType = 183, + LiteralType = 184, + ImportType = 185, + ObjectBindingPattern = 186, + ArrayBindingPattern = 187, + BindingElement = 188, + ArrayLiteralExpression = 189, + ObjectLiteralExpression = 190, + PropertyAccessExpression = 191, + ElementAccessExpression = 192, + CallExpression = 193, + NewExpression = 194, + TaggedTemplateExpression = 195, + TypeAssertionExpression = 196, + ParenthesizedExpression = 197, + FunctionExpression = 198, + ArrowFunction = 199, + DeleteExpression = 200, + TypeOfExpression = 201, + VoidExpression = 202, + AwaitExpression = 203, + PrefixUnaryExpression = 204, + PostfixUnaryExpression = 205, + BinaryExpression = 206, + ConditionalExpression = 207, + TemplateExpression = 208, + YieldExpression = 209, + SpreadElement = 210, + ClassExpression = 211, + OmittedExpression = 212, + ExpressionWithTypeArguments = 213, + AsExpression = 214, + NonNullExpression = 215, + MetaProperty = 216, + SyntheticExpression = 217, + TemplateSpan = 218, + SemicolonClassElement = 219, + Block = 220, + VariableStatement = 221, + EmptyStatement = 222, + ExpressionStatement = 223, + IfStatement = 224, + DoStatement = 225, + WhileStatement = 226, + ForStatement = 227, + ForInStatement = 228, + ForOfStatement = 229, + ContinueStatement = 230, + BreakStatement = 231, + ReturnStatement = 232, + WithStatement = 233, + SwitchStatement = 234, + LabeledStatement = 235, + ThrowStatement = 236, + TryStatement = 237, + DebuggerStatement = 238, + VariableDeclaration = 239, + VariableDeclarationList = 240, + FunctionDeclaration = 241, + ClassDeclaration = 242, + InterfaceDeclaration = 243, + TypeAliasDeclaration = 244, + EnumDeclaration = 245, + ModuleDeclaration = 246, + ModuleBlock = 247, + CaseBlock = 248, + NamespaceExportDeclaration = 249, + ImportEqualsDeclaration = 250, + ImportDeclaration = 251, + ImportClause = 252, + NamespaceImport = 253, + NamedImports = 254, + ImportSpecifier = 255, + ExportAssignment = 256, + ExportDeclaration = 257, + NamedExports = 258, + ExportSpecifier = 259, + MissingDeclaration = 260, + ExternalModuleReference = 261, + JsxElement = 262, + JsxSelfClosingElement = 263, + JsxOpeningElement = 264, + JsxClosingElement = 265, + JsxFragment = 266, + JsxOpeningFragment = 267, + JsxClosingFragment = 268, + JsxAttribute = 269, + JsxAttributes = 270, + JsxSpreadAttribute = 271, + JsxExpression = 272, + CaseClause = 273, + DefaultClause = 274, + HeritageClause = 275, + CatchClause = 276, + PropertyAssignment = 277, + ShorthandPropertyAssignment = 278, + SpreadAssignment = 279, + EnumMember = 280, + UnparsedPrologue = 281, + UnparsedPrepend = 282, + UnparsedText = 283, + UnparsedInternalText = 284, + UnparsedSyntheticReference = 285, + SourceFile = 286, + Bundle = 287, + UnparsedSource = 288, + InputFiles = 289, + JSDocTypeExpression = 290, + JSDocAllType = 291, + JSDocUnknownType = 292, + JSDocNullableType = 293, + JSDocNonNullableType = 294, + JSDocOptionalType = 295, + JSDocFunctionType = 296, + JSDocVariadicType = 297, + JSDocNamepathType = 298, + JSDocComment = 299, + JSDocTypeLiteral = 300, + JSDocSignature = 301, + JSDocTag = 302, + JSDocAugmentsTag = 303, + JSDocAuthorTag = 304, + JSDocClassTag = 305, + JSDocCallbackTag = 306, + JSDocEnumTag = 307, + JSDocParameterTag = 308, + JSDocReturnTag = 309, + JSDocThisTag = 310, + JSDocTypeTag = 311, + JSDocTemplateTag = 312, + JSDocTypedefTag = 313, + JSDocPropertyTag = 314, + SyntaxList = 315, + NotEmittedStatement = 316, + PartiallyEmittedExpression = 317, + CommaListExpression = 318, + MergeDeclarationMarker = 319, + EndOfDeclarationMarker = 320, + Count = 321, FirstAssignment = 60, LastAssignment = 72, FirstCompoundAssignment = 61, @@ -404,15 +406,15 @@ declare namespace ts { FirstReservedWord = 74, LastReservedWord = 109, FirstKeyword = 74, - LastKeyword = 148, + LastKeyword = 149, FirstFutureReservedWord = 110, LastFutureReservedWord = 118, - FirstTypeNode = 164, - LastTypeNode = 184, + FirstTypeNode = 165, + LastTypeNode = 185, FirstPunctuation = 18, LastPunctuation = 72, FirstToken = 0, - LastToken = 148, + LastToken = 149, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -421,13 +423,13 @@ declare namespace ts { LastTemplateToken = 17, FirstBinaryOperator = 28, LastBinaryOperator = 72, - FirstNode = 149, - FirstJSDocNode = 289, - LastJSDocNode = 312, - FirstJSDocTagNode = 300, - LastJSDocTagNode = 312, + FirstNode = 150, + FirstJSDocNode = 290, + LastJSDocNode = 314, + FirstJSDocTagNode = 302, + LastJSDocTagNode = 314, } - enum NodeFlags { + export enum NodeFlags { None = 0, Let = 1, Const = 2, @@ -456,7 +458,7 @@ declare namespace ts { ContextFlags = 12679168, TypeExcludesFlags = 20480, } - enum ModifierFlags { + export enum ModifierFlags { None = 0, Export = 1, Ambient = 2, @@ -477,7 +479,7 @@ declare namespace ts { ExportDefault = 513, All = 3071 } - enum JsxFlags { + export enum JsxFlags { None = 0, /** An element from a named property of the JSX.IntrinsicElements interface */ IntrinsicNamedElement = 1, @@ -485,40 +487,40 @@ declare namespace ts { IntrinsicIndexedElement = 2, IntrinsicElement = 3 } - interface Node extends TextRange { + export interface Node extends TextRange { kind: SyntaxKind; flags: NodeFlags; decorators?: NodeArray; modifiers?: ModifiersArray; parent: Node; } - interface JSDocContainer { + export interface JSDocContainer { } - 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 | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | EndOfFileToken; - type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; - type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; - type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertySignature | PropertyDeclaration | PropertyAssignment | EnumMember; - interface NodeArray extends ReadonlyArray, TextRange { + 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 | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | EndOfFileToken; + export type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; + export type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; + export type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertySignature | PropertyDeclaration | PropertyAssignment | EnumMember; + export interface NodeArray extends ReadonlyArray, TextRange { hasTrailingComma?: boolean; } - interface Token extends Node { + export interface Token extends Node { kind: TKind; } - type DotDotDotToken = Token; - type QuestionToken = Token; - type ExclamationToken = Token; - type ColonToken = Token; - type EqualsToken = Token; - type AsteriskToken = Token; - type EqualsGreaterThanToken = Token; - type EndOfFileToken = Token & JSDocContainer; - type ReadonlyToken = Token; - type AwaitKeywordToken = Token; - type PlusToken = Token; - type MinusToken = Token; - type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; - type ModifiersArray = NodeArray; - interface Identifier extends PrimaryExpression, Declaration { + export type DotDotDotToken = Token; + export type QuestionToken = Token; + export type ExclamationToken = Token; + export type ColonToken = Token; + export type EqualsToken = Token; + export type AsteriskToken = Token; + export type EqualsGreaterThanToken = Token; + export type EndOfFileToken = Token & JSDocContainer; + export type ReadonlyToken = Token; + export type AwaitKeywordToken = Token; + export type PlusToken = Token; + export type MinusToken = Token; + export type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; + export type ModifiersArray = NodeArray; + export interface Identifier extends PrimaryExpression, Declaration { kind: SyntaxKind.Identifier; /** * Prefer to use `id.unescapedText`. (Note: This is available only in services, not internally to the TypeScript compiler.) @@ -528,37 +530,37 @@ declare namespace ts { originalKeywordKind?: SyntaxKind; isInJSDocNamespace?: boolean; } - interface TransientIdentifier extends Identifier { + export interface TransientIdentifier extends Identifier { resolvedSymbol: Symbol; } - interface QualifiedName extends Node { + export interface QualifiedName extends Node { kind: SyntaxKind.QualifiedName; left: EntityName; right: Identifier; } - type EntityName = Identifier | QualifiedName; - type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName; - type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | BindingPattern; - interface Declaration extends Node { + export type EntityName = Identifier | QualifiedName; + export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName; + export type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | BindingPattern; + export interface Declaration extends Node { _declarationBrand: any; } - interface NamedDeclaration extends Declaration { + export interface NamedDeclaration extends Declaration { name?: DeclarationName; } - interface DeclarationStatement extends NamedDeclaration, Statement { + export interface DeclarationStatement extends NamedDeclaration, Statement { name?: Identifier | StringLiteral | NumericLiteral; } - interface ComputedPropertyName extends Node { + export interface ComputedPropertyName extends Node { parent: Declaration; kind: SyntaxKind.ComputedPropertyName; expression: Expression; } - interface Decorator extends Node { + export interface Decorator extends Node { kind: SyntaxKind.Decorator; parent: NamedDeclaration; expression: LeftHandSideExpression; } - interface TypeParameterDeclaration extends NamedDeclaration { + export interface TypeParameterDeclaration extends NamedDeclaration { kind: SyntaxKind.TypeParameter; parent: DeclarationWithTypeParameterChildren | InferTypeNode; name: Identifier; @@ -567,22 +569,22 @@ declare namespace ts { default?: TypeNode; expression?: Expression; } - interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { + export interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SignatureDeclaration["kind"]; name?: PropertyName; typeParameters?: NodeArray; parameters: NodeArray; type?: TypeNode; } - type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; - interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { + export type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; + export interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.CallSignature; } - interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement { + export interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.ConstructSignature; } - type BindingName = Identifier | BindingPattern; - interface VariableDeclaration extends NamedDeclaration { + export type BindingName = Identifier | BindingPattern; + export interface VariableDeclaration extends NamedDeclaration { kind: SyntaxKind.VariableDeclaration; parent: VariableDeclarationList | CatchClause; name: BindingName; @@ -590,12 +592,12 @@ declare namespace ts { type?: TypeNode; initializer?: Expression; } - interface VariableDeclarationList extends Node { + export interface VariableDeclarationList extends Node { kind: SyntaxKind.VariableDeclarationList; parent: VariableStatement | ForStatement | ForOfStatement | ForInStatement; declarations: NodeArray; } - interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { + export interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.Parameter; parent: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; @@ -604,7 +606,7 @@ declare namespace ts { type?: TypeNode; initializer?: Expression; } - interface BindingElement extends NamedDeclaration { + export interface BindingElement extends NamedDeclaration { kind: SyntaxKind.BindingElement; parent: BindingPattern; propertyName?: PropertyName; @@ -612,14 +614,14 @@ declare namespace ts { name: BindingName; initializer?: Expression; } - interface PropertySignature extends TypeElement, JSDocContainer { + export interface PropertySignature extends TypeElement, JSDocContainer { kind: SyntaxKind.PropertySignature; name: PropertyName; questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } - interface PropertyDeclaration extends ClassElement, JSDocContainer { + export interface PropertyDeclaration extends ClassElement, JSDocContainer { kind: SyntaxKind.PropertyDeclaration; parent: ClassLikeDeclaration; name: PropertyName; @@ -628,20 +630,20 @@ declare namespace ts { type?: TypeNode; initializer?: Expression; } - interface ObjectLiteralElement extends NamedDeclaration { + export interface ObjectLiteralElement extends NamedDeclaration { _objectLiteralBrand: any; name?: PropertyName; } /** Unlike ObjectLiteralElement, excludes JSXAttribute and JSXSpreadAttribute. */ - type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration; - interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer { + export type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration; + export interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.PropertyAssignment; name: PropertyName; questionToken?: QuestionToken; initializer: Expression; } - interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { + export interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.ShorthandPropertyAssignment; name: Identifier; @@ -650,27 +652,27 @@ declare namespace ts { equalsToken?: Token; objectAssignmentInitializer?: Expression; } - interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer { + export interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.SpreadAssignment; expression: Expression; } - type VariableLikeDeclaration = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertyAssignment | PropertySignature | JsxAttribute | ShorthandPropertyAssignment | EnumMember | JSDocPropertyTag | JSDocParameterTag; - interface PropertyLikeDeclaration extends NamedDeclaration { + export type VariableLikeDeclaration = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertyAssignment | PropertySignature | JsxAttribute | ShorthandPropertyAssignment | EnumMember | JSDocPropertyTag | JSDocParameterTag; + export interface PropertyLikeDeclaration extends NamedDeclaration { name: PropertyName; } - interface ObjectBindingPattern extends Node { + export interface ObjectBindingPattern extends Node { kind: SyntaxKind.ObjectBindingPattern; parent: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } - interface ArrayBindingPattern extends Node { + export interface ArrayBindingPattern extends Node { kind: SyntaxKind.ArrayBindingPattern; parent: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } - type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; - type ArrayBindingElement = BindingElement | OmittedExpression; + export type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; + export type ArrayBindingElement = BindingElement | OmittedExpression; /** * Several node kinds share function-like features such as a signature, * a name, and a body. These nodes should extend FunctionLikeDeclarationBase. @@ -679,298 +681,298 @@ declare namespace ts { * - MethodDeclaration * - AccessorDeclaration */ - interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { + export interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { _functionLikeDeclarationBrand: any; asteriskToken?: AsteriskToken; questionToken?: QuestionToken; exclamationToken?: ExclamationToken; body?: Block | Expression; } - type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction; + export type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction; /** @deprecated Use SignatureDeclaration */ - type FunctionLike = SignatureDeclaration; - interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement { + export type FunctionLike = SignatureDeclaration; + export interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.FunctionDeclaration; name?: Identifier; body?: FunctionBody; } - interface MethodSignature extends SignatureDeclarationBase, TypeElement { + export interface MethodSignature extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.MethodSignature; parent: ObjectTypeDeclaration; name: PropertyName; } - interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.MethodDeclaration; parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } - interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { + export interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { kind: SyntaxKind.Constructor; parent: ClassLikeDeclaration; body?: FunctionBody; } /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */ - interface SemicolonClassElement extends ClassElement { + export interface SemicolonClassElement extends ClassElement { kind: SyntaxKind.SemicolonClassElement; parent: ClassLikeDeclaration; } - interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.GetAccessor; parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } - interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.SetAccessor; parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } - type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; - interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { + export type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; + export interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; parent: ObjectTypeDeclaration; } - interface TypeNode extends Node { + export interface TypeNode extends Node { _typeNodeBrand: any; } - interface KeywordTypeNode extends TypeNode { + export interface KeywordTypeNode extends TypeNode { kind: SyntaxKind.AnyKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.NumberKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; } - interface ImportTypeNode extends NodeWithTypeArguments { + export interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportType; isTypeOf?: boolean; argument: TypeNode; qualifier?: EntityName; } - interface ThisTypeNode extends TypeNode { + export interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; } - type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; - interface FunctionOrConstructorTypeNodeBase extends TypeNode, SignatureDeclarationBase { + export type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; + export interface FunctionOrConstructorTypeNodeBase extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType; type: TypeNode; } - interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase { + export interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase { kind: SyntaxKind.FunctionType; } - interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase { + export interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase { kind: SyntaxKind.ConstructorType; } - interface NodeWithTypeArguments extends TypeNode { + export interface NodeWithTypeArguments extends TypeNode { typeArguments?: NodeArray; } - type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments; - interface TypeReferenceNode extends NodeWithTypeArguments { + export type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments; + export interface TypeReferenceNode extends NodeWithTypeArguments { kind: SyntaxKind.TypeReference; typeName: EntityName; } - interface TypePredicateNode extends TypeNode { + export interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; parent: SignatureDeclaration | JSDocTypeExpression; parameterName: Identifier | ThisTypeNode; type: TypeNode; } - interface TypeQueryNode extends TypeNode { + export interface TypeQueryNode extends TypeNode { kind: SyntaxKind.TypeQuery; exprName: EntityName; } - interface TypeLiteralNode extends TypeNode, Declaration { + export interface TypeLiteralNode extends TypeNode, Declaration { kind: SyntaxKind.TypeLiteral; members: NodeArray; } - interface ArrayTypeNode extends TypeNode { + export interface ArrayTypeNode extends TypeNode { kind: SyntaxKind.ArrayType; elementType: TypeNode; } - interface TupleTypeNode extends TypeNode { + export interface TupleTypeNode extends TypeNode { kind: SyntaxKind.TupleType; elementTypes: NodeArray; } - interface OptionalTypeNode extends TypeNode { + export interface OptionalTypeNode extends TypeNode { kind: SyntaxKind.OptionalType; type: TypeNode; } - interface RestTypeNode extends TypeNode { + export interface RestTypeNode extends TypeNode { kind: SyntaxKind.RestType; type: TypeNode; } - type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; - interface UnionTypeNode extends TypeNode { + export type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; + export interface UnionTypeNode extends TypeNode { kind: SyntaxKind.UnionType; types: NodeArray; } - interface IntersectionTypeNode extends TypeNode { + export interface IntersectionTypeNode extends TypeNode { kind: SyntaxKind.IntersectionType; types: NodeArray; } - interface ConditionalTypeNode extends TypeNode { + export interface ConditionalTypeNode extends TypeNode { kind: SyntaxKind.ConditionalType; checkType: TypeNode; extendsType: TypeNode; trueType: TypeNode; falseType: TypeNode; } - interface InferTypeNode extends TypeNode { + export interface InferTypeNode extends TypeNode { kind: SyntaxKind.InferType; typeParameter: TypeParameterDeclaration; } - interface ParenthesizedTypeNode extends TypeNode { + export interface ParenthesizedTypeNode extends TypeNode { kind: SyntaxKind.ParenthesizedType; type: TypeNode; } - interface TypeOperatorNode extends TypeNode { + export interface TypeOperatorNode extends TypeNode { kind: SyntaxKind.TypeOperator; - operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword; + operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.TagKeyword; type: TypeNode; } - interface IndexedAccessTypeNode extends TypeNode { + export interface IndexedAccessTypeNode extends TypeNode { kind: SyntaxKind.IndexedAccessType; objectType: TypeNode; indexType: TypeNode; } - interface MappedTypeNode extends TypeNode, Declaration { + export interface MappedTypeNode extends TypeNode, Declaration { kind: SyntaxKind.MappedType; readonlyToken?: ReadonlyToken | PlusToken | MinusToken; typeParameter: TypeParameterDeclaration; questionToken?: QuestionToken | PlusToken | MinusToken; type?: TypeNode; } - interface LiteralTypeNode extends TypeNode { + export interface LiteralTypeNode extends TypeNode { kind: SyntaxKind.LiteralType; literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } - interface StringLiteral extends LiteralExpression { + export interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; } - type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; - interface Expression extends Node { + export type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; + export interface Expression extends Node { _expressionBrand: any; } - interface OmittedExpression extends Expression { + export interface OmittedExpression extends Expression { kind: SyntaxKind.OmittedExpression; } - interface PartiallyEmittedExpression extends LeftHandSideExpression { + export interface PartiallyEmittedExpression extends LeftHandSideExpression { kind: SyntaxKind.PartiallyEmittedExpression; expression: Expression; } - interface UnaryExpression extends Expression { + export interface UnaryExpression extends Expression { _unaryExpressionBrand: any; } /** Deprecated, please use UpdateExpression */ - type IncrementExpression = UpdateExpression; - interface UpdateExpression extends UnaryExpression { + export type IncrementExpression = UpdateExpression; + export interface UpdateExpression extends UnaryExpression { _updateExpressionBrand: any; } - type PrefixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.TildeToken | SyntaxKind.ExclamationToken; - interface PrefixUnaryExpression extends UpdateExpression { + export type PrefixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.TildeToken | SyntaxKind.ExclamationToken; + export interface PrefixUnaryExpression extends UpdateExpression { kind: SyntaxKind.PrefixUnaryExpression; operator: PrefixUnaryOperator; operand: UnaryExpression; } - type PostfixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken; - interface PostfixUnaryExpression extends UpdateExpression { + export type PostfixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken; + export interface PostfixUnaryExpression extends UpdateExpression { kind: SyntaxKind.PostfixUnaryExpression; operand: LeftHandSideExpression; operator: PostfixUnaryOperator; } - interface LeftHandSideExpression extends UpdateExpression { + export interface LeftHandSideExpression extends UpdateExpression { _leftHandSideExpressionBrand: any; } - interface MemberExpression extends LeftHandSideExpression { + export interface MemberExpression extends LeftHandSideExpression { _memberExpressionBrand: any; } - interface PrimaryExpression extends MemberExpression { + export interface PrimaryExpression extends MemberExpression { _primaryExpressionBrand: any; } - interface NullLiteral extends PrimaryExpression, TypeNode { + export interface NullLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.NullKeyword; } - interface BooleanLiteral extends PrimaryExpression, TypeNode { + export interface BooleanLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword; } - interface ThisExpression extends PrimaryExpression, KeywordTypeNode { + export interface ThisExpression extends PrimaryExpression, KeywordTypeNode { kind: SyntaxKind.ThisKeyword; } - interface SuperExpression extends PrimaryExpression { + export interface SuperExpression extends PrimaryExpression { kind: SyntaxKind.SuperKeyword; } - interface ImportExpression extends PrimaryExpression { + export interface ImportExpression extends PrimaryExpression { kind: SyntaxKind.ImportKeyword; } - interface DeleteExpression extends UnaryExpression { + export interface DeleteExpression extends UnaryExpression { kind: SyntaxKind.DeleteExpression; expression: UnaryExpression; } - interface TypeOfExpression extends UnaryExpression { + export interface TypeOfExpression extends UnaryExpression { kind: SyntaxKind.TypeOfExpression; expression: UnaryExpression; } - interface VoidExpression extends UnaryExpression { + export interface VoidExpression extends UnaryExpression { kind: SyntaxKind.VoidExpression; expression: UnaryExpression; } - interface AwaitExpression extends UnaryExpression { + export interface AwaitExpression extends UnaryExpression { kind: SyntaxKind.AwaitExpression; expression: UnaryExpression; } - interface YieldExpression extends Expression { + export interface YieldExpression extends Expression { kind: SyntaxKind.YieldExpression; asteriskToken?: AsteriskToken; expression?: Expression; } - interface SyntheticExpression extends Expression { + export interface SyntheticExpression extends Expression { kind: SyntaxKind.SyntheticExpression; isSpread: boolean; type: Type; } - type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; - type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; - type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; - type AdditiveOperator = SyntaxKind.PlusToken | SyntaxKind.MinusToken; - type AdditiveOperatorOrHigher = MultiplicativeOperatorOrHigher | AdditiveOperator; - type ShiftOperator = SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken; - type ShiftOperatorOrHigher = AdditiveOperatorOrHigher | ShiftOperator; - type RelationalOperator = SyntaxKind.LessThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.InstanceOfKeyword | SyntaxKind.InKeyword; - type RelationalOperatorOrHigher = ShiftOperatorOrHigher | RelationalOperator; - type EqualityOperator = SyntaxKind.EqualsEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.ExclamationEqualsToken; - type EqualityOperatorOrHigher = RelationalOperatorOrHigher | EqualityOperator; - type BitwiseOperator = SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken; - type BitwiseOperatorOrHigher = EqualityOperatorOrHigher | BitwiseOperator; - type LogicalOperator = SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken; - type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; - type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken; - type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; - type AssignmentOperatorOrHigher = LogicalOperatorOrHigher | AssignmentOperator; - type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; - type BinaryOperatorToken = Token; - interface BinaryExpression extends Expression, Declaration { + export type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; + export type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; + export type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; + export type AdditiveOperator = SyntaxKind.PlusToken | SyntaxKind.MinusToken; + export type AdditiveOperatorOrHigher = MultiplicativeOperatorOrHigher | AdditiveOperator; + export type ShiftOperator = SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken; + export type ShiftOperatorOrHigher = AdditiveOperatorOrHigher | ShiftOperator; + export type RelationalOperator = SyntaxKind.LessThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.InstanceOfKeyword | SyntaxKind.InKeyword; + export type RelationalOperatorOrHigher = ShiftOperatorOrHigher | RelationalOperator; + export type EqualityOperator = SyntaxKind.EqualsEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.ExclamationEqualsToken; + export type EqualityOperatorOrHigher = RelationalOperatorOrHigher | EqualityOperator; + export type BitwiseOperator = SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken; + export type BitwiseOperatorOrHigher = EqualityOperatorOrHigher | BitwiseOperator; + export type LogicalOperator = SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken; + export type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; + export type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken; + export type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; + export type AssignmentOperatorOrHigher = LogicalOperatorOrHigher | AssignmentOperator; + export type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; + export type BinaryOperatorToken = Token; + export interface BinaryExpression extends Expression, Declaration { kind: SyntaxKind.BinaryExpression; left: Expression; operatorToken: BinaryOperatorToken; right: Expression; } - type AssignmentOperatorToken = Token; - interface AssignmentExpression extends BinaryExpression { + export type AssignmentOperatorToken = Token; + export interface AssignmentExpression extends BinaryExpression { left: LeftHandSideExpression; operatorToken: TOperator; } - interface ObjectDestructuringAssignment extends AssignmentExpression { + export interface ObjectDestructuringAssignment extends AssignmentExpression { left: ObjectLiteralExpression; } - interface ArrayDestructuringAssignment extends AssignmentExpression { + export interface ArrayDestructuringAssignment extends AssignmentExpression { left: ArrayLiteralExpression; } - type DestructuringAssignment = ObjectDestructuringAssignment | ArrayDestructuringAssignment; - type BindingOrAssignmentElement = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | OmittedExpression | SpreadElement | ArrayLiteralExpression | ObjectLiteralExpression | AssignmentExpression | Identifier | PropertyAccessExpression | ElementAccessExpression; - type BindingOrAssignmentElementRestIndicator = DotDotDotToken | SpreadElement | SpreadAssignment; - type BindingOrAssignmentElementTarget = BindingOrAssignmentPattern | Identifier | PropertyAccessExpression | ElementAccessExpression | OmittedExpression; - type ObjectBindingOrAssignmentPattern = ObjectBindingPattern | ObjectLiteralExpression; - type ArrayBindingOrAssignmentPattern = ArrayBindingPattern | ArrayLiteralExpression; - type AssignmentPattern = ObjectLiteralExpression | ArrayLiteralExpression; - type BindingOrAssignmentPattern = ObjectBindingOrAssignmentPattern | ArrayBindingOrAssignmentPattern; - interface ConditionalExpression extends Expression { + export type DestructuringAssignment = ObjectDestructuringAssignment | ArrayDestructuringAssignment; + export type BindingOrAssignmentElement = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | OmittedExpression | SpreadElement | ArrayLiteralExpression | ObjectLiteralExpression | AssignmentExpression | Identifier | PropertyAccessExpression | ElementAccessExpression; + export type BindingOrAssignmentElementRestIndicator = DotDotDotToken | SpreadElement | SpreadAssignment; + export type BindingOrAssignmentElementTarget = BindingOrAssignmentPattern | Identifier | PropertyAccessExpression | ElementAccessExpression | OmittedExpression; + export type ObjectBindingOrAssignmentPattern = ObjectBindingPattern | ObjectLiteralExpression; + export type ArrayBindingOrAssignmentPattern = ArrayBindingPattern | ArrayLiteralExpression; + export type AssignmentPattern = ObjectLiteralExpression | ArrayLiteralExpression; + export type BindingOrAssignmentPattern = ObjectBindingOrAssignmentPattern | ArrayBindingOrAssignmentPattern; + export interface ConditionalExpression extends Expression { kind: SyntaxKind.ConditionalExpression; condition: Expression; questionToken: QuestionToken; @@ -978,34 +980,37 @@ declare namespace ts { colonToken: ColonToken; whenFalse: Expression; } - type FunctionBody = Block; - type ConciseBody = FunctionBody | Expression; - interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { + export type FunctionBody = Block; + export type ConciseBody = FunctionBody | Expression; + export interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.FunctionExpression; name?: Identifier; body: FunctionBody; } - interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { + export interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.ArrowFunction; equalsGreaterThanToken: EqualsGreaterThanToken; body: ConciseBody; name: never; } - interface LiteralLikeNode extends Node { + export interface LiteralLikeNode extends Node { text: string; isUnterminated?: boolean; hasExtendedUnicodeEscape?: boolean; } - interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { + export interface TemplateLiteralLikeNode extends LiteralLikeNode { + rawText?: string; + } + export interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { _literalExpressionBrand: any; } - interface RegularExpressionLiteral extends LiteralExpression { + export interface RegularExpressionLiteral extends LiteralExpression { kind: SyntaxKind.RegularExpressionLiteral; } - interface NoSubstitutionTemplateLiteral extends LiteralExpression { + export interface NoSubstitutionTemplateLiteral extends LiteralExpression, TemplateLiteralLikeNode { kind: SyntaxKind.NoSubstitutionTemplateLiteral; } - enum TokenFlags { + export enum TokenFlags { None = 0, Scientific = 16, Octal = 32, @@ -1013,45 +1018,45 @@ declare namespace ts { BinarySpecifier = 128, OctalSpecifier = 256, } - interface NumericLiteral extends LiteralExpression { + export interface NumericLiteral extends LiteralExpression { kind: SyntaxKind.NumericLiteral; } - interface BigIntLiteral extends LiteralExpression { + export interface BigIntLiteral extends LiteralExpression { kind: SyntaxKind.BigIntLiteral; } - interface TemplateHead extends LiteralLikeNode { + export interface TemplateHead extends TemplateLiteralLikeNode { kind: SyntaxKind.TemplateHead; parent: TemplateExpression; } - interface TemplateMiddle extends LiteralLikeNode { + export interface TemplateMiddle extends TemplateLiteralLikeNode { kind: SyntaxKind.TemplateMiddle; parent: TemplateSpan; } - interface TemplateTail extends LiteralLikeNode { + export interface TemplateTail extends TemplateLiteralLikeNode { kind: SyntaxKind.TemplateTail; parent: TemplateSpan; } - type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; - interface TemplateExpression extends PrimaryExpression { + export type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; + export interface TemplateExpression extends PrimaryExpression { kind: SyntaxKind.TemplateExpression; head: TemplateHead; templateSpans: NodeArray; } - interface TemplateSpan extends Node { + export interface TemplateSpan extends Node { kind: SyntaxKind.TemplateSpan; parent: TemplateExpression; expression: Expression; literal: TemplateMiddle | TemplateTail; } - interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer { + export interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer { kind: SyntaxKind.ParenthesizedExpression; expression: Expression; } - interface ArrayLiteralExpression extends PrimaryExpression { + export interface ArrayLiteralExpression extends PrimaryExpression { kind: SyntaxKind.ArrayLiteralExpression; elements: NodeArray; } - interface SpreadElement extends Expression { + export interface SpreadElement extends Expression { kind: SyntaxKind.SpreadElement; parent: ArrayLiteralExpression | CallExpression | NewExpression; expression: Expression; @@ -1062,413 +1067,413 @@ declare namespace ts { * JSXAttribute or JSXSpreadAttribute. ObjectLiteralExpression, on the other hand, can only have properties of type * ObjectLiteralElement (e.g. PropertyAssignment, ShorthandPropertyAssignment etc.) */ - interface ObjectLiteralExpressionBase extends PrimaryExpression, Declaration { + export interface ObjectLiteralExpressionBase extends PrimaryExpression, Declaration { properties: NodeArray; } - interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { + export interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { kind: SyntaxKind.ObjectLiteralExpression; } - type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; - type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; - interface PropertyAccessExpression extends MemberExpression, NamedDeclaration { + export type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; + export type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; + export interface PropertyAccessExpression extends MemberExpression, NamedDeclaration { kind: SyntaxKind.PropertyAccessExpression; expression: LeftHandSideExpression; name: Identifier; } - interface SuperPropertyAccessExpression extends PropertyAccessExpression { + export interface SuperPropertyAccessExpression extends PropertyAccessExpression { expression: SuperExpression; } /** Brand for a PropertyAccessExpression which, like a QualifiedName, consists of a sequence of identifiers separated by dots. */ - interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { + export interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { _propertyAccessExpressionLikeQualifiedNameBrand?: any; expression: EntityNameExpression; } - interface ElementAccessExpression extends MemberExpression { + export interface ElementAccessExpression extends MemberExpression { kind: SyntaxKind.ElementAccessExpression; expression: LeftHandSideExpression; argumentExpression: Expression; } - interface SuperElementAccessExpression extends ElementAccessExpression { + export interface SuperElementAccessExpression extends ElementAccessExpression { expression: SuperExpression; } - type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; - interface CallExpression extends LeftHandSideExpression, Declaration { + export type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; + export interface CallExpression extends LeftHandSideExpression, Declaration { kind: SyntaxKind.CallExpression; expression: LeftHandSideExpression; typeArguments?: NodeArray; arguments: NodeArray; } - interface SuperCall extends CallExpression { + export interface SuperCall extends CallExpression { expression: SuperExpression; } - interface ImportCall extends CallExpression { + export interface ImportCall extends CallExpression { expression: ImportExpression; } - interface ExpressionWithTypeArguments extends NodeWithTypeArguments { + export interface ExpressionWithTypeArguments extends NodeWithTypeArguments { kind: SyntaxKind.ExpressionWithTypeArguments; parent: HeritageClause | JSDocAugmentsTag; expression: LeftHandSideExpression; } - interface NewExpression extends PrimaryExpression, Declaration { + export interface NewExpression extends PrimaryExpression, Declaration { kind: SyntaxKind.NewExpression; expression: LeftHandSideExpression; typeArguments?: NodeArray; arguments?: NodeArray; } - interface TaggedTemplateExpression extends MemberExpression { + export interface TaggedTemplateExpression extends MemberExpression { kind: SyntaxKind.TaggedTemplateExpression; tag: LeftHandSideExpression; typeArguments?: NodeArray; template: TemplateLiteral; } - type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; - interface AsExpression extends Expression { + export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; + export interface AsExpression extends Expression { kind: SyntaxKind.AsExpression; expression: Expression; type: TypeNode; } - interface TypeAssertion extends UnaryExpression { + export interface TypeAssertion extends UnaryExpression { kind: SyntaxKind.TypeAssertionExpression; type: TypeNode; expression: UnaryExpression; } - type AssertionExpression = TypeAssertion | AsExpression; - interface NonNullExpression extends LeftHandSideExpression { + export type AssertionExpression = TypeAssertion | AsExpression; + export interface NonNullExpression extends LeftHandSideExpression { kind: SyntaxKind.NonNullExpression; expression: Expression; } - interface MetaProperty extends PrimaryExpression { + export interface MetaProperty extends PrimaryExpression { kind: SyntaxKind.MetaProperty; keywordToken: SyntaxKind.NewKeyword | SyntaxKind.ImportKeyword; name: Identifier; } - interface JsxElement extends PrimaryExpression { + export interface JsxElement extends PrimaryExpression { kind: SyntaxKind.JsxElement; openingElement: JsxOpeningElement; children: NodeArray; closingElement: JsxClosingElement; } - type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; - type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; - interface JsxTagNamePropertyAccess extends PropertyAccessExpression { + export type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; + export type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; + export type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; + export interface JsxTagNamePropertyAccess extends PropertyAccessExpression { expression: JsxTagNameExpression; } - interface JsxAttributes extends ObjectLiteralExpressionBase { + export interface JsxAttributes extends ObjectLiteralExpressionBase { kind: SyntaxKind.JsxAttributes; parent: JsxOpeningLikeElement; } - interface JsxOpeningElement extends Expression { + export interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; parent: JsxElement; tagName: JsxTagNameExpression; typeArguments?: NodeArray; attributes: JsxAttributes; } - interface JsxSelfClosingElement extends PrimaryExpression { + export interface JsxSelfClosingElement extends PrimaryExpression { kind: SyntaxKind.JsxSelfClosingElement; tagName: JsxTagNameExpression; typeArguments?: NodeArray; attributes: JsxAttributes; } - interface JsxFragment extends PrimaryExpression { + export interface JsxFragment extends PrimaryExpression { kind: SyntaxKind.JsxFragment; openingFragment: JsxOpeningFragment; children: NodeArray; closingFragment: JsxClosingFragment; } - interface JsxOpeningFragment extends Expression { + export interface JsxOpeningFragment extends Expression { kind: SyntaxKind.JsxOpeningFragment; parent: JsxFragment; } - interface JsxClosingFragment extends Expression { + export interface JsxClosingFragment extends Expression { kind: SyntaxKind.JsxClosingFragment; parent: JsxFragment; } - interface JsxAttribute extends ObjectLiteralElement { + export interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; parent: JsxAttributes; name: Identifier; initializer?: StringLiteral | JsxExpression; } - interface JsxSpreadAttribute extends ObjectLiteralElement { + export interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; parent: JsxAttributes; expression: Expression; } - interface JsxClosingElement extends Node { + export interface JsxClosingElement extends Node { kind: SyntaxKind.JsxClosingElement; parent: JsxElement; tagName: JsxTagNameExpression; } - interface JsxExpression extends Expression { + export interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; parent: JsxElement | JsxAttributeLike; dotDotDotToken?: Token; expression?: Expression; } - interface JsxText extends LiteralLikeNode { + export interface JsxText extends LiteralLikeNode { kind: SyntaxKind.JsxText; containsOnlyTriviaWhiteSpaces: boolean; parent: JsxElement; } - type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; - interface Statement extends Node { + export type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; + export interface Statement extends Node { _statementBrand: any; } - interface NotEmittedStatement extends Statement { + export interface NotEmittedStatement extends Statement { kind: SyntaxKind.NotEmittedStatement; } /** * A list of comma-separated expressions. This node is only created by transformations. */ - interface CommaListExpression extends Expression { + export interface CommaListExpression extends Expression { kind: SyntaxKind.CommaListExpression; elements: NodeArray; } - interface EmptyStatement extends Statement { + export interface EmptyStatement extends Statement { kind: SyntaxKind.EmptyStatement; } - interface DebuggerStatement extends Statement { + export interface DebuggerStatement extends Statement { kind: SyntaxKind.DebuggerStatement; } - interface MissingDeclaration extends DeclarationStatement { + export interface MissingDeclaration extends DeclarationStatement { kind: SyntaxKind.MissingDeclaration; name?: Identifier; } - type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; - interface Block extends Statement { + export type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; + export interface Block extends Statement { kind: SyntaxKind.Block; statements: NodeArray; } - interface VariableStatement extends Statement, JSDocContainer { + export interface VariableStatement extends Statement, JSDocContainer { kind: SyntaxKind.VariableStatement; declarationList: VariableDeclarationList; } - interface ExpressionStatement extends Statement, JSDocContainer { + export interface ExpressionStatement extends Statement, JSDocContainer { kind: SyntaxKind.ExpressionStatement; expression: Expression; } - interface IfStatement extends Statement { + export interface IfStatement extends Statement { kind: SyntaxKind.IfStatement; expression: Expression; thenStatement: Statement; elseStatement?: Statement; } - interface IterationStatement extends Statement { + export interface IterationStatement extends Statement { statement: Statement; } - interface DoStatement extends IterationStatement { + export interface DoStatement extends IterationStatement { kind: SyntaxKind.DoStatement; expression: Expression; } - interface WhileStatement extends IterationStatement { + export interface WhileStatement extends IterationStatement { kind: SyntaxKind.WhileStatement; expression: Expression; } - type ForInitializer = VariableDeclarationList | Expression; - interface ForStatement extends IterationStatement { + export type ForInitializer = VariableDeclarationList | Expression; + export interface ForStatement extends IterationStatement { kind: SyntaxKind.ForStatement; initializer?: ForInitializer; condition?: Expression; incrementor?: Expression; } - type ForInOrOfStatement = ForInStatement | ForOfStatement; - interface ForInStatement extends IterationStatement { + export type ForInOrOfStatement = ForInStatement | ForOfStatement; + export interface ForInStatement extends IterationStatement { kind: SyntaxKind.ForInStatement; initializer: ForInitializer; expression: Expression; } - interface ForOfStatement extends IterationStatement { + export interface ForOfStatement extends IterationStatement { kind: SyntaxKind.ForOfStatement; awaitModifier?: AwaitKeywordToken; initializer: ForInitializer; expression: Expression; } - interface BreakStatement extends Statement { + export interface BreakStatement extends Statement { kind: SyntaxKind.BreakStatement; label?: Identifier; } - interface ContinueStatement extends Statement { + export interface ContinueStatement extends Statement { kind: SyntaxKind.ContinueStatement; label?: Identifier; } - type BreakOrContinueStatement = BreakStatement | ContinueStatement; - interface ReturnStatement extends Statement { + export type BreakOrContinueStatement = BreakStatement | ContinueStatement; + export interface ReturnStatement extends Statement { kind: SyntaxKind.ReturnStatement; expression?: Expression; } - interface WithStatement extends Statement { + export interface WithStatement extends Statement { kind: SyntaxKind.WithStatement; expression: Expression; statement: Statement; } - interface SwitchStatement extends Statement { + export interface SwitchStatement extends Statement { kind: SyntaxKind.SwitchStatement; expression: Expression; caseBlock: CaseBlock; possiblyExhaustive?: boolean; } - interface CaseBlock extends Node { + export interface CaseBlock extends Node { kind: SyntaxKind.CaseBlock; parent: SwitchStatement; clauses: NodeArray; } - interface CaseClause extends Node { + export interface CaseClause extends Node { kind: SyntaxKind.CaseClause; parent: CaseBlock; expression: Expression; statements: NodeArray; } - interface DefaultClause extends Node { + export interface DefaultClause extends Node { kind: SyntaxKind.DefaultClause; parent: CaseBlock; statements: NodeArray; } - type CaseOrDefaultClause = CaseClause | DefaultClause; - interface LabeledStatement extends Statement, JSDocContainer { + export type CaseOrDefaultClause = CaseClause | DefaultClause; + export interface LabeledStatement extends Statement, JSDocContainer { kind: SyntaxKind.LabeledStatement; label: Identifier; statement: Statement; } - interface ThrowStatement extends Statement { + export interface ThrowStatement extends Statement { kind: SyntaxKind.ThrowStatement; expression?: Expression; } - interface TryStatement extends Statement { + export interface TryStatement extends Statement { kind: SyntaxKind.TryStatement; tryBlock: Block; catchClause?: CatchClause; finallyBlock?: Block; } - interface CatchClause extends Node { + export interface CatchClause extends Node { kind: SyntaxKind.CatchClause; parent: TryStatement; variableDeclaration?: VariableDeclaration; block: Block; } - type ObjectTypeDeclaration = ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode; - type DeclarationWithTypeParameters = DeclarationWithTypeParameterChildren | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature; - type DeclarationWithTypeParameterChildren = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; - interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { + export type ObjectTypeDeclaration = ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode; + export type DeclarationWithTypeParameters = DeclarationWithTypeParameterChildren | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature; + export type DeclarationWithTypeParameterChildren = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; + export interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression; name?: Identifier; typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; } - interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { + export interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.ClassDeclaration; /** May be undefined in `export default class { ... }`. */ name?: Identifier; } - interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { + export interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { kind: SyntaxKind.ClassExpression; } - type ClassLikeDeclaration = ClassDeclaration | ClassExpression; - interface ClassElement extends NamedDeclaration { + export type ClassLikeDeclaration = ClassDeclaration | ClassExpression; + export interface ClassElement extends NamedDeclaration { _classElementBrand: any; name?: PropertyName; } - interface TypeElement extends NamedDeclaration { + export interface TypeElement extends NamedDeclaration { _typeElementBrand: any; name?: PropertyName; questionToken?: QuestionToken; } - interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { + export interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.InterfaceDeclaration; name: Identifier; typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; } - interface HeritageClause extends Node { + export interface HeritageClause extends Node { kind: SyntaxKind.HeritageClause; parent: InterfaceDeclaration | ClassLikeDeclaration; token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword; types: NodeArray; } - interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { + export interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.TypeAliasDeclaration; name: Identifier; typeParameters?: NodeArray; type: TypeNode; } - interface EnumMember extends NamedDeclaration, JSDocContainer { + export interface EnumMember extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.EnumMember; parent: EnumDeclaration; name: PropertyName; initializer?: Expression; } - interface EnumDeclaration extends DeclarationStatement, JSDocContainer { + export interface EnumDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.EnumDeclaration; name: Identifier; members: NodeArray; } - type ModuleName = Identifier | StringLiteral; - type ModuleBody = NamespaceBody | JSDocNamespaceBody; - interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { + export type ModuleName = Identifier | StringLiteral; + export type ModuleBody = NamespaceBody | JSDocNamespaceBody; + export interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ModuleDeclaration; parent: ModuleBody | SourceFile; name: ModuleName; body?: ModuleBody | JSDocNamespaceDeclaration; } - type NamespaceBody = ModuleBlock | NamespaceDeclaration; - interface NamespaceDeclaration extends ModuleDeclaration { + export type NamespaceBody = ModuleBlock | NamespaceDeclaration; + export interface NamespaceDeclaration extends ModuleDeclaration { name: Identifier; body: NamespaceBody; } - type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; - interface JSDocNamespaceDeclaration extends ModuleDeclaration { + export type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; + export interface JSDocNamespaceDeclaration extends ModuleDeclaration { name: Identifier; body?: JSDocNamespaceBody; } - interface ModuleBlock extends Node, Statement { + export interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; parent: ModuleDeclaration; statements: NodeArray; } - type ModuleReference = EntityName | ExternalModuleReference; + export type ModuleReference = EntityName | ExternalModuleReference; /** * One of: * - import x = require("mod"); * - import x = M.x; */ - interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { + export interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ImportEqualsDeclaration; parent: SourceFile | ModuleBlock; name: Identifier; moduleReference: ModuleReference; } - interface ExternalModuleReference extends Node { + export interface ExternalModuleReference extends Node { kind: SyntaxKind.ExternalModuleReference; parent: ImportEqualsDeclaration; expression: Expression; } - interface ImportDeclaration extends Statement { + export interface ImportDeclaration extends Statement { kind: SyntaxKind.ImportDeclaration; parent: SourceFile | ModuleBlock; importClause?: ImportClause; /** If this is not a StringLiteral it will be a grammar error. */ moduleSpecifier: Expression; } - type NamedImportBindings = NamespaceImport | NamedImports; - interface ImportClause extends NamedDeclaration { + export type NamedImportBindings = NamespaceImport | NamedImports; + export interface ImportClause extends NamedDeclaration { kind: SyntaxKind.ImportClause; parent: ImportDeclaration; name?: Identifier; namedBindings?: NamedImportBindings; } - interface NamespaceImport extends NamedDeclaration { + export interface NamespaceImport extends NamedDeclaration { kind: SyntaxKind.NamespaceImport; parent: ImportClause; name: Identifier; } - interface NamespaceExportDeclaration extends DeclarationStatement { + export interface NamespaceExportDeclaration extends DeclarationStatement { kind: SyntaxKind.NamespaceExportDeclaration; name: Identifier; } - interface ExportDeclaration extends DeclarationStatement, JSDocContainer { + export interface ExportDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ExportDeclaration; parent: SourceFile | ModuleBlock; /** Will not be assigned in the case of `export * from "foo";` */ @@ -1476,161 +1481,166 @@ declare namespace ts { /** If this is not a StringLiteral it will be a grammar error. */ moduleSpecifier?: Expression; } - interface NamedImports extends Node { + export interface NamedImports extends Node { kind: SyntaxKind.NamedImports; parent: ImportClause; elements: NodeArray; } - interface NamedExports extends Node { + export interface NamedExports extends Node { kind: SyntaxKind.NamedExports; parent: ExportDeclaration; elements: NodeArray; } - type NamedImportsOrExports = NamedImports | NamedExports; - interface ImportSpecifier extends NamedDeclaration { + export type NamedImportsOrExports = NamedImports | NamedExports; + export interface ImportSpecifier extends NamedDeclaration { kind: SyntaxKind.ImportSpecifier; parent: NamedImports; propertyName?: Identifier; name: Identifier; } - interface ExportSpecifier extends NamedDeclaration { + export interface ExportSpecifier extends NamedDeclaration { kind: SyntaxKind.ExportSpecifier; parent: NamedExports; propertyName?: Identifier; name: Identifier; } - type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; + export type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; /** * This is either an `export =` or an `export default` declaration. * Unless `isExportEquals` is set, this node was parsed as an `export default`. */ - interface ExportAssignment extends DeclarationStatement { + export interface ExportAssignment extends DeclarationStatement { kind: SyntaxKind.ExportAssignment; parent: SourceFile; isExportEquals?: boolean; expression: Expression; } - interface FileReference extends TextRange { + export interface FileReference extends TextRange { fileName: string; } - interface CheckJsDirective extends TextRange { + export interface CheckJsDirective extends TextRange { enabled: boolean; } - type CommentKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia; - interface CommentRange extends TextRange { + export type CommentKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia; + export interface CommentRange extends TextRange { hasTrailingNewLine?: boolean; kind: CommentKind; } - interface SynthesizedComment extends CommentRange { + export interface SynthesizedComment extends CommentRange { text: string; pos: -1; end: -1; } - interface JSDocTypeExpression extends TypeNode { + export interface JSDocTypeExpression extends TypeNode { kind: SyntaxKind.JSDocTypeExpression; type: TypeNode; } - interface JSDocType extends TypeNode { + export interface JSDocType extends TypeNode { _jsDocTypeBrand: any; } - interface JSDocAllType extends JSDocType { + export interface JSDocAllType extends JSDocType { kind: SyntaxKind.JSDocAllType; } - interface JSDocUnknownType extends JSDocType { + export interface JSDocUnknownType extends JSDocType { kind: SyntaxKind.JSDocUnknownType; } - interface JSDocNonNullableType extends JSDocType { + export interface JSDocNonNullableType extends JSDocType { kind: SyntaxKind.JSDocNonNullableType; type: TypeNode; } - interface JSDocNullableType extends JSDocType { + export interface JSDocNullableType extends JSDocType { kind: SyntaxKind.JSDocNullableType; type: TypeNode; } - interface JSDocOptionalType extends JSDocType { + export interface JSDocOptionalType extends JSDocType { kind: SyntaxKind.JSDocOptionalType; type: TypeNode; } - interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase { + export interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase { kind: SyntaxKind.JSDocFunctionType; } - interface JSDocVariadicType extends JSDocType { + export interface JSDocVariadicType extends JSDocType { kind: SyntaxKind.JSDocVariadicType; type: TypeNode; } - type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; - interface JSDoc extends Node { + export interface JSDocNamepathType extends JSDocType { + kind: SyntaxKind.JSDocNamepathType; + type: TypeNode; + } + export type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; + export interface JSDoc extends Node { kind: SyntaxKind.JSDocComment; parent: HasJSDoc; tags?: NodeArray; comment?: string; } - interface JSDocTag extends Node { + export interface JSDocTag extends Node { parent: JSDoc | JSDocTypeLiteral; tagName: Identifier; comment?: string; } - interface JSDocUnknownTag extends JSDocTag { + export interface JSDocUnknownTag extends JSDocTag { kind: SyntaxKind.JSDocTag; } /** * Note that `@extends` is a synonym of `@augments`. * Both tags are represented by this interface. */ - interface JSDocAugmentsTag extends JSDocTag { + export interface JSDocAugmentsTag extends JSDocTag { kind: SyntaxKind.JSDocAugmentsTag; class: ExpressionWithTypeArguments & { expression: Identifier | PropertyAccessEntityNameExpression; }; } - interface JSDocAuthorTag extends JSDocTag { + export interface JSDocAuthorTag extends JSDocTag { kind: SyntaxKind.JSDocAuthorTag; } - interface JSDocClassTag extends JSDocTag { + export interface JSDocClassTag extends JSDocTag { kind: SyntaxKind.JSDocClassTag; } - interface JSDocEnumTag extends JSDocTag { + export interface JSDocEnumTag extends JSDocTag, Declaration { + parent: JSDoc; kind: SyntaxKind.JSDocEnumTag; typeExpression?: JSDocTypeExpression; } - interface JSDocThisTag extends JSDocTag { + export interface JSDocThisTag extends JSDocTag { kind: SyntaxKind.JSDocThisTag; typeExpression?: JSDocTypeExpression; } - interface JSDocTemplateTag extends JSDocTag { + export interface JSDocTemplateTag extends JSDocTag { kind: SyntaxKind.JSDocTemplateTag; constraint: JSDocTypeExpression | undefined; typeParameters: NodeArray; } - interface JSDocReturnTag extends JSDocTag { + export interface JSDocReturnTag extends JSDocTag { kind: SyntaxKind.JSDocReturnTag; typeExpression?: JSDocTypeExpression; } - interface JSDocTypeTag extends JSDocTag { + export interface JSDocTypeTag extends JSDocTag { kind: SyntaxKind.JSDocTypeTag; typeExpression: JSDocTypeExpression; } - interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { + export interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { parent: JSDoc; kind: SyntaxKind.JSDocTypedefTag; fullName?: JSDocNamespaceDeclaration | Identifier; name?: Identifier; typeExpression?: JSDocTypeExpression | JSDocTypeLiteral; } - interface JSDocCallbackTag extends JSDocTag, NamedDeclaration { + export interface JSDocCallbackTag extends JSDocTag, NamedDeclaration { parent: JSDoc; kind: SyntaxKind.JSDocCallbackTag; fullName?: JSDocNamespaceDeclaration | Identifier; name?: Identifier; typeExpression: JSDocSignature; } - interface JSDocSignature extends JSDocType, Declaration { + export interface JSDocSignature extends JSDocType, Declaration { kind: SyntaxKind.JSDocSignature; - typeParameters?: ReadonlyArray; - parameters: ReadonlyArray; + typeParameters?: readonly JSDocTemplateTag[]; + parameters: readonly JSDocParameterTag[]; type: JSDocReturnTag | undefined; } - interface JSDocPropertyLikeTag extends JSDocTag, Declaration { + export interface JSDocPropertyLikeTag extends JSDocTag, Declaration { parent: JSDoc; name: EntityName; typeExpression?: JSDocTypeExpression; @@ -1638,19 +1648,19 @@ declare namespace ts { isNameFirst: boolean; isBracketed: boolean; } - interface JSDocPropertyTag extends JSDocPropertyLikeTag { + export interface JSDocPropertyTag extends JSDocPropertyLikeTag { kind: SyntaxKind.JSDocPropertyTag; } - interface JSDocParameterTag extends JSDocPropertyLikeTag { + export interface JSDocParameterTag extends JSDocPropertyLikeTag { kind: SyntaxKind.JSDocParameterTag; } - interface JSDocTypeLiteral extends JSDocType { + export interface JSDocTypeLiteral extends JSDocType { kind: SyntaxKind.JSDocTypeLiteral; - jsDocPropertyTags?: ReadonlyArray; + jsDocPropertyTags?: readonly JSDocPropertyLikeTag[]; /** If true, then this type literal represents an *array* of its type. */ isArrayType?: boolean; } - enum FlowFlags { + export enum FlowFlags { Unreachable = 1, Start = 2, BranchLabel = 4, @@ -1667,65 +1677,65 @@ declare namespace ts { Label = 12, Condition = 96 } - interface FlowLock { + export interface FlowLock { locked?: boolean; } - interface AfterFinallyFlow extends FlowNodeBase, FlowLock { + export interface AfterFinallyFlow extends FlowNodeBase, FlowLock { antecedent: FlowNode; } - interface PreFinallyFlow extends FlowNodeBase { + export interface PreFinallyFlow extends FlowNodeBase { antecedent: FlowNode; lock: FlowLock; } - type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation; - interface FlowNodeBase { + export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation; + export interface FlowNodeBase { flags: FlowFlags; id?: number; } - interface FlowStart extends FlowNodeBase { + export interface FlowStart extends FlowNodeBase { container?: FunctionExpression | ArrowFunction | MethodDeclaration; } - interface FlowLabel extends FlowNodeBase { + export interface FlowLabel extends FlowNodeBase { antecedents: FlowNode[] | undefined; } - interface FlowAssignment extends FlowNodeBase { + export interface FlowAssignment extends FlowNodeBase { node: Expression | VariableDeclaration | BindingElement; antecedent: FlowNode; } - interface FlowCondition extends FlowNodeBase { + export interface FlowCondition extends FlowNodeBase { expression: Expression; antecedent: FlowNode; } - interface FlowSwitchClause extends FlowNodeBase { + export interface FlowSwitchClause extends FlowNodeBase { switchStatement: SwitchStatement; clauseStart: number; clauseEnd: number; antecedent: FlowNode; } - interface FlowArrayMutation extends FlowNodeBase { + export interface FlowArrayMutation extends FlowNodeBase { node: CallExpression | BinaryExpression; antecedent: FlowNode; } - type FlowType = Type | IncompleteType; - interface IncompleteType { + export type FlowType = Type | IncompleteType; + export interface IncompleteType { flags: TypeFlags; type: Type; } - interface AmdDependency { + export interface AmdDependency { path: string; name?: string; } - interface SourceFile extends Declaration { + export interface SourceFile extends Declaration { kind: SyntaxKind.SourceFile; statements: NodeArray; endOfFileToken: Token; fileName: string; text: string; - amdDependencies: ReadonlyArray; + amdDependencies: readonly AmdDependency[]; moduleName?: string; - referencedFiles: ReadonlyArray; - typeReferenceDirectives: ReadonlyArray; - libReferenceDirectives: ReadonlyArray; + referencedFiles: readonly FileReference[]; + typeReferenceDirectives: readonly FileReference[]; + libReferenceDirectives: readonly FileReference[]; languageVariant: LanguageVariant; isDeclarationFile: boolean; /** @@ -1739,12 +1749,12 @@ declare namespace ts { hasNoDefaultLib: boolean; languageVersion: ScriptTarget; } - interface Bundle extends Node { + export interface Bundle extends Node { kind: SyntaxKind.Bundle; - prepends: ReadonlyArray; - sourceFiles: ReadonlyArray; + prepends: readonly (InputFiles | UnparsedSource)[]; + sourceFiles: readonly SourceFile[]; } - interface InputFiles extends Node { + export interface InputFiles extends Node { kind: SyntaxKind.InputFiles; javascriptPath?: string; javascriptText: string; @@ -1755,70 +1765,70 @@ declare namespace ts { declarationMapPath?: string; declarationMapText?: string; } - interface UnparsedSource extends Node { + export interface UnparsedSource extends Node { kind: SyntaxKind.UnparsedSource; fileName: string; text: string; - prologues: ReadonlyArray; - helpers: ReadonlyArray | undefined; - referencedFiles: ReadonlyArray; - typeReferenceDirectives: ReadonlyArray | undefined; - libReferenceDirectives: ReadonlyArray; + prologues: readonly UnparsedPrologue[]; + helpers: readonly UnscopedEmitHelper[] | undefined; + referencedFiles: readonly FileReference[]; + typeReferenceDirectives: readonly string[] | undefined; + libReferenceDirectives: readonly FileReference[]; hasNoDefaultLib?: boolean; sourceMapPath?: string; sourceMapText?: string; - syntheticReferences?: ReadonlyArray; - texts: ReadonlyArray; + syntheticReferences?: readonly UnparsedSyntheticReference[]; + texts: readonly UnparsedSourceText[]; } - type UnparsedSourceText = UnparsedPrepend | UnparsedTextLike; - type UnparsedNode = UnparsedPrologue | UnparsedSourceText | UnparsedSyntheticReference; - interface UnparsedSection extends Node { + export type UnparsedSourceText = UnparsedPrepend | UnparsedTextLike; + export type UnparsedNode = UnparsedPrologue | UnparsedSourceText | UnparsedSyntheticReference; + export interface UnparsedSection extends Node { kind: SyntaxKind; data?: string; parent: UnparsedSource; } - interface UnparsedPrologue extends UnparsedSection { + export interface UnparsedPrologue extends UnparsedSection { kind: SyntaxKind.UnparsedPrologue; data: string; parent: UnparsedSource; } - interface UnparsedPrepend extends UnparsedSection { + export interface UnparsedPrepend extends UnparsedSection { kind: SyntaxKind.UnparsedPrepend; data: string; parent: UnparsedSource; - texts: ReadonlyArray; + texts: readonly UnparsedTextLike[]; } - interface UnparsedTextLike extends UnparsedSection { + export interface UnparsedTextLike extends UnparsedSection { kind: SyntaxKind.UnparsedText | SyntaxKind.UnparsedInternalText; parent: UnparsedSource; } - interface UnparsedSyntheticReference extends UnparsedSection { + export interface UnparsedSyntheticReference extends UnparsedSection { kind: SyntaxKind.UnparsedSyntheticReference; parent: UnparsedSource; } - interface JsonSourceFile extends SourceFile { + export interface JsonSourceFile extends SourceFile { statements: NodeArray; } - interface TsConfigSourceFile extends JsonSourceFile { + export interface TsConfigSourceFile extends JsonSourceFile { extendedSourceFiles?: string[]; } - interface JsonMinusNumericLiteral extends PrefixUnaryExpression { + export interface JsonMinusNumericLiteral extends PrefixUnaryExpression { kind: SyntaxKind.PrefixUnaryExpression; operator: SyntaxKind.MinusToken; operand: NumericLiteral; } - interface JsonObjectExpressionStatement extends ExpressionStatement { + export interface JsonObjectExpressionStatement extends ExpressionStatement { expression: ObjectLiteralExpression | ArrayLiteralExpression | JsonMinusNumericLiteral | NumericLiteral | StringLiteral | BooleanLiteral | NullLiteral; } - interface ScriptReferenceHost { + export interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; getSourceFile(fileName: string): SourceFile | undefined; getSourceFileByPath(path: Path): SourceFile | undefined; getCurrentDirectory(): string; } - interface ParseConfigHost { + export interface ParseConfigHost { useCaseSensitiveFileNames: boolean; - readDirectory(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): ReadonlyArray; + readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): readonly string[]; /** * Gets a value indicating whether the specified path exists and is a file. * @param path The path to test. @@ -1832,26 +1842,26 @@ declare namespace ts { * specified like "./blah" to an absolute path to an actual * tsconfig file, e.g. "/root/blah/tsconfig.json" */ - type ResolvedConfigFileName = string & { + export type ResolvedConfigFileName = string & { _isResolvedConfigFileName: never; }; - type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: ReadonlyArray) => void; - class OperationCanceledException { + export type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[]) => void; + export class OperationCanceledException { } - interface CancellationToken { + export interface CancellationToken { isCancellationRequested(): boolean; /** @throws OperationCanceledException if isCancellationRequested is true */ throwIfCancellationRequested(): void; } - interface Program extends ScriptReferenceHost { + export interface Program extends ScriptReferenceHost { /** * Get a list of root file names that were passed to a 'createProgram' */ - getRootFileNames(): ReadonlyArray; + getRootFileNames(): readonly string[]; /** * Get a list of files in the program */ - getSourceFiles(): ReadonlyArray; + getSourceFiles(): readonly SourceFile[]; /** * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then * the JavaScript and declaration files will be produced for all the files in this program. @@ -1863,33 +1873,42 @@ declare namespace ts { * will be invoked when writing the JavaScript and declaration files. */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; /** The first time this is called, it will return global diagnostics (no location). */ - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getConfigFileParsingDiagnostics(): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; /** * Gets a type checker that can be used to semantically analyze source files in the program. */ getTypeChecker(): TypeChecker; + getNodeCount(): number; + getIdentifierCount(): number; + getSymbolCount(): number; + getTypeCount(): number; + getRelationCacheSizes(): { + assignable: number; + identity: number; + subtype: number; + }; isSourceFileFromExternalLibrary(file: SourceFile): boolean; isSourceFileDefaultLibrary(file: SourceFile): boolean; - getProjectReferences(): ReadonlyArray | undefined; - getResolvedProjectReferences(): ReadonlyArray | undefined; + getProjectReferences(): readonly ProjectReference[] | undefined; + getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined; } - interface ResolvedProjectReference { + export interface ResolvedProjectReference { commandLine: ParsedCommandLine; sourceFile: SourceFile; - references?: ReadonlyArray; + references?: readonly (ResolvedProjectReference | undefined)[]; } - type CustomTransformerFactory = (context: TransformationContext) => CustomTransformer; - interface CustomTransformer { + export type CustomTransformerFactory = (context: TransformationContext) => CustomTransformer; + export interface CustomTransformer { transformSourceFile(node: SourceFile): SourceFile; transformBundle(node: Bundle): Bundle; } - interface CustomTransformers { + export interface CustomTransformers { /** Custom transformers to evaluate before built-in .js transformations. */ before?: (TransformerFactory | CustomTransformerFactory)[]; /** Custom transformers to evaluate after built-in .js transformations. */ @@ -1897,7 +1916,7 @@ declare namespace ts { /** Custom transformers to evaluate after built-in .d.ts transformations. */ afterDeclarations?: (TransformerFactory | CustomTransformerFactory)[]; } - interface SourceMapSpan { + export interface SourceMapSpan { /** Line number in the .js file. */ emittedLine: number; /** Column number in the .js file. */ @@ -1912,25 +1931,26 @@ declare namespace ts { sourceIndex: number; } /** Return code used by getEmitOutput function to indicate status of the function */ - enum ExitStatus { + export enum ExitStatus { Success = 0, DiagnosticsPresent_OutputsSkipped = 1, DiagnosticsPresent_OutputsGenerated = 2, - InvalidProject_OutputsSkipped = 3 + InvalidProject_OutputsSkipped = 3, + ProjectReferenceCycle_OutputsSkupped = 4 } - interface EmitResult { + export interface EmitResult { emitSkipped: boolean; /** Contains declaration emit diagnostics */ - diagnostics: ReadonlyArray; + diagnostics: readonly Diagnostic[]; emittedFiles?: string[]; } - interface TypeChecker { + export interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; getDeclaredTypeOfSymbol(symbol: Symbol): Type; getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol | undefined; getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined; - getSignaturesOfType(type: Type, kind: SignatureKind): ReadonlyArray; + getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined; getBaseTypes(type: InterfaceType): BaseType[]; getBaseTypeOfLiteralType(type: Type): Type; @@ -1984,7 +2004,7 @@ declare namespace ts { typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; - getRootSymbols(symbol: Symbol): ReadonlyArray; + getRootSymbols(symbol: Symbol): readonly Symbol[]; getContextualType(node: Expression): Type | undefined; /** * returns unknownSignature in the case of an error. @@ -2016,7 +2036,7 @@ declare namespace ts { */ runWithCancellationToken(token: CancellationToken, cb: (checker: TypeChecker) => T): T; } - enum NodeBuilderFlags { + export enum NodeBuilderFlags { None = 0, NoTruncation = 1, WriteArrayAsGenericType = 2, @@ -2047,7 +2067,7 @@ declare namespace ts { InInitialEntityName = 16777216, InReverseMappedType = 33554432 } - enum TypeFormatFlags { + export enum TypeFormatFlags { None = 0, NoTruncation = 1, WriteArrayAsGenericType = 2, @@ -2070,31 +2090,31 @@ declare namespace ts { /** @deprecated */ WriteOwnNameForAnyLike = 0, NodeBuilderFlagsMask = 9469291 } - enum SymbolFormatFlags { + export enum SymbolFormatFlags { None = 0, WriteTypeParametersOrArguments = 1, UseOnlyExternalAliasing = 2, AllowAnyNodeKind = 4, UseAliasDefinedOutsideCurrentScope = 8, } - enum TypePredicateKind { + export enum TypePredicateKind { This = 0, Identifier = 1 } - interface TypePredicateBase { + export interface TypePredicateBase { kind: TypePredicateKind; type: Type; } - interface ThisTypePredicate extends TypePredicateBase { + export interface ThisTypePredicate extends TypePredicateBase { kind: TypePredicateKind.This; } - interface IdentifierTypePredicate extends TypePredicateBase { + export interface IdentifierTypePredicate extends TypePredicateBase { kind: TypePredicateKind.Identifier; parameterName: string; parameterIndex: number; } - type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; - enum SymbolFlags { + export type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; + export enum SymbolFlags { None = 0, FunctionScopedVariable = 1, BlockScopedVariable = 2, @@ -2126,28 +2146,28 @@ declare namespace ts { ModuleExports = 134217728, Enum = 384, Variable = 3, - Value = 67220415, - Type = 67897832, + Value = 111551, + Type = 788968, Namespace = 1920, Module = 1536, Accessor = 98304, - FunctionScopedVariableExcludes = 67220414, - BlockScopedVariableExcludes = 67220415, - ParameterExcludes = 67220415, + FunctionScopedVariableExcludes = 111550, + BlockScopedVariableExcludes = 111551, + ParameterExcludes = 111551, PropertyExcludes = 0, - EnumMemberExcludes = 68008959, - FunctionExcludes = 67219887, - ClassExcludes = 68008383, - InterfaceExcludes = 67897736, - RegularEnumExcludes = 68008191, - ConstEnumExcludes = 68008831, + EnumMemberExcludes = 900095, + FunctionExcludes = 110991, + ClassExcludes = 899503, + InterfaceExcludes = 788872, + RegularEnumExcludes = 899327, + ConstEnumExcludes = 899967, ValueModuleExcludes = 110735, NamespaceModuleExcludes = 0, - MethodExcludes = 67212223, - GetAccessorExcludes = 67154879, - SetAccessorExcludes = 67187647, - TypeParameterExcludes = 67635688, - TypeAliasExcludes = 67897832, + MethodExcludes = 103359, + GetAccessorExcludes = 46015, + SetAccessorExcludes = 78783, + TypeParameterExcludes = 526824, + TypeAliasExcludes = 788968, AliasExcludes = 2097152, ModuleMember = 2623475, ExportHasLocal = 944, @@ -2155,7 +2175,7 @@ declare namespace ts { PropertyOrAccessor = 98308, ClassMember = 106500, } - interface Symbol { + export interface Symbol { flags: SymbolFlags; escapedName: __String; declarations: Declaration[]; @@ -2164,7 +2184,7 @@ declare namespace ts { exports?: SymbolTable; globalExports?: SymbolTable; } - enum InternalSymbolName { + export enum InternalSymbolName { Call = "__call", Constructor = "__constructor", New = "__new", @@ -2191,13 +2211,13 @@ declare namespace ts { * with a normal string (which is good, it cannot be misused on assignment or on usage), * while still being comparable with a normal string via === (also good) and castable from a string. */ - type __String = (string & { + export type __String = (string & { __escapedIdentifier: void; }) | (void & { __escapedIdentifier: void; }) | InternalSymbolName; /** ReadonlyMap where keys are `__String`s. */ - interface ReadonlyUnderscoreEscapedMap { + export interface ReadonlyUnderscoreEscapedMap { get(key: __String): T | undefined; has(key: __String): boolean; forEach(action: (value: T, key: __String) => void): void; @@ -2207,14 +2227,14 @@ declare namespace ts { entries(): Iterator<[__String, T]>; } /** Map where keys are `__String`s. */ - interface UnderscoreEscapedMap extends ReadonlyUnderscoreEscapedMap { + export interface UnderscoreEscapedMap extends ReadonlyUnderscoreEscapedMap { set(key: __String, value: T): this; delete(key: __String): boolean; clear(): void; } /** SymbolTable based on ES6 Map interface. */ - type SymbolTable = UnderscoreEscapedMap; - enum TypeFlags { + export type SymbolTable = UnderscoreEscapedMap; + export enum TypeFlags { Any = 1, Unknown = 2, String = 4, @@ -2242,6 +2262,7 @@ declare namespace ts { Conditional = 16777216, Substitution = 33554432, NonPrimitive = 67108864, + StructuralTag = 134217728, Literal = 2944, Unit = 109440, StringOrNumberLiteral = 384, @@ -2254,44 +2275,44 @@ declare namespace ts { ESSymbolLike = 12288, VoidLike = 49152, UnionOrIntersection = 3145728, - StructuredType = 3670016, + StructuredType = 137887744, TypeVariable = 8650752, InstantiableNonPrimitive = 58982400, InstantiablePrimitive = 4194304, Instantiable = 63176704, - StructuredOrInstantiable = 66846720, - Narrowable = 133970943, + StructuredOrInstantiable = 201064448, + Narrowable = 268188671, NotUnionOrUnit = 67637251, } - type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; - interface Type { + export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; + export interface Type { flags: TypeFlags; symbol: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; - aliasTypeArguments?: ReadonlyArray; + aliasTypeArguments?: readonly Type[]; } - interface LiteralType extends Type { + export interface LiteralType extends Type { value: string | number | PseudoBigInt; freshType: LiteralType; regularType: LiteralType; } - interface UniqueESSymbolType extends Type { + export interface UniqueESSymbolType extends Type { symbol: Symbol; escapedName: __String; } - interface StringLiteralType extends LiteralType { + export interface StringLiteralType extends LiteralType { value: string; } - interface NumberLiteralType extends LiteralType { + export interface NumberLiteralType extends LiteralType { value: number; } - interface BigIntLiteralType extends LiteralType { + export interface BigIntLiteralType extends LiteralType { value: PseudoBigInt; } - interface EnumType extends Type { + export interface EnumType extends Type { } - enum ObjectFlags { + export enum ObjectFlags { Class = 1, Interface = 2, Reference = 4, @@ -2311,18 +2332,18 @@ declare namespace ts { ArrayLiteral = 65536, ClassOrInterface = 3, } - interface ObjectType extends Type { + export interface ObjectType extends Type { objectFlags: ObjectFlags; } /** Class and interface types (ObjectFlags.Class and ObjectFlags.Interface). */ - interface InterfaceType extends ObjectType { + export interface InterfaceType extends ObjectType { typeParameters: TypeParameter[] | undefined; outerTypeParameters: TypeParameter[] | undefined; localTypeParameters: TypeParameter[] | undefined; thisType: TypeParameter | undefined; } - type BaseType = ObjectType | IntersectionType; - interface InterfaceTypeWithDeclaredMembers extends InterfaceType { + export type BaseType = ObjectType | IntersectionType; + export interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; declaredConstructSignatures: Signature[]; @@ -2339,49 +2360,49 @@ declare namespace ts { * if the class or interface has no type parameters and the reference isn't specifying an * explicit "this" argument. */ - interface TypeReference extends ObjectType { + export interface TypeReference extends ObjectType { target: GenericType; - typeArguments?: ReadonlyArray; + typeArguments?: readonly Type[]; } - interface GenericType extends InterfaceType, TypeReference { + export interface GenericType extends InterfaceType, TypeReference { } - interface TupleType extends GenericType { + export interface TupleType extends GenericType { minLength: number; hasRestElement: boolean; readonly: boolean; associatedNames?: __String[]; } - interface TupleTypeReference extends TypeReference { + export interface TupleTypeReference extends TypeReference { target: TupleType; } - interface UnionOrIntersectionType extends Type { + export interface UnionOrIntersectionType extends Type { types: Type[]; } - interface UnionType extends UnionOrIntersectionType { + export interface UnionType extends UnionOrIntersectionType { } - interface IntersectionType extends UnionOrIntersectionType { + export interface IntersectionType extends UnionOrIntersectionType { } - type StructuredType = ObjectType | UnionType | IntersectionType; - interface EvolvingArrayType extends ObjectType { + export type StructuredType = ObjectType | UnionType | IntersectionType | StructuralTagType; + export interface EvolvingArrayType extends ObjectType { elementType: Type; finalArrayType?: Type; } - interface InstantiableType extends Type { + export interface InstantiableType extends Type { } - interface TypeParameter extends InstantiableType { + export interface TypeParameter extends InstantiableType { } - interface IndexedAccessType extends InstantiableType { + export interface IndexedAccessType extends InstantiableType { objectType: Type; indexType: Type; constraint?: Type; simplifiedForReading?: Type; simplifiedForWriting?: Type; } - type TypeVariable = TypeParameter | IndexedAccessType; - interface IndexType extends InstantiableType { + export type TypeVariable = TypeParameter | IndexedAccessType; + export interface IndexType extends InstantiableType { type: InstantiableType | UnionOrIntersectionType; } - interface ConditionalRoot { + export interface ConditionalRoot { node: ConditionalTypeNode; checkType: Type; extendsType: Type; @@ -2394,36 +2415,39 @@ declare namespace ts { aliasSymbol?: Symbol; aliasTypeArguments?: Type[]; } - interface ConditionalType extends InstantiableType { + export interface ConditionalType extends InstantiableType { root: ConditionalRoot; checkType: Type; extendsType: Type; resolvedTrueType: Type; resolvedFalseType: Type; } - interface SubstitutionType extends InstantiableType { + export interface SubstitutionType extends InstantiableType { typeVariable: TypeVariable; substitute: Type; } - enum SignatureKind { + export interface StructuralTagType extends Type { + type: Type; + } + export enum SignatureKind { Call = 0, Construct = 1 } - interface Signature { + export interface Signature { declaration?: SignatureDeclaration | JSDocSignature; - typeParameters?: ReadonlyArray; - parameters: ReadonlyArray; + typeParameters?: readonly TypeParameter[]; + parameters: readonly Symbol[]; } - enum IndexKind { + export enum IndexKind { String = 0, Number = 1 } - interface IndexInfo { + export interface IndexInfo { type: Type; isReadonly: boolean; declaration?: IndexSignatureDeclaration; } - enum InferencePriority { + export enum InferencePriority { NakedTypeVariable = 1, HomomorphicMappedType = 2, PartialHomomorphicMappedType = 4, @@ -2432,16 +2456,18 @@ declare namespace ts { LiteralKeyof = 32, NoConstraints = 64, AlwaysStrict = 128, - PriorityImpliesCombination = 56 + MaxValue = 256, + PriorityImpliesCombination = 56, + Circularity = -1 } /** @deprecated Use FileExtensionInfo instead. */ - type JsFileExtensionInfo = FileExtensionInfo; - interface FileExtensionInfo { + export type JsFileExtensionInfo = FileExtensionInfo; + export interface FileExtensionInfo { extension: string; isMixedContent: boolean; scriptKind?: ScriptKind; } - interface DiagnosticMessage { + export interface DiagnosticMessage { key: string; category: DiagnosticCategory; code: number; @@ -2454,19 +2480,19 @@ declare namespace ts { * While it seems that DiagnosticMessageChain is structurally similar to DiagnosticMessage, * the difference is that messages are all preformatted in DMC. */ - interface DiagnosticMessageChain { + export interface DiagnosticMessageChain { messageText: string; category: DiagnosticCategory; code: number; next?: DiagnosticMessageChain[]; } - interface Diagnostic extends DiagnosticRelatedInformation { + export interface Diagnostic extends DiagnosticRelatedInformation { /** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */ reportsUnnecessary?: {}; source?: string; relatedInformation?: DiagnosticRelatedInformation[]; } - interface DiagnosticRelatedInformation { + export interface DiagnosticRelatedInformation { category: DiagnosticCategory; code: number; file: SourceFile | undefined; @@ -2474,25 +2500,25 @@ declare namespace ts { length: number | undefined; messageText: string | DiagnosticMessageChain; } - interface DiagnosticWithLocation extends Diagnostic { + export interface DiagnosticWithLocation extends Diagnostic { file: SourceFile; start: number; length: number; } - enum DiagnosticCategory { + export enum DiagnosticCategory { Warning = 0, Error = 1, Suggestion = 2, Message = 3 } - enum ModuleResolutionKind { + export enum ModuleResolutionKind { Classic = 1, NodeJs = 2 } - interface PluginImport { + export interface PluginImport { name: string; } - interface ProjectReference { + export interface ProjectReference { /** A normalized path on disk */ path: string; /** The path as the user originally wrote it */ @@ -2502,8 +2528,8 @@ declare namespace ts { /** True if it is intended that this reference form a circularity */ circular?: boolean; } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; - interface CompilerOptions { + export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; + export interface CompilerOptions { allowJs?: boolean; allowSyntheticDefaultImports?: boolean; allowUmdGlobalAccess?: boolean; @@ -2586,14 +2612,14 @@ declare namespace ts { esModuleInterop?: boolean; [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } - interface TypeAcquisition { + export interface TypeAcquisition { enableAutoDiscovery?: boolean; enable?: boolean; include?: string[]; exclude?: string[]; [option: string]: string[] | boolean | undefined; } - enum ModuleKind { + export enum ModuleKind { None = 0, CommonJS = 1, AMD = 2, @@ -2602,22 +2628,22 @@ declare namespace ts { ES2015 = 5, ESNext = 99 } - enum JsxEmit { + export enum JsxEmit { None = 0, Preserve = 1, React = 2, ReactNative = 3 } - enum NewLineKind { + export enum NewLineKind { CarriageReturnLineFeed = 0, LineFeed = 1 } - interface LineAndCharacter { + export interface LineAndCharacter { /** 0-based. */ line: number; character: number; } - enum ScriptKind { + export enum ScriptKind { Unknown = 0, JS = 1, JSX = 2, @@ -2631,7 +2657,7 @@ declare namespace ts { */ Deferred = 7 } - enum ScriptTarget { + export enum ScriptTarget { ES3 = 0, ES5 = 1, ES2015 = 2, @@ -2644,38 +2670,38 @@ declare namespace ts { JSON = 100, Latest = 99 } - enum LanguageVariant { + export enum LanguageVariant { Standard = 0, JSX = 1 } /** Either a parsed command line or a parsed tsconfig.json */ - interface ParsedCommandLine { + export interface ParsedCommandLine { options: CompilerOptions; typeAcquisition?: TypeAcquisition; fileNames: string[]; - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; raw?: any; errors: Diagnostic[]; wildcardDirectories?: MapLike; compileOnSave?: boolean; } - enum WatchDirectoryFlags { + export enum WatchDirectoryFlags { None = 0, Recursive = 1 } - interface ExpandResult { + export interface ExpandResult { fileNames: string[]; wildcardDirectories: MapLike; } - interface CreateProgramOptions { - rootNames: ReadonlyArray; + export interface CreateProgramOptions { + rootNames: readonly string[]; options: CompilerOptions; - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; host?: CompilerHost; oldProgram?: Program; - configFileParsingDiagnostics?: ReadonlyArray; + configFileParsingDiagnostics?: readonly Diagnostic[]; } - interface ModuleResolutionHost { + export interface ModuleResolutionHost { fileExists(fileName: string): boolean; readFile(fileName: string): string | undefined; trace?(s: string): void; @@ -2695,7 +2721,7 @@ declare namespace ts { * * Prefer to return a `ResolvedModuleFull` so that the file type does not have to be inferred. */ - interface ResolvedModule { + export interface ResolvedModule { /** Path of the file the module was resolved to. */ resolvedFileName: string; /** True if `resolvedFileName` comes from `node_modules`. */ @@ -2706,7 +2732,7 @@ declare namespace ts { * Prefer this over `ResolvedModule`. * If changing this, remember to change `moduleResolutionIsEqualTo`. */ - interface ResolvedModuleFull extends ResolvedModule { + export interface ResolvedModuleFull extends ResolvedModule { /** * Extension of resolvedFileName. This must match what's at the end of resolvedFileName. * This is optional for backwards-compatibility, but will be added if not provided. @@ -2718,7 +2744,7 @@ declare namespace ts { * Unique identifier with a package name and version. * If changing this, remember to change `packageIdIsEqual`. */ - interface PackageId { + export interface PackageId { /** * Name of the package. * Should not include `@types`. @@ -2733,7 +2759,7 @@ declare namespace ts { /** Version of the package, e.g. "1.2.3" */ version: string; } - enum Extension { + export enum Extension { Ts = ".ts", Tsx = ".tsx", Dts = ".d.ts", @@ -2742,21 +2768,21 @@ declare namespace ts { Json = ".json", TsBuildInfo = ".tsbuildinfo" } - interface ResolvedModuleWithFailedLookupLocations { + export interface ResolvedModuleWithFailedLookupLocations { readonly resolvedModule: ResolvedModuleFull | undefined; } - interface ResolvedTypeReferenceDirective { + export interface ResolvedTypeReferenceDirective { primary: boolean; resolvedFileName: string | undefined; packageId?: PackageId; /** True if `resolvedFileName` comes from `node_modules`. */ isExternalLibraryImport?: boolean; } - interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { + export interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; - readonly failedLookupLocations: ReadonlyArray; + readonly failedLookupLocations: readonly string[]; } - interface CompilerHost extends ModuleResolutionHost { + export interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; getCancellationToken?(): CancellationToken; @@ -2767,25 +2793,25 @@ declare namespace ts { getCanonicalFileName(fileName: string): string; useCaseSensitiveFileNames(): boolean; getNewLine(): string; - readDirectory?(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): string[]; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; + readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; /** * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[]; getEnvironmentVariable?(name: string): string | undefined; createHash?(data: string): string; getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; } - interface SourceMapRange extends TextRange { + export interface SourceMapRange extends TextRange { source?: SourceMapSource; } - interface SourceMapSource { + export interface SourceMapSource { fileName: string; text: string; skipTrivia?: (pos: number) => number; } - enum EmitFlags { + export enum EmitFlags { None = 0, SingleLine = 1, AdviseOnEmitNode = 2, @@ -2816,18 +2842,18 @@ declare namespace ts { Iterator = 8388608, NoAsciiEscaping = 16777216, } - interface EmitHelper { + export interface EmitHelper { readonly name: string; readonly scoped: boolean; readonly text: string | ((node: EmitHelperUniqueNameCallback) => string); readonly priority?: number; } - interface UnscopedEmitHelper extends EmitHelper { + export interface UnscopedEmitHelper extends EmitHelper { readonly scoped: false; readonly text: string; } - type EmitHelperUniqueNameCallback = (name: string) => string; - enum EmitHint { + export type EmitHelperUniqueNameCallback = (name: string) => string; + export enum EmitHint { SourceFile = 0, Expression = 1, IdentifierName = 2, @@ -2835,7 +2861,7 @@ declare namespace ts { Unspecified = 4, EmbeddedStatement = 5 } - interface TransformationContext { + export interface TransformationContext { /** Gets the compiler options supplied to the transformer. */ getCompilerOptions(): CompilerOptions; /** Starts a new lexical environment. */ @@ -2885,7 +2911,7 @@ declare namespace ts { */ onEmitNode: (hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) => void; } - interface TransformationResult { + export interface TransformationResult { /** Gets the transformed source files. */ transformed: T[]; /** Gets diagnostics for the transformation. */ @@ -2914,17 +2940,17 @@ declare namespace ts { * A function that is used to initialize and return a `Transformer` callback, which in turn * will be used to transform one or more nodes. */ - type TransformerFactory = (context: TransformationContext) => Transformer; + export type TransformerFactory = (context: TransformationContext) => Transformer; /** * A function that transforms a node. */ - type Transformer = (node: T) => T; + export type Transformer = (node: T) => T; /** * A function that accepts and possibly transforms a node. */ - type Visitor = (node: Node) => VisitResult; - type VisitResult = T | T[] | undefined; - interface Printer { + export type Visitor = (node: Node) => VisitResult; + export type VisitResult = T | T[] | undefined; + export interface Printer { /** * Print a node and its subtree as-is, without any emit transformations. * @param hint A value indicating the purpose of a node. This is primarily used to @@ -2952,7 +2978,7 @@ declare namespace ts { */ printBundle(bundle: Bundle): string; } - interface PrintHandlers { + export interface PrintHandlers { /** * A hook used by the Printer when generating unique names to avoid collisions with * globally defined names that exist outside of the current source file. @@ -2995,28 +3021,28 @@ declare namespace ts { */ substituteNode?(hint: EmitHint, node: Node): Node; } - interface PrinterOptions { + export interface PrinterOptions { removeComments?: boolean; newLine?: NewLineKind; omitTrailingSemicolon?: boolean; noEmitHelpers?: boolean; } - interface GetEffectiveTypeRootsHost { + export interface GetEffectiveTypeRootsHost { directoryExists?(directoryName: string): boolean; getCurrentDirectory?(): string; } - interface TextSpan { + export interface TextSpan { start: number; length: number; } - interface TextChangeRange { + export interface TextChangeRange { span: TextSpan; newLength: number; } - interface SyntaxList extends Node { + export interface SyntaxList extends Node { _children: Node[]; } - enum ListFormat { + export enum ListFormat { None = 0, SingleLine = 0, MultiLine = 1, @@ -3083,7 +3109,7 @@ declare namespace ts { IndexSignatureParameters = 8848, JSDocComment = 33 } - interface UserPreferences { + export interface UserPreferences { readonly disableSuggestions?: boolean; readonly quotePreference?: "auto" | "double" | "single"; readonly includeCompletionsForModuleExports?: boolean; @@ -3095,22 +3121,23 @@ declare namespace ts { readonly providePrefixAndSuffixTextForRename?: boolean; } /** Represents a bigint literal value without requiring bigint support */ - interface PseudoBigInt { + export interface PseudoBigInt { negative: boolean; base10Value: string; } + export {}; } declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; declare namespace ts { - enum FileWatcherEventKind { + export enum FileWatcherEventKind { Created = 0, Changed = 1, Deleted = 2 } - type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind) => void; - type DirectoryWatcherCallback = (fileName: string) => void; - interface System { + export type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind) => void; + export type DirectoryWatcherCallback = (fileName: string) => void; + export interface System { args: string[]; newLine: string; useCaseSensitiveFileNames: boolean; @@ -3132,7 +3159,7 @@ declare namespace ts { getExecutingFilePath(): string; getCurrentDirectory(): string; getDirectories(path: string): string[]; - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; getModifiedTime?(path: string): Date | undefined; setModifiedTime?(path: string, time: Date): void; deleteFile?(path: string): void; @@ -3151,11 +3178,12 @@ declare namespace ts { base64decode?(input: string): string; base64encode?(input: string): string; } - interface FileWatcher { + export interface FileWatcher { close(): void; } - function getNodeMajorVersion(): number | undefined; - let sys: System; + export function getNodeMajorVersion(): number | undefined; + export let sys: System; + export {}; } declare namespace ts { type ErrorCallback = (message: DiagnosticMessage, length: number) => void; @@ -3166,6 +3194,7 @@ declare namespace ts { getTokenPos(): number; getTokenText(): string; getTokenValue(): string; + hasUnicodeEscape(): boolean; hasExtendedUnicodeEscape(): boolean; hasPrecedingLineBreak(): boolean; isIdentifier(): boolean; @@ -3215,7 +3244,7 @@ declare namespace ts { } declare namespace ts { function isExternalModuleNameRelative(moduleName: string): boolean; - function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): SortedReadonlyArray; + function sortAndDeduplicateDiagnostics(diagnostics: readonly T[]): SortedReadonlyArray; } declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -3244,13 +3273,13 @@ declare namespace ts { * This function will then merge those changes into a single change range valid between V1 and * Vn. */ - function collapseTextChangeRangesAcrossMultipleVersions(changes: ReadonlyArray): TextChangeRange; + function collapseTextChangeRangesAcrossMultipleVersions(changes: readonly TextChangeRange[]): TextChangeRange; function getTypeParameterOwner(d: Declaration): Declaration | undefined; type ParameterPropertyDeclaration = ParameterDeclaration & { parent: ConstructorDeclaration; name: Identifier; }; - function isParameterPropertyDeclaration(node: Node): node is ParameterPropertyDeclaration; + function isParameterPropertyDeclaration(node: Node, parent: Node): node is ParameterPropertyDeclaration; function isEmptyBindingPattern(node: BindingName): node is BindingPattern; function isEmptyBindingElement(node: BindingElement): boolean; function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; @@ -3316,7 +3345,7 @@ declare namespace ts { * * For binding patterns, parameter tags are matched by position. */ - function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray; + function getJSDocParameterTags(param: ParameterDeclaration): readonly JSDocParameterTag[]; /** * Gets the JSDoc type parameter tags for the node if present. * @@ -3327,7 +3356,7 @@ declare namespace ts { * node are returned first, so in the previous example, the template * tag on the containing function expression would be first. */ - function getJSDocTypeParameterTags(param: TypeParameterDeclaration): ReadonlyArray; + function getJSDocTypeParameterTags(param: TypeParameterDeclaration): readonly JSDocTemplateTag[]; /** * Return true if the node has JSDoc parameter tags. * @@ -3369,14 +3398,14 @@ declare namespace ts { */ function getJSDocReturnType(node: Node): TypeNode | undefined; /** Get all JSDoc tags related to a node, including those on parent nodes. */ - function getJSDocTags(node: Node): ReadonlyArray; + function getJSDocTags(node: Node): readonly JSDocTag[]; /** Gets all JSDoc tags of a specified kind, or undefined if not present. */ - function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): ReadonlyArray; + function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): readonly JSDocTag[]; /** * 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): ReadonlyArray; + function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[]; function getEffectiveConstraintOfTypeParameter(node: TypeParameterDeclaration): TypeNode | undefined; } declare namespace ts { @@ -3601,7 +3630,7 @@ declare namespace ts { function isStringLiteralLike(node: Node): node is StringLiteralLike; } declare namespace ts { - function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; + export function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; /** * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes * stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise, @@ -3615,25 +3644,26 @@ declare namespace ts { * @remarks `forEachChild` must visit the children of a node in the order * that they appear in the source code. The language service depends on this property to locate nodes by position. */ - function forEachChild(node: Node, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray) => T | undefined): T | undefined; - function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; - function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName | undefined; + export function forEachChild(node: Node, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray) => T | undefined): T | undefined; + export function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; + export function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName | undefined; /** * Parse json text into SyntaxTree and return node and parse errors if any * @param fileName * @param sourceText */ - function parseJsonText(fileName: string, sourceText: string): JsonSourceFile; - function isExternalModule(file: SourceFile): boolean; - function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + export function parseJsonText(fileName: string, sourceText: string): JsonSourceFile; + export function isExternalModule(file: SourceFile): boolean; + export function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + export {}; } declare namespace ts { - function parseCommandLine(commandLine: ReadonlyArray, readFile?: (path: string) => string | undefined): ParsedCommandLine; - type DiagnosticReporter = (diagnostic: Diagnostic) => void; + export function parseCommandLine(commandLine: readonly string[], readFile?: (path: string) => string | undefined): ParsedCommandLine; + export type DiagnosticReporter = (diagnostic: Diagnostic) => void; /** * Reports config file diagnostics */ - interface ConfigFileDiagnosticsReporter { + export interface ConfigFileDiagnosticsReporter { /** * Reports unrecoverable error when parsing config file */ @@ -3642,18 +3672,18 @@ declare namespace ts { /** * Interface extending ParseConfigHost to support ParseConfigFile that reads config file and reports errors */ - interface ParseConfigFileHost extends ParseConfigHost, ConfigFileDiagnosticsReporter { + export interface ParseConfigFileHost extends ParseConfigHost, ConfigFileDiagnosticsReporter { getCurrentDirectory(): string; } /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ - function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map): ParsedCommandLine | undefined; + export function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map): ParsedCommandLine | undefined; /** * Read tsconfig.json file * @param fileName The path to the config file */ - function readConfigFile(fileName: string, readFile: (path: string) => string | undefined): { + export function readConfigFile(fileName: string, readFile: (path: string) => string | undefined): { config?: any; error?: Diagnostic; }; @@ -3662,7 +3692,7 @@ declare namespace ts { * @param fileName The path to the config file * @param jsonText The text of the config file */ - function parseConfigFileTextToJson(fileName: string, jsonText: string): { + export function parseConfigFileTextToJson(fileName: string, jsonText: string): { config?: any; error?: Diagnostic; }; @@ -3670,11 +3700,11 @@ declare namespace ts { * Read tsconfig.json file * @param fileName The path to the config file */ - function readJsonConfigFile(fileName: string, readFile: (path: string) => string | undefined): TsConfigSourceFile; + export function readJsonConfigFile(fileName: string, readFile: (path: string) => string | undefined): TsConfigSourceFile; /** * Convert the json syntax tree into the json value */ - function convertToObject(sourceFile: JsonSourceFile, errors: Push): any; + export function convertToObject(sourceFile: JsonSourceFile, errors: Push): any; /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse @@ -3682,7 +3712,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; + export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map): ParsedCommandLine; /** * Parse the contents of a config file (tsconfig.json). * @param jsonNode The contents of the config file to parse @@ -3690,8 +3720,8 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; - interface ParsedTsconfig { + export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map): ParsedCommandLine; + export interface ParsedTsconfig { raw: any; options?: CompilerOptions; typeAcquisition?: TypeAcquisition; @@ -3700,18 +3730,19 @@ declare namespace ts { */ extendedConfigPath?: string; } - interface ExtendedConfigCacheEntry { + export interface ExtendedConfigCacheEntry { extendedResult: TsConfigSourceFile; extendedConfig: ParsedTsconfig | undefined; } - function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { + export function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; }; - function convertTypeAcquisitionFromJson(jsonOptions: any, basePath: string, configFileName?: string): { + export function convertTypeAcquisitionFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: TypeAcquisition; errors: Diagnostic[]; }; + export {}; } declare namespace ts { function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined; @@ -3755,7 +3786,7 @@ declare namespace ts { function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; } declare namespace ts { - function createNodeArray(elements?: ReadonlyArray, hasTrailingComma?: boolean): NodeArray; + function createNodeArray(elements?: readonly T[], hasTrailingComma?: boolean): NodeArray; /** If a node is passed, creates a string literal whose source text is read from a source node during emit. */ function createLiteral(value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier): StringLiteral; function createLiteral(value: number | PseudoBigInt): NumericLiteral; @@ -3793,67 +3824,67 @@ declare namespace ts { function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; function createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration; function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; - function createParameter(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; - function updateParameter(node: ParameterDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; + function createParameter(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + function updateParameter(node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; function createDecorator(expression: Expression): Decorator; function updateDecorator(node: Decorator, expression: Expression): Decorator; - function createPropertySignature(modifiers: ReadonlyArray | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; - function updatePropertySignature(node: PropertySignature, modifiers: ReadonlyArray | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; - function createProperty(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; - function updateProperty(node: PropertyDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; - function createMethodSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature; + function createPropertySignature(modifiers: readonly Modifier[] | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function updatePropertySignature(node: PropertySignature, modifiers: readonly Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function createProperty(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + function updateProperty(node: PropertyDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + function createMethodSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature; function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined): MethodSignature; - function createMethod(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - function updateMethod(node: MethodDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - function createConstructor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, body: Block | undefined): ConstructorDeclaration; - function updateConstructor(node: ConstructorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, body: Block | undefined): ConstructorDeclaration; - function createGetAccessor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - function updateGetAccessor(node: GetAccessorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: PropertyName, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - function createSetAccessor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, parameters: ReadonlyArray, body: Block | undefined): SetAccessorDeclaration; - function updateSetAccessor(node: SetAccessorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: PropertyName, parameters: ReadonlyArray, body: Block | undefined): SetAccessorDeclaration; - function createCallSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): CallSignatureDeclaration; + function createMethod(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function updateMethod(node: MethodDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function createConstructor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function updateConstructor(node: ConstructorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function createGetAccessor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function updateGetAccessor(node: GetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function createSetAccessor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + function updateSetAccessor(node: SetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + function createCallSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration; function updateCallSignature(node: CallSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): CallSignatureDeclaration; - function createConstructSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): ConstructSignatureDeclaration; + function createConstructSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration; function updateConstructSignature(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructSignatureDeclaration; - function createIndexSignature(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode): IndexSignatureDeclaration; - function updateIndexSignature(node: IndexSignatureDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode): IndexSignatureDeclaration; + function createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + function updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode; function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode; function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode; - function createTypeReferenceNode(typeName: string | EntityName, typeArguments: ReadonlyArray | undefined): TypeReferenceNode; + function createTypeReferenceNode(typeName: string | EntityName, typeArguments: readonly TypeNode[] | undefined): TypeReferenceNode; function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray | undefined): TypeReferenceNode; - function createFunctionTypeNode(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): FunctionTypeNode; + function createFunctionTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode; function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): FunctionTypeNode; - function createConstructorTypeNode(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): ConstructorTypeNode; + function createConstructorTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructorTypeNode; function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructorTypeNode; function createTypeQueryNode(exprName: EntityName): TypeQueryNode; function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode; - function createTypeLiteralNode(members: ReadonlyArray | undefined): TypeLiteralNode; + function createTypeLiteralNode(members: readonly TypeElement[] | undefined): TypeLiteralNode; function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray): TypeLiteralNode; function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; - function createTupleTypeNode(elementTypes: ReadonlyArray): TupleTypeNode; - function updateTupleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray): TupleTypeNode; + function createTupleTypeNode(elementTypes: readonly TypeNode[]): TupleTypeNode; + function updateTupleTypeNode(node: TupleTypeNode, elementTypes: readonly TypeNode[]): TupleTypeNode; function createOptionalTypeNode(type: TypeNode): OptionalTypeNode; function updateOptionalTypeNode(node: OptionalTypeNode, type: TypeNode): OptionalTypeNode; function createRestTypeNode(type: TypeNode): RestTypeNode; function updateRestTypeNode(node: RestTypeNode, type: TypeNode): RestTypeNode; - function createUnionTypeNode(types: ReadonlyArray): UnionTypeNode; + function createUnionTypeNode(types: readonly TypeNode[]): UnionTypeNode; function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray): UnionTypeNode; - function createIntersectionTypeNode(types: ReadonlyArray): IntersectionTypeNode; + function createIntersectionTypeNode(types: readonly TypeNode[]): IntersectionTypeNode; function updateIntersectionTypeNode(node: IntersectionTypeNode, types: NodeArray): IntersectionTypeNode; - function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: ReadonlyArray): UnionOrIntersectionTypeNode; + function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: readonly TypeNode[]): UnionOrIntersectionTypeNode; function createConditionalTypeNode(checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function updateConditionalTypeNode(node: ConditionalTypeNode, checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function createInferTypeNode(typeParameter: TypeParameterDeclaration): InferTypeNode; function updateInferTypeNode(node: InferTypeNode, typeParameter: TypeParameterDeclaration): InferTypeNode; - function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; - function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; + function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; + function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode; function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; function createThisTypeNode(): ThisTypeNode; function createTypeOperatorNode(type: TypeNode): TypeOperatorNode; - function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword, type: TypeNode): TypeOperatorNode; + function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.TagKeyword, type: TypeNode): TypeOperatorNode; function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode; function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; @@ -3861,36 +3892,36 @@ declare namespace ts { function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode; function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; - function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; - function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray): ObjectBindingPattern; - function createArrayBindingPattern(elements: ReadonlyArray): ArrayBindingPattern; - function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ReadonlyArray): ArrayBindingPattern; + function createObjectBindingPattern(elements: readonly BindingElement[]): ObjectBindingPattern; + function updateObjectBindingPattern(node: ObjectBindingPattern, elements: readonly BindingElement[]): ObjectBindingPattern; + function createArrayBindingPattern(elements: readonly ArrayBindingElement[]): ArrayBindingPattern; + function updateArrayBindingPattern(node: ArrayBindingPattern, elements: readonly ArrayBindingElement[]): ArrayBindingPattern; function createBindingElement(dotDotDotToken: DotDotDotToken | undefined, propertyName: string | PropertyName | undefined, name: string | BindingName, initializer?: Expression): BindingElement; function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken | undefined, propertyName: PropertyName | undefined, name: BindingName, initializer: Expression | undefined): BindingElement; - function createArrayLiteral(elements?: ReadonlyArray, multiLine?: boolean): ArrayLiteralExpression; - function updateArrayLiteral(node: ArrayLiteralExpression, elements: ReadonlyArray): ArrayLiteralExpression; - function createObjectLiteral(properties?: ReadonlyArray, multiLine?: boolean): ObjectLiteralExpression; - function updateObjectLiteral(node: ObjectLiteralExpression, properties: ReadonlyArray): ObjectLiteralExpression; + function createArrayLiteral(elements?: readonly Expression[], multiLine?: boolean): ArrayLiteralExpression; + function updateArrayLiteral(node: ArrayLiteralExpression, elements: readonly Expression[]): ArrayLiteralExpression; + function createObjectLiteral(properties?: readonly ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; + function updateObjectLiteral(node: ObjectLiteralExpression, properties: readonly ObjectLiteralElementLike[]): ObjectLiteralExpression; function createPropertyAccess(expression: Expression, name: string | Identifier): PropertyAccessExpression; function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression; function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; - function createCall(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): CallExpression; - function updateCall(node: CallExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray): CallExpression; - function createNew(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; - function updateNew(node: NewExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; + function createCall(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): CallExpression; + function updateCall(node: CallExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[]): CallExpression; + function createNew(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression; + function updateNew(node: NewExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression; /** @deprecated */ function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function createTaggedTemplate(tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; + function createTaggedTemplate(tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; /** @deprecated */ function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; + function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; function createParen(expression: Expression): ParenthesizedExpression; function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; - function createFunctionExpression(modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; - function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; - function createArrowFunction(modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; - function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; + function createFunctionExpression(modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[] | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; + function updateFunctionExpression(node: FunctionExpression, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block): FunctionExpression; + function createArrowFunction(modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; + function updateArrowFunction(node: ArrowFunction, modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; function createTypeOf(expression: Expression): TypeOfExpression; @@ -3908,22 +3939,22 @@ declare namespace ts { /** @deprecated */ function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token, whenTrue: Expression, colonToken: Token, whenFalse: Expression): ConditionalExpression; - function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; - function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; - function createTemplateHead(text: string): TemplateHead; - function createTemplateMiddle(text: string): TemplateMiddle; - function createTemplateTail(text: string): TemplateTail; - function createNoSubstitutionTemplateLiteral(text: string): NoSubstitutionTemplateLiteral; + function createTemplateExpression(head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression; + function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression; + function createTemplateHead(text: string, rawText?: string): TemplateHead; + function createTemplateMiddle(text: string, rawText?: string): TemplateMiddle; + function createTemplateTail(text: string, rawText?: string): TemplateTail; + function createNoSubstitutionTemplateLiteral(text: string, rawText?: string): NoSubstitutionTemplateLiteral; function createYield(expression?: Expression): YieldExpression; function createYield(asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function createSpread(expression: Expression): SpreadElement; function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; - function createClassExpression(modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; - function updateClassExpression(node: ClassExpression, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; + function createClassExpression(modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; + function updateClassExpression(node: ClassExpression, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; function createOmittedExpression(): OmittedExpression; - function createExpressionWithTypeArguments(typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; - function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; + function createExpressionWithTypeArguments(typeArguments: readonly TypeNode[] | undefined, expression: Expression): ExpressionWithTypeArguments; + function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: readonly TypeNode[] | undefined, expression: Expression): ExpressionWithTypeArguments; function createAsExpression(expression: Expression, type: TypeNode): AsExpression; function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression; function createNonNullExpression(expression: Expression): NonNullExpression; @@ -3933,10 +3964,10 @@ declare namespace ts { function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function createSemicolonClassElement(): SemicolonClassElement; - function createBlock(statements: ReadonlyArray, multiLine?: boolean): Block; - function updateBlock(node: Block, statements: ReadonlyArray): Block; - function createVariableStatement(modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList | ReadonlyArray): VariableStatement; - function updateVariableStatement(node: VariableStatement, modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList): VariableStatement; + function createBlock(statements: readonly Statement[], multiLine?: boolean): Block; + function updateBlock(node: Block, statements: readonly Statement[]): Block; + function createVariableStatement(modifiers: readonly Modifier[] | undefined, declarationList: VariableDeclarationList | readonly VariableDeclaration[]): VariableStatement; + function updateVariableStatement(node: VariableStatement, modifiers: readonly Modifier[] | undefined, declarationList: VariableDeclarationList): VariableStatement; function createEmptyStatement(): EmptyStatement; function createExpressionStatement(expression: Expression): ExpressionStatement; function updateExpressionStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; @@ -3975,76 +4006,76 @@ declare namespace ts { function createDebuggerStatement(): DebuggerStatement; function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration; function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; - function createVariableDeclarationList(declarations: ReadonlyArray, flags?: NodeFlags): VariableDeclarationList; - function updateVariableDeclarationList(node: VariableDeclarationList, declarations: ReadonlyArray): VariableDeclarationList; - function createFunctionDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - function updateFunctionDeclaration(node: FunctionDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - function createClassDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; - function updateClassDeclaration(node: ClassDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; - function createInterfaceDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; - function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; - function createTypeAliasDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, type: TypeNode): TypeAliasDeclaration; - function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, typeParameters: ReadonlyArray | undefined, type: TypeNode): TypeAliasDeclaration; - function createEnumDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, members: ReadonlyArray): EnumDeclaration; - function updateEnumDeclaration(node: EnumDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, members: ReadonlyArray): EnumDeclaration; - function createModuleDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; - function updateModuleDeclaration(node: ModuleDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; - function createModuleBlock(statements: ReadonlyArray): ModuleBlock; - function updateModuleBlock(node: ModuleBlock, statements: ReadonlyArray): ModuleBlock; - function createCaseBlock(clauses: ReadonlyArray): CaseBlock; - function updateCaseBlock(node: CaseBlock, clauses: ReadonlyArray): CaseBlock; + function createVariableDeclarationList(declarations: readonly VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; + function updateVariableDeclarationList(node: VariableDeclarationList, declarations: readonly VariableDeclaration[]): VariableDeclarationList; + function createFunctionDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function updateFunctionDeclaration(node: FunctionDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function createClassDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + function updateClassDeclaration(node: ClassDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + function createInterfaceDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + function createTypeAliasDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + function createEnumDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; + function updateEnumDeclaration(node: EnumDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; + function createModuleDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; + function updateModuleDeclaration(node: ModuleDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; + function createModuleBlock(statements: readonly Statement[]): ModuleBlock; + function updateModuleBlock(node: ModuleBlock, statements: readonly Statement[]): ModuleBlock; + function createCaseBlock(clauses: readonly CaseOrDefaultClause[]): CaseBlock; + function updateCaseBlock(node: CaseBlock, clauses: readonly CaseOrDefaultClause[]): CaseBlock; function createNamespaceExportDeclaration(name: string | Identifier): NamespaceExportDeclaration; function updateNamespaceExportDeclaration(node: NamespaceExportDeclaration, name: Identifier): NamespaceExportDeclaration; - function createImportEqualsDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function createImportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; - function updateImportDeclaration(node: ImportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; + function createImportEqualsDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function createImportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; + function updateImportDeclaration(node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; function createImportClause(name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function updateImportClause(node: ImportClause, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function createNamespaceImport(name: Identifier): NamespaceImport; function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; - function createNamedImports(elements: ReadonlyArray): NamedImports; - function updateNamedImports(node: NamedImports, elements: ReadonlyArray): NamedImports; + function createNamedImports(elements: readonly ImportSpecifier[]): NamedImports; + function updateNamedImports(node: NamedImports, elements: readonly ImportSpecifier[]): NamedImports; function createImportSpecifier(propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; - function createExportAssignment(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; - function updateExportAssignment(node: ExportAssignment, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, expression: Expression): ExportAssignment; - function createExportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; - function updateExportDeclaration(node: ExportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; - function createNamedExports(elements: ReadonlyArray): NamedExports; - function updateNamedExports(node: NamedExports, elements: ReadonlyArray): NamedExports; + function createExportAssignment(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; + function updateExportAssignment(node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; + function createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; + function updateExportDeclaration(node: ExportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; + function createNamedExports(elements: readonly ExportSpecifier[]): NamedExports; + function updateNamedExports(node: NamedExports, elements: readonly ExportSpecifier[]): NamedExports; function createExportSpecifier(propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier; function updateExportSpecifier(node: ExportSpecifier, propertyName: Identifier | undefined, name: Identifier): ExportSpecifier; function createExternalModuleReference(expression: Expression): ExternalModuleReference; function updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference; - function createJsxElement(openingElement: JsxOpeningElement, children: ReadonlyArray, closingElement: JsxClosingElement): JsxElement; - function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: ReadonlyArray, closingElement: JsxClosingElement): JsxElement; - function createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxSelfClosingElement; - function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxSelfClosingElement; - function createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxOpeningElement; - function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxOpeningElement; + function createJsxElement(openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; + function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; + function createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; + function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; + function createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement; + function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement; function createJsxClosingElement(tagName: JsxTagNameExpression): JsxClosingElement; function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement; - function createJsxFragment(openingFragment: JsxOpeningFragment, children: ReadonlyArray, closingFragment: JsxClosingFragment): JsxFragment; + function createJsxFragment(openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; function createJsxText(text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText; function updateJsxText(node: JsxText, text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText; function createJsxOpeningFragment(): JsxOpeningFragment; function createJsxJsxClosingFragment(): JsxClosingFragment; - function updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: ReadonlyArray, closingFragment: JsxClosingFragment): JsxFragment; + function updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; - function createJsxAttributes(properties: ReadonlyArray): JsxAttributes; - function updateJsxAttributes(node: JsxAttributes, properties: ReadonlyArray): JsxAttributes; + function createJsxAttributes(properties: readonly JsxAttributeLike[]): JsxAttributes; + function updateJsxAttributes(node: JsxAttributes, properties: readonly JsxAttributeLike[]): JsxAttributes; function createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; function createJsxExpression(dotDotDotToken: DotDotDotToken | undefined, expression: Expression | undefined): JsxExpression; function updateJsxExpression(node: JsxExpression, expression: Expression | undefined): JsxExpression; - function createCaseClause(expression: Expression, statements: ReadonlyArray): CaseClause; - function updateCaseClause(node: CaseClause, expression: Expression, statements: ReadonlyArray): CaseClause; - function createDefaultClause(statements: ReadonlyArray): DefaultClause; - function updateDefaultClause(node: DefaultClause, statements: ReadonlyArray): DefaultClause; - function createHeritageClause(token: HeritageClause["token"], types: ReadonlyArray): HeritageClause; - function updateHeritageClause(node: HeritageClause, types: ReadonlyArray): HeritageClause; + function createCaseClause(expression: Expression, statements: readonly Statement[]): CaseClause; + function updateCaseClause(node: CaseClause, expression: Expression, statements: readonly Statement[]): CaseClause; + function createDefaultClause(statements: readonly Statement[]): DefaultClause; + function updateDefaultClause(node: DefaultClause, statements: readonly Statement[]): DefaultClause; + function createHeritageClause(token: HeritageClause["token"], types: readonly ExpressionWithTypeArguments[]): HeritageClause; + function updateHeritageClause(node: HeritageClause, types: readonly ExpressionWithTypeArguments[]): HeritageClause; function createCatchClause(variableDeclaration: string | VariableDeclaration | undefined, block: Block): CatchClause; function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration | undefined, block: Block): CatchClause; function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; @@ -4055,7 +4086,7 @@ declare namespace ts { function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember; function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember; - function updateSourceFileNode(node: SourceFile, statements: ReadonlyArray, isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean, libReferences?: SourceFile["libReferenceDirectives"]): SourceFile; + function updateSourceFileNode(node: SourceFile, statements: readonly Statement[], isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean, libReferences?: SourceFile["libReferenceDirectives"]): SourceFile; /** * Creates a shallow, memberwise clone of a node for mutation. */ @@ -4077,20 +4108,20 @@ declare namespace ts { */ function createPartiallyEmittedExpression(expression: Expression, original?: Node): PartiallyEmittedExpression; function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; - function createCommaList(elements: ReadonlyArray): CommaListExpression; - function updateCommaList(node: CommaListExpression, elements: ReadonlyArray): CommaListExpression; - function createBundle(sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; + function createCommaList(elements: readonly Expression[]): CommaListExpression; + function updateCommaList(node: CommaListExpression, elements: readonly Expression[]): CommaListExpression; + function createBundle(sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle; function createUnparsedSourceFile(text: string): UnparsedSource; function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts", stripInternal?: boolean): UnparsedSource; function createUnparsedSourceFile(text: string, mapPath: string | undefined, map: string | undefined): UnparsedSource; function createInputFiles(javascriptText: string, declarationText: string): InputFiles; function createInputFiles(readFileText: (path: string) => string | undefined, javascriptPath: string, javascriptMapPath: string | undefined, declarationPath: string, declarationMapPath: string | undefined, buildInfoPath: string | undefined): InputFiles; function createInputFiles(javascriptText: string, declarationText: string, javascriptMapPath: string | undefined, javascriptMapText: string | undefined, declarationMapPath: string | undefined, declarationMapText: string | undefined): InputFiles; - function updateBundle(node: Bundle, sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; - function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray): CallExpression; - function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; - function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray): CallExpression; - function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; + function updateBundle(node: Bundle, sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle; + function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[]): CallExpression; + function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; function createComma(left: Expression, right: Expression): Expression; function createLessThan(left: Expression, right: Expression): Expression; function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment; @@ -4266,20 +4297,20 @@ declare namespace ts { function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; } declare namespace ts { - function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string | undefined; - function resolveTripleslashReference(moduleName: string, containingFile: string): string; - function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; - function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - interface FormatDiagnosticsHost { + export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string | undefined; + export function resolveTripleslashReference(moduleName: string, containingFile: string): string; + export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; + export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + export interface FormatDiagnosticsHost { getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; getNewLine(): string; } - function formatDiagnostics(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; - function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string; - function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; - function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string; - function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): ReadonlyArray; + export function formatDiagnostics(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string; + export function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string; + export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string; + export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string; + export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[]; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' * that represent a compilation unit. @@ -4290,7 +4321,7 @@ declare namespace ts { * @param createProgramOptions - The options for creating a program. * @returns A 'Program' object. */ - function createProgram(createProgramOptions: CreateProgramOptions): Program; + export function createProgram(createProgramOptions: CreateProgramOptions): Program; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' * that represent a compilation unit. @@ -4305,16 +4336,17 @@ declare namespace ts { * @param configFileParsingDiagnostics - error during config file parsing * @returns A 'Program' object. */ - function createProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: ReadonlyArray): Program; - /** @deprecated */ interface ResolveProjectReferencePathHost { + export function createProgram(rootNames: readonly string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: readonly Diagnostic[]): Program; + /** @deprecated */ export interface ResolveProjectReferencePathHost { fileExists(fileName: string): boolean; } /** * Returns the target config filename of a project reference. * Note: The file might not exist. */ - function resolveProjectReferencePath(ref: ProjectReference): ResolvedConfigFileName; - /** @deprecated */ function resolveProjectReferencePath(host: ResolveProjectReferencePathHost, ref: ProjectReference): ResolvedConfigFileName; + export function resolveProjectReferencePath(ref: ProjectReference): ResolvedConfigFileName; + /** @deprecated */ export function resolveProjectReferencePath(host: ResolveProjectReferencePathHost, ref: ProjectReference): ResolvedConfigFileName; + export {}; } declare namespace ts { interface EmitOutput { @@ -4366,31 +4398,31 @@ declare namespace ts { /** * Get a list of files in the program */ - getSourceFiles(): ReadonlyArray; + getSourceFiles(): readonly SourceFile[]; /** * Get the diagnostics for compiler options */ - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the diagnostics that dont belong to any file */ - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the diagnostics from config file parsing */ - getConfigFileParsingDiagnostics(): ReadonlyArray; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; /** * Get the syntax diagnostics, for all source files if source file is not supplied */ - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the declaration diagnostics, for all source files if source file is not supplied */ - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; /** * Get all the dependencies of the file */ - getAllDependencies(sourceFile: SourceFile): ReadonlyArray; + getAllDependencies(sourceFile: SourceFile): readonly string[]; /** * Gets the semantic diagnostics from the program corresponding to this state of file (if provided) or whole program * The semantic diagnostics are cached and managed here @@ -4399,7 +4431,7 @@ declare namespace ts { * In case of SemanticDiagnosticsBuilderProgram if the source file is not provided, * it will iterate through all the affected files, to ensure that cache stays valid and yet provide a way to get all semantic diagnostics */ - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Emits the JavaScript and declaration files. * When targetSource file is specified, emits the files corresponding to that source file, @@ -4425,7 +4457,7 @@ declare namespace ts { * Gets the semantic diagnostics from the program for the next affected file and caches it * Returns undefined if the iteration is complete */ - getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult>; + getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult; } /** * The builder that can handle the changes in program and iterate through changed file to emit the files @@ -4442,19 +4474,19 @@ declare namespace ts { /** * Create the builder to manage semantic diagnostics and cache them */ - function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; - function createSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; + function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): SemanticDiagnosticsBuilderProgram; + function createSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): SemanticDiagnosticsBuilderProgram; /** * Create the builder that can handle the changes in program and iterate through changed files * to emit the those files and manage semantic diagnostics cache as well */ - function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; - function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; + function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): EmitAndSemanticDiagnosticsBuilderProgram; + function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): EmitAndSemanticDiagnosticsBuilderProgram; /** * Creates a builder thats just abstraction over program and can be used with watch */ - function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderProgram; - function createAbstractBuilder(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): BuilderProgram; + function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): BuilderProgram; + function createAbstractBuilder(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): BuilderProgram; } declare namespace ts { interface ReadBuildProgramHost { @@ -4465,21 +4497,21 @@ declare namespace ts { function readBuilderProgram(compilerOptions: CompilerOptions, host: ReadBuildProgramHost): EmitAndSemanticDiagnosticsBuilderProgram | undefined; function createIncrementalCompilerHost(options: CompilerOptions, system?: System): CompilerHost; interface IncrementalProgramOptions { - rootNames: ReadonlyArray; + rootNames: readonly string[]; options: CompilerOptions; - configFileParsingDiagnostics?: ReadonlyArray; - projectReferences?: ReadonlyArray; + configFileParsingDiagnostics?: readonly Diagnostic[]; + projectReferences?: readonly ProjectReference[]; host?: CompilerHost; createProgram?: CreateProgram; } function createIncrementalProgram({ rootNames, options, configFileParsingDiagnostics, projectReferences, host, createProgram }: IncrementalProgramOptions): T; - type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions) => void; + type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions, errorCount?: number) => void; /** Create the program with rootNames and options, if they are undefined, oldProgram and new configFile diagnostics create new program */ - type CreateProgram = (rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: T, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray | undefined) => T; + type CreateProgram = (rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: T, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[] | undefined) => T; /** Host that has watch functionality used in --watch mode */ interface WatchHost { /** If provided, called with Diagnostic message that informs about change in watch status */ - onWatchStatusChange?(diagnostic: Diagnostic, newLine: string, options: CompilerOptions): void; + onWatchStatusChange?(diagnostic: Diagnostic, newLine: string, options: CompilerOptions, errorCount?: number): void; /** Used to watch changes in source files, missing files needed to update the program or config file */ watchFile(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher; /** Used to watch resolved module's failed lookup locations, config file specs, type roots where auto type reference directives are added */ @@ -4515,7 +4547,7 @@ declare namespace ts { /** If provided, used in resolutions as well as handling directory structure */ getDirectories?(path: string): string[]; /** If provided, used to cache and handle directory structure modifications */ - readDirectory?(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; /** Symbol links resolution */ realpath?(path: string): string; /** If provided would be used to write log about compilation */ @@ -4523,9 +4555,9 @@ declare namespace ts { /** If provided is used to get the environment variable */ getEnvironmentVariable?(name: string): string | undefined; /** If provided, used to resolve the module names, otherwise typescript's default module resolution */ - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[]; } interface WatchCompilerHost extends ProgramHost, WatchHost { /** If provided, callback to invoke after every new program creation */ @@ -4540,7 +4572,7 @@ declare namespace ts { /** Compiler options */ options: CompilerOptions; /** Project References */ - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; } /** * Host to create watch with config file @@ -4554,7 +4586,7 @@ declare namespace ts { * Used to generate source file names from the config file and its include, exclude, files rules * and also to cache the directory stucture */ - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; } interface Watch { /** Synchronize with host and get updated program */ @@ -4578,7 +4610,7 @@ declare namespace ts { * Create the watch compiler host for either configFile or fileNames and its options */ function createWatchCompilerHost(configFileName: string, optionsToExtend: CompilerOptions | undefined, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): WatchCompilerHostOfConfigFile; - function createWatchCompilerHost(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: ReadonlyArray): WatchCompilerHostOfFilesAndCompilerOptions; + function createWatchCompilerHost(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: readonly ProjectReference[]): WatchCompilerHostOfFilesAndCompilerOptions; /** * Creates the watch from the host for root files and compiler options */ @@ -4631,8 +4663,8 @@ declare namespace ts { function createBuilderStatusReporter(system: System, pretty?: boolean): DiagnosticReporter; function createSolutionBuilderHost(system?: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportErrorSummary?: ReportEmitErrorSummary): SolutionBuilderHost; function createSolutionBuilderWithWatchHost(system?: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): SolutionBuilderWithWatchHost; - function createSolutionBuilder(host: SolutionBuilderHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilder; - function createSolutionBuilderWithWatch(host: SolutionBuilderWithWatchHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilder; + function createSolutionBuilder(host: SolutionBuilderHost, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder; + function createSolutionBuilderWithWatch(host: SolutionBuilderWithWatchHost, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder; enum InvalidatedProjectKind { Build = 0, UpdateBundle = 1, @@ -4657,14 +4689,14 @@ declare namespace ts { getBuilderProgram(): T | undefined; getProgram(): Program | undefined; getSourceFile(fileName: string): SourceFile | undefined; - getSourceFiles(): ReadonlyArray; - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getConfigFileParsingDiagnostics(): ReadonlyArray; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getAllDependencies(sourceFile: SourceFile): ReadonlyArray; - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult>; + getSourceFiles(): readonly SourceFile[]; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getAllDependencies(sourceFile: SourceFile): readonly string[]; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult; emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult | undefined; } interface UpdateBundleProject extends InvalidatedProjectBase { @@ -4727,7 +4759,7 @@ declare namespace ts.server { readonly kind: EventBeginInstallTypes | EventEndInstallTypes; readonly eventId: number; readonly typingsInstallerVersion: string; - readonly packagesToInstall: ReadonlyArray; + readonly packagesToInstall: readonly string[]; } interface BeginInstallTypes extends InstallTypes { readonly kind: EventBeginInstallTypes; @@ -4780,8 +4812,8 @@ declare namespace ts { getProperties(): Symbol[]; getProperty(propertyName: string): Symbol | undefined; getApparentProperties(): Symbol[]; - getCallSignatures(): ReadonlyArray; - getConstructSignatures(): ReadonlyArray; + getCallSignatures(): readonly Signature[]; + getConstructSignatures(): readonly Signature[]; getStringIndexType(): Type | undefined; getNumberIndexType(): Type | undefined; getBaseTypes(): BaseType[] | undefined; @@ -4809,7 +4841,7 @@ declare namespace ts { interface SourceFile { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineEndOfPosition(pos: number): number; - getLineStarts(): ReadonlyArray; + getLineStarts(): readonly number[]; getPositionOfLineAndCharacter(line: number, character: number): number; update(newText: string, textChangeRange: TextChangeRange): SourceFile; } @@ -4866,7 +4898,7 @@ declare namespace ts { getScriptKind?(fileName: string): ScriptKind; getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): IScriptSnapshot | undefined; - getProjectReferences?(): ReadonlyArray | undefined; + getProjectReferences?(): readonly ProjectReference[] | undefined; getLocalizedDiagnosticMessages?(): any; getCancellationToken?(): HostCancellationToken; getCurrentDirectory(): string; @@ -4875,14 +4907,14 @@ declare namespace ts { trace?(s: string): void; error?(s: string): void; useCaseSensitiveFileNames?(): boolean; - readDirectory?(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; readFile?(path: string, encoding?: string): string | undefined; realpath?(path: string): string; fileExists?(path: string): boolean; getTypeRootsVersion?(): number; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined; - resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[]; getDirectories?(directoryName: string): string[]; /** * Gets a set of custom transformers to use during emit. @@ -4920,17 +4952,17 @@ declare namespace ts { getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): ReadonlyArray | undefined; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): readonly RenameLocation[] | undefined; getSmartSelectionRange(fileName: string, position: number): SelectionRange; - getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; - getTypeDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; - getImplementationAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getTypeDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; + getImplementationAtPosition(fileName: string, position: number): readonly ImplementationLocation[] | undefined; getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] | undefined; findReferences(fileName: string, position: number): ReferencedSymbol[] | undefined; getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] | undefined; /** @deprecated */ - getOccurrencesAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getOccurrencesAtPosition(fileName: string, position: number): readonly ReferenceEntry[] | undefined; getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; getNavigationTree(fileName: string): NavigationTree; @@ -4950,7 +4982,7 @@ declare namespace ts { getJsxClosingTagAtPosition(fileName: string, position: number): JsxClosingTagInfo | undefined; getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan | undefined; toLineColumnOffset?(fileName: string, position: number): LineAndCharacter; - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray, formatOptions: FormatCodeSettings, preferences: UserPreferences): ReadonlyArray; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: readonly number[], formatOptions: FormatCodeSettings, preferences: UserPreferences): readonly CodeFixAction[]; getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings, preferences: UserPreferences): CombinedCodeActions; applyCodeActionCommand(action: CodeActionCommand, formatSettings?: FormatCodeSettings): Promise; applyCodeActionCommand(action: CodeActionCommand[], formatSettings?: FormatCodeSettings): Promise; @@ -4963,8 +4995,8 @@ declare namespace ts { applyCodeActionCommand(fileName: string, action: CodeActionCommand | CodeActionCommand[]): Promise; getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined): 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): ReadonlyArray; - getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): ReadonlyArray; + organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; + getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; getProgram(): Program | undefined; dispose(): void; @@ -5113,8 +5145,8 @@ declare namespace ts { fixAllDescription?: string; } interface CombinedCodeActions { - changes: ReadonlyArray; - commands?: ReadonlyArray; + changes: readonly FileTextChanges[]; + commands?: readonly CodeActionCommand[]; } type CodeActionCommand = InstallPackageAction; interface InstallPackageAction { @@ -5296,7 +5328,7 @@ declare namespace ts { containerName: string; } interface DefinitionInfoAndBoundSpan { - definitions?: ReadonlyArray; + definitions?: readonly DefinitionInfo[]; textSpan: TextSpan; } interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { @@ -5665,6 +5697,7 @@ declare namespace ts { } } declare namespace ts { + /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier(): Classifier; } declare namespace ts { diff --git a/lib/typescript.js b/lib/typescript.js index b93aa3daff63c..05c4f67ab7a99 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -14,6 +14,13 @@ and limitations under the License. ***************************************************************************** */ "use strict"; +var __spreadArrays = (this && this.__spreadArrays) || function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +}; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { @@ -73,7 +80,7 @@ var ts; (function (ts) { // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configureNightly` too. - ts.versionMajorMinor = "3.6"; + ts.versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ ts.version = ts.versionMajorMinor + ".0-dev"; })(ts || (ts = {})); @@ -91,7 +98,7 @@ var ts; ts.emptyArray = []; /** Create a MapLike with good performance. */ function createDictionaryObject() { - var map = Object.create(/*prototype*/ null); // tslint:disable-line:no-null-keyword + var map = Object.create(/*prototype*/ null); // eslint-disable-line no-null/no-null // Using 'delete' on an object causes V8 to put the object in dictionary mode. // This disables creation of hidden classes, which are expensive when an object is // constantly changing shape. @@ -126,7 +133,7 @@ var ts; } ts.createMapFromTemplate = createMapFromTemplate; // Internet Explorer's Map doesn't support iteration, so don't use it. - // tslint:disable-next-line no-in-operator variable-name + // eslint-disable-next-line no-in-operator ts.MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); // Keep the class inside a function so it doesn't get compiled if it's not used. function shimMap() { @@ -190,7 +197,7 @@ var ts; return this; }; class_1.prototype.has = function (key) { - // tslint:disable-next-line:no-in-operator + // eslint-disable-next-line no-in-operator return key in this.data; }; class_1.prototype.delete = function (key) { @@ -783,7 +790,7 @@ var ts; return array1; if (!some(array1)) return array2; - return array1.concat(array2); + return __spreadArrays(array1, array2); } ts.concatenate = concatenate; function deduplicateRelational(array, equalityComparer, comparer) { @@ -840,6 +847,7 @@ var ts; // equality comparison case true: // relational comparison + // falls through case 0 /* EqualTo */: continue; case -1 /* LessThan */: @@ -1230,6 +1238,18 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; + function getAllKeys(obj) { + var result = []; + do { + var names = Object.getOwnPropertyNames(obj); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name = names_1[_i]; + pushIfUnique(result, name); + } + } while (obj = Object.getPrototypeOf(obj)); + return result; + } + ts.getAllKeys = getAllKeys; function getOwnValues(sparseArray) { var values = []; for (var key in sparseArray) { @@ -1427,7 +1447,7 @@ var ts; } ts.cast = cast; /** Does nothing. */ - function noop(_) { } // tslint:disable-line no-empty + function noop(_) { } ts.noop = noop; /** Do nothing and return false */ function returnFalse() { return false; } @@ -1939,7 +1959,7 @@ var ts; return function (arg) { return f(arg) || g(arg); }; } ts.or = or; - function assertType(_) { } // tslint:disable-line no-empty + function assertType(_) { } ts.assertType = assertType; function singleElementArray(t) { return t === undefined ? undefined : [t]; @@ -2016,8 +2036,10 @@ var ts; (function (ts) { var Debug; (function (Debug) { + /* eslint-disable prefer-const */ Debug.currentAssertionLevel = 0 /* None */; Debug.isDebugging = false; + /* eslint-enable prefer-const */ function shouldAssert(level) { return Debug.currentAssertionLevel >= level; } @@ -2066,6 +2088,7 @@ var ts; } Debug.fail = fail; function assertDefined(value, message) { + // eslint-disable-next-line no-null/no-null if (value === undefined || value === null) return fail(message); return value; @@ -2081,7 +2104,7 @@ var ts; Debug.assertEachDefined = assertEachDefined; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } - var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); + var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); return fail(message + " " + detail, stackCrawlMark || assertNever); } Debug.assertNever = assertNever; @@ -2369,6 +2392,47 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var nullLogger = { + logEvent: ts.noop, + logErrEvent: ts.noop, + logPerfEvent: ts.noop, + logInfoEvent: ts.noop, + logStartCommand: ts.noop, + logStopCommand: ts.noop, + logStartUpdateProgram: ts.noop, + logStopUpdateProgram: ts.noop, + logStartUpdateGraph: ts.noop, + logStopUpdateGraph: ts.noop, + logStartResolveModule: ts.noop, + logStopResolveModule: ts.noop, + logStartParseSourceFile: ts.noop, + logStopParseSourceFile: ts.noop, + logStartReadFile: ts.noop, + logStopReadFile: ts.noop, + logStartBindFile: ts.noop, + logStopBindFile: ts.noop, + logStartScheduledOperation: ts.noop, + logStopScheduledOperation: ts.noop, + }; + // Load optional module to enable Event Tracing for Windows + // See https://github.com/microsoft/typescript-etw for more information + var etwModule; + try { + // require() will throw an exception if the module is not installed + // It may also return undefined if not installed properly + etwModule = require("@microsoft/typescript-etw"); + } + catch (e) { + etwModule = undefined; + } + /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ + ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; + var args = typeof process === "undefined" ? [] : process.argv; + ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify(args)); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { // https://semver.org/#spec-item-2 // > A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative @@ -2893,200 +2957,203 @@ var ts; SyntaxKind[SyntaxKind["FromKeyword"] = 145] = "FromKeyword"; SyntaxKind[SyntaxKind["GlobalKeyword"] = 146] = "GlobalKeyword"; SyntaxKind[SyntaxKind["BigIntKeyword"] = 147] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 148] = "OfKeyword"; + SyntaxKind[SyntaxKind["TagKeyword"] = 148] = "TagKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 149] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 149] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 150] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 150] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 151] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 151] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 152] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 153] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 152] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 153] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 154] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 154] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 155] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 156] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 157] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 158] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 159] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 160] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 161] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 162] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 163] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 155] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 156] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 157] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 158] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 159] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 160] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 161] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 162] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 163] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 164] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 164] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 165] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 166] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 167] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 168] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 169] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 170] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 171] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 172] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 173] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 174] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 175] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 176] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 177] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 178] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 179] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 180] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 181] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 182] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 183] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 184] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 165] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 166] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 167] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 168] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 169] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 170] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 171] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 172] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 173] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 174] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 175] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 176] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 177] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 178] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 179] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 180] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 181] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 182] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 183] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 184] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 185] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 185] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 186] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 187] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 186] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 187] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 188] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 188] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 189] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 190] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 191] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 192] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 193] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 194] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 195] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 196] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 197] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 198] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 199] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 200] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 201] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 202] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 203] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 204] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 205] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 206] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 207] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 208] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 209] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 210] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 211] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 212] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 213] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 214] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 215] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 216] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 189] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 190] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 191] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 192] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 193] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 194] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 195] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 196] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 197] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 198] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 199] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 200] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 201] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 202] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 203] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 204] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 205] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 206] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 207] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 208] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 209] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 210] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 211] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 212] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 213] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 214] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 215] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 216] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 217] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 217] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 218] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 218] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 219] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 219] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 220] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 221] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 222] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 223] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 224] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 225] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 226] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 227] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 228] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 229] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 230] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 231] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 232] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 233] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 234] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 235] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 236] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 237] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 238] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 239] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 240] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 241] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 242] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 243] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 244] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 245] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 246] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 247] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 248] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 249] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 250] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 251] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 252] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 253] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 254] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 255] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 256] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 257] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 258] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 259] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 220] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 221] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 222] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 223] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 224] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 225] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 226] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 227] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 228] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 229] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 230] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 231] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 232] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 233] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 234] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 235] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 236] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 237] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 238] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 239] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 240] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 241] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 242] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 243] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 244] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 245] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 246] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 247] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 248] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 249] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 250] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 251] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 252] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 253] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 254] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 255] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 256] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 257] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 258] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 259] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 260] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 260] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 261] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 261] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 262] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 263] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 264] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 265] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 266] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 267] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 268] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 269] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 270] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 271] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 262] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 263] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 264] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 265] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 266] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 267] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 268] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 269] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 270] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 271] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 272] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 272] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 273] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 274] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 275] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 273] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 274] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 275] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 276] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 276] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 277] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 278] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 277] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 278] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 279] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 279] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 280] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 280] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 281] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 282] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 283] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 284] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 281] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 282] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 283] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 284] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 285] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 285] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 286] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 287] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 288] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 286] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 287] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 288] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 289] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 289] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 290] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 290] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 291] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 291] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 292] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 293] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 294] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 295] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 296] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 297] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 298] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 299] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 300] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 301] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 302] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 303] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 304] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 305] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 306] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 307] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 308] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 309] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 310] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 311] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 312] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 292] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 293] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 294] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 295] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 296] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 297] = "JSDocVariadicType"; + // https://jsdoc.app/about-namepaths.html + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 298] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 299] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 300] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 301] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 302] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 303] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 304] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 305] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 306] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 307] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 308] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 309] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 310] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 311] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 312] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 313] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 314] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 313] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 315] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 314] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 315] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 316] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 317] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 318] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 316] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 317] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 318] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 319] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 320] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 319] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 321] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 60] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 72] = "LastAssignment"; @@ -3095,15 +3162,15 @@ var ts; SyntaxKind[SyntaxKind["FirstReservedWord"] = 74] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 109] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 74] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 148] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 149] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 110] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 118] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 164] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 184] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 165] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 185] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 72] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 148] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 149] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -3112,13 +3179,13 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 72] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 149] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 289] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 312] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 300] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 312] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 150] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 290] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 314] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 302] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 314] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 119] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 148] = "LastContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 149] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -3242,6 +3309,8 @@ var ts; /* @internal */ TokenFlags[TokenFlags["ContainsSeparator"] = 512] = "ContainsSeparator"; /* @internal */ + TokenFlags[TokenFlags["UnicodeEscape"] = 1024] = "UnicodeEscape"; + /* @internal */ TokenFlags[TokenFlags["BinaryOrOctalSpecifier"] = 384] = "BinaryOrOctalSpecifier"; /* @internal */ TokenFlags[TokenFlags["NumericLiteralFlags"] = 1008] = "NumericLiteralFlags"; @@ -3272,6 +3341,13 @@ var ts; return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + /*@internal*/ + var RefFileKind; + (function (RefFileKind) { + RefFileKind[RefFileKind["Import"] = 0] = "Import"; + RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile"; + RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective"; + })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {})); /* @internal */ var StructureIsReused; (function (StructureIsReused) { @@ -3292,6 +3368,8 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; // When build skipped because passed in project is invalid ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped"; + // When build is skipped because project references form cycle + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); /* @internal */ var UnionReduction; @@ -3357,7 +3435,6 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 4096] = "UseTypeOfFunction"; TypeFormatFlags[TypeFormatFlags["OmitParameterModifiers"] = 8192] = "OmitParameterModifiers"; TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; - // even though `T` can't be accessed in the current scope. // Error Handling TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; // TypeFormatFlags exclusive @@ -3412,22 +3489,33 @@ var ts; /* @internal */ var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { + // The TypeReferenceNode could not be resolved. + // The type name should be emitted using a safe fallback. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; - // should be emitted using a safe fallback. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a type with a constructor // function that can be reached at runtime (e.g. a `class` // declaration or a `var` declaration for the static side // of a type, such as the global `Promise` type in lib.d.ts). + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a Void-like, Nullable, or Never type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType"; + // The TypeReferenceNode resolves to a Number-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + // The TypeReferenceNode resolves to a BigInt-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType"; + // The TypeReferenceNode resolves to a String-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType"; + // The TypeReferenceNode resolves to a Boolean-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType"; + // The TypeReferenceNode resolves to an Array-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType"; + // The TypeReferenceNode resolves to the ESSymbol type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType"; + // The TypeReferenceNode resolved to the global Promise constructor symbol. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise"; + // The TypeReferenceNode resolves to a Function type or a type with call signatures. TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature"; - // with call signatures. + // The TypeReferenceNode resolves to any other type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var SymbolFlags; @@ -3465,32 +3553,32 @@ var ts; SymbolFlags[SymbolFlags["All"] = 67108863] = "All"; SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; - SymbolFlags[SymbolFlags["Value"] = 67220415] = "Value"; - SymbolFlags[SymbolFlags["Type"] = 67897832] = "Type"; + SymbolFlags[SymbolFlags["Value"] = 111551] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 788968] = "Type"; SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; // Variables can be redeclared, but can not redeclare a block-scoped declaration with the // same name, or any other value that is not a variable, e.g. ValueModule or Class - SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 67220414] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 111550] = "FunctionScopedVariableExcludes"; // Block-scoped declarations are not allowed to be re-declared // they can not merge with anything in the value space - SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 67220415] = "BlockScopedVariableExcludes"; - SymbolFlags[SymbolFlags["ParameterExcludes"] = 67220415] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 111551] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 111551] = "ParameterExcludes"; SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; - SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 68008959] = "EnumMemberExcludes"; - SymbolFlags[SymbolFlags["FunctionExcludes"] = 67219887] = "FunctionExcludes"; - SymbolFlags[SymbolFlags["ClassExcludes"] = 68008383] = "ClassExcludes"; - SymbolFlags[SymbolFlags["InterfaceExcludes"] = 67897736] = "InterfaceExcludes"; - SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 68008191] = "RegularEnumExcludes"; - SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 68008831] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 110991] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899503] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 788872] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 110735] = "ValueModuleExcludes"; SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; - SymbolFlags[SymbolFlags["MethodExcludes"] = 67212223] = "MethodExcludes"; - SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 67154879] = "GetAccessorExcludes"; - SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 67187647] = "SetAccessorExcludes"; - SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 67635688] = "TypeParameterExcludes"; - SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 67897832] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 103359] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 46015] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 78783] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 526824] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 788968] = "TypeAliasExcludes"; SymbolFlags[SymbolFlags["AliasExcludes"] = 2097152] = "AliasExcludes"; SymbolFlags[SymbolFlags["ModuleMember"] = 2623475] = "ModuleMember"; SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; @@ -3609,6 +3697,7 @@ var ts; TypeFlags[TypeFlags["Conditional"] = 16777216] = "Conditional"; TypeFlags[TypeFlags["Substitution"] = 33554432] = "Substitution"; TypeFlags[TypeFlags["NonPrimitive"] = 67108864] = "NonPrimitive"; + TypeFlags[TypeFlags["StructuralTag"] = 134217728] = "StructuralTag"; /* @internal */ TypeFlags[TypeFlags["AnyOrUnknown"] = 3] = "AnyOrUnknown"; /* @internal */ @@ -3635,22 +3724,22 @@ var ts; /* @internal */ TypeFlags[TypeFlags["DisjointDomains"] = 67238908] = "DisjointDomains"; TypeFlags[TypeFlags["UnionOrIntersection"] = 3145728] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 3670016] = "StructuredType"; + TypeFlags[TypeFlags["StructuredType"] = 137887744] = "StructuredType"; TypeFlags[TypeFlags["TypeVariable"] = 8650752] = "TypeVariable"; TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 58982400] = "InstantiableNonPrimitive"; TypeFlags[TypeFlags["InstantiablePrimitive"] = 4194304] = "InstantiablePrimitive"; TypeFlags[TypeFlags["Instantiable"] = 63176704] = "Instantiable"; - TypeFlags[TypeFlags["StructuredOrInstantiable"] = 66846720] = "StructuredOrInstantiable"; + TypeFlags[TypeFlags["StructuredOrInstantiable"] = 201064448] = "StructuredOrInstantiable"; /* @internal */ TypeFlags[TypeFlags["ObjectFlagsType"] = 3899392] = "ObjectFlagsType"; /* @internal */ TypeFlags[TypeFlags["Simplifiable"] = 25165824] = "Simplifiable"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - TypeFlags[TypeFlags["Narrowable"] = 133970943] = "Narrowable"; + TypeFlags[TypeFlags["Narrowable"] = 268188671] = "Narrowable"; TypeFlags[TypeFlags["NotUnionOrUnit"] = 67637251] = "NotUnionOrUnit"; /* @internal */ - TypeFlags[TypeFlags["NotPrimitiveUnion"] = 66994211] = "NotPrimitiveUnion"; + TypeFlags[TypeFlags["NotPrimitiveUnion"] = 201211939] = "NotPrimitiveUnion"; // The following flags are aggregated during union and intersection type construction /* @internal */ TypeFlags[TypeFlags["IncludesMask"] = 68943871] = "IncludesMask"; @@ -3740,7 +3829,9 @@ var ts; InferencePriority[InferencePriority["LiteralKeyof"] = 32] = "LiteralKeyof"; InferencePriority[InferencePriority["NoConstraints"] = 64] = "NoConstraints"; InferencePriority[InferencePriority["AlwaysStrict"] = 128] = "AlwaysStrict"; + InferencePriority[InferencePriority["MaxValue"] = 256] = "MaxValue"; InferencePriority[InferencePriority["PriorityImpliesCombination"] = 56] = "PriorityImpliesCombination"; + InferencePriority[InferencePriority["Circularity"] = -1] = "Circularity"; })(InferencePriority = ts.InferencePriority || (ts.InferencePriority = {})); /* @internal */ var InferenceFlags; @@ -3818,6 +3909,9 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; + // NOTE: ES module kinds should be contiguous to more easily check whether a module kind is *any* ES module kind. + // Non-ES module kinds should not come between ES2015 (the earliest ES module kind) and ESNext (the last ES + // module kind). ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); @@ -4402,7 +4496,7 @@ var ts; function getCustomPollingBasedLevels(baseVariable, defaultLevels) { var customLevels = getCustomLevels(baseVariable); return (pollingIntervalChanged || customLevels) && - createPollingIntervalBasedLevels(customLevels ? __assign({}, defaultLevels, customLevels) : defaultLevels); + createPollingIntervalBasedLevels(customLevels ? __assign(__assign({}, defaultLevels), customLevels) : defaultLevels); } } ts.setCustomPollingValues = setCustomPollingValues; @@ -4556,6 +4650,38 @@ var ts; } } ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile; + /* @internal */ + function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) { + var cache = ts.createMap(); + var callbacksCache = ts.createMultiMap(); + var toCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); + return function (fileName, callback, pollingInterval) { + var path = toCanonicalFileName(fileName); + var existing = cache.get(path); + if (existing) { + existing.refCount++; + } + else { + cache.set(path, { + watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval), + refCount: 1 + }); + } + callbacksCache.add(path, callback); + return { + close: function () { + var watcher = ts.Debug.assertDefined(cache.get(path)); + callbacksCache.remove(path, callback); + watcher.refCount--; + if (watcher.refCount) + return; + cache.delete(path); + ts.closeFileWatcherOf(watcher); + } + }; + }; + } + ts.createSingleFileWatcherPerName = createSingleFileWatcherPerName; /** * Returns true if file status changed */ @@ -4582,6 +4708,8 @@ var ts; ts.getFileWatcherEventKind = getFileWatcherEventKind; /*@internal*/ ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"]; + /*@internal*/ + ts.sysLog = ts.noop; // eslint-disable-line prefer-const /** * Watch the directory recursively using host provided method to watch child directories * that means if this is recursive watcher, watch the children directories as well @@ -4702,6 +4830,7 @@ var ts; } ts.getNodeMajorVersion = getNodeMajorVersion; // TODO: GH#18217 this is used as if it's certainly defined in many places. + // eslint-disable-next-line prefer-const ts.sys = (function () { // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual // byte order mark from the specified encoding. Using any other byte order mark does @@ -4722,6 +4851,7 @@ var ts; 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 FileSystemEntryKind; @@ -4732,6 +4862,7 @@ var ts; var useNonPollingWatchers = process.env.TSC_NONPOLLING_WATCHER; var tscWatchFile = process.env.TSC_WATCHFILE; var tscWatchDirectory = process.env.TSC_WATCHDIRECTORY; + var fsWatchFile = createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames); var dynamicPollingWatchFile; var nodeSystem = { args: process.argv.slice(2), @@ -4868,7 +4999,7 @@ var ts; return useNonPollingWatchers ? createNonPollingWatchFile() : // Default to do not use polling interval as it is before this experiment branch - function (fileName, callback) { return fsWatchFile(fileName, callback); }; + function (fileName, callback) { return fsWatchFile(fileName, callback, /*pollingInterval*/ undefined); }; } function getWatchDirectory() { // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows @@ -4942,7 +5073,7 @@ var ts; return watcher; } } - function fsWatchFile(fileName, callback, pollingInterval) { + function fsWatchFileWorker(fileName, callback, pollingInterval) { _fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged); var eventKind; return { @@ -5000,6 +5131,12 @@ var ts; } function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingWatchFile, pollingInterval) { var options; + var lastDirectoryPartWithDirectorySeparator; + var lastDirectoryPart; + if (isLinuxOrMacOs) { + lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator)); + lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length); + } /** Watcher for the file system entry depending on whether it is missing or present */ var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry() : @@ -5016,6 +5153,7 @@ var ts; * @param createWatcher */ function invokeCallbackAndUpdateWatcher(createWatcher) { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); // Call the callback for current directory callback("rename", ""); // If watcher is not closed, update it @@ -5040,7 +5178,9 @@ var ts; } } try { - var presentWatcher = _fs.watch(fileOrDirectory, options, callback); + var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ? + callbackChangingToMissingFileSystemEntry : + callback); // Watch the missing file or directory or error presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); }); return presentWatcher; @@ -5052,11 +5192,23 @@ var ts; return watchPresentFileSystemEntryWithFsWatchFile(); } } + function callbackChangingToMissingFileSystemEntry(event, relativeName) { + // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations + // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path + return event === "rename" && + (!relativeName || + relativeName === lastDirectoryPart || + relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) && + !fileSystemEntryExists(fileOrDirectory, entryKind) ? + invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) : + callback(event, relativeName); + } /** * Watch the file or directory using fs.watchFile since fs.watch threw exception * Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point */ function watchPresentFileSystemEntryWithFsWatchFile() { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile"); return fallbackPollingWatchFile(fileOrDirectory, createFileWatcherCallback(callback), pollingInterval); } /** @@ -5089,7 +5241,7 @@ var ts; function createWatchDirectoryUsing(fsWatchFile) { return function (directoryName, callback) { return fsWatchFile(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium); }; } - function readFile(fileName, _encoding) { + function readFileWorker(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -5117,7 +5269,14 @@ var ts; // Default is UTF-8 with no byte order mark return buffer.toString("utf8"); } + function readFile(fileName, _encoding) { + ts.perfLogger.logStartReadFile(fileName); + var file = readFileWorker(fileName, _encoding); + ts.perfLogger.logStopReadFile(); + return file; + } function writeFile(fileName, data, writeByteOrderMark) { + ts.perfLogger.logEvent("WriteFile: " + fileName); // If a BOM is required, emit one if (writeByteOrderMark) { data = byteOrderMarkIndicator + data; @@ -5134,6 +5293,7 @@ var ts; } } function getAccessibleFileSystemEntries(path) { + ts.perfLogger.logEvent("ReadDir: " + (path || ".")); try { var entries = _fs.readdirSync(path || ".").sort(); var files = []; @@ -5189,6 +5349,7 @@ var ts; return fileSystemEntryExists(path, 1 /* Directory */); } function getDirectories(path) { + ts.perfLogger.logEvent("ReadDir: " + path); return ts.filter(_fs.readdirSync(path), function (dir) { return fileSystemEntryExists(ts.combinePaths(path, dir), 1 /* Directory */); }); } function realpath(path) { @@ -5316,7 +5477,6 @@ var ts; function diag(code, category, key, message, reportsUnnecessary) { return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary }; } - // tslint:disable-next-line variable-name ts.Diagnostics = { Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), @@ -5379,7 +5539,6 @@ var ts; A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), - An_accessor_cannot_be_declared_in_an_ambient_context: diag(1086, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_declared_in_an_ambient_context_1086", "An accessor cannot be declared in an ambient context."), _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), @@ -5434,7 +5593,6 @@ var ts; Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: diag(1150, ts.DiagnosticCategory.Error, "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", "'new T[]' cannot be used to create an array. Use 'new Array()' instead."), const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), @@ -5532,6 +5690,7 @@ var ts; 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."), Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), 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."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -5564,7 +5723,7 @@ var ts; Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), - The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), @@ -5578,6 +5737,7 @@ var ts; readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), + An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), @@ -6358,6 +6518,8 @@ var ts; Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2: diag(6381, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381", "Project '{0}' is out of date because output for it was generated with version '{1}' that differs with current version '{2}'"), + Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), + Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), 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."), @@ -6473,6 +6635,7 @@ var ts; require_call_may_be_converted_to_an_import: diag(80005, ts.DiagnosticCategory.Suggestion, "require_call_may_be_converted_to_an_import_80005", "'require' call may be converted to an import."), This_may_be_converted_to_an_async_function: diag(80006, ts.DiagnosticCategory.Suggestion, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."), await_has_no_effect_on_the_type_of_this_expression: diag(80007, ts.DiagnosticCategory.Suggestion, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."), + Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, ts.DiagnosticCategory.Suggestion, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."), Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"), Make_super_call_the_first_statement_in_the_constructor: diag(90002, ts.DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"), Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"), @@ -6590,6 +6753,12 @@ var ts; Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"), Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"), Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"), + Enable_the_jsx_flag_in_your_configuration_file: diag(95088, ts.DiagnosticCategory.Message, "Enable_the_jsx_flag_in_your_configuration_file_95088", "Enable the '--jsx' flag in your configuration file"), + Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"), + Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"), + Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"), + Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"), + Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"), 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?"), @@ -6684,10 +6853,11 @@ var ts; _a.yield = 118 /* YieldKeyword */, _a.async = 122 /* AsyncKeyword */, _a.await = 123 /* AwaitKeyword */, - _a.of = 148 /* OfKeyword */, + _a.of = 149 /* OfKeyword */, + _a.tag = 148 /* TagKeyword */, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 28 /* LessThanToken */, ">": 30 /* GreaterThanToken */, "<=": 31 /* LessThanEqualsToken */, ">=": 32 /* GreaterThanEqualsToken */, "==": 33 /* EqualsEqualsToken */, "!=": 34 /* ExclamationEqualsToken */, "===": 35 /* EqualsEqualsEqualsToken */, "!==": 36 /* ExclamationEqualsEqualsToken */, "=>": 37 /* EqualsGreaterThanToken */, "+": 38 /* PlusToken */, "-": 39 /* MinusToken */, "**": 41 /* AsteriskAsteriskToken */, "*": 40 /* AsteriskToken */, "/": 42 /* SlashToken */, "%": 43 /* PercentToken */, "++": 44 /* PlusPlusToken */, "--": 45 /* MinusMinusToken */, "<<": 46 /* LessThanLessThanToken */, ">": 47 /* GreaterThanGreaterThanToken */, ">>>": 48 /* GreaterThanGreaterThanGreaterThanToken */, "&": 49 /* AmpersandToken */, "|": 50 /* BarToken */, "^": 51 /* CaretToken */, "!": 52 /* ExclamationToken */, "~": 53 /* TildeToken */, "&&": 54 /* AmpersandAmpersandToken */, "||": 55 /* BarBarToken */, "?": 56 /* QuestionToken */, ":": 57 /* ColonToken */, "=": 60 /* EqualsToken */, "+=": 61 /* PlusEqualsToken */, "-=": 62 /* MinusEqualsToken */, "*=": 63 /* AsteriskEqualsToken */, "**=": 64 /* AsteriskAsteriskEqualsToken */, "/=": 65 /* SlashEqualsToken */, "%=": 66 /* PercentEqualsToken */, "<<=": 67 /* LessThanLessThanEqualsToken */, ">>=": 68 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 70 /* AmpersandEqualsToken */, "|=": 71 /* BarEqualsToken */, "^=": 72 /* CaretEqualsToken */, "@": 58 /* AtToken */, "`": 59 /* BacktickToken */ })); + var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 28 /* LessThanToken */, ">": 30 /* GreaterThanToken */, "<=": 31 /* LessThanEqualsToken */, ">=": 32 /* GreaterThanEqualsToken */, "==": 33 /* EqualsEqualsToken */, "!=": 34 /* ExclamationEqualsToken */, "===": 35 /* EqualsEqualsEqualsToken */, "!==": 36 /* ExclamationEqualsEqualsToken */, "=>": 37 /* EqualsGreaterThanToken */, "+": 38 /* PlusToken */, "-": 39 /* MinusToken */, "**": 41 /* AsteriskAsteriskToken */, "*": 40 /* AsteriskToken */, "/": 42 /* SlashToken */, "%": 43 /* PercentToken */, "++": 44 /* PlusPlusToken */, "--": 45 /* MinusMinusToken */, "<<": 46 /* LessThanLessThanToken */, ">": 47 /* GreaterThanGreaterThanToken */, ">>>": 48 /* GreaterThanGreaterThanGreaterThanToken */, "&": 49 /* AmpersandToken */, "|": 50 /* BarToken */, "^": 51 /* CaretToken */, "!": 52 /* ExclamationToken */, "~": 53 /* TildeToken */, "&&": 54 /* AmpersandAmpersandToken */, "||": 55 /* BarBarToken */, "?": 56 /* QuestionToken */, ":": 57 /* ColonToken */, "=": 60 /* EqualsToken */, "+=": 61 /* PlusEqualsToken */, "-=": 62 /* MinusEqualsToken */, "*=": 63 /* AsteriskEqualsToken */, "**=": 64 /* AsteriskAsteriskEqualsToken */, "/=": 65 /* SlashEqualsToken */, "%=": 66 /* PercentEqualsToken */, "<<=": 67 /* LessThanLessThanEqualsToken */, ">>=": 68 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 70 /* AmpersandEqualsToken */, "|=": 71 /* BarEqualsToken */, "^=": 72 /* CaretEqualsToken */, "@": 58 /* AtToken */, "`": 59 /* BacktickToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -6734,6 +6904,14 @@ var ts; */ var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + /** + * Generated by scripts/regenerate-unicode-identifier-parts.js on node v12.4.0 with unicode 12.1 + * based on http://www.unicode.org/reports/tr31/ and https://www.ecma-international.org/ecma-262/6.0/#sec-names-and-keywords + * unicodeESNextIdentifierStart corresponds to the ID_Start and Other_ID_Start property, and + * unicodeESNextIdentifierPart corresponds to ID_Continue, Other_ID_Continue, plus ID_Start and Other_ID_Start + */ + var unicodeESNextIdentifierStart = [65, 90, 97, 122, 170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2809, 2809, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101]; + var unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2208, 2228, 2230, 2237, 2259, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3328, 3331, 3333, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7673, 7675, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43047, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69376, 69404, 69415, 69415, 69424, 69456, 69600, 69622, 69632, 69702, 69734, 69743, 69759, 69818, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69958, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70096, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70206, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70751, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71680, 71738, 71840, 71913, 71935, 71935, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123584, 123641, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101, 917760, 917999]; function lookupInUnicodeMap(code, map) { // Bail out quickly if it couldn't possibly be in the map. if (code < map[0]) { @@ -6760,15 +6938,17 @@ var ts; return false; } /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierStart) : - lookupInUnicodeMap(code, unicodeES3IdentifierStart); + return languageVersion >= 2 /* ES2015 */ ? + lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : + languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierPart) : - lookupInUnicodeMap(code, unicodeES3IdentifierPart); + return languageVersion >= 2 /* ES2015 */ ? + lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : + languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { var result = []; @@ -6941,6 +7121,7 @@ var ts; case 32 /* space */: case 47 /* slash */: // starts of normal trivia + // falls through case 60 /* lessThan */: case 124 /* bar */: case 61 /* equals */: @@ -7264,11 +7445,12 @@ var ts; ts.isIdentifierPart = isIdentifierPart; /* @internal */ function isIdentifierText(name, languageVersion) { - if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { + var ch = codePointAt(name, 0); + if (!isIdentifierStart(ch, languageVersion)) { return false; } - for (var i = 1; i < name.length; i++) { - if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { + for (var i = charSize(ch); i < name.length; i += charSize(ch)) { + if (!isIdentifierPart(ch = codePointAt(name, i), languageVersion)) { return false; } } @@ -7292,13 +7474,14 @@ var ts; var tokenFlags; var inJSDocType = 0; setText(text, start, length); - return { + var scanner = { getStartPos: function () { return startPos; }, getTextPos: function () { return pos; }, getToken: function () { return token; }, getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, isIdentifier: function () { return token === 73 /* Identifier */ || token > 109 /* LastReservedWord */; }, @@ -7326,6 +7509,15 @@ var ts; lookAhead: lookAhead, scanRange: scanRange, }; + if (ts.Debug.isDebugging) { + Object.defineProperty(scanner, "__debugShowCurrentPositionInText", { + get: function () { + var text = scanner.getText(); + return text.slice(0, scanner.getStartPos()) + "║" + text.slice(scanner.getStartPos()); + }, + }); + } + return scanner; function error(message, errPos, length) { if (errPos === void 0) { errPos = pos; } if (onError) { @@ -7425,7 +7617,7 @@ var ts; } } function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) { - if (!isIdentifierStart(text.charCodeAt(pos), languageVersion)) { + if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) { return; } var identifierStart = pos; @@ -7633,6 +7825,7 @@ var ts; pos++; return scanExtendedUnicodeEscape(); } + tokenFlags |= 1024 /* UnicodeEscape */; // '\uDDDD' return scanHexadecimalEscape(/*numDigits*/ 4); case 120 /* x */: @@ -7715,21 +7908,41 @@ var ts; } return -1; } + function peekExtendedUnicodeEscape() { + if (languageVersion >= 2 /* ES2015 */ && codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) { + var start_2 = pos; + pos += 3; + var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); + var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; + pos = start_2; + return escapedValue; + } + return -1; + } function scanIdentifierParts() { var result = ""; var start = pos; while (pos < end) { - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); if (isIdentifierPart(ch, languageVersion)) { - pos++; + pos += charSize(ch); } else if (ch === 92 /* backslash */) { + ch = peekExtendedUnicodeEscape(); + if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + result += scanExtendedUnicodeEscape(); + start = pos; + continue; + } ch = peekUnicodeEscape(); if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } + tokenFlags |= 1024 /* UnicodeEscape */; result += text.substring(start, pos); - result += String.fromCharCode(ch); + result += utf16EncodeAsString(ch); // Valid Unicode escape is always six characters pos += 6; start = pos; @@ -7817,14 +8030,14 @@ var ts; function scan() { var _a; startPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; var asteriskSeen = false; while (true) { tokenPos = pos; if (pos >= end) { return token = 1 /* EndOfFileToken */; } - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); // Special handling for shebang if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); @@ -8189,9 +8402,17 @@ var ts; pos++; return token = 58 /* AtToken */; case 92 /* backslash */: + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; + tokenFlags |= 1024 /* UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } @@ -8200,9 +8421,9 @@ var ts; return token = 0 /* Unknown */; default: if (isIdentifierStart(ch, languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; + pos += charSize(ch); + while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) + pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); if (ch === 92 /* backslash */) { tokenValue += scanIdentifierParts(); @@ -8210,16 +8431,16 @@ var ts; return token = getIdentifierToken(); } else if (isWhiteSpaceSingleLine(ch)) { - pos++; + pos += charSize(ch); continue; } else if (isLineBreak(ch)) { tokenFlags |= 1 /* PrecedingLineBreak */; - pos++; + pos += charSize(ch); continue; } error(ts.Diagnostics.Invalid_character); - pos++; + pos += charSize(ch); return token = 0 /* Unknown */; } } @@ -8336,7 +8557,7 @@ var ts; // First non-whitespace character on this line. var firstNonWhitespace = 0; // These initial values are special because the first line is: - // firstNonWhitespace = 0 to indicate that we want leading whitspace, + // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { char = text.charCodeAt(pos); if (char === 123 /* openBrace */) { @@ -8370,17 +8591,22 @@ var ts; // they allow dashes function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { - var firstCharPosition = pos; + // An identifier or keyword has already been parsed - check for a `-` and then append it and everything after it to the token + // Do note that this means that `scanJsxIdentifier` effectively _mutates_ the visible token without advancing to a new token + // Any caller should be expecting this behavior and should only read the pos or token value after calling it. while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { + if (ch === 45 /* minus */) { + tokenValue += "-"; pos++; + continue; } - else { + var oldPos = pos; + tokenValue += scanIdentifierParts(); // reuse `scanIdentifierParts` so unicode escapes are handled + if (pos === oldPos) { break; } } - tokenValue += text.substring(firstCharPosition, pos); } return token; } @@ -8398,12 +8624,12 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; if (pos >= end) { return token = 1 /* EndOfFileToken */; } - var ch = text.charCodeAt(pos); - pos++; + var ch = codePointAt(text, pos); + pos += charSize(ch); switch (ch) { case 9 /* tab */: case 11 /* verticalTab */: @@ -8441,12 +8667,33 @@ var ts; return token = 24 /* DotToken */; case 96 /* backtick */: return token = 59 /* BacktickToken */; - } - if (isIdentifierStart(ch, 99 /* Latest */)) { - while (isIdentifierPart(text.charCodeAt(pos), 99 /* Latest */) && pos < end) { + case 92 /* backslash */: + pos--; + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } + var cookedChar = peekUnicodeEscape(); + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + pos += 6; + tokenFlags |= 1024 /* UnicodeEscape */; + tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); + return token = getIdentifierToken(); + } pos++; - } + return token = 0 /* Unknown */; + } + if (isIdentifierStart(ch, languageVersion)) { + var char = ch; + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) + pos += charSize(char); tokenValue = text.substring(tokenPos, pos); + if (char === 92 /* backslash */) { + tokenValue += scanIdentifierParts(); + } return token = getIdentifierToken(); } else { @@ -8522,13 +8769,40 @@ var ts; tokenPos = textPos; token = 0 /* Unknown */; tokenValue = undefined; - tokenFlags = 0; + tokenFlags = 0 /* None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; } } ts.createScanner = createScanner; + /* @internal */ + var codePointAt = String.prototype.codePointAt ? function (s, i) { return s.codePointAt(i); } : function codePointAt(str, i) { + // from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt + var size = str.length; + // Account for out-of-bounds indices: + if (i < 0 || i >= size) { + return undefined; // String.codePointAt returns `undefined` for OOB indexes + } + // Get the first code unit + var first = str.charCodeAt(i); + // check if it’s the start of a surrogate pair + if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) { // high surrogate and there is a next code unit + var second = str.charCodeAt(i + 1); + if (second >= 0xDC00 && second <= 0xDFFF) { // low surrogate + // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + } + } + return first; + }; + /* @internal */ + function charSize(ch) { + if (ch >= 0x10000) { + return 2; + } + return 1; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -8695,7 +8969,7 @@ var ts; } ts.copyEntries = copyEntries; function arrayToSet(array, makeKey) { - return ts.arrayToMap(array, makeKey || (function (s) { return s; }), function () { return true; }); + return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue); } ts.arrayToSet = arrayToSet; function cloneMap(map) { @@ -8804,7 +9078,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 285 /* SourceFile */) { + while (node && node.kind !== 286 /* SourceFile */) { node = node.parent; } return node; @@ -8812,11 +9086,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 220 /* Block */: + case 248 /* CaseBlock */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: return true; } return false; @@ -8901,7 +9175,7 @@ var ts; break; } } - to.splice.apply(to, [statementIndex, 0].concat(from)); + to.splice.apply(to, __spreadArrays([statementIndex, 0], from)); return to; } function insertStatementAfterPrologue(to, statement, isPrologueDirective) { @@ -8984,7 +9258,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 313 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 315 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -9003,7 +9277,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 289 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 290 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -9049,6 +9323,8 @@ var ts; ts.isBigIntLiteral(node))) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } + // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text + // had to include a backslash: `not \${a} substitution`. var escapeText = neverAsciiEscape || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; // If we can't reach the original source text, use the canonical form if it's a number, // or a (possibly escaped) quoted form of the original text if it's string-like. @@ -9061,15 +9337,21 @@ var ts; return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; } case 14 /* NoSubstitutionTemplateLiteral */: - return "`" + escapeText(node.text, 96 /* backtick */) + "`"; case 15 /* TemplateHead */: - // tslint:disable-next-line no-invalid-template-strings - return "`" + escapeText(node.text, 96 /* backtick */) + "${"; case 16 /* TemplateMiddle */: - // tslint:disable-next-line no-invalid-template-strings - return "}" + escapeText(node.text, 96 /* backtick */) + "${"; case 17 /* TemplateTail */: - return "}" + escapeText(node.text, 96 /* backtick */) + "`"; + var rawText = node.rawText || escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); + switch (node.kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + return "`" + rawText + "`"; + case 15 /* TemplateHead */: + return "`" + rawText + "${"; + case 16 /* TemplateMiddle */: + return "}" + rawText + "${"; + case 17 /* TemplateTail */: + return "}" + rawText + "`"; + } + break; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 13 /* RegularExpressionLiteral */: @@ -9095,7 +9377,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 238 /* VariableDeclaration */ && node.parent.kind === 275 /* CatchClause */; + return node.kind === 239 /* VariableDeclaration */ && node.parent.kind === 276 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -9127,11 +9409,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 === 245 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 246 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 285 /* SourceFile */ || - node.kind === 245 /* ModuleDeclaration */ || + return node.kind === 286 /* SourceFile */ || + node.kind === 246 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -9148,9 +9430,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: return ts.isExternalModule(node.parent); - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -9164,24 +9446,61 @@ var ts; return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS) && !!node.commonJsModuleIndicator); } ts.isEffectiveExternalModule = isEffectiveExternalModule; + /** + * Returns whether the source file will be treated as if it were in strict mode at runtime. + */ + function isEffectiveStrictModeSourceFile(node, compilerOptions) { + // We can only verify strict mode for JS/TS files + switch (node.scriptKind) { + case 1 /* JS */: + case 3 /* TS */: + case 2 /* JSX */: + case 4 /* TSX */: + break; + default: + return false; + } + // Strict mode does not matter for declaration files. + if (node.isDeclarationFile) { + return false; + } + // If `alwaysStrict` is set, then treat the file as strict. + if (ts.getStrictOptionValue(compilerOptions, "alwaysStrict")) { + return true; + } + // Starting with a "use strict" directive indicates the file is strict. + if (ts.startsWithUseStrict(node.statements)) { + return true; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + // ECMAScript Modules are always strict. + if (ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { + return true; + } + // Other modules are strict unless otherwise specified. + return !compilerOptions.noImplicitUseStrict; + } + return false; + } + ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 275 /* CatchClause */: - case 245 /* ModuleDeclaration */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 286 /* SourceFile */: + case 248 /* CaseBlock */: + case 276 /* CatchClause */: + case 246 /* ModuleDeclaration */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return true; - case 219 /* Block */: + case 220 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -9191,9 +9510,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: - case 299 /* JSDocSignature */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 301 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -9203,25 +9522,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 157 /* MethodSignature */: + case 164 /* IndexSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 296 /* JSDocFunctionType */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 312 /* JSDocTemplateTag */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -9231,8 +9550,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: return true; default: return false; @@ -9241,15 +9560,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 220 /* VariableStatement */: - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 221 /* VariableStatement */: + case 242 /* ClassDeclaration */: + case 241 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: return true; default: return false; @@ -9285,7 +9604,7 @@ var ts; case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 151 /* 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"); @@ -9298,9 +9617,9 @@ var ts; switch (name.kind) { case 73 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -9345,7 +9664,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 219 /* Block */) { + if (node.body && node.body.kind === 220 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -9359,7 +9678,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 285 /* SourceFile */: + case 286 /* 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 @@ -9368,25 +9687,25 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 239 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 244 /* TypeAliasDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: errorNode = node.name; break; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -9394,6 +9713,7 @@ var ts; // construct. return getSpanOfTokenAtPosition(sourceFile, node.pos); } + ts.Debug.assert(!ts.isJSDoc(errorNode)); var isMissing = nodeIsMissing(errorNode); var pos = isMissing || ts.isJsxText(node) ? errorNode.pos @@ -9423,7 +9743,7 @@ var ts; } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { @@ -9435,19 +9755,25 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 99 /* SuperKeyword */; + return n.kind === 193 /* CallExpression */ && n.expression.kind === 99 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 93 /* ImportKeyword */; + return n.kind === 193 /* CallExpression */ && n.expression.kind === 93 /* ImportKeyword */; } ts.isImportCall = isImportCall; + function isImportMeta(n) { + return ts.isMetaProperty(n) + && n.keywordToken === 93 /* ImportKeyword */ + && n.name.escapedText === "meta"; + } + ts.isImportMeta = isImportMeta; function isLiteralImportTypeNode(n) { return ts.isImportTypeNode(n) && ts.isLiteralTypeNode(n.argument) && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 222 /* ExpressionStatement */ + return node.kind === 223 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -9456,11 +9782,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 152 /* Parameter */ || - node.kind === 151 /* TypeParameter */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 198 /* ArrowFunction */ || - node.kind === 196 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 153 /* Parameter */ || + node.kind === 152 /* TypeParameter */ || + node.kind === 198 /* FunctionExpression */ || + node.kind === 199 /* ArrowFunction */ || + node.kind === 197 /* ParenthesizedExpression */) ? 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 '/**/' @@ -9476,7 +9802,7 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (164 /* FirstTypeNode */ <= node.kind && node.kind <= 184 /* LastTypeNode */) { + if (165 /* FirstTypeNode */ <= node.kind && node.kind <= 185 /* LastTypeNode */) { return true; } switch (node.kind) { @@ -9492,32 +9818,32 @@ var ts; case 133 /* NeverKeyword */: return true; case 107 /* VoidKeyword */: - return node.parent.kind !== 201 /* VoidExpression */; - case 212 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 202 /* VoidExpression */; + case 213 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 151 /* TypeParameter */: - return node.parent.kind === 182 /* MappedType */ || node.parent.kind === 177 /* InferType */; + case 152 /* TypeParameter */: + return node.parent.kind === 183 /* MappedType */ || node.parent.kind === 178 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 73 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 150 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 191 /* 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 === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */ || node.kind === 190 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 73 /* Identifier */ || node.kind === 150 /* QualifiedName */ || node.kind === 191 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 149 /* QualifiedName */: - case 190 /* PropertyAccessExpression */: + case 150 /* QualifiedName */: + case 191 /* PropertyAccessExpression */: case 101 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 168 /* TypeQuery */) { + if (parent.kind === 169 /* TypeQuery */) { return false; } - if (parent.kind === 184 /* ImportType */) { + if (parent.kind === 185 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -9526,40 +9852,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 (164 /* FirstTypeNode */ <= parent.kind && parent.kind <= 184 /* LastTypeNode */) { + if (165 /* FirstTypeNode */ <= parent.kind && parent.kind <= 185 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return node === parent.constraint; - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return node === parent.constraint; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 153 /* Parameter */: + case 239 /* VariableDeclaration */: return node === parent.type; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return node === parent.type; - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: return node === parent.type; - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: return node === parent.type; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -9584,23 +9910,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitor(node); - case 247 /* CaseBlock */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 248 /* CaseBlock */: + case 220 /* Block */: + case 224 /* IfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 233 /* WithStatement */: + case 234 /* SwitchStatement */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: + case 235 /* LabeledStatement */: + case 237 /* TryStatement */: + case 276 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -9610,26 +9936,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 245 /* EnumDeclaration */: + case 243 /* InterfaceDeclaration */: + case 246 /* ModuleDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 151 /* 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); @@ -9652,10 +9978,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 170 /* ArrayType */) { + if (node && node.kind === 171 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 165 /* TypeReference */) { + else if (node && node.kind === 166 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9665,12 +9991,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 169 /* TypeLiteral */: + case 243 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 170 /* TypeLiteral */: return node.members; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return node.properties; } } @@ -9678,14 +10004,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 187 /* BindingElement */: - case 279 /* EnumMember */: - case 152 /* Parameter */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 277 /* ShorthandPropertyAssignment */: - case 238 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 280 /* EnumMember */: + case 153 /* Parameter */: + case 277 /* PropertyAssignment */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 278 /* ShorthandPropertyAssignment */: + case 239 /* VariableDeclaration */: return true; } } @@ -9697,8 +10023,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 239 /* VariableDeclarationList */ - && node.parent.parent.kind === 220 /* VariableStatement */; + return node.parent.kind === 240 /* VariableDeclarationList */ + && node.parent.parent.kind === 221 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -9709,13 +10035,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: return true; } return false; @@ -9726,7 +10052,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 234 /* LabeledStatement */) { + if (node.statement.kind !== 235 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -9734,17 +10060,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 219 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 220 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 157 /* MethodDeclaration */ && node.parent.kind === 189 /* ObjectLiteralExpression */; + return node && node.kind === 158 /* MethodDeclaration */ && node.parent.kind === 190 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 157 /* MethodDeclaration */ && - (node.parent.kind === 189 /* ObjectLiteralExpression */ || - node.parent.kind === 210 /* ClassExpression */); + return node.kind === 158 /* MethodDeclaration */ && + (node.parent.kind === 190 /* ObjectLiteralExpression */ || + node.parent.kind === 211 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -9757,7 +10083,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 276 /* PropertyAssignment */) { + if (property.kind === 277 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -9798,14 +10124,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 285 /* SourceFile */); + ts.Debug.assert(node.kind !== 286 /* 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 150 /* ComputedPropertyName */: + case 151 /* 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 @@ -9820,9 +10146,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 153 /* Decorator */: + case 154 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 153 /* 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; @@ -9833,26 +10159,26 @@ var ts; node = node.parent; } break; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 245 /* ModuleDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 244 /* EnumDeclaration */: - case 285 /* SourceFile */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 246 /* ModuleDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 245 /* EnumDeclaration */: + case 286 /* SourceFile */: return node; } } @@ -9862,9 +10188,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 159 /* Constructor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: return container; } } @@ -9886,27 +10212,27 @@ var ts; return node; } switch (node.kind) { - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: node = node.parent; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return node; - case 153 /* Decorator */: + case 154 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 153 /* 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; @@ -9922,14 +10248,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 197 /* FunctionExpression */ || func.kind === 198 /* ArrowFunction */) { + if (func.kind === 198 /* FunctionExpression */ || func.kind === 199 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 196 /* ParenthesizedExpression */) { + while (parent.kind === 197 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 192 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 193 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -9945,7 +10271,7 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) + return (kind === 191 /* PropertyAccessExpression */ || kind === 192 /* ElementAccessExpression */) && node.expression.kind === 99 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; @@ -9954,20 +10280,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) + return (kind === 191 /* PropertyAccessExpression */ || kind === 192 /* ElementAccessExpression */) && node.expression.kind === 101 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return node; } return undefined; @@ -9975,10 +10301,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return node.tag; - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -9987,25 +10313,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: // classes are valid targets return true; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 241 /* ClassDeclaration */; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + return parent.kind === 242 /* ClassDeclaration */; + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 158 /* 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 === 241 /* ClassDeclaration */; - case 152 /* Parameter */: + && parent.kind === 242 /* ClassDeclaration */; + case 153 /* 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 === 158 /* Constructor */ - || parent.kind === 157 /* MethodDeclaration */ - || parent.kind === 160 /* SetAccessor */) - && grandparent.kind === 241 /* ClassDeclaration */; + && (parent.kind === 159 /* Constructor */ + || parent.kind === 158 /* MethodDeclaration */ + || parent.kind === 161 /* SetAccessor */) + && grandparent.kind === 242 /* ClassDeclaration */; } return false; } @@ -10021,10 +10347,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 161 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -10033,9 +10359,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 263 /* JsxOpeningElement */ || - parent.kind === 262 /* JsxSelfClosingElement */ || - parent.kind === 264 /* JsxClosingElement */) { + if (parent.kind === 264 /* JsxOpeningElement */ || + parent.kind === 263 /* JsxSelfClosingElement */ || + parent.kind === 265 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -10048,45 +10374,45 @@ var ts; case 103 /* TrueKeyword */: case 88 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 213 /* AsExpression */: - case 195 /* TypeAssertionExpression */: - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 209 /* SpreadElement */: - case 207 /* TemplateExpression */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 195 /* TaggedTemplateExpression */: + case 214 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 215 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: + case 198 /* FunctionExpression */: + case 211 /* ClassExpression */: + case 199 /* ArrowFunction */: + case 202 /* VoidExpression */: + case 200 /* DeleteExpression */: + case 201 /* TypeOfExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: + case 206 /* BinaryExpression */: + case 207 /* ConditionalExpression */: + case 210 /* SpreadElement */: + case 208 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: - case 211 /* OmittedExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 208 /* YieldExpression */: - case 202 /* AwaitExpression */: - case 215 /* MetaProperty */: + case 212 /* OmittedExpression */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 266 /* JsxFragment */: + case 209 /* YieldExpression */: + case 203 /* AwaitExpression */: + case 216 /* MetaProperty */: return true; - case 149 /* QualifiedName */: - while (node.parent.kind === 149 /* QualifiedName */) { + case 150 /* QualifiedName */: + while (node.parent.kind === 150 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node); + return node.parent.kind === 169 /* TypeQuery */ || isJSXTagName(node); case 73 /* Identifier */: - if (node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node)) { + if (node.parent.kind === 169 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through @@ -10103,49 +10429,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 187 /* BindingElement */: + case 239 /* VariableDeclaration */: + case 153 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 280 /* EnumMember */: + case 277 /* PropertyAssignment */: + case 188 /* BindingElement */: return parent.initializer === node; - case 222 /* ExpressionStatement */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 231 /* ReturnStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 235 /* ThrowStatement */: + case 223 /* ExpressionStatement */: + case 224 /* IfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 232 /* ReturnStatement */: + case 233 /* WithStatement */: + case 234 /* SwitchStatement */: + case 273 /* CaseClause */: + case 236 /* ThrowStatement */: return parent.expression === node; - case 226 /* ForStatement */: + case 227 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 240 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 240 /* VariableDeclarationList */) || forInStatement.expression === node; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: return node === parent.expression; - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return node === parent.expression; - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return node === parent.expression; - case 153 /* Decorator */: - case 271 /* JsxExpression */: - case 270 /* JsxSpreadAttribute */: - case 278 /* SpreadAssignment */: + case 154 /* Decorator */: + case 272 /* JsxExpression */: + case 271 /* JsxSpreadAttribute */: + case 279 /* SpreadAssignment */: return true; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -10153,7 +10479,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */; + return node.kind === 250 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 261 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -10162,7 +10488,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 260 /* ExternalModuleReference */; + return node.kind === 250 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 261 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -10194,7 +10520,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 192 /* CallExpression */) { + if (callExpression.kind !== 193 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -10306,11 +10632,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 197 /* FunctionExpression */ || e.kind === 198 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 198 /* FunctionExpression */ || e.kind === 199 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 197 /* FunctionExpression */ || - initializer.kind === 210 /* ClassExpression */ || - initializer.kind === 198 /* ArrowFunction */) { + if (initializer.kind === 198 /* FunctionExpression */ || + initializer.kind === 211 /* ClassExpression */ || + initializer.kind === 199 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -10478,7 +10804,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 222 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 223 /* ExpressionStatement */ && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -10487,7 +10813,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 240 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 241 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -10496,14 +10822,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: return node.parent; - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: return node.parent.parent; - case 192 /* CallExpression */: + case 193 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 183 /* LiteralType */: + case 184 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -10513,12 +10839,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: return node.moduleSpecifier; - case 249 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 260 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 184 /* ImportType */: + case 250 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 261 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 185 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -10527,11 +10853,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return node; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -10539,19 +10865,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 250 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 251 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 152 /* Parameter */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 277 /* ShorthandPropertyAssignment */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 153 /* Parameter */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 278 /* ShorthandPropertyAssignment */: + case 277 /* PropertyAssignment */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -10565,7 +10891,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 311 /* JSDocTypedefTag */ || node.kind === 304 /* JSDocCallbackTag */; + return node.kind === 313 /* JSDocTypedefTag */ || node.kind === 306 /* JSDocCallbackTag */ || node.kind === 307 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10590,12 +10916,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return node.initializer; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return node.initializer; } } @@ -10606,7 +10932,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 245 /* ModuleDeclaration */ + node.body.kind === 246 /* ModuleDeclaration */ ? node.body : undefined; } @@ -10621,11 +10947,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 152 /* Parameter */) { + if (node.kind === 153 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 151 /* TypeParameter */) { + if (node.kind === 152 /* TypeParameter */) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -10636,10 +10962,10 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 276 /* PropertyAssignment */ || - parent.kind === 255 /* ExportAssignment */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 222 /* ExpressionStatement */ && node.kind === 190 /* PropertyAccessExpression */ || + if (parent.kind === 277 /* PropertyAssignment */ || + parent.kind === 256 /* ExportAssignment */ || + parent.kind === 156 /* PropertyDeclaration */ || + parent.kind === 223 /* ExpressionStatement */ && node.kind === 191 /* PropertyAccessExpression */ || getNestedModuleDeclaration(parent) || ts.isBinaryExpression(node) && node.operatorToken.kind === 60 /* EqualsToken */) { return parent; @@ -10700,7 +11026,7 @@ var ts; function getTypeParameterFromJsDoc(node) { var name = node.name.escapedText; var typeParameters = node.parent.parent.parent.typeParameters; - return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); + return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { @@ -10710,7 +11036,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 === 296 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 297 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10723,31 +11049,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 60 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 44 /* PlusPlusToken */ || unaryOperator === 45 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 196 /* ParenthesizedExpression */: - case 188 /* ArrayLiteralExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: + case 189 /* ArrayLiteralExpression */: + case 210 /* SpreadElement */: + case 215 /* NonNullExpression */: node = parent; break; - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -10774,22 +11100,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 219 /* Block */: - case 220 /* VariableStatement */: - case 232 /* WithStatement */: - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 220 /* Block */: + case 221 /* VariableStatement */: + case 233 /* WithStatement */: + case 224 /* IfStatement */: + case 234 /* SwitchStatement */: + case 248 /* CaseBlock */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: + case 235 /* LabeledStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 237 /* TryStatement */: + case 276 /* CatchClause */: return true; } return false; @@ -10806,33 +11132,33 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 178 /* ParenthesizedType */); + return walkUp(node, 179 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 196 /* ParenthesizedExpression */); + return walkUp(node, 197 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 197 /* ParenthesizedExpression */) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 197 /* 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 !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 191 /* PropertyAccessExpression */ && node.kind !== 192 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 199 /* DeleteExpression */; + return node && node.kind === 200 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -10882,7 +11208,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 10 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 150 /* ComputedPropertyName */ && + node.parent.kind === 151 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -10890,32 +11216,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 190 /* PropertyAccessExpression */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 280 /* EnumMember */: + case 277 /* PropertyAssignment */: + case 191 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 149 /* QualifiedName */) { + while (parent.kind === 150 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 168 /* TypeQuery */ || parent.kind === 165 /* TypeReference */; + return parent.kind === 169 /* TypeQuery */ || parent.kind === 166 /* TypeReference */; } return false; - case 187 /* BindingElement */: - case 254 /* ImportSpecifier */: + case 188 /* BindingElement */: + case 255 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 258 /* ExportSpecifier */: - case 268 /* JsxAttribute */: + case 259 /* ExportSpecifier */: + case 269 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -10932,13 +11258,13 @@ var ts; // export default // module.exports = function isAliasSymbolDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 248 /* NamespaceExportDeclaration */ || - node.kind === 251 /* ImportClause */ && !!node.name || - node.kind === 252 /* NamespaceImport */ || - node.kind === 254 /* ImportSpecifier */ || - node.kind === 258 /* ExportSpecifier */ || - node.kind === 255 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + return node.kind === 250 /* ImportEqualsDeclaration */ || + node.kind === 249 /* NamespaceExportDeclaration */ || + node.kind === 252 /* ImportClause */ && !!node.name || + node.kind === 253 /* NamespaceImport */ || + node.kind === 255 /* ImportSpecifier */ || + node.kind === 259 /* ExportSpecifier */ || + node.kind === 256 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -10971,9 +11297,9 @@ var ts; ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { - return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray - : ts.emptyArray; + return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray : + ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : + ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { @@ -11004,17 +11330,21 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 74 /* FirstKeyword */ <= token && token <= 148 /* LastKeyword */; + return 74 /* FirstKeyword */ <= token && token <= 149 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 119 /* FirstContextualKeyword */ <= token && token <= 148 /* LastContextualKeyword */; + return 119 /* FirstContextualKeyword */ <= token && token <= 149 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { return isKeyword(token) && !isContextualKeyword(token); } ts.isNonContextualKeyword = isNonContextualKeyword; + function isFutureReservedKeyword(token) { + return 110 /* FirstFutureReservedWord */ <= token && token <= 118 /* LastFutureReservedWord */; + } + ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { var token = ts.stringToToken(name); return token !== undefined && isNonContextualKeyword(token); @@ -11043,14 +11373,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -11064,10 +11394,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -11100,7 +11430,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 150 /* ComputedPropertyName */ && + return name.kind === 151 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression) && !isSignedNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); @@ -11122,7 +11452,7 @@ var ts; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -11177,11 +11507,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 152 /* Parameter */; + return root.kind === 153 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 187 /* BindingElement */) { + while (node.kind === 188 /* BindingElement */) { node = node.parent.parent; } return node; @@ -11189,15 +11519,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 197 /* FunctionExpression */ - || kind === 240 /* FunctionDeclaration */ - || kind === 198 /* ArrowFunction */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 245 /* ModuleDeclaration */ - || kind === 285 /* SourceFile */; + return kind === 159 /* Constructor */ + || kind === 198 /* FunctionExpression */ + || kind === 241 /* FunctionDeclaration */ + || kind === 199 /* ArrowFunction */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */ + || kind === 246 /* ModuleDeclaration */ + || kind === 286 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -11216,23 +11546,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 194 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 193 /* NewExpression */: + case 194 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: + case 204 /* PrefixUnaryExpression */: + case 201 /* TypeOfExpression */: + case 202 /* VoidExpression */: + case 200 /* DeleteExpression */: + case 203 /* AwaitExpression */: + case 207 /* ConditionalExpression */: + case 209 /* YieldExpression */: return 1 /* Right */; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (operator) { case 41 /* AsteriskAsteriskToken */: case 60 /* EqualsToken */: @@ -11256,15 +11586,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 194 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 205 /* BinaryExpression */) { + if (expression.kind === 206 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 203 /* PrefixUnaryExpression */ || expression.kind === 204 /* PostfixUnaryExpression */) { + else if (expression.kind === 204 /* PrefixUnaryExpression */ || expression.kind === 205 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -11274,15 +11604,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: return 0; - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return 1; - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return 2; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return 4; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0; @@ -11303,21 +11633,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: + case 204 /* PrefixUnaryExpression */: + case 201 /* TypeOfExpression */: + case 202 /* VoidExpression */: + case 200 /* DeleteExpression */: + case 203 /* AwaitExpression */: return 16; - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return 17; - case 192 /* CallExpression */: + case 193 /* CallExpression */: return 18; - case 193 /* NewExpression */: + case 194 /* NewExpression */: return hasArguments ? 19 : 18; - case 194 /* TaggedTemplateExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 195 /* TaggedTemplateExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return 19; case 101 /* ThisKeyword */: case 99 /* SuperKeyword */: @@ -11328,19 +11658,19 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 211 /* ClassExpression */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 266 /* JsxFragment */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 196 /* ParenthesizedExpression */: - case 211 /* OmittedExpression */: + case 208 /* TemplateExpression */: + case 197 /* ParenthesizedExpression */: + case 212 /* OmittedExpression */: return 20; default: return -1; @@ -11460,6 +11790,10 @@ var ts; } } ts.createDiagnosticCollection = createDiagnosticCollection; + var templateSubstitutionRegExp = /\$\{/g; + function escapeTemplateSubstitution(str) { + return str.replace(templateSubstitutionRegExp, "\\${"); + } // This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, // paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in // the language service. These characters should be escaped when printing, and if any characters are added, @@ -11467,7 +11801,8 @@ var ts; // There is no reason for this other than that JSON.stringify does not handle it either. var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var backtickQuoteEscapedCharsRegExp = /[\\\`\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + // Template strings should be preserved as much as possible + var backtickQuoteEscapedCharsRegExp = /[\\\`]/g; var escapedCharsMap = ts.createMapFromTemplate({ "\t": "\\t", "\v": "\\v", @@ -11645,7 +11980,7 @@ var ts; }; } ts.createTextWriter = createTextWriter; - function getTrailingSemicolonOmittingWriter(writer) { + function getTrailingSemicolonDeferringWriter(writer) { var pendingTrailingSemicolon = false; function commitPendingTrailingSemicolon() { if (pendingTrailingSemicolon) { @@ -11653,7 +11988,7 @@ var ts; pendingTrailingSemicolon = false; } } - return __assign({}, writer, { writeTrailingSemicolon: function () { + return __assign(__assign({}, writer), { writeTrailingSemicolon: function () { pendingTrailingSemicolon = true; }, writeLiteral: function (s) { @@ -11707,6 +12042,17 @@ var ts; decreaseIndent: function () { commitPendingTrailingSemicolon(); writer.decreaseIndent(); + }, + resetPendingTrailingSemicolon: function () { + pendingTrailingSemicolon = false; + } }); + } + ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter; + function getTrailingSemicolonOmittingWriter(writer) { + var deferringWriter = getTrailingSemicolonDeferringWriter(writer); + return __assign(__assign({}, deferringWriter), { writeLine: function () { + deferringWriter.resetPendingTrailingSemicolon(); + writer.writeLine(); } }); } ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; @@ -11828,6 +12174,7 @@ var ts; return accessor.parameters[hasThis ? 1 : 0]; } } + ts.getSetAccessorValueParameter = getSetAccessorValueParameter; /** Get the type annotation for the value parameter. */ function getSetAccessorTypeAnnotationNode(accessor) { var parameter = getSetAccessorValueParameter(accessor); @@ -11864,10 +12211,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 160 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 160 /* SetAccessor */) { + else if (accessor.kind === 161 /* SetAccessor */) { setAccessor = accessor; } else { @@ -11887,10 +12234,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 159 /* GetAccessor */ && !getAccessor) { + if (member.kind === 160 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 160 /* SetAccessor */ && !setAccessor) { + if (member.kind === 161 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -11936,7 +12283,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 === 297 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 299 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -12234,8 +12581,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 189 /* ObjectLiteralExpression */ - || kind === 188 /* ArrayLiteralExpression */; + return kind === 190 /* ObjectLiteralExpression */ + || kind === 189 /* ArrayLiteralExpression */; } return false; } @@ -12267,17 +12614,17 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 150 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 191 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 189 /* ObjectLiteralExpression */ && + return expression.kind === 190 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 188 /* ArrayLiteralExpression */ && + return expression.kind === 189 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -12575,8 +12922,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 246 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -12653,35 +13000,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return accessKind(parent); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 44 /* PlusPlusToken */ || operator === 45 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? operatorToken.kind === 60 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 276 /* PropertyAssignment */: { + case 277 /* 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 277 /* ShorthandPropertyAssignment */: + case 278 /* 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 188 /* ArrayLiteralExpression */: + case 189 /* 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 === 222 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 223 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -12727,8 +13074,8 @@ var ts; /** * Mutates the map with newMap such that keys in map will be same as newMap. */ - function mutateMap(map, newMap, options) { - var createNewValue = options.createNewValue, onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; + function mutateMapSkippingNewValues(map, newMap, options) { + var onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; // Needs update map.forEach(function (existingValue, key) { var valueInNewMap = newMap.get(key); @@ -12742,6 +13089,15 @@ var ts; onExistingValue(existingValue, valueInNewMap, key); } }); + } + ts.mutateMapSkippingNewValues = mutateMapSkippingNewValues; + /** + * Mutates the map with newMap such that keys in map will be same as newMap. + */ + function mutateMap(map, newMap, options) { + // Needs update + mutateMapSkippingNewValues(map, newMap, options); + var createNewValue = options.createNewValue; // Add new values that are not already present newMap.forEach(function (valueInNewMap, key) { if (!map.has(key)) { @@ -12836,7 +13192,7 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) + return (kind >= 165 /* FirstTypeNode */ && kind <= 185 /* LastTypeNode */) || kind === 121 /* AnyKeyword */ || kind === 144 /* UnknownKeyword */ || kind === 136 /* NumberKeyword */ @@ -12850,18 +13206,18 @@ var ts; || kind === 142 /* UndefinedKeyword */ || kind === 97 /* NullKeyword */ || kind === 133 /* NeverKeyword */ - || kind === 212 /* ExpressionWithTypeArguments */ - || kind === 290 /* JSDocAllType */ - || kind === 291 /* JSDocUnknownType */ - || kind === 292 /* JSDocNullableType */ - || kind === 293 /* JSDocNonNullableType */ - || kind === 294 /* JSDocOptionalType */ - || kind === 295 /* JSDocFunctionType */ - || kind === 296 /* JSDocVariadicType */; + || kind === 213 /* ExpressionWithTypeArguments */ + || kind === 291 /* JSDocAllType */ + || kind === 292 /* JSDocUnknownType */ + || kind === 293 /* JSDocNullableType */ + || kind === 294 /* JSDocNonNullableType */ + || kind === 295 /* JSDocOptionalType */ + || kind === 296 /* JSDocFunctionType */ + || kind === 297 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */ || node.kind === 191 /* ElementAccessExpression */; + return node.kind === 191 /* PropertyAccessExpression */ || node.kind === 192 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function isBundleFileTextLike(section) { @@ -12981,7 +13337,7 @@ var ts; return { span: span, newLength: newLength }; } ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); // eslint-disable-line prefer-const /** * Called to merge all the changes that occurred across several versions of a script snapshot * into a single change. i.e. if a user keeps making successive edits to a script we will @@ -13098,17 +13454,17 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 151 /* TypeParameter */) { + if (d && d.kind === 152 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 243 /* InterfaceDeclaration */) { return current; } } } } ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 158 /* Constructor */; + function isParameterPropertyDeclaration(node, parent) { + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 159 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -13138,14 +13494,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 238 /* VariableDeclaration */) { + if (node.kind === 239 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 239 /* VariableDeclarationList */) { + if (node && node.kind === 240 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 220 /* VariableStatement */) { + if (node && node.kind === 221 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -13209,7 +13565,8 @@ var ts; return false; } try { - // tslint:disable-next-line no-unnecessary-qualifier (making clear this is a global mutation!) + // making clear this is a global mutation! + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier ts.localizedDiagnosticMessages = JSON.parse(fileContents); } catch (_a) { @@ -13291,27 +13648,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: var expr = hostNode.expression; + if (expr.kind === 206 /* BinaryExpression */ && expr.operatorToken.kind === 60 /* EqualsToken */) { + expr = expr.left; + } switch (expr.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return expr.name; - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 196 /* ParenthesizedExpression */: { + case 197 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 234 /* LabeledStatement */: { + case 235 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -13337,16 +13697,16 @@ var ts; switch (declaration.kind) { case 73 /* Identifier */: return declaration; - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: { + case 314 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 149 /* QualifiedName */) { + if (name.kind === 150 /* QualifiedName */) { return name.right; } break; } - case 192 /* CallExpression */: - case 205 /* BinaryExpression */: { + case 193 /* CallExpression */: + case 206 /* BinaryExpression */: { var expr = declaration; switch (ts.getAssignmentDeclarationKind(expr)) { case 1 /* ExportsProperty */: @@ -13362,9 +13722,11 @@ var ts; return undefined; } } - case 311 /* JSDocTypedefTag */: + case 313 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 255 /* ExportAssignment */: { + case 307 /* JSDocEnumTag */: + return nameForNamelessJSDocTypedef(declaration); + case 256 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } @@ -13569,7 +13931,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 297 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 299 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13589,10 +13951,9 @@ var ts; } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getEffectiveConstraintOfTypeParameter(node) { - return node.constraint ? node.constraint - : ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] - ? node.parent.constraint - : undefined; + return node.constraint ? node.constraint : + ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint : + undefined; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; })(ts || (ts = {})); @@ -13642,193 +14003,193 @@ var ts; ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 149 /* QualifiedName */; + return node.kind === 150 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 150 /* ComputedPropertyName */; + return node.kind === 151 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 151 /* TypeParameter */; + return node.kind === 152 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 152 /* Parameter */; + return node.kind === 153 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 153 /* Decorator */; + return node.kind === 154 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 154 /* PropertySignature */; + return node.kind === 155 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 155 /* PropertyDeclaration */; + return node.kind === 156 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 156 /* MethodSignature */; + return node.kind === 157 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 158 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 158 /* Constructor */; + return node.kind === 159 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 160 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 161 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 161 /* CallSignature */; + return node.kind === 162 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 162 /* ConstructSignature */; + return node.kind === 163 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 163 /* IndexSignature */; + return node.kind === 164 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */ || node.kind === 159 /* GetAccessor */; + return node.kind === 161 /* SetAccessor */ || node.kind === 160 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 164 /* TypePredicate */; + return node.kind === 165 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 165 /* TypeReference */; + return node.kind === 166 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 166 /* FunctionType */; + return node.kind === 167 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 167 /* ConstructorType */; + return node.kind === 168 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 168 /* TypeQuery */; + return node.kind === 169 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 169 /* TypeLiteral */; + return node.kind === 170 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 170 /* ArrayType */; + return node.kind === 171 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 171 /* TupleType */; + return node.kind === 172 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 174 /* UnionType */; + return node.kind === 175 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 175 /* IntersectionType */; + return node.kind === 176 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 176 /* ConditionalType */; + return node.kind === 177 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 177 /* InferType */; + return node.kind === 178 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 178 /* ParenthesizedType */; + return node.kind === 179 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 179 /* ThisType */; + return node.kind === 180 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 180 /* TypeOperator */; + return node.kind === 181 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 181 /* IndexedAccessType */; + return node.kind === 182 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 182 /* MappedType */; + return node.kind === 183 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 183 /* LiteralType */; + return node.kind === 184 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 184 /* ImportType */; + return node.kind === 185 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 185 /* ObjectBindingPattern */; + return node.kind === 186 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 186 /* ArrayBindingPattern */; + return node.kind === 187 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 187 /* BindingElement */; + return node.kind === 188 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 188 /* ArrayLiteralExpression */; + return node.kind === 189 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 189 /* ObjectLiteralExpression */; + return node.kind === 190 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */; + return node.kind === 191 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 191 /* ElementAccessExpression */; + return node.kind === 192 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 192 /* CallExpression */; + return node.kind === 193 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 193 /* NewExpression */; + return node.kind === 194 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 194 /* TaggedTemplateExpression */; + return node.kind === 195 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 195 /* TypeAssertionExpression */; + return node.kind === 196 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isConstTypeReference(node) { @@ -13837,376 +14198,376 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function isParenthesizedExpression(node) { - return node.kind === 196 /* ParenthesizedExpression */; + return node.kind === 197 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 315 /* PartiallyEmittedExpression */) { + while (node.kind === 317 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 197 /* FunctionExpression */; + return node.kind === 198 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 198 /* ArrowFunction */; + return node.kind === 199 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 199 /* DeleteExpression */; + return node.kind === 200 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 200 /* TypeOfExpression */; + return node.kind === 201 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 201 /* VoidExpression */; + return node.kind === 202 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 202 /* AwaitExpression */; + return node.kind === 203 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 203 /* PrefixUnaryExpression */; + return node.kind === 204 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 204 /* PostfixUnaryExpression */; + return node.kind === 205 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 205 /* BinaryExpression */; + return node.kind === 206 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 206 /* ConditionalExpression */; + return node.kind === 207 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 207 /* TemplateExpression */; + return node.kind === 208 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 208 /* YieldExpression */; + return node.kind === 209 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 209 /* SpreadElement */; + return node.kind === 210 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 210 /* ClassExpression */; + return node.kind === 211 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 211 /* OmittedExpression */; + return node.kind === 212 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 213 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 213 /* AsExpression */; + return node.kind === 214 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 214 /* NonNullExpression */; + return node.kind === 215 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 215 /* MetaProperty */; + return node.kind === 216 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 217 /* TemplateSpan */; + return node.kind === 218 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 218 /* SemicolonClassElement */; + return node.kind === 219 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 219 /* Block */; + return node.kind === 220 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 220 /* VariableStatement */; + return node.kind === 221 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 221 /* EmptyStatement */; + return node.kind === 222 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 222 /* ExpressionStatement */; + return node.kind === 223 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 223 /* IfStatement */; + return node.kind === 224 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 224 /* DoStatement */; + return node.kind === 225 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 225 /* WhileStatement */; + return node.kind === 226 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 226 /* ForStatement */; + return node.kind === 227 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 227 /* ForInStatement */; + return node.kind === 228 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 228 /* ForOfStatement */; + return node.kind === 229 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 229 /* ContinueStatement */; + return node.kind === 230 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 230 /* BreakStatement */; + return node.kind === 231 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 230 /* BreakStatement */ || node.kind === 229 /* ContinueStatement */; + return node.kind === 231 /* BreakStatement */ || node.kind === 230 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 231 /* ReturnStatement */; + return node.kind === 232 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 232 /* WithStatement */; + return node.kind === 233 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 233 /* SwitchStatement */; + return node.kind === 234 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 234 /* LabeledStatement */; + return node.kind === 235 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 235 /* ThrowStatement */; + return node.kind === 236 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 236 /* TryStatement */; + return node.kind === 237 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 237 /* DebuggerStatement */; + return node.kind === 238 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 238 /* VariableDeclaration */; + return node.kind === 239 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 239 /* VariableDeclarationList */; + return node.kind === 240 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 240 /* FunctionDeclaration */; + return node.kind === 241 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 241 /* ClassDeclaration */; + return node.kind === 242 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 242 /* InterfaceDeclaration */; + return node.kind === 243 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 243 /* TypeAliasDeclaration */; + return node.kind === 244 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 244 /* EnumDeclaration */; + return node.kind === 245 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */; + return node.kind === 246 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 246 /* ModuleBlock */; + return node.kind === 247 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 247 /* CaseBlock */; + return node.kind === 248 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 248 /* NamespaceExportDeclaration */; + return node.kind === 249 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */; + return node.kind === 250 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 250 /* ImportDeclaration */; + return node.kind === 251 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 251 /* ImportClause */; + return node.kind === 252 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 252 /* NamespaceImport */; + return node.kind === 253 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 253 /* NamedImports */; + return node.kind === 254 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 254 /* ImportSpecifier */; + return node.kind === 255 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 255 /* ExportAssignment */; + return node.kind === 256 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 256 /* ExportDeclaration */; + return node.kind === 257 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 257 /* NamedExports */; + return node.kind === 258 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 258 /* ExportSpecifier */; + return node.kind === 259 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 259 /* MissingDeclaration */; + return node.kind === 260 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 260 /* ExternalModuleReference */; + return node.kind === 261 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 261 /* JsxElement */; + return node.kind === 262 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 262 /* JsxSelfClosingElement */; + return node.kind === 263 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 263 /* JsxOpeningElement */; + return node.kind === 264 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 264 /* JsxClosingElement */; + return node.kind === 265 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 265 /* JsxFragment */; + return node.kind === 266 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 266 /* JsxOpeningFragment */; + return node.kind === 267 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 267 /* JsxClosingFragment */; + return node.kind === 268 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 268 /* JsxAttribute */; + return node.kind === 269 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 269 /* JsxAttributes */; + return node.kind === 270 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 270 /* JsxSpreadAttribute */; + return node.kind === 271 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 271 /* JsxExpression */; + return node.kind === 272 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 272 /* CaseClause */; + return node.kind === 273 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 273 /* DefaultClause */; + return node.kind === 274 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 274 /* HeritageClause */; + return node.kind === 275 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 275 /* CatchClause */; + return node.kind === 276 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 276 /* PropertyAssignment */; + return node.kind === 277 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 277 /* ShorthandPropertyAssignment */; + return node.kind === 278 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 278 /* SpreadAssignment */; + return node.kind === 279 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 280 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 285 /* SourceFile */; + return node.kind === 286 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 286 /* Bundle */; + return node.kind === 287 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 287 /* UnparsedSource */; + return node.kind === 288 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; function isUnparsedPrepend(node) { - return node.kind === 281 /* UnparsedPrepend */; + return node.kind === 282 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; function isUnparsedTextLike(node) { switch (node.kind) { - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 283 /* UnparsedText */: + case 284 /* UnparsedInternalText */: return true; default: return false; @@ -14215,105 +14576,105 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 280 /* UnparsedPrologue */ || - node.kind === 284 /* UnparsedSyntheticReference */; + node.kind === 281 /* UnparsedPrologue */ || + node.kind === 285 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 289 /* JSDocTypeExpression */; + return node.kind === 290 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 290 /* JSDocAllType */; + return node.kind === 291 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 291 /* JSDocUnknownType */; + return node.kind === 292 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 292 /* JSDocNullableType */; + return node.kind === 293 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 293 /* JSDocNonNullableType */; + return node.kind === 294 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 294 /* JSDocOptionalType */; + return node.kind === 295 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 295 /* JSDocFunctionType */; + return node.kind === 296 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 296 /* JSDocVariadicType */; + return node.kind === 297 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 297 /* JSDocComment */; + return node.kind === 299 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAuthorTag(node) { - return node.kind === 302 /* JSDocAuthorTag */; + return node.kind === 304 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocAugmentsTag(node) { - return node.kind === 301 /* JSDocAugmentsTag */; + return node.kind === 303 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 303 /* JSDocClassTag */; + return node.kind === 305 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 305 /* JSDocEnumTag */; + return node.kind === 307 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 308 /* JSDocThisTag */; + return node.kind === 310 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 306 /* JSDocParameterTag */; + return node.kind === 308 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 307 /* JSDocReturnTag */; + return node.kind === 309 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 309 /* JSDocTypeTag */; + return node.kind === 311 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 310 /* JSDocTemplateTag */; + return node.kind === 312 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 311 /* JSDocTypedefTag */; + return node.kind === 313 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 312 /* JSDocPropertyTag */; + return node.kind === 314 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 312 /* JSDocPropertyTag */ || node.kind === 306 /* JSDocParameterTag */; + return node.kind === 314 /* JSDocPropertyTag */ || node.kind === 308 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 298 /* JSDocTypeLiteral */; + return node.kind === 300 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 304 /* JSDocCallbackTag */; + return node.kind === 306 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 299 /* JSDocSignature */; + return node.kind === 301 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -14324,7 +14685,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 313 /* SyntaxList */; + return n.kind === 315 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -14334,7 +14695,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 149 /* FirstNode */; + return kind >= 150 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -14343,7 +14704,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 148 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 149 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -14428,7 +14789,7 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 149 /* QualifiedName */ + return kind === 150 /* QualifiedName */ || kind === 73 /* Identifier */; } ts.isEntityName = isEntityName; @@ -14437,14 +14798,14 @@ var ts; return kind === 73 /* Identifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 150 /* ComputedPropertyName */; + || kind === 151 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; return kind === 73 /* Identifier */ - || kind === 185 /* ObjectBindingPattern */ - || kind === 186 /* ArrayBindingPattern */; + || kind === 186 /* ObjectBindingPattern */ + || kind === 187 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -14459,13 +14820,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return true; default: return false; @@ -14474,14 +14835,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 167 /* ConstructorType */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 301 /* JSDocSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 167 /* FunctionType */: + case 296 /* JSDocFunctionType */: + case 168 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -14496,29 +14857,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 155 /* PropertyDeclaration */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 163 /* IndexSignature */ - || kind === 218 /* SemicolonClassElement */; + return kind === 159 /* Constructor */ + || kind === 156 /* PropertyDeclaration */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */ + || kind === 164 /* IndexSignature */ + || kind === 219 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */); + return node && (node.kind === 242 /* ClassDeclaration */ || node.kind === 211 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */); + return node && (node.kind === 160 /* GetAccessor */ || node.kind === 161 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return true; default: return false; @@ -14528,11 +14889,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 162 /* ConstructSignature */ - || kind === 161 /* CallSignature */ - || kind === 154 /* PropertySignature */ - || kind === 156 /* MethodSignature */ - || kind === 163 /* IndexSignature */; + return kind === 163 /* ConstructSignature */ + || kind === 162 /* CallSignature */ + || kind === 155 /* PropertySignature */ + || kind === 157 /* MethodSignature */ + || kind === 164 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -14541,12 +14902,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 276 /* PropertyAssignment */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 278 /* SpreadAssignment */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 277 /* PropertyAssignment */ + || kind === 278 /* ShorthandPropertyAssignment */ + || kind === 279 /* SpreadAssignment */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -14561,8 +14922,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: return true; } return false; @@ -14573,8 +14934,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 186 /* ArrayBindingPattern */ - || kind === 185 /* ObjectBindingPattern */; + return kind === 187 /* ArrayBindingPattern */ + || kind === 186 /* ObjectBindingPattern */; } return false; } @@ -14582,15 +14943,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 188 /* ArrayLiteralExpression */ - || kind === 189 /* ObjectLiteralExpression */; + return kind === 189 /* ArrayLiteralExpression */ + || kind === 190 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 187 /* BindingElement */ - || kind === 211 /* OmittedExpression */; + return kind === 188 /* BindingElement */ + || kind === 212 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -14599,9 +14960,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 239 /* VariableDeclaration */: + case 153 /* Parameter */: + case 188 /* BindingElement */: return true; } return false; @@ -14622,8 +14983,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 186 /* ObjectBindingPattern */: + case 190 /* ObjectLiteralExpression */: return true; } return false; @@ -14635,8 +14996,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 187 /* ArrayBindingPattern */: + case 189 /* ArrayLiteralExpression */: return true; } return false; @@ -14645,26 +15006,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */ - || kind === 184 /* ImportType */; + return kind === 191 /* PropertyAccessExpression */ + || kind === 150 /* QualifiedName */ + || kind === 185 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */; + return kind === 191 /* PropertyAccessExpression */ + || kind === 150 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 153 /* Decorator */: + case 264 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 195 /* TaggedTemplateExpression */: + case 154 /* Decorator */: return true; default: return false; @@ -14672,12 +15033,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 192 /* CallExpression */ || node.kind === 193 /* NewExpression */; + return node.kind === 193 /* CallExpression */ || node.kind === 194 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 207 /* TemplateExpression */ + return kind === 208 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -14688,33 +15049,33 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 193 /* NewExpression */: - case 192 /* CallExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 194 /* TaggedTemplateExpression */: - case 188 /* ArrayLiteralExpression */: - case 196 /* ParenthesizedExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: + case 194 /* NewExpression */: + case 193 /* CallExpression */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 266 /* JsxFragment */: + case 195 /* TaggedTemplateExpression */: + case 189 /* ArrayLiteralExpression */: + case 197 /* ParenthesizedExpression */: + case 190 /* ObjectLiteralExpression */: + case 211 /* ClassExpression */: + case 198 /* FunctionExpression */: case 73 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: case 88 /* FalseKeyword */: case 97 /* NullKeyword */: case 101 /* ThisKeyword */: case 103 /* TrueKeyword */: case 99 /* SuperKeyword */: - case 214 /* NonNullExpression */: - case 215 /* MetaProperty */: + case 215 /* NonNullExpression */: + case 216 /* MetaProperty */: case 93 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: @@ -14728,13 +15089,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 195 /* TypeAssertionExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: + case 200 /* DeleteExpression */: + case 201 /* TypeOfExpression */: + case 202 /* VoidExpression */: + case 203 /* AwaitExpression */: + case 196 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -14743,9 +15104,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return true; - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; default: @@ -14764,15 +15125,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: - case 198 /* ArrowFunction */: - case 205 /* BinaryExpression */: - case 209 /* SpreadElement */: - case 213 /* AsExpression */: - case 211 /* OmittedExpression */: - case 316 /* CommaListExpression */: - case 315 /* PartiallyEmittedExpression */: + case 207 /* ConditionalExpression */: + case 209 /* YieldExpression */: + case 199 /* ArrowFunction */: + case 206 /* BinaryExpression */: + case 210 /* SpreadElement */: + case 214 /* AsExpression */: + case 212 /* OmittedExpression */: + case 318 /* CommaListExpression */: + case 317 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -14780,18 +15141,18 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 195 /* TypeAssertionExpression */ - || kind === 213 /* AsExpression */; + return kind === 196 /* TypeAssertionExpression */ + || kind === 214 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 315 /* PartiallyEmittedExpression */; + return node.kind === 317 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 314 /* NotEmittedStatement */; + return node.kind === 316 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -14802,13 +15163,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: return true; - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -14816,7 +15177,7 @@ var ts; ts.isIterationStatement = isIterationStatement; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 227 /* ForInStatement */ || node.kind === 228 /* ForOfStatement */; + return node.kind === 228 /* ForInStatement */ || node.kind === 229 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -14840,113 +15201,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */ + return kind === 247 /* ModuleBlock */ + || kind === 246 /* ModuleDeclaration */ || kind === 73 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */; + return kind === 247 /* ModuleBlock */ + || kind === 246 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 73 /* Identifier */ - || kind === 245 /* ModuleDeclaration */; + || kind === 246 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 253 /* NamedImports */ - || kind === 252 /* NamespaceImport */; + return kind === 254 /* NamedImports */ + || kind === 253 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ || node.kind === 244 /* EnumDeclaration */; + return node.kind === 246 /* ModuleDeclaration */ || node.kind === 245 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 198 /* ArrowFunction */ - || kind === 187 /* BindingElement */ - || kind === 241 /* ClassDeclaration */ - || kind === 210 /* ClassExpression */ - || kind === 158 /* Constructor */ - || kind === 244 /* EnumDeclaration */ - || kind === 279 /* EnumMember */ - || kind === 258 /* ExportSpecifier */ - || kind === 240 /* FunctionDeclaration */ - || kind === 197 /* FunctionExpression */ - || kind === 159 /* GetAccessor */ - || kind === 251 /* ImportClause */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 254 /* ImportSpecifier */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 268 /* JsxAttribute */ - || kind === 157 /* MethodDeclaration */ - || kind === 156 /* MethodSignature */ - || kind === 245 /* ModuleDeclaration */ - || kind === 248 /* NamespaceExportDeclaration */ - || kind === 252 /* NamespaceImport */ - || kind === 152 /* Parameter */ - || kind === 276 /* PropertyAssignment */ - || kind === 155 /* PropertyDeclaration */ - || kind === 154 /* PropertySignature */ - || kind === 160 /* SetAccessor */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 151 /* TypeParameter */ - || kind === 238 /* VariableDeclaration */ - || kind === 311 /* JSDocTypedefTag */ - || kind === 304 /* JSDocCallbackTag */ - || kind === 312 /* JSDocPropertyTag */; + return kind === 199 /* ArrowFunction */ + || kind === 188 /* BindingElement */ + || kind === 242 /* ClassDeclaration */ + || kind === 211 /* ClassExpression */ + || kind === 159 /* Constructor */ + || kind === 245 /* EnumDeclaration */ + || kind === 280 /* EnumMember */ + || kind === 259 /* ExportSpecifier */ + || kind === 241 /* FunctionDeclaration */ + || kind === 198 /* FunctionExpression */ + || kind === 160 /* GetAccessor */ + || kind === 252 /* ImportClause */ + || kind === 250 /* ImportEqualsDeclaration */ + || kind === 255 /* ImportSpecifier */ + || kind === 243 /* InterfaceDeclaration */ + || kind === 269 /* JsxAttribute */ + || kind === 158 /* MethodDeclaration */ + || kind === 157 /* MethodSignature */ + || kind === 246 /* ModuleDeclaration */ + || kind === 249 /* NamespaceExportDeclaration */ + || kind === 253 /* NamespaceImport */ + || kind === 153 /* Parameter */ + || kind === 277 /* PropertyAssignment */ + || kind === 156 /* PropertyDeclaration */ + || kind === 155 /* PropertySignature */ + || kind === 161 /* SetAccessor */ + || kind === 278 /* ShorthandPropertyAssignment */ + || kind === 244 /* TypeAliasDeclaration */ + || kind === 152 /* TypeParameter */ + || kind === 239 /* VariableDeclaration */ + || kind === 313 /* JSDocTypedefTag */ + || kind === 306 /* JSDocCallbackTag */ + || kind === 314 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 240 /* FunctionDeclaration */ - || kind === 259 /* MissingDeclaration */ - || kind === 241 /* ClassDeclaration */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 244 /* EnumDeclaration */ - || kind === 245 /* ModuleDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */ - || kind === 255 /* ExportAssignment */ - || kind === 248 /* NamespaceExportDeclaration */; + return kind === 241 /* FunctionDeclaration */ + || kind === 260 /* MissingDeclaration */ + || kind === 242 /* ClassDeclaration */ + || kind === 243 /* InterfaceDeclaration */ + || kind === 244 /* TypeAliasDeclaration */ + || kind === 245 /* EnumDeclaration */ + || kind === 246 /* ModuleDeclaration */ + || kind === 251 /* ImportDeclaration */ + || kind === 250 /* ImportEqualsDeclaration */ + || kind === 257 /* ExportDeclaration */ + || kind === 256 /* ExportAssignment */ + || kind === 249 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 230 /* BreakStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 224 /* DoStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 221 /* EmptyStatement */ - || kind === 227 /* ForInStatement */ - || kind === 228 /* ForOfStatement */ - || kind === 226 /* ForStatement */ - || kind === 223 /* IfStatement */ - || kind === 234 /* LabeledStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 233 /* SwitchStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 236 /* TryStatement */ - || kind === 220 /* VariableStatement */ - || kind === 225 /* WhileStatement */ - || kind === 232 /* WithStatement */ - || kind === 314 /* NotEmittedStatement */ - || kind === 318 /* EndOfDeclarationMarker */ - || kind === 317 /* MergeDeclarationMarker */; + return kind === 231 /* BreakStatement */ + || kind === 230 /* ContinueStatement */ + || kind === 238 /* DebuggerStatement */ + || kind === 225 /* DoStatement */ + || kind === 223 /* ExpressionStatement */ + || kind === 222 /* EmptyStatement */ + || kind === 228 /* ForInStatement */ + || kind === 229 /* ForOfStatement */ + || kind === 227 /* ForStatement */ + || kind === 224 /* IfStatement */ + || kind === 235 /* LabeledStatement */ + || kind === 232 /* ReturnStatement */ + || kind === 234 /* SwitchStatement */ + || kind === 236 /* ThrowStatement */ + || kind === 237 /* TryStatement */ + || kind === 221 /* VariableStatement */ + || kind === 226 /* WhileStatement */ + || kind === 233 /* WithStatement */ + || kind === 316 /* NotEmittedStatement */ + || kind === 320 /* EndOfDeclarationMarker */ + || kind === 319 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 151 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 310 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 152 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 312 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14973,10 +15334,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 219 /* Block */) + if (node.kind !== 220 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 236 /* TryStatement */ || node.parent.kind === 275 /* CatchClause */) { + if (node.parent.kind === 237 /* TryStatement */ || node.parent.kind === 276 /* CatchClause */) { return false; } } @@ -14986,8 +15347,8 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 260 /* ExternalModuleReference */ - || kind === 149 /* QualifiedName */ + return kind === 261 /* ExternalModuleReference */ + || kind === 150 /* QualifiedName */ || kind === 73 /* Identifier */; } ts.isModuleReference = isModuleReference; @@ -14997,70 +15358,70 @@ var ts; var kind = node.kind; return kind === 101 /* ThisKeyword */ || kind === 73 /* Identifier */ - || kind === 190 /* PropertyAccessExpression */; + || kind === 191 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 261 /* JsxElement */ - || kind === 271 /* JsxExpression */ - || kind === 262 /* JsxSelfClosingElement */ + return kind === 262 /* JsxElement */ + || kind === 272 /* JsxExpression */ + || kind === 263 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 265 /* JsxFragment */; + || kind === 266 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 268 /* JsxAttribute */ - || kind === 270 /* JsxSpreadAttribute */; + return kind === 269 /* JsxAttribute */ + || kind === 271 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 271 /* JsxExpression */; + || kind === 272 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 263 /* JsxOpeningElement */ - || kind === 262 /* JsxSelfClosingElement */; + return kind === 264 /* JsxOpeningElement */ + || kind === 263 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 272 /* CaseClause */ - || kind === 273 /* DefaultClause */; + return kind === 273 /* CaseClause */ + || kind === 274 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 289 /* FirstJSDocNode */ && node.kind <= 312 /* LastJSDocNode */; + return node.kind >= 290 /* FirstJSDocNode */ && node.kind <= 314 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 297 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 299 /* JSDocComment */ || 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 >= 300 /* FirstJSDocTagNode */ && node.kind <= 312 /* LastJSDocTagNode */; + return node.kind >= 302 /* FirstJSDocTagNode */ && node.kind <= 314 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 161 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 160 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -15090,12 +15451,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 268 /* JsxAttribute */ || node.kind === 270 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 269 /* JsxAttribute */ || node.kind === 271 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 165 /* TypeReference */ || node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 166 /* TypeReference */ || node.kind === 213 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -15131,7 +15492,7 @@ var ts; /* @internal */ (function (ts) { function isNamedImportsOrExports(node) { - return node.kind === 253 /* NamedImports */ || node.kind === 257 /* NamedExports */; + return node.kind === 254 /* NamedImports */ || node.kind === 258 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -15149,7 +15510,7 @@ var ts; this.checker = checker; } } - function Signature() { } // tslint:disable-line no-empty + function Signature() { } function Node(kind, pos, end) { this.pos = pos; this.end = end; @@ -15166,6 +15527,7 @@ var ts; this.text = text; this.skipTrivia = skipTrivia || (function (pos) { return pos; }); } + // eslint-disable-next-line prefer-const ts.objectAllocator = { getNodeConstructor: function () { return Node; }, getTokenConstructor: function () { return Node; }, @@ -15612,7 +15974,7 @@ var ts; var rest = path.substring(rootLength).split(ts.directorySeparator); if (rest.length && !ts.lastOrUndefined(rest)) rest.pop(); - return [root].concat(rest); + return __spreadArrays([root], rest); } /** * Parse a path into an array containing a root component (at index 0) and zero or more path @@ -15712,7 +16074,7 @@ var ts; for (; start < fromComponents.length; start++) { relative.push(".."); } - return [""].concat(relative, components); + return __spreadArrays([""], relative, components); } ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; function getRelativePathFromFile(from, to, getCanonicalFileName) { @@ -15793,7 +16155,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { paths[_i - 1] = arguments[_i]; } - var combined = ts.some(paths) ? combinePaths.apply(void 0, [path].concat(paths)) : ts.normalizeSlashes(path); + var combined = ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : ts.normalizeSlashes(path); var normalized = ts.getPathFromPathComponents(ts.reducePathComponents(ts.getPathComponents(combined))); return normalized && hasTrailingDirectorySeparator(combined) ? ensureTrailingDirectorySeparator(normalized) : normalized; } @@ -16232,14 +16594,14 @@ var ts; ts.supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */]; ts.supportedJSExtensions = [".js" /* Js */, ".jsx" /* Jsx */]; ts.supportedJSAndJsonExtensions = [".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */]; - var allSupportedExtensions = ts.supportedTSExtensions.concat(ts.supportedJSExtensions); - var allSupportedExtensionsWithJson = ts.supportedTSExtensions.concat(ts.supportedJSExtensions, [".json" /* Json */]); + var allSupportedExtensions = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions); + var allSupportedExtensionsWithJson = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions, [".json" /* Json */]); function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && options.allowJs; if (!extraFileExtensions || extraFileExtensions.length === 0) { return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; } - var extensions = (needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions).concat(ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); + var extensions = __spreadArrays(needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions, ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); return ts.deduplicate(extensions, ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } ts.getSupportedExtensions = getSupportedExtensions; @@ -16253,7 +16615,7 @@ var ts; if (supportedExtensions === ts.supportedTSExtensions) { return ts.supportedTSExtensionsWithJson; } - return supportedExtensions.concat([".json" /* Json */]); + return __spreadArrays(supportedExtensions, [".json" /* Json */]); } ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { @@ -16573,6 +16935,7 @@ var ts; } ts.skipTypeChecking = skipTypeChecking; function isJsonEqual(a, b) { + // eslint-disable-next-line no-null/no-null return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && ts.equalOwnProperties(a, b, isJsonEqual); } ts.isJsonEqual = isJsonEqual; @@ -16676,14 +17039,12 @@ var ts; SignatureFlags[SignatureFlags["IgnoreMissingOpenBrace"] = 16] = "IgnoreMissingOpenBrace"; SignatureFlags[SignatureFlags["JSDoc"] = 32] = "JSDoc"; })(SignatureFlags || (SignatureFlags = {})); - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 285 /* SourceFile */) { + if (kind === 286 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 73 /* Identifier */) { @@ -16735,19 +17096,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 <= 148 /* LastToken */) { + if (!node || node.kind <= 149 /* LastToken */) { return; } switch (node.kind) { - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -16755,9 +17116,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 152 /* Parameter */: + case 153 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -16765,7 +17126,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -16773,51 +17134,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 154 /* PropertySignature */: + case 155 /* 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 276 /* PropertyAssignment */: + case 277 /* 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 238 /* VariableDeclaration */: + case 239 /* 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 187 /* BindingElement */: + case 188 /* 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 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -16829,345 +17190,345 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 171 /* TupleType */: + case 172 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 177 /* InferType */: + case 178 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 184 /* ImportType */: + case 185 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 178 /* ParenthesizedType */: - case 180 /* TypeOperator */: + case 179 /* ParenthesizedType */: + case 181 /* TypeOperator */: return visitNode(cbNode, node.type); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 182 /* MappedType */: + case 183 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 183 /* LiteralType */: + case 184 /* LiteralType */: return visitNode(cbNode, node.literal); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 213 /* AsExpression */: + case 214 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return visitNode(cbNode, node.name); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 220 /* Block */: + case 247 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 285 /* SourceFile */: + case 286 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 230 /* ContinueStatement */: + case 231 /* BreakStatement */: return visitNode(cbNode, node.label); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 272 /* CaseClause */: + case 273 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 153 /* Decorator */: + case 154 /* Decorator */: return visitNode(cbNode, node.expression); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* 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 242 /* InterfaceDeclaration */: + case 243 /* 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 243 /* TypeAliasDeclaration */: + case 244 /* 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 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 279 /* EnumMember */: + case 280 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 254 /* NamedImports */: + case 258 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 259 /* MissingDeclaration */: + case 260 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 261 /* JsxElement */: + case 262 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 172 /* OptionalType */: - case 173 /* RestType */: - case 289 /* JSDocTypeExpression */: - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 294 /* JSDocOptionalType */: - case 296 /* JSDocVariadicType */: + case 173 /* OptionalType */: + case 174 /* RestType */: + case 290 /* JSDocTypeExpression */: + case 294 /* JSDocNonNullableType */: + case 293 /* JSDocNullableType */: + case 295 /* JSDocOptionalType */: + case 297 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 297 /* JSDocComment */: + case 299 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: + case 314 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 302 /* JSDocAuthorTag */: + case 304 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName); - case 301 /* JSDocAugmentsTag */: + case 303 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 311 /* JSDocTypedefTag */: + case 313 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 289 /* JSDocTypeExpression */ + node.typeExpression.kind === 290 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 304 /* JSDocCallbackTag */: + case 306 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 308 /* JSDocThisTag */: - case 305 /* JSDocEnumTag */: + case 309 /* JSDocReturnTag */: + case 311 /* JSDocTypeTag */: + case 310 /* JSDocThisTag */: + case 307 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 299 /* JSDocSignature */: + case 301 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 298 /* JSDocTypeLiteral */: + case 300 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 300 /* JSDocTag */: - case 303 /* JSDocClassTag */: + case 302 /* JSDocTag */: + case 305 /* JSDocClassTag */: return visitNode(cbNode, node.tagName); - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -17176,12 +17537,14 @@ var ts; if (setParentNodes === void 0) { setParentNodes = false; } ts.performance.mark("beforeParse"); var result; + ts.perfLogger.logStartParseSourceFile(fileName); if (languageVersion === 100 /* JSON */) { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */); } else { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind); } + ts.perfLogger.logStopParseSourceFile(); ts.performance.mark("afterParse"); ts.performance.measure("Parse", "beforeParse", "afterParse"); return result; @@ -17250,12 +17613,10 @@ var ts; var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); var disallowInAndDecoratorContext = 2048 /* DisallowInContext */ | 8192 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name var sourceFile; var parseDiagnostics; var syntaxCursor; @@ -17265,6 +17626,7 @@ var ts; var identifiers; var identifierCount; var parsingContext; + var notParenthesizedArrow; // Flags that dictate what parsing context we're in. For example: // Whether or not we are in strict parsing mode. All that changes in strict parsing mode is // that some tokens that would be considered identifiers may be considered keywords. @@ -17385,7 +17747,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(222 /* ExpressionStatement */); + var statement = createNode(223 /* ExpressionStatement */); switch (token()) { case 22 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); @@ -17421,6 +17783,9 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; sourceFile.parseDiagnostics = parseDiagnostics; var result = sourceFile; clearState(); @@ -17472,6 +17837,7 @@ var ts; identifiers = undefined; syntaxCursor = undefined; sourceText = undefined; + notParenthesizedArrow = undefined; } function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { var isDeclarationFile = isDeclarationFileName(fileName); @@ -17541,7 +17907,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(285 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(286 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -17681,9 +18047,17 @@ var ts; function token() { return currentToken; } - function nextToken() { + function nextTokenWithoutCheck() { return currentToken = scanner.scan(); } + function nextToken() { + // if the keyword had an escape + if (ts.isKeyword(currentToken) && (scanner.hasUnicodeEscape() || scanner.hasExtendedUnicodeEscape())) { + // issue a parse error for the escape + parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), ts.Diagnostics.Keywords_cannot_contain_escape_characters); + } + return nextTokenWithoutCheck(); + } function nextTokenJSDoc() { return currentToken = scanner.scanJsDocToken(); } @@ -17922,7 +18296,7 @@ var ts; node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); - nextToken(); + nextTokenWithoutCheck(); return finishNode(node); } // Only for end of file because the error gets reported incorrectly on embedded script tags. @@ -17958,7 +18332,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(150 /* ComputedPropertyName */); + var node = createNode(151 /* ComputedPropertyName */); parseExpected(22 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -18392,14 +18766,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 158 /* Constructor */: - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 218 /* SemicolonClassElement */: + case 159 /* Constructor */: + case 164 /* IndexSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 219 /* SemicolonClassElement */: return true; - case 157 /* MethodDeclaration */: + case 158 /* 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. @@ -18414,8 +18788,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: return true; } } @@ -18424,58 +18798,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 220 /* VariableStatement */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 222 /* ExpressionStatement */: - case 235 /* ThrowStatement */: - case 231 /* ReturnStatement */: - case 233 /* SwitchStatement */: - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 221 /* EmptyStatement */: - case 236 /* TryStatement */: - case 234 /* LabeledStatement */: - case 224 /* DoStatement */: - case 237 /* DebuggerStatement */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 241 /* FunctionDeclaration */: + case 221 /* VariableStatement */: + case 220 /* Block */: + case 224 /* IfStatement */: + case 223 /* ExpressionStatement */: + case 236 /* ThrowStatement */: + case 232 /* ReturnStatement */: + case 234 /* SwitchStatement */: + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 227 /* ForStatement */: + case 226 /* WhileStatement */: + case 233 /* WithStatement */: + case 222 /* EmptyStatement */: + case 237 /* TryStatement */: + case 235 /* LabeledStatement */: + case 225 /* DoStatement */: + case 238 /* DebuggerStatement */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 257 /* ExportDeclaration */: + case 256 /* ExportAssignment */: + case 246 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 280 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 154 /* PropertySignature */: - case 161 /* CallSignature */: + case 163 /* ConstructSignature */: + case 157 /* MethodSignature */: + case 164 /* IndexSignature */: + case 155 /* PropertySignature */: + case 162 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 238 /* VariableDeclaration */) { + if (node.kind !== 239 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -18496,7 +18870,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 152 /* Parameter */) { + if (node.kind !== 153 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -18563,7 +18937,7 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */); + parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use @@ -18601,6 +18975,9 @@ var ts; } return result; } + function getExpectedCommaDiagnostic(kind) { + return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + } function createMissingList() { var list = createNodeArray([], getNodePos()); list.isMissingList = true; @@ -18632,7 +19009,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(149 /* QualifiedName */, entity.pos); + var node = createNode(150 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -18669,7 +19046,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(207 /* TemplateExpression */); + var template = createNode(208 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -18681,7 +19058,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(217 /* TemplateSpan */); + var span = createNode(218 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 19 /* CloseBraceToken */) { @@ -18710,6 +19087,16 @@ var ts; function parseLiteralLikeNode(kind) { var node = createNode(kind); node.text = scanner.getTokenValue(); + switch (kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + var isLast = kind === 14 /* NoSubstitutionTemplateLiteral */ || kind === 17 /* TemplateTail */; + var tokenText = scanner.getTokenText(); + node.rawText = tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); + break; + } if (scanner.hasExtendedUnicodeEscape()) { node.hasExtendedUnicodeEscape = true; } @@ -18731,7 +19118,7 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(165 /* TypeReference */); + var node = createNode(166 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); @@ -18741,14 +19128,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: { + case 167 /* FunctionType */: + case 168 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -18756,20 +19143,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(164 /* TypePredicate */, lhs.pos); + var node = createNode(165 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(179 /* ThisType */); + var node = createNode(180 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(290 /* JSDocAllType */); + var result = createNode(291 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(294 /* JSDocOptionalType */, result); + return createPostfixType(295 /* JSDocOptionalType */, result); } else { nextToken(); @@ -18777,7 +19164,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(293 /* JSDocNonNullableType */); + var result = createNode(294 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -18801,28 +19188,28 @@ var ts; token() === 30 /* GreaterThanToken */ || token() === 60 /* EqualsToken */ || token() === 50 /* BarToken */) { - var result = createNode(291 /* JSDocUnknownType */, pos); + var result = createNode(292 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(292 /* JSDocNullableType */, pos); + var result = createNode(293 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(295 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(296 /* JSDocFunctionType */); nextToken(); fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(165 /* TypeReference */); + var node = createNode(166 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(152 /* Parameter */); + var parameter = createNode(153 /* Parameter */); if (token() === 101 /* ThisKeyword */ || token() === 96 /* NewKeyword */) { parameter.name = parseIdentifierName(); parseExpected(57 /* ColonToken */); @@ -18832,27 +19219,44 @@ var ts; } function parseJSDocType() { scanner.setInJSDocType(true); + var moduleSpecifier = parseOptionalToken(131 /* ModuleKeyword */); + if (moduleSpecifier) { + var moduleTag = createNode(298 /* JSDocNamepathType */, moduleSpecifier.pos); + terminate: while (true) { + switch (token()) { + case 19 /* CloseBraceToken */: + case 1 /* EndOfFileToken */: + case 27 /* CommaToken */: + case 5 /* WhitespaceTrivia */: + break terminate; + default: + nextTokenJSDoc(); + } + } + scanner.setInJSDocType(false); + return finishNode(moduleTag); + } var dotdotdot = parseOptionalToken(25 /* DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(296 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(297 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 60 /* EqualsToken */) { - return createPostfixType(294 /* JSDocOptionalType */, type); + return createPostfixType(295 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(168 /* TypeQuery */); + var node = createNode(169 /* TypeQuery */); parseExpected(105 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(152 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(87 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -18897,7 +19301,7 @@ var ts; isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(152 /* Parameter */); + var node = createNodeWithJSDoc(153 /* Parameter */); if (token() === 101 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); @@ -18998,7 +19402,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 162 /* ConstructSignature */) { + if (kind === 163 /* ConstructSignature */) { parseExpected(96 /* NewKeyword */); } fillSignature(57 /* ColonToken */, 4 /* Type */, node); @@ -19059,7 +19463,7 @@ var ts; return token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 163 /* IndexSignature */; + node.kind = 164 /* IndexSignature */; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -19069,13 +19473,13 @@ var ts; node.name = parsePropertyName(); node.questionToken = parseOptionalToken(56 /* QuestionToken */); if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - node.kind = 156 /* MethodSignature */; + node.kind = 157 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] fillSignature(57 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 154 /* PropertySignature */; + node.kind = 155 /* PropertySignature */; node.type = parseTypeAnnotation(); if (token() === 60 /* EqualsToken */) { // Although type literal properties cannot not have initializers, we attempt @@ -19121,10 +19525,10 @@ var ts; } function parseTypeMember() { if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - return parseSignatureMember(161 /* CallSignature */); + return parseSignatureMember(162 /* CallSignature */); } if (token() === 96 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(162 /* ConstructSignature */); + return parseSignatureMember(163 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -19150,7 +19554,7 @@ var ts; return false; } function parseTypeLiteral() { - var node = createNode(169 /* TypeLiteral */); + var node = createNode(170 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -19176,14 +19580,14 @@ var ts; return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 94 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(152 /* TypeParameter */); node.name = parseIdentifier(); parseExpected(94 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(182 /* MappedType */); + var node = createNode(183 /* MappedType */); parseExpected(18 /* OpenBraceToken */); if (token() === 134 /* ReadonlyKeyword */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { node.readonlyToken = parseTokenNode(); @@ -19208,23 +19612,23 @@ var ts; function parseTupleElementType() { var pos = getNodePos(); if (parseOptional(25 /* DotDotDotToken */)) { - var node = createNode(173 /* RestType */, pos); + var node = createNode(174 /* RestType */, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 292 /* JSDocNullableType */ && type.pos === type.type.pos) { - type.kind = 172 /* OptionalType */; + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 293 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 173 /* OptionalType */; } return type; } function parseTupleType() { - var node = createNode(171 /* TupleType */); + var node = createNode(172 /* TupleType */); node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(178 /* ParenthesizedType */); + var node = createNode(179 /* ParenthesizedType */); parseExpected(20 /* OpenParenToken */); node.type = parseType(); parseExpected(21 /* CloseParenToken */); @@ -19232,7 +19636,7 @@ var ts; } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(96 /* NewKeyword */) ? 167 /* ConstructorType */ : 166 /* FunctionType */; + var kind = parseOptional(96 /* NewKeyword */) ? 168 /* ConstructorType */ : 167 /* FunctionType */; var node = createNodeWithJSDoc(kind, pos); fillSignature(37 /* EqualsGreaterThanToken */, 4 /* Type */, node); return finishNode(node); @@ -19242,10 +19646,10 @@ var ts; return token() === 24 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(183 /* LiteralType */); + var node = createNode(184 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(203 /* PrefixUnaryExpression */); + unaryMinusExpression = createNode(204 /* PrefixUnaryExpression */); unaryMinusExpression.operator = 39 /* MinusToken */; nextToken(); } @@ -19266,7 +19670,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(184 /* ImportType */); + var node = createNode(185 /* ImportType */); if (parseOptional(105 /* TypeOfKeyword */)) { node.isTypeOf = true; } @@ -19356,6 +19760,7 @@ var ts; case 134 /* ReadonlyKeyword */: case 140 /* SymbolKeyword */: case 143 /* UniqueKeyword */: + case 148 /* TagKeyword */: case 107 /* VoidKeyword */: case 142 /* UndefinedKeyword */: case 97 /* NullKeyword */: @@ -19402,26 +19807,26 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 52 /* ExclamationToken */: - type = createPostfixType(293 /* JSDocNonNullableType */, type); + type = createPostfixType(294 /* JSDocNonNullableType */, type); break; case 56 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(292 /* JSDocNullableType */, type); + type = createPostfixType(293 /* JSDocNullableType */, type); break; case 22 /* OpenBracketToken */: parseExpected(22 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(181 /* IndexedAccessType */, type.pos); + var node = createNode(182 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(170 /* ArrayType */, type.pos); + var node = createNode(171 /* ArrayType */, type.pos); node.elementType = type; parseExpected(23 /* CloseBracketToken */); type = finishNode(node); @@ -19440,16 +19845,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(180 /* TypeOperator */); + var node = createNode(181 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(177 /* InferType */); + var node = createNode(178 /* InferType */); parseExpected(128 /* InferKeyword */); - var typeParameter = createNode(151 /* TypeParameter */); + var typeParameter = createNode(152 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -19460,6 +19865,7 @@ var ts; case 130 /* KeyOfKeyword */: case 143 /* UniqueKeyword */: case 134 /* ReadonlyKeyword */: + case 148 /* TagKeyword */: return parseTypeOperator(operator); case 128 /* InferKeyword */: return parseInferType(); @@ -19482,10 +19888,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(175 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); + return parseUnionOrIntersectionType(176 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(174 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); + return parseUnionOrIntersectionType(175 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); } function isStartOfFunctionType() { if (token() === 28 /* LessThanToken */) { @@ -19542,7 +19948,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(164 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(165 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -19569,7 +19975,7 @@ var ts; } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(87 /* ExtendsKeyword */)) { - var node = createNode(176 /* ConditionalType */, type.pos); + var node = createNode(177 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); @@ -19763,7 +20169,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(208 /* YieldExpression */); + var node = createNode(209 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -19785,13 +20191,13 @@ var ts; ts.Debug.assert(token() === 37 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(198 /* ArrowFunction */, asyncModifier.pos); + node = createNode(199 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(198 /* ArrowFunction */, identifier.pos); + node = createNode(199 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(152 /* Parameter */, identifier.pos); + var parameter = createNode(153 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); @@ -19955,7 +20361,15 @@ var ts; } } function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + var tokenPos = scanner.getTokenPos(); + if (notParenthesizedArrow && notParenthesizedArrow.has(tokenPos.toString())) { + return undefined; + } + var result = parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + if (!result) { + (notParenthesizedArrow || (notParenthesizedArrow = ts.createMap())).set(tokenPos.toString(), true); + } + return result; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" @@ -19988,7 +20402,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(198 /* ArrowFunction */); + var node = createNodeWithJSDoc(199 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -20054,7 +20468,7 @@ var ts; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(206 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(207 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -20069,7 +20483,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 94 /* InKeyword */ || t === 148 /* OfKeyword */; + return t === 94 /* InKeyword */ || t === 149 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -20134,39 +20548,39 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(205 /* BinaryExpression */, left.pos); + var node = createNode(206 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(213 /* AsExpression */, left.pos); + var node = createNode(214 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(203 /* PrefixUnaryExpression */); + var node = createNode(204 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(199 /* DeleteExpression */); + var node = createNode(200 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(200 /* TypeOfExpression */); + var node = createNode(201 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(201 /* VoidExpression */); + var node = createNode(202 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -20182,7 +20596,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(202 /* AwaitExpression */); + var node = createNode(203 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -20226,7 +20640,7 @@ var ts; if (token() === 41 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 195 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 196 /* 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 { @@ -20323,7 +20737,7 @@ var ts; */ function parseUpdateExpression() { if (token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) { - var node = createNode(203 /* PrefixUnaryExpression */); + var node = createNode(204 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -20336,7 +20750,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(204 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(205 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -20392,7 +20806,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(215 /* MetaProperty */, fullStart); + var node = createNode(216 /* MetaProperty */, fullStart); node.keywordToken = 93 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); @@ -20474,7 +20888,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(190 /* PropertyAccessExpression */, expression.pos); + var node = createNode(191 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -20483,8 +20897,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 263 /* JsxOpeningElement */) { - var node = createNode(261 /* JsxElement */, opening.pos); + if (opening.kind === 264 /* JsxOpeningElement */) { + var node = createNode(262 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -20493,15 +20907,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 266 /* JsxOpeningFragment */) { - var node = createNode(265 /* JsxFragment */, opening.pos); + else if (opening.kind === 267 /* JsxOpeningFragment */) { + var node = createNode(266 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 262 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 263 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -20516,7 +20930,7 @@ var ts; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(205 /* BinaryExpression */, result.pos); + var badNode = createNode(206 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -20575,7 +20989,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(269 /* JsxAttributes */); + var jsxAttributes = createNode(270 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -20584,7 +20998,7 @@ var ts; parseExpected(28 /* LessThanToken */); if (token() === 30 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(266 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(267 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -20596,7 +21010,7 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(263 /* JsxOpeningElement */, fullStart); + node = createNode(264 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -20608,7 +21022,7 @@ var ts; parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(262 /* JsxSelfClosingElement */, fullStart); + node = createNode(263 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -20625,7 +21039,7 @@ var ts; var expression = token() === 101 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(191 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -20633,7 +21047,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(271 /* JsxExpression */); + var node = createNode(272 /* JsxExpression */); if (!parseExpected(18 /* OpenBraceToken */)) { return undefined; } @@ -20659,7 +21073,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(268 /* JsxAttribute */); + var node = createNode(269 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 60 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -20674,7 +21088,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(270 /* JsxSpreadAttribute */); + var node = createNode(271 /* JsxSpreadAttribute */); parseExpected(18 /* OpenBraceToken */); parseExpected(25 /* DotDotDotToken */); node.expression = parseExpression(); @@ -20682,7 +21096,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(264 /* JsxClosingElement */); + var node = createNode(265 /* JsxClosingElement */); parseExpected(29 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -20695,7 +21109,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(267 /* JsxClosingFragment */); + var node = createNode(268 /* JsxClosingFragment */); parseExpected(29 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -20710,7 +21124,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(195 /* TypeAssertionExpression */); + var node = createNode(196 /* TypeAssertionExpression */); parseExpected(28 /* LessThanToken */); node.type = parseType(); parseExpected(30 /* GreaterThanToken */); @@ -20721,7 +21135,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(24 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(191 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -20729,14 +21143,14 @@ var ts; } if (token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(214 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(215 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(22 /* OpenBracketToken */)) { - var indexedAccess = createNode(191 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(192 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; if (token() === 23 /* CloseBracketToken */) { indexedAccess.argumentExpression = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); @@ -20763,7 +21177,7 @@ var ts; return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(194 /* TaggedTemplateExpression */, tag.pos); + var tagExpression = createNode(195 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 14 /* NoSubstitutionTemplateLiteral */ @@ -20788,7 +21202,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(192 /* CallExpression */, expression.pos); + var callExpr = createNode(193 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -20796,7 +21210,7 @@ var ts; continue; } else if (token() === 20 /* OpenParenToken */) { - var callExpr = createNode(192 /* CallExpression */, expression.pos); + var callExpr = createNode(193 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -20834,6 +21248,7 @@ var ts; case 15 /* TemplateHead */: // foo `...${100}...` // these are the only tokens can legally follow a type argument // list. So we definitely want to treat them as type arg lists. + // falls through case 24 /* DotToken */: // foo. case 21 /* CloseParenToken */: // foo) case 23 /* CloseBracketToken */: // foo] @@ -20860,6 +21275,7 @@ var ts; // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. + // falls through default: // Anything else treat as an expression. return false; @@ -20910,28 +21326,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(196 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(197 /* ParenthesizedExpression */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(209 /* SpreadElement */); + var node = createNode(210 /* SpreadElement */); parseExpected(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? createNode(211 /* OmittedExpression */) : + token() === 27 /* CommaToken */ ? createNode(212 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(188 /* ArrayLiteralExpression */); + var node = createNode(189 /* ArrayLiteralExpression */); parseExpected(22 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -20943,17 +21359,17 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(25 /* DotDotDotToken */)) { - node.kind = 278 /* SpreadAssignment */; + node.kind = 279 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + return parseAccessorDeclaration(node, 160 /* GetAccessor */); } if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + return parseAccessorDeclaration(node, 161 /* SetAccessor */); } var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); @@ -20971,7 +21387,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 57 /* ColonToken */); if (isShorthandPropertyAssignment) { - node.kind = 277 /* ShorthandPropertyAssignment */; + node.kind = 278 /* ShorthandPropertyAssignment */; var equalsToken = parseOptionalToken(60 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; @@ -20979,14 +21395,14 @@ var ts; } } else { - node.kind = 276 /* PropertyAssignment */; + node.kind = 277 /* PropertyAssignment */; parseExpected(57 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(189 /* ObjectLiteralExpression */); + var node = createNode(190 /* ObjectLiteralExpression */); parseExpected(18 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21005,7 +21421,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(197 /* FunctionExpression */); + var node = createNodeWithJSDoc(198 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(91 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); @@ -21030,7 +21446,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(96 /* NewKeyword */); if (parseOptional(24 /* DotToken */)) { - var node_2 = createNode(215 /* MetaProperty */, fullStart); + var node_2 = createNode(216 /* MetaProperty */, fullStart); node_2.keywordToken = 96 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -21047,7 +21463,7 @@ var ts; } break; } - var node = createNode(193 /* NewExpression */, fullStart); + var node = createNode(194 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 20 /* OpenParenToken */) { @@ -21057,7 +21473,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(219 /* Block */); + var node = createNode(220 /* Block */); if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21090,12 +21506,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(221 /* EmptyStatement */); + var node = createNode(222 /* EmptyStatement */); parseExpected(26 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(223 /* IfStatement */); + var node = createNode(224 /* IfStatement */); parseExpected(92 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -21105,7 +21521,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(224 /* DoStatement */); + var node = createNode(225 /* DoStatement */); parseExpected(83 /* DoKeyword */); node.statement = parseStatement(); parseExpected(108 /* WhileKeyword */); @@ -21120,7 +21536,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(225 /* WhileStatement */); + var node = createNode(226 /* WhileStatement */); parseExpected(108 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -21143,8 +21559,8 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(148 /* OfKeyword */) : parseOptional(148 /* OfKeyword */)) { - var forOfStatement = createNode(228 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(149 /* OfKeyword */) : parseOptional(149 /* OfKeyword */)) { + var forOfStatement = createNode(229 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -21152,14 +21568,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(94 /* InKeyword */)) { - var forInStatement = createNode(227 /* ForInStatement */, pos); + var forInStatement = createNode(228 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(226 /* ForStatement */, pos); + var forStatement = createNode(227 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(26 /* SemicolonToken */); if (token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */) { @@ -21177,7 +21593,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 230 /* BreakStatement */ ? 74 /* BreakKeyword */ : 79 /* ContinueKeyword */); + parseExpected(kind === 231 /* BreakStatement */ ? 74 /* BreakKeyword */ : 79 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -21185,7 +21601,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(231 /* ReturnStatement */); + var node = createNode(232 /* ReturnStatement */); parseExpected(98 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -21194,7 +21610,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(232 /* WithStatement */); + var node = createNode(233 /* WithStatement */); parseExpected(109 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -21203,7 +21619,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(272 /* CaseClause */); + var node = createNode(273 /* CaseClause */); parseExpected(75 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(57 /* ColonToken */); @@ -21211,7 +21627,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(273 /* DefaultClause */); + var node = createNode(274 /* DefaultClause */); parseExpected(81 /* DefaultKeyword */); parseExpected(57 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -21221,12 +21637,12 @@ var ts; return token() === 75 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(233 /* SwitchStatement */); + var node = createNode(234 /* SwitchStatement */); parseExpected(100 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - var caseBlock = createNode(247 /* CaseBlock */); + var caseBlock = createNode(248 /* CaseBlock */); parseExpected(18 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(19 /* CloseBraceToken */); @@ -21241,7 +21657,7 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(235 /* ThrowStatement */); + var node = createNode(236 /* ThrowStatement */); parseExpected(102 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -21249,7 +21665,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(236 /* TryStatement */); + var node = createNode(237 /* TryStatement */); parseExpected(104 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 76 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -21262,7 +21678,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(275 /* CatchClause */); + var result = createNode(276 /* CatchClause */); parseExpected(76 /* CatchKeyword */); if (parseOptional(20 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -21276,7 +21692,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(237 /* DebuggerStatement */); + var node = createNode(238 /* DebuggerStatement */); parseExpected(80 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -21288,12 +21704,12 @@ var ts; var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); if (expression.kind === 73 /* Identifier */ && parseOptional(57 /* ColonToken */)) { - node.kind = 234 /* LabeledStatement */; + node.kind = 235 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 222 /* ExpressionStatement */; + node.kind = 223 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -21415,6 +21831,7 @@ var ts; case 80 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. + // falls through case 76 /* CatchKeyword */: case 89 /* FinallyKeyword */: return true; @@ -21460,16 +21877,16 @@ var ts; case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); case 106 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(239 /* VariableDeclaration */)); case 112 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(239 /* VariableDeclaration */)); } break; case 91 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(240 /* FunctionDeclaration */)); + return parseFunctionDeclaration(createNodeWithJSDoc(241 /* FunctionDeclaration */)); case 77 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(241 /* ClassDeclaration */)); + return parseClassDeclaration(createNodeWithJSDoc(242 /* ClassDeclaration */)); case 92 /* IfKeyword */: return parseIfStatement(); case 83 /* DoKeyword */: @@ -21479,9 +21896,9 @@ var ts; case 90 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 79 /* ContinueKeyword */: - return parseBreakOrContinueStatement(229 /* ContinueStatement */); + return parseBreakOrContinueStatement(230 /* ContinueStatement */); case 74 /* BreakKeyword */: - return parseBreakOrContinueStatement(230 /* BreakStatement */); + return parseBreakOrContinueStatement(231 /* BreakStatement */); case 98 /* ReturnKeyword */: return parseReturnStatement(); case 109 /* WithKeyword */: @@ -21492,6 +21909,7 @@ var ts; return parseThrowStatement(); case 104 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. + // falls through case 76 /* CatchKeyword */: case 89 /* FinallyKeyword */: return parseTryStatement(); @@ -21527,10 +21945,21 @@ var ts; return modifier.kind === 126 /* DeclareKeyword */; } function parseDeclaration() { + var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); }); + // `parseListElement` attempted to get the reused node at this position, + // but the ambient context flag was not yet set, so the node appeared + // not reusable in that context. + var isAmbient = ts.some(modifiers, isDeclareModifier); + if (isAmbient) { + var node_3 = tryReuseAmbientDeclaration(); + if (node_3) { + return node_3; + } + } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (ts.some(node.modifiers, isDeclareModifier)) { + if (isAmbient) { for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var m = _a[_i]; m.flags |= 4194304 /* Ambient */; @@ -21541,6 +21970,14 @@ var ts; return parseDeclarationWorker(node); } } + function tryReuseAmbientDeclaration() { + return doInsideOfContext(4194304 /* Ambient */, function () { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + }); + } function parseDeclarationWorker(node) { switch (token()) { case 106 /* VarKeyword */: @@ -21578,7 +22015,7 @@ var ts; if (node.decorators || node.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(259 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(260 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -21601,16 +22038,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 27 /* CommaToken */) { - return createNode(211 /* OmittedExpression */); + return createNode(212 /* OmittedExpression */); } - var node = createNode(187 /* BindingElement */); + var node = createNode(188 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(187 /* BindingElement */); + var node = createNode(188 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -21626,14 +22063,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(185 /* ObjectBindingPattern */); + var node = createNode(186 /* ObjectBindingPattern */); parseExpected(18 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(186 /* ArrayBindingPattern */); + var node = createNode(187 /* ArrayBindingPattern */); parseExpected(22 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(23 /* CloseBracketToken */); @@ -21655,7 +22092,7 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(238 /* VariableDeclaration */); + var node = createNode(239 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 73 /* Identifier */ && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { @@ -21668,7 +22105,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(239 /* VariableDeclarationList */); + var node = createNode(240 /* VariableDeclarationList */); switch (token()) { case 106 /* VarKeyword */: break; @@ -21691,7 +22128,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 148 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 149 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -21706,13 +22143,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 220 /* VariableStatement */; + node.kind = 221 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 240 /* FunctionDeclaration */; + node.kind = 241 /* FunctionDeclaration */; parseExpected(91 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); @@ -21736,7 +22173,7 @@ var ts; function tryParseConstructorDeclaration(node) { return tryParse(function () { if (parseConstructorName()) { - node.kind = 158 /* Constructor */; + node.kind = 159 /* Constructor */; fillSignature(57 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); @@ -21744,7 +22181,7 @@ var ts; }); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 157 /* MethodDeclaration */; + node.kind = 158 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; @@ -21753,7 +22190,7 @@ var ts; return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 155 /* PropertyDeclaration */; + node.kind = 156 /* PropertyDeclaration */; if (!node.questionToken && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } @@ -21858,7 +22295,7 @@ var ts; if (!parseOptional(58 /* AtToken */)) { break; } - var decorator = createNode(153 /* Decorator */, decoratorStart); + var decorator = createNode(154 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -21908,7 +22345,7 @@ var ts; } function parseClassElement() { if (token() === 26 /* SemicolonToken */) { - var result = createNode(218 /* SemicolonClassElement */); + var result = createNode(219 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -21916,10 +22353,10 @@ var ts; node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + return parseAccessorDeclaration(node, 160 /* GetAccessor */); } if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + return parseAccessorDeclaration(node, 161 /* SetAccessor */); } if (token() === 125 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(node); @@ -21948,10 +22385,10 @@ var ts; return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 210 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 211 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 241 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 242 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -21994,22 +22431,21 @@ var ts; function parseHeritageClause() { var tok = token(); ts.Debug.assert(tok === 87 /* ExtendsKeyword */ || tok === 110 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(274 /* HeritageClause */); + var node = createNode(275 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(213 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 28 /* LessThanToken */ - ? parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) - : undefined; + return token() === 28 /* LessThanToken */ ? + parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) : undefined; } function isHeritageClause() { return token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; @@ -22018,7 +22454,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 242 /* InterfaceDeclaration */; + node.kind = 243 /* InterfaceDeclaration */; parseExpected(111 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -22027,7 +22463,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 243 /* TypeAliasDeclaration */; + node.kind = 244 /* TypeAliasDeclaration */; parseExpected(141 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -22041,13 +22477,13 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNodeWithJSDoc(279 /* EnumMember */); + var node = createNodeWithJSDoc(280 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 244 /* EnumDeclaration */; + node.kind = 245 /* EnumDeclaration */; parseExpected(85 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(18 /* OpenBraceToken */)) { @@ -22060,7 +22496,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(246 /* ModuleBlock */); + var node = createNode(247 /* ModuleBlock */); if (parseExpected(18 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(19 /* CloseBraceToken */); @@ -22071,7 +22507,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 245 /* ModuleDeclaration */; + node.kind = 246 /* ModuleDeclaration */; // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -22083,7 +22519,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 245 /* ModuleDeclaration */; + node.kind = 246 /* ModuleDeclaration */; if (token() === 146 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); @@ -22129,7 +22565,7 @@ var ts; return nextToken() === 42 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 248 /* NamespaceExportDeclaration */; + node.kind = 249 /* NamespaceExportDeclaration */; parseExpected(120 /* AsKeyword */); parseExpected(132 /* NamespaceKeyword */); node.name = parseIdentifier(); @@ -22147,7 +22583,7 @@ var ts; } } // Import statement - node.kind = 250 /* ImportDeclaration */; + node.kind = 251 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; @@ -22162,7 +22598,7 @@ var ts; return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 249 /* ImportEqualsDeclaration */; + node.kind = 250 /* ImportEqualsDeclaration */; node.name = identifier; parseExpected(60 /* EqualsToken */); node.moduleReference = parseModuleReference(); @@ -22176,7 +22612,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(251 /* ImportClause */, fullStart); + var importClause = createNode(252 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -22186,7 +22622,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(27 /* CommaToken */)) { - importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(253 /* NamedImports */); + importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(254 /* NamedImports */); } return finishNode(importClause); } @@ -22196,7 +22632,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(260 /* ExternalModuleReference */); + var node = createNode(261 /* ExternalModuleReference */); parseExpected(135 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -22219,7 +22655,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(252 /* NamespaceImport */); + var namespaceImport = createNode(253 /* NamespaceImport */); parseExpected(40 /* AsteriskToken */); parseExpected(120 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -22234,14 +22670,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 253 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); + node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 254 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(258 /* ExportSpecifier */); + return parseImportOrExportSpecifier(259 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(254 /* ImportSpecifier */); + return parseImportOrExportSpecifier(255 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -22266,19 +22702,19 @@ var ts; else { node.name = identifierName; } - if (kind === 254 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 255 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 256 /* ExportDeclaration */; + node.kind = 257 /* ExportDeclaration */; if (parseOptional(40 /* AsteriskToken */)) { parseExpected(145 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(257 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(258 /* 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. @@ -22291,7 +22727,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 255 /* ExportAssignment */; + node.kind = 256 /* ExportAssignment */; if (parseOptional(60 /* EqualsToken */)) { node.isExportEquals = true; } @@ -22311,12 +22747,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */ - || node.kind === 250 /* ImportDeclaration */ - || node.kind === 255 /* ExportAssignment */ - || node.kind === 256 /* ExportDeclaration */ - ? node - : undefined; + || node.kind === 250 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 261 /* ExternalModuleReference */ + || node.kind === 251 /* ImportDeclaration */ + || node.kind === 256 /* ExportAssignment */ + || node.kind === 257 /* ExportDeclaration */ ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { return sourceFile.flags & 1048576 /* PossiblyContainsImportMeta */ ? @@ -22378,7 +22812,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(289 /* JSDocTypeExpression */); + var result = createNode(290 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -22390,8 +22824,8 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseIsolatedJSDocComment(content, start, length) { initializeState(content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = { languageVariant: 0 /* Standard */, text: content }; // tslint:disable-line no-object-literal-type-assertion - var jsDoc = parseJSDocCommentWorker(start, length); + sourceFile = { languageVariant: 0 /* Standard */, text: content }; + var jsDoc = doInsideOfContext(2097152 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); var diagnostics = parseDiagnostics; clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -22402,7 +22836,7 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = parseJSDocCommentWorker(start, length); + var comment = doInsideOfContext(2097152 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); if (comment) { comment.parent = parent; } @@ -22541,7 +22975,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(297 /* JSDocComment */, start); + var result = createNode(299 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -22741,7 +23175,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(300 /* JSDocTag */, start); + var result = createNode(302 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -22788,7 +23222,7 @@ var ts; switch (node.kind) { case 137 /* ObjectKeyword */: return true; - case 170 /* ArrayType */: + case 171 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -22804,8 +23238,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(312 /* JSDocPropertyTag */, start) : - createNode(306 /* JSDocParameterTag */, start); + createNode(314 /* JSDocPropertyTag */, start) : + createNode(308 /* JSDocParameterTag */, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -22822,20 +23256,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(289 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(290 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; - var start_2 = scanner.getStartPos(); + var start_3 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 306 /* JSDocParameterTag */ || child.kind === 312 /* JSDocPropertyTag */) { + if (child.kind === 308 /* JSDocParameterTag */ || child.kind === 314 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(298 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(300 /* JSDocTypeLiteral */, start_3); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression.type.kind === 171 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -22847,7 +23281,7 @@ var ts; if (ts.some(tags, ts.isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(307 /* JSDocReturnTag */, start); + var result = createNode(309 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); @@ -22856,13 +23290,13 @@ var ts; if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(309 /* JSDocTypeTag */, start); + var result = createNode(311 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAuthorTag(start, tagName, indent) { - var result = createNode(302 /* JSDocAuthorTag */, start); + var result = createNode(304 /* JSDocAuthorTag */, start); result.tagName = tagName; var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); }); if (!authorInfoWithEmail) { @@ -22916,14 +23350,14 @@ var ts; } } function parseAugmentsTag(start, tagName) { - var result = createNode(301 /* JSDocAugmentsTag */, start); + var result = createNode(303 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18 /* OpenBraceToken */); - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(213 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -22935,7 +23369,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var prop = createNode(190 /* PropertyAccessExpression */, node.pos); + var prop = createNode(191 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -22943,19 +23377,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(303 /* JSDocClassTag */, start); + var tag = createNode(305 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(308 /* JSDocThisTag */, start); + var tag = createNode(310 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(305 /* JSDocEnumTag */, start); + var tag = createNode(307 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); @@ -22964,7 +23398,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(311 /* JSDocTypedefTag */, start); + var typedefTag = createNode(313 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -22978,9 +23412,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(298 /* JSDocTypeLiteral */, start); + jsdocTypeLiteral = createNode(300 /* JSDocTypeLiteral */, start); } - if (child.kind === 309 /* JSDocTypeTag */) { + if (child.kind === 311 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -22993,7 +23427,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 171 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -23012,7 +23446,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(24 /* DotToken */)) { - var jsDocNamespaceNode = createNode(245 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(246 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -23026,14 +23460,14 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(304 /* JSDocCallbackTag */, start); + var callbackTag = createNode(306 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(299 /* JSDocSignature */, start); + var jsdocSignature = createNode(301 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -23041,7 +23475,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(58 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 307 /* JSDocReturnTag */) { + if (tag && tag.kind === 309 /* JSDocReturnTag */) { return tag; } } @@ -23086,7 +23520,7 @@ var ts; case 58 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 306 /* JSDocParameterTag */ || child.kind === 312 /* JSDocPropertyTag */) && + if (child && (child.kind === 308 /* JSDocParameterTag */ || child.kind === 314 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -23150,13 +23584,13 @@ var ts; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(151 /* TypeParameter */); + var typeParameter = createNode(152 /* TypeParameter */); typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); finishNode(typeParameter); skipWhitespace(); typeParameters.push(typeParameter); } while (parseOptionalJsdoc(27 /* CommaToken */)); - var result = createNode(310 /* JSDocTemplateTag */, start); + var result = createNode(312 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -23191,16 +23625,19 @@ var ts; if (!ts.tokenIsIdentifierOrKeyword(token())) { return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } + identifierCount++; var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); var result = createNode(73 /* Identifier */, pos); - result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); + if (token() !== 73 /* Identifier */) { + result.originalKeywordKind = token(); + } + result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); finishNode(result, end); nextTokenJSDoc(); return result; } } - JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {})); })(Parser || (Parser = {})); var IncrementalParser; @@ -24046,6 +24483,7 @@ var ts; type: "boolean", category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_incremental_compilation, + transpileOptionValue: undefined }, { name: "locale", @@ -24055,7 +24493,7 @@ var ts; }, ]; /* @internal */ - ts.optionDeclarations = ts.commonOptionsWithBuild.concat([ + ts.optionDeclarations = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "all", type: "boolean", @@ -24157,7 +24595,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation + description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation, + transpileOptionValue: undefined }, { name: "allowJs", @@ -24194,6 +24633,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "declarationMap", @@ -24202,6 +24642,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "emitDeclarationOnly", @@ -24209,6 +24650,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Only_emit_d_ts_declaration_files, + transpileOptionValue: undefined }, { name: "sourceMap", @@ -24227,6 +24669,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "outDir", @@ -24254,6 +24697,7 @@ var ts; isTSConfigOnly: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_project_compilation, + transpileOptionValue: undefined }, { name: "tsBuildInfoFile", @@ -24263,6 +24707,7 @@ var ts; paramType: ts.Diagnostics.FILE, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, + transpileOptionValue: undefined }, { name: "removeComments", @@ -24279,6 +24724,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Do_not_emit_outputs, + transpileOptionValue: undefined }, { name: "importHelpers", @@ -24298,7 +24744,8 @@ var ts; name: "isolatedModules", type: "boolean", category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule + description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule, + transpileOptionValue: true }, // Strict Type Checks { @@ -24432,7 +24879,8 @@ var ts; affectsModuleResolution: true, isTSConfigOnly: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl + description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl, + transpileOptionValue: undefined }, { // this option can only be specified in tsconfig.json @@ -24447,7 +24895,8 @@ var ts; }, affectsModuleResolution: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime + description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime, + transpileOptionValue: undefined }, { name: "typeRoots", @@ -24471,7 +24920,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation, + transpileOptionValue: undefined }, { name: "allowSyntheticDefaultImports", @@ -24568,6 +25018,7 @@ var ts; category: ts.Diagnostics.Advanced_Options, paramType: ts.Diagnostics.FILE, description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "reactNamespace", @@ -24617,14 +25068,20 @@ var ts; type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts + description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts, + // We are not returning a sourceFile for lib file when asked by the program, + // so pass --noLib to avoid reporting a file not found error. + transpileOptionValue: true }, { name: "noResolve", type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files + description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files, + // We are not doing a full typecheck, we are not resolving the whole context, + // so pass --noResolve to avoid reporting missing file errors. + transpileOptionValue: true }, { name: "stripInternal", @@ -24660,6 +25117,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + transpileOptionValue: undefined }, { name: "preserveConstEnums", @@ -24675,7 +25133,8 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Output_directory_for_generated_declaration_files + description: ts.Diagnostics.Output_directory_for_generated_declaration_files, + transpileOptionValue: undefined }, { name: "skipLibCheck", @@ -24762,7 +25221,11 @@ var ts; return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics; }); /* @internal */ - ts.buildOpts = ts.commonOptionsWithBuild.concat([ + ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) { + return ts.hasProperty(option, "transpileOptionValue"); + }); + /* @internal */ + ts.buildOpts = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "verbose", shortName: "v", @@ -25326,7 +25789,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 276 /* PropertyAssignment */) { + if (element.kind !== 277 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -25390,7 +25853,7 @@ var ts; return false; case 97 /* NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for - return null; // tslint:disable-line:no-null-keyword + return null; // eslint-disable-line no-null/no-null case 10 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); @@ -25408,13 +25871,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: if (valueExpression.operator !== 39 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -25431,7 +25894,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25482,13 +25945,13 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName); }); var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames }); - var config = __assign({ compilerOptions: __assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { + var config = __assign(__assign({ compilerOptions: __assign(__assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { var _a; - return (__assign({}, prev, (_a = {}, _a[cur[0]] = cur[1], _a))); - }, {}), { showConfig: undefined, configFile: undefined, configFilePath: undefined, help: undefined, init: undefined, listFiles: undefined, listEmittedFiles: undefined, project: undefined, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign({}, r, { path: r.originalPath, originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { + return (__assign(__assign({}, prev), (_a = {}, _a[cur[0]] = cur[1], _a))); + }, {})), { showConfig: undefined, configFile: undefined, configFilePath: undefined, help: undefined, init: undefined, listFiles: undefined, listEmittedFiles: undefined, project: undefined, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign(__assign({}, r), { path: r.originalPath ? r.originalPath : "", originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs), exclude: configParseResult.configFileSpecs.validatedExcludeSpecs - } : {}), { compilerOnSave: !!configParseResult.compileOnSave ? true : undefined }); + } : {})), { compileOnSave: !!configParseResult.compileOnSave ? true : undefined }); return config; } ts.convertToTSConfig = convertToTSConfig; @@ -25713,8 +26176,7 @@ var ts; } ts.setConfigFileInOptions = setConfigFileInOptions; function isNullOrUndefined(x) { - // tslint:disable-next-line:no-null-keyword - return x === undefined || x === null; + return x === undefined || x === null; // eslint-disable-line no-null/no-null } function directoryOfCombinedPath(fileName, basePath) { // Use the `getNormalizedAbsolutePath` function to avoid canonicalizing the path, as it must remain noncanonical @@ -25880,7 +26342,7 @@ var ts; basePath = ts.normalizeSlashes(basePath); var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath); if (resolutionStack.indexOf(resolvedPath) >= 0) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))); + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, __spreadArrays(resolutionStack, [resolvedPath]).join(" -> "))); return { raw: json || convertToObject(sourceFile, errors) }; } var ownConfig = json ? @@ -26569,8 +27031,9 @@ var ts; return; } var value = jsonContent[fieldName]; - if (typeof value !== typeOfTag || value === null) { + if (typeof value !== typeOfTag || value === null) { // eslint-disable-line no-null/no-null if (state.traceEnabled) { + // eslint-disable-next-line no-null/no-null trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, fieldName, typeOfTag, value === null ? "null" : typeof value); } return; @@ -26829,7 +27292,7 @@ var ts; var packageJsonPath = ts.combinePaths(root, normalized, "package.json"); // `types-publisher` sometimes creates packages with `"typings": null` for packages that don't provide their own types. // See `createNotNeededPackageJSON` in the types-publisher` repo. - // tslint:disable-next-line:no-null-keyword + // eslint-disable-next-line no-null/no-null var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); @@ -27013,6 +27476,7 @@ var ts; trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); } } + ts.perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/); switch (moduleResolution) { case ts.ModuleResolutionKind.NodeJs: result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); @@ -27023,6 +27487,9 @@ var ts; default: return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); } + if (result && result.resolvedModule) + ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, result); if (!ts.isExternalModuleNameRelative(moduleName)) { @@ -27232,7 +27699,7 @@ var ts; ts.tryResolveJSModule = tryResolveJSModule; var jsOnlyExtensions = [Extensions.JavaScript]; var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript]; - var tsPlusJsonExtensions = tsExtensions.concat([Extensions.Json]); + var tsPlusJsonExtensions = __spreadArrays(tsExtensions, [Extensions.Json]); var tsconfigExtensions = [Extensions.TSConfig]; function tryResolveJSModuleWorker(moduleName, initialDir, host) { return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); @@ -27268,7 +27735,7 @@ var ts; if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) { var path = realPath(resolvedValue.path, host, traceEnabled); var originalPath = path === resolvedValue.path ? undefined : resolvedValue.path; - resolvedValue = __assign({}, resolvedValue, { path: path, originalPath: originalPath }); + resolvedValue = __assign(__assign({}, resolvedValue), { path: path, originalPath: originalPath }); } // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } }; @@ -27289,7 +27756,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); // tslint:disable-line + ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -27777,24 +28244,24 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. other uninstantiated module declarations. - case 246 /* ModuleBlock */: { + case 247 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -27816,7 +28283,7 @@ var ts; }); return state_1; } - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return getModuleInstanceState(node); case 73 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should @@ -27855,7 +28322,9 @@ var ts; var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); + ts.perfLogger.logStartBindFile("" + file.fileName); binder(file, options); + ts.perfLogger.logStopBindFile(); ts.performance.mark("afterBind"); ts.performance.measure("Bind", "beforeBind", "afterBind"); } @@ -27889,7 +28358,7 @@ var ts; // or if compiler options contain alwaysStrict. var inStrictMode; var symbolCount = 0; - var Symbol; // tslint:disable-line variable-name + var Symbol; var classifiableNames; var unreachableFlow = { flags: 1 /* Unreachable */ }; var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; @@ -27957,7 +28426,7 @@ var ts; function addDeclarationToSymbol(symbol, node, symbolFlags) { symbol.flags |= symbolFlags; node.symbol = symbol; - symbol.declarations = ts.append(symbol.declarations, node); + symbol.declarations = ts.appendIfUnique(symbol.declarations, node); if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -27968,7 +28437,7 @@ var ts; if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 67220415 /* Value */) { + if (symbolFlags & 111551 /* Value */) { setValueDeclaration(symbol, node); } } @@ -27984,7 +28453,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 === 255 /* ExportAssignment */) { + if (node.kind === 256 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -27993,7 +28462,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 151 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -28008,36 +28477,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: return "__constructor" /* Constructor */; - case 166 /* FunctionType */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: + case 167 /* FunctionType */: + case 162 /* CallSignature */: + case 301 /* JSDocSignature */: return "__call" /* Call */; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 168 /* ConstructorType */: + case 163 /* ConstructSignature */: return "__new" /* New */; - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: return "__index" /* Index */; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 285 /* SourceFile */: + case 286 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 152 /* Parameter */: + case 153 /* 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 === 295 /* 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 === 296 /* 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; @@ -28137,7 +28606,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 === 255 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 256 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -28155,7 +28624,7 @@ var ts; } }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); - file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInformation_1)) : diag); + file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInformation_1)) : diag); symbol = createSymbol(0 /* None */, name); } } @@ -28172,7 +28641,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 258 /* ExportSpecifier */ || (node.kind === 249 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 259 /* ExportSpecifier */ || (node.kind === 250 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -28197,10 +28666,10 @@ var ts; if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { - if (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node)) { + if (!container.locals || (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } - var exportKind = symbolFlags & 67220415 /* Value */ ? 1048576 /* ExportValue */ : 0; + var exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -28239,7 +28708,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 !== 198 /* ArrowFunction */) { + if (node.kind !== 199 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -28272,7 +28741,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 === 158 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 159 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -28286,13 +28755,13 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 158 /* Constructor */) { + if (node.kind === 159 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -28336,8 +28805,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 241 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 241 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -28370,78 +28839,82 @@ var ts; return; } switch (node.kind) { - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: bindWhileStatement(node); break; - case 224 /* DoStatement */: + case 225 /* DoStatement */: bindDoStatement(node); break; - case 226 /* ForStatement */: + case 227 /* ForStatement */: bindForStatement(node); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 223 /* IfStatement */: + case 224 /* IfStatement */: bindIfStatement(node); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 232 /* ReturnStatement */: + case 236 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 236 /* TryStatement */: + case 237 /* TryStatement */: bindTryStatement(node); break; - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: bindSwitchStatement(node); break; - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: bindCaseBlock(node); break; - case 272 /* CaseClause */: + case 273 /* CaseClause */: bindCaseClause(node); break; - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: bindLabeledStatement(node); break; - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 192 /* CallExpression */: + case 193 /* CallExpression */: bindCallExpressionFlow(node); break; - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; + case 305 /* JSDocClassTag */: + bindJSDocClassTag(node); + break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 285 /* SourceFile */: { + case 286 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 220 /* Block */: + case 247 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -28454,18 +28927,18 @@ var ts; switch (expr.kind) { case 73 /* Identifier */: case 101 /* ThisKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return isNarrowableReference(expr); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return hasNarrowableArgument(expr); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return expr.operator === 52 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; @@ -28473,7 +28946,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 73 /* Identifier */ || expr.kind === 101 /* ThisKeyword */ || expr.kind === 99 /* SuperKeyword */ || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isElementAccessExpression(expr) && expr.argumentExpression && + ts.isElementAccessExpression(expr) && (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && isNarrowableReference(expr.expression); } @@ -28486,7 +28959,7 @@ var ts; } } } - if (expr.expression.kind === 190 /* PropertyAccessExpression */ && + if (expr.expression.kind === 191 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -28519,9 +28992,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 60 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -28599,33 +29072,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 224 /* IfStatement */: + case 226 /* WhileStatement */: + case 225 /* DoStatement */: return parent.expression === node; - case 226 /* ForStatement */: - case 206 /* ConditionalExpression */: + case 227 /* ForStatement */: + case 207 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 196 /* ParenthesizedExpression */) { + if (node.kind === 197 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 203 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { + else if (node.kind === 204 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 205 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || + return node.kind === 206 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 55 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */ || - node.parent.kind === 203 /* PrefixUnaryExpression */ && + while (node.parent.kind === 197 /* ParenthesizedExpression */ || + node.parent.kind === 204 /* PrefixUnaryExpression */ && node.parent.operator === 52 /* ExclamationToken */) { node = node.parent; } @@ -28667,7 +29140,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 234 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 235 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -28701,13 +29174,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 228 /* ForOfStatement */) { + if (node.kind === 229 /* ForOfStatement */) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 239 /* VariableDeclarationList */) { + if (node.initializer.kind !== 240 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -28729,7 +29202,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 231 /* ReturnStatement */) { + if (node.kind === 232 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -28749,7 +29222,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 230 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 231 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -28877,7 +29350,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 273 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 274 /* 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). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -28944,14 +29417,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 224 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 225 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */) { + if (node.kind === 206 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -28962,10 +29435,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 188 /* ArrayLiteralExpression */) { + else if (node.kind === 189 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 209 /* SpreadElement */) { + if (e.kind === 210 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -28973,16 +29446,16 @@ var ts; } } } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 190 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 276 /* PropertyAssignment */) { + if (p.kind === 277 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 277 /* ShorthandPropertyAssignment */) { + else if (p.kind === 278 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 278 /* SpreadAssignment */) { + else if (p.kind === 279 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -29038,7 +29511,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 60 /* EqualsToken */ && node.left.kind === 191 /* ElementAccessExpression */) { + if (operator === 60 /* EqualsToken */ && node.left.kind === 192 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29049,7 +29522,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + if (node.expression.kind === 191 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -29088,19 +29561,26 @@ var ts; } function bindJSDocTypeAlias(node) { node.tagName.parent = node; - if (node.fullName) { + if (node.kind !== 307 /* JSDocEnumTag */ && node.fullName) { setParentPointers(node, node.fullName); } } + function bindJSDocClassTag(node) { + bindEachChild(node); + var host = ts.getHostSignatureFromJSDoc(node); + if (host && host.kind !== 158 /* MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* Class */); + } + } function bindCallExpressionFlow(node) { // If the target of the call expression is a function expression or arrow function we have // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = node.expression; - while (expr.kind === 196 /* ParenthesizedExpression */) { + while (expr.kind === 197 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 197 /* FunctionExpression */ || expr.kind === 198 /* ArrowFunction */) { + if (expr.kind === 198 /* FunctionExpression */ || expr.kind === 199 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -29108,7 +29588,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + if (node.expression.kind === 191 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29117,54 +29597,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 269 /* JsxAttributes */: + case 211 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 190 /* ObjectLiteralExpression */: + case 170 /* TypeLiteral */: + case 300 /* JSDocTypeLiteral */: + case 270 /* JsxAttributes */: return 1 /* IsContainer */; - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 246 /* ModuleDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 183 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 285 /* SourceFile */: + case 286 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: - case 295 /* JSDocFunctionType */: - case 166 /* FunctionType */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 167 /* ConstructorType */: + case 159 /* Constructor */: + case 241 /* FunctionDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 162 /* CallSignature */: + case 301 /* JSDocSignature */: + case 296 /* JSDocFunctionType */: + case 167 /* FunctionType */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 168 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 275 /* CatchClause */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 247 /* CaseBlock */: + case 276 /* CatchClause */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 248 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 219 /* Block */: + case 220 /* 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 @@ -29197,45 +29677,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 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 285 /* SourceFile */: + case 286 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 242 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 189 /* ObjectLiteralExpression */: - case 242 /* InterfaceDeclaration */: - case 269 /* JsxAttributes */: + case 170 /* TypeLiteral */: + case 300 /* JSDocTypeLiteral */: + case 190 /* ObjectLiteralExpression */: + case 243 /* InterfaceDeclaration */: + case 270 /* 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 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 299 /* JSDocSignature */: - case 163 /* IndexSignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 295 /* JSDocFunctionType */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 301 /* JSDocSignature */: + case 164 /* IndexSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 296 /* JSDocFunctionType */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 244 /* TypeAliasDeclaration */: + case 183 /* 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 @@ -29336,7 +29816,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */ || prop.name.kind !== 73 /* Identifier */) { + if (prop.kind === 279 /* SpreadAssignment */ || prop.name.kind !== 73 /* Identifier */) { continue; } var identifier = prop.name; @@ -29348,7 +29828,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 === 276 /* PropertyAssignment */ || prop.kind === 277 /* ShorthandPropertyAssignment */ || prop.kind === 157 /* MethodDeclaration */ + var currentKind = prop.kind === 277 /* PropertyAssignment */ || prop.kind === 278 /* ShorthandPropertyAssignment */ || prop.kind === 158 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -29380,10 +29860,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -29414,9 +29894,37 @@ var ts; currentFlow = { flags: 2 /* Start */ }; parent = typeAlias; bind(typeAlias.typeExpression); - if (!typeAlias.fullName || typeAlias.fullName.kind === 73 /* Identifier */) { + var declName = ts.getNameOfDeclaration(typeAlias); + if ((ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName) && declName && ts.isPropertyAccessEntityNameExpression(declName.parent)) { + // typedef anchored to an A.B.C assignment - we need to bind into B's namespace under name C + var isTopLevel = isTopLevelNamespaceAssignment(declName.parent); + if (isTopLevel) { + bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); + var oldContainer = container; + switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { + case 1 /* ExportsProperty */: + case 2 /* ModuleExports */: + container = file; + break; + case 4 /* ThisProperty */: + container = declName.parent.expression; + break; + case 3 /* PrototypeProperty */: + container = declName.parent.expression.name; + break; + case 5 /* Property */: + container = ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; + break; + case 0 /* None */: + return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); + } + declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + container = oldContainer; + } + } + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 73 /* Identifier */) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); } else { bind(typeAlias.fullName); @@ -29435,7 +29943,8 @@ var ts; node.originalKeywordKind >= 110 /* FirstFutureReservedWord */ && node.originalKeywordKind <= 118 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && - !(node.flags & 4194304 /* Ambient */)) { + !(node.flags & 4194304 /* Ambient */) && + !(node.flags & 2097152 /* JSDoc */)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -29521,8 +30030,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 285 /* SourceFile */ && - blockScopeContainer.kind !== 245 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 286 /* SourceFile */ && + blockScopeContainer.kind !== 246 /* 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. @@ -29583,7 +30092,7 @@ var ts; file.bindDiagnostics.push(diag); } else { - file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } } function bind(node) { @@ -29617,7 +30126,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 > 148 /* LastToken */) { + if (node.kind > 149 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -29688,17 +30197,17 @@ var ts; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); break; } // falls through case 101 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 277 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 278 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -29709,10 +30218,10 @@ var ts; file.commonJsModuleIndicator && ts.isModuleExportsPropertyAccessExpression(node) && !lookupSymbolForNameWorker(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 67220414 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -29740,76 +30249,76 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return checkStrictModeCatchClause(node); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return checkStrictModeWithStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 179 /* ThisType */: + case 180 /* ThisType */: seenThisKeyword = true; return; - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: break; // Binding the children will handle everything - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return bindTypeParameter(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return bindParameter(node); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 187 /* BindingElement */: + case 188 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return bindPropertyWorker(node); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 279 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 280 /* EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* 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 */ : 67212223 /* MethodExcludes */); - case 240 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); + case 241 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 158 /* Constructor */: + case 159 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 159 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 67154879 /* GetAccessorExcludes */); - case 160 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67187647 /* SetAccessorExcludes */); - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 299 /* JSDocSignature */: - case 167 /* ConstructorType */: + case 160 /* GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); + case 161 /* SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); + case 167 /* FunctionType */: + case 296 /* JSDocFunctionType */: + case 301 /* JSDocSignature */: + case 168 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 182 /* MappedType */: + case 170 /* TypeLiteral */: + case 300 /* JSDocTypeLiteral */: + case 183 /* MappedType */: return bindAnonymousTypeWorker(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return bindFunctionExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -29828,64 +30337,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 242 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 242 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 67897736 /* InterfaceExcludes */); - case 243 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); - case 244 /* EnumDeclaration */: + case 243 /* InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); + case 244 /* TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + case 245 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return bindJsxAttributes(node); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 250 /* ImportEqualsDeclaration */: + case 253 /* NamespaceImport */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return bindImportClause(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return bindExportDeclaration(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return bindExportAssignment(node); - case 285 /* SourceFile */: + case 286 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 219 /* Block */: + case 220 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 306 /* JSDocParameterTag */: - if (node.parent.kind === 299 /* JSDocSignature */) { + case 308 /* JSDocParameterTag */: + if (node.parent.kind === 301 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 298 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 300 /* JSDocTypeLiteral */) { break; } // falls through - case 312 /* JSDocPropertyTag */: + case 314 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 294 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 295 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -30029,8 +30539,8 @@ var ts; ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 198 /* 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 === 60 /* EqualsToken */) { @@ -30044,26 +30554,27 @@ var ts; constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable(); // It's acceptable for multiple 'this' assignments of the same identifier to occur declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 159 /* Constructor */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 285 /* SourceFile */: + case 286 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220414 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); } break; default: @@ -30074,7 +30585,7 @@ var ts; if (node.expression.kind === 101 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 285 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 286 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -30088,7 +30599,7 @@ var ts; node.left.parent = node; node.right.parent = node; var lhs = node.left; - bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false); + bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false, /*containerIsClass*/ true); } function bindObjectDefinePrototypeProperty(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); @@ -30107,12 +30618,12 @@ var ts; lhs.parent = parent; constructorFunction.parent = classPrototype; classPrototype.parent = lhs; - bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true); + bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true, /*containerIsClass*/ true); } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); + var isToplevel = node.parent.parent.kind === 286 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } function bindSpecialPropertyAssignment(node) { @@ -30141,10 +30652,10 @@ var ts; */ function bindStaticPropertyAssignment(node) { node.expression.parent = node; - bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } - function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { - if (isToplevel && !isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */))) { + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { + if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* Assignment */; var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; @@ -30160,6 +30671,9 @@ var ts; } }); } + if (containerIsClass && namespaceSymbol) { + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + } return namespaceSymbol; } function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { @@ -30172,15 +30686,18 @@ var ts; (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); var includes = isMethod ? 8192 /* Method */ : 4 /* Property */; - var excludes = isMethod ? 67212223 /* MethodExcludes */ : 0 /* PropertyExcludes */; + var excludes = isMethod ? 103359 /* MethodExcludes */ : 0 /* PropertyExcludes */; declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + function isTopLevelNamespaceAssignment(propertyAccess) { + return ts.isBinaryExpression(propertyAccess.parent) + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 286 /* SourceFile */ + : propertyAccess.parent.parent.kind === 286 /* SourceFile */; + } + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); - var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 285 /* SourceFile */ - : propertyAccess.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } /** @@ -30249,8 +30766,8 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 241 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); + if (node.kind === 242 /* ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { var bindingName = node.name ? node.name.escapedText : "__class" /* Class */; @@ -30283,19 +30800,16 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 68008831 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 68008191 /* RegularEnumExcludes */); + ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - var isEnum = ts.isInJSFile(node) && !!ts.getJSDocEnumTag(node); - var enumFlags = (isEnum ? 256 /* RegularEnum */ : 0 /* None */); - var enumExcludes = (isEnum ? 68008191 /* RegularEnumExcludes */ : 0 /* None */); if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */ | enumFlags, 67220415 /* BlockScopedVariableExcludes */ | enumExcludes); + bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); } else if (ts.isParameterDeclaration(node)) { // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration @@ -30307,15 +30821,15 @@ var ts; // function foo([a,a]) {} // Duplicate Identifier error // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter // // which correctly set excluded symbols - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220415 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */ | enumFlags, 67220414 /* FunctionScopedVariableExcludes */ | enumExcludes); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); } } } function bindParameter(node) { - if (node.kind === 306 /* JSDocParameterTag */ && container.kind !== 299 /* JSDocSignature */) { + if (node.kind === 308 /* JSDocParameterTag */ && container.kind !== 301 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -30327,11 +30841,11 @@ var ts; bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220415 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); } // If this is a property-parameter, then also declare the property symbol into the // containing class. - if (ts.isParameterPropertyDeclaration(node)) { + if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); } @@ -30345,10 +30859,10 @@ var ts; checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16 /* Function */, 67219887 /* FunctionExcludes */); + bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 67219887 /* FunctionExcludes */); + declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */); } } function bindFunctionExpression(node) { @@ -30386,26 +30900,26 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 177 /* InferType */) { + else if (node.parent.kind === 178 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } else { bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } // reachability checks @@ -30420,11 +30934,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 221 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 222 /* EmptyStatement */) || // report error on class declarations - node.kind === 241 /* ClassDeclaration */ || + node.kind === 242 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 245 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 246 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -30468,12 +30982,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: return true; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; @@ -30522,58 +31036,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 192 /* CallExpression */: + case 193 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 152 /* Parameter */: + case 153 /* Parameter */: return computeParameter(node, subtreeFlags); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 158 /* Constructor */: + case 159 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -30618,12 +31132,12 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 189 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 190 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ES2018 if they contain rest transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 188 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 189 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } @@ -30671,8 +31185,8 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 213 /* AsExpression */ - || expressionKind === 195 /* TypeAssertionExpression */) { + if (expressionKind === 214 /* AsExpression */ + || expressionKind === 196 /* TypeAssertionExpression */) { transformFlags |= 1 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -31010,13 +31524,13 @@ var ts; var excludeFlags = 536870912 /* NodeExcludes */; switch (kind) { case 122 /* AsyncKeyword */: - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ES2018 syntax (for async generators) transformFlags |= 16 /* AssertES2018 */ | 32 /* AssertES2017 */; break; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 315 /* PartiallyEmittedExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: + case 317 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; excludeFlags = 536870912 /* OuterExpressionExcludes */; @@ -31027,25 +31541,25 @@ var ts; case 119 /* AbstractKeyword */: case 126 /* DeclareKeyword */: case 78 /* ConstKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 214 /* NonNullExpression */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 215 /* NonNullExpression */: case 134 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: case 11 /* JsxText */: - case 264 /* JsxClosingElement */: - case 265 /* JsxFragment */: - case 266 /* JsxOpeningFragment */: - case 267 /* JsxClosingFragment */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 271 /* JsxExpression */: + case 265 /* JsxClosingElement */: + case 266 /* JsxFragment */: + case 267 /* JsxOpeningFragment */: + case 268 /* JsxClosingFragment */: + case 269 /* JsxAttribute */: + case 270 /* JsxAttributes */: + case 271 /* JsxSpreadAttribute */: + case 272 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 2 /* AssertJsx */; break; @@ -31053,11 +31567,11 @@ var ts; case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: - case 277 /* ShorthandPropertyAssignment */: + case 208 /* TemplateExpression */: + case 195 /* TaggedTemplateExpression */: + case 278 /* ShorthandPropertyAssignment */: case 117 /* StaticKeyword */: - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; @@ -31074,14 +31588,14 @@ var ts; case 9 /* BigIntLiteral */: transformFlags |= 4 /* AssertESNext */; break; - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 16 /* AssertES2018 */; } transformFlags |= 128 /* AssertES2015 */; break; - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 131072 /* ContainsYield */; @@ -31095,49 +31609,49 @@ var ts; case 124 /* BooleanKeyword */: case 140 /* SymbolKeyword */: case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 164 /* TypePredicate */: - case 165 /* TypeReference */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 168 /* TypeQuery */: - case 169 /* TypeLiteral */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 177 /* InferType */: - case 178 /* ParenthesizedType */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: - case 248 /* NamespaceExportDeclaration */: + case 152 /* TypeParameter */: + case 155 /* PropertySignature */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 165 /* TypePredicate */: + case 166 /* TypeReference */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 169 /* TypeQuery */: + case 170 /* TypeLiteral */: + case 171 /* ArrayType */: + case 172 /* TupleType */: + case 173 /* OptionalType */: + case 174 /* RestType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: + case 177 /* ConditionalType */: + case 178 /* InferType */: + case 179 /* ParenthesizedType */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 180 /* ThisType */: + case 181 /* TypeOperator */: + case 182 /* IndexedAccessType */: + case 183 /* MappedType */: + case 184 /* LiteralType */: + case 249 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 1 /* AssertTypeScript */; excludeFlags = -2 /* TypeExcludes */; break; - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. transformFlags |= 16384 /* ContainsComputedPropertyName */; break; - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: transformFlags |= 128 /* AssertES2015 */ | 4096 /* ContainsRestOrSpread */; break; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; break; case 99 /* SuperKeyword */: @@ -31149,28 +31663,28 @@ var ts; // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 2048 /* ContainsLexicalThis */; break; - case 185 /* ObjectBindingPattern */: + case 186 /* ObjectBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; if (subtreeFlags & 4096 /* ContainsRestOrSpread */) { transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; } excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 187 /* BindingElement */: + case 188 /* BindingElement */: transformFlags |= 128 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 4096 /* ContainsRestOrSpread */; } break; - case 153 /* Decorator */: + case 154 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */ | 1024 /* ContainsTypeScriptClassSyntax */; break; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: excludeFlags = 536896512 /* ObjectLiteralExcludes */; if (subtreeFlags & 16384 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -31183,26 +31697,26 @@ var ts; transformFlags |= 16 /* AssertES2018 */; } break; - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: excludeFlags = 536875008 /* ArrayLiteralOrCallOrNewExcludes */; break; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 32768 /* ContainsBlockScopedBinding */) { transformFlags |= 128 /* AssertES2015 */; } break; - case 285 /* SourceFile */: + case 286 /* SourceFile */: break; - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: // Return statements may require an `await` in ES2018. transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */ | 16 /* AssertES2018 */; break; - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 230 /* ContinueStatement */: + case 231 /* BreakStatement */: transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -31220,33 +31734,33 @@ var ts; * than calling this function. */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) { + if (kind >= 165 /* FirstTypeNode */ && kind <= 185 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 188 /* ArrayLiteralExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 189 /* ArrayLiteralExpression */: return 536875008 /* ArrayLiteralOrCallOrNewExcludes */; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return 537168896 /* ModuleExcludes */; - case 152 /* Parameter */: + case 153 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return 537371648 /* ArrowFunctionExcludes */; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: return 537373696 /* FunctionExcludes */; - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return 536944640 /* VariableDeclarationListExcludes */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return 536888320 /* ClassExcludes */; - case 158 /* Constructor */: + case 159 /* Constructor */: return 537372672 /* ConstructorExcludes */; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return 537372672 /* MethodOrAccessorExcludes */; case 121 /* AnyKeyword */: case 136 /* NumberKeyword */: @@ -31257,30 +31771,30 @@ var ts; case 124 /* BooleanKeyword */: case 140 /* SymbolKeyword */: case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 152 /* TypeParameter */: + case 155 /* PropertySignature */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return 536896512 /* ObjectLiteralExcludes */; - case 275 /* CatchClause */: + case 276 /* CatchClause */: return 536879104 /* CatchClauseExcludes */; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: return 536875008 /* BindingPatternExcludes */; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 315 /* PartiallyEmittedExpression */: - case 196 /* ParenthesizedExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: + case 317 /* PartiallyEmittedExpression */: + case 197 /* ParenthesizedExpression */: case 99 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -31455,7 +31969,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 === 168 /* TypeQuery */) { + if (d.type && d.type.kind === 169 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -31506,6 +32020,179 @@ var ts; WideningKind[WideningKind["Normal"] = 0] = "Normal"; WideningKind[WideningKind["GeneratorYield"] = 1] = "GeneratorYield"; })(WideningKind || (WideningKind = {})); + var TypeFacts; + (function (TypeFacts) { + TypeFacts[TypeFacts["None"] = 0] = "None"; + TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; + TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; + TypeFacts[TypeFacts["TypeofEQBigInt"] = 4] = "TypeofEQBigInt"; + TypeFacts[TypeFacts["TypeofEQBoolean"] = 8] = "TypeofEQBoolean"; + TypeFacts[TypeFacts["TypeofEQSymbol"] = 16] = "TypeofEQSymbol"; + TypeFacts[TypeFacts["TypeofEQObject"] = 32] = "TypeofEQObject"; + TypeFacts[TypeFacts["TypeofEQFunction"] = 64] = "TypeofEQFunction"; + TypeFacts[TypeFacts["TypeofEQHostObject"] = 128] = "TypeofEQHostObject"; + TypeFacts[TypeFacts["TypeofNEString"] = 256] = "TypeofNEString"; + TypeFacts[TypeFacts["TypeofNENumber"] = 512] = "TypeofNENumber"; + TypeFacts[TypeFacts["TypeofNEBigInt"] = 1024] = "TypeofNEBigInt"; + TypeFacts[TypeFacts["TypeofNEBoolean"] = 2048] = "TypeofNEBoolean"; + TypeFacts[TypeFacts["TypeofNESymbol"] = 4096] = "TypeofNESymbol"; + TypeFacts[TypeFacts["TypeofNEObject"] = 8192] = "TypeofNEObject"; + TypeFacts[TypeFacts["TypeofNEFunction"] = 16384] = "TypeofNEFunction"; + TypeFacts[TypeFacts["TypeofNEHostObject"] = 32768] = "TypeofNEHostObject"; + TypeFacts[TypeFacts["EQUndefined"] = 65536] = "EQUndefined"; + TypeFacts[TypeFacts["EQNull"] = 131072] = "EQNull"; + TypeFacts[TypeFacts["EQUndefinedOrNull"] = 262144] = "EQUndefinedOrNull"; + TypeFacts[TypeFacts["NEUndefined"] = 524288] = "NEUndefined"; + TypeFacts[TypeFacts["NENull"] = 1048576] = "NENull"; + TypeFacts[TypeFacts["NEUndefinedOrNull"] = 2097152] = "NEUndefinedOrNull"; + TypeFacts[TypeFacts["Truthy"] = 4194304] = "Truthy"; + TypeFacts[TypeFacts["Falsy"] = 8388608] = "Falsy"; + TypeFacts[TypeFacts["All"] = 16777215] = "All"; + // The following members encode facts about particular kinds of types for use in the getTypeFacts function. + // The presence of a particular fact means that the given test is true for some (and possibly all) values + // of that kind of type. + TypeFacts[TypeFacts["BaseStringStrictFacts"] = 3735041] = "BaseStringStrictFacts"; + TypeFacts[TypeFacts["BaseStringFacts"] = 12582401] = "BaseStringFacts"; + TypeFacts[TypeFacts["StringStrictFacts"] = 16317953] = "StringStrictFacts"; + TypeFacts[TypeFacts["StringFacts"] = 16776705] = "StringFacts"; + TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 12123649] = "EmptyStringStrictFacts"; + TypeFacts[TypeFacts["EmptyStringFacts"] = 12582401] = "EmptyStringFacts"; + TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 7929345] = "NonEmptyStringStrictFacts"; + TypeFacts[TypeFacts["NonEmptyStringFacts"] = 16776705] = "NonEmptyStringFacts"; + TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 3734786] = "BaseNumberStrictFacts"; + TypeFacts[TypeFacts["BaseNumberFacts"] = 12582146] = "BaseNumberFacts"; + TypeFacts[TypeFacts["NumberStrictFacts"] = 16317698] = "NumberStrictFacts"; + TypeFacts[TypeFacts["NumberFacts"] = 16776450] = "NumberFacts"; + TypeFacts[TypeFacts["ZeroNumberStrictFacts"] = 12123394] = "ZeroNumberStrictFacts"; + TypeFacts[TypeFacts["ZeroNumberFacts"] = 12582146] = "ZeroNumberFacts"; + TypeFacts[TypeFacts["NonZeroNumberStrictFacts"] = 7929090] = "NonZeroNumberStrictFacts"; + TypeFacts[TypeFacts["NonZeroNumberFacts"] = 16776450] = "NonZeroNumberFacts"; + TypeFacts[TypeFacts["BaseBigIntStrictFacts"] = 3734276] = "BaseBigIntStrictFacts"; + TypeFacts[TypeFacts["BaseBigIntFacts"] = 12581636] = "BaseBigIntFacts"; + TypeFacts[TypeFacts["BigIntStrictFacts"] = 16317188] = "BigIntStrictFacts"; + TypeFacts[TypeFacts["BigIntFacts"] = 16775940] = "BigIntFacts"; + TypeFacts[TypeFacts["ZeroBigIntStrictFacts"] = 12122884] = "ZeroBigIntStrictFacts"; + TypeFacts[TypeFacts["ZeroBigIntFacts"] = 12581636] = "ZeroBigIntFacts"; + TypeFacts[TypeFacts["NonZeroBigIntStrictFacts"] = 7928580] = "NonZeroBigIntStrictFacts"; + TypeFacts[TypeFacts["NonZeroBigIntFacts"] = 16775940] = "NonZeroBigIntFacts"; + TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 3733256] = "BaseBooleanStrictFacts"; + TypeFacts[TypeFacts["BaseBooleanFacts"] = 12580616] = "BaseBooleanFacts"; + TypeFacts[TypeFacts["BooleanStrictFacts"] = 16316168] = "BooleanStrictFacts"; + TypeFacts[TypeFacts["BooleanFacts"] = 16774920] = "BooleanFacts"; + TypeFacts[TypeFacts["FalseStrictFacts"] = 12121864] = "FalseStrictFacts"; + TypeFacts[TypeFacts["FalseFacts"] = 12580616] = "FalseFacts"; + TypeFacts[TypeFacts["TrueStrictFacts"] = 7927560] = "TrueStrictFacts"; + TypeFacts[TypeFacts["TrueFacts"] = 16774920] = "TrueFacts"; + TypeFacts[TypeFacts["SymbolStrictFacts"] = 7925520] = "SymbolStrictFacts"; + TypeFacts[TypeFacts["SymbolFacts"] = 16772880] = "SymbolFacts"; + TypeFacts[TypeFacts["ObjectStrictFacts"] = 7888800] = "ObjectStrictFacts"; + TypeFacts[TypeFacts["ObjectFacts"] = 16736160] = "ObjectFacts"; + TypeFacts[TypeFacts["FunctionStrictFacts"] = 7880640] = "FunctionStrictFacts"; + TypeFacts[TypeFacts["FunctionFacts"] = 16728000] = "FunctionFacts"; + TypeFacts[TypeFacts["UndefinedFacts"] = 9830144] = "UndefinedFacts"; + TypeFacts[TypeFacts["NullFacts"] = 9363232] = "NullFacts"; + TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts"; + TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts"; + })(TypeFacts || (TypeFacts = {})); + var typeofEQFacts = ts.createMapFromTemplate({ + string: 1 /* TypeofEQString */, + number: 2 /* TypeofEQNumber */, + bigint: 4 /* TypeofEQBigInt */, + boolean: 8 /* TypeofEQBoolean */, + symbol: 16 /* TypeofEQSymbol */, + undefined: 65536 /* EQUndefined */, + object: 32 /* TypeofEQObject */, + function: 64 /* TypeofEQFunction */ + }); + var typeofNEFacts = ts.createMapFromTemplate({ + string: 256 /* TypeofNEString */, + number: 512 /* TypeofNENumber */, + bigint: 1024 /* TypeofNEBigInt */, + boolean: 2048 /* TypeofNEBoolean */, + symbol: 4096 /* TypeofNESymbol */, + undefined: 524288 /* NEUndefined */, + object: 8192 /* TypeofNEObject */, + function: 16384 /* TypeofNEFunction */ + }); + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; + TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; + TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); + var CheckMode; + (function (CheckMode) { + CheckMode[CheckMode["Normal"] = 0] = "Normal"; + CheckMode[CheckMode["Contextual"] = 1] = "Contextual"; + CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; + CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive"; + CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; + CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; + })(CheckMode || (CheckMode = {})); + var ContextFlags; + (function (ContextFlags) { + ContextFlags[ContextFlags["None"] = 0] = "None"; + ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; + })(ContextFlags || (ContextFlags = {})); + var AccessFlags; + (function (AccessFlags) { + AccessFlags[AccessFlags["None"] = 0] = "None"; + AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; + AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; + AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; + AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; + })(AccessFlags || (AccessFlags = {})); + var CallbackCheck; + (function (CallbackCheck) { + CallbackCheck[CallbackCheck["None"] = 0] = "None"; + CallbackCheck[CallbackCheck["Bivariant"] = 1] = "Bivariant"; + CallbackCheck[CallbackCheck["Strict"] = 2] = "Strict"; + })(CallbackCheck || (CallbackCheck = {})); + var MappedTypeModifiers; + (function (MappedTypeModifiers) { + MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly"; + MappedTypeModifiers[MappedTypeModifiers["ExcludeReadonly"] = 2] = "ExcludeReadonly"; + MappedTypeModifiers[MappedTypeModifiers["IncludeOptional"] = 4] = "IncludeOptional"; + MappedTypeModifiers[MappedTypeModifiers["ExcludeOptional"] = 8] = "ExcludeOptional"; + })(MappedTypeModifiers || (MappedTypeModifiers = {})); + var ExpandingFlags; + (function (ExpandingFlags) { + ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; + ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; + ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; + ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; + })(ExpandingFlags || (ExpandingFlags = {})); + var MembersOrExportsResolutionKind; + (function (MembersOrExportsResolutionKind) { + MembersOrExportsResolutionKind["resolvedExports"] = "resolvedExports"; + MembersOrExportsResolutionKind["resolvedMembers"] = "resolvedMembers"; + })(MembersOrExportsResolutionKind || (MembersOrExportsResolutionKind = {})); + var UnusedKind; + (function (UnusedKind) { + UnusedKind[UnusedKind["Local"] = 0] = "Local"; + UnusedKind[UnusedKind["Parameter"] = 1] = "Parameter"; + })(UnusedKind || (UnusedKind = {})); + var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); + var DeclarationMeaning; + (function (DeclarationMeaning) { + DeclarationMeaning[DeclarationMeaning["GetAccessor"] = 1] = "GetAccessor"; + DeclarationMeaning[DeclarationMeaning["SetAccessor"] = 2] = "SetAccessor"; + DeclarationMeaning[DeclarationMeaning["PropertyAssignment"] = 4] = "PropertyAssignment"; + DeclarationMeaning[DeclarationMeaning["Method"] = 8] = "Method"; + DeclarationMeaning[DeclarationMeaning["GetOrSetAccessor"] = 3] = "GetOrSetAccessor"; + DeclarationMeaning[DeclarationMeaning["PropertyAssignmentOrMethod"] = 12] = "PropertyAssignmentOrMethod"; + })(DeclarationMeaning || (DeclarationMeaning = {})); + var DeclarationSpaces; + (function (DeclarationSpaces) { + DeclarationSpaces[DeclarationSpaces["None"] = 0] = "None"; + DeclarationSpaces[DeclarationSpaces["ExportValue"] = 1] = "ExportValue"; + DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; + DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; + })(DeclarationSpaces || (DeclarationSpaces = {})); function getNodeId(node) { if (!node.id) { node.id = nextNodeId; @@ -31553,11 +32240,9 @@ var ts; var cancellationToken; var requestedExternalEmitHelpers; var externalHelpersModule; - // tslint:disable variable-name var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); - // tslint:enable variable-name var typeCount = 0; var symbolCount = 0; var enumCount = 0; @@ -31831,7 +32516,7 @@ var ts; // Ensure file is type checked checkSourceFile(file); ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); - diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.get(file.fileName)); + diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); if (!file.isDeclarationFile && (!unusedIsError(0 /* Local */) || !unusedIsError(1 /* Parameter */))) { addUnusedDiagnostics(); } @@ -31843,7 +32528,7 @@ var ts; function addUnusedDiagnostics() { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { if (!ts.containsParseError(containingNode) && !unusedIsError(kind)) { - (diagnostics || (diagnostics = [])).push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); } @@ -31872,6 +32557,7 @@ var ts; var literalTypes = ts.createMap(); var indexedAccessTypes = ts.createMap(); var substitutionTypes = ts.createMap(); + var structuralTags = ts.createMap(); var evolvingArrayTypes = []; var undefinedProperties = ts.createMap(); var unknownSymbol = createSymbol(4 /* Property */, "unknown"); @@ -32055,102 +32741,7 @@ var ts; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); - // Suggestion diagnostics must have a file. Keyed by source file name. - var suggestionDiagnostics = ts.createMultiMap(); - var TypeFacts; - (function (TypeFacts) { - TypeFacts[TypeFacts["None"] = 0] = "None"; - TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; - TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; - TypeFacts[TypeFacts["TypeofEQBigInt"] = 4] = "TypeofEQBigInt"; - TypeFacts[TypeFacts["TypeofEQBoolean"] = 8] = "TypeofEQBoolean"; - TypeFacts[TypeFacts["TypeofEQSymbol"] = 16] = "TypeofEQSymbol"; - TypeFacts[TypeFacts["TypeofEQObject"] = 32] = "TypeofEQObject"; - TypeFacts[TypeFacts["TypeofEQFunction"] = 64] = "TypeofEQFunction"; - TypeFacts[TypeFacts["TypeofEQHostObject"] = 128] = "TypeofEQHostObject"; - TypeFacts[TypeFacts["TypeofNEString"] = 256] = "TypeofNEString"; - TypeFacts[TypeFacts["TypeofNENumber"] = 512] = "TypeofNENumber"; - TypeFacts[TypeFacts["TypeofNEBigInt"] = 1024] = "TypeofNEBigInt"; - TypeFacts[TypeFacts["TypeofNEBoolean"] = 2048] = "TypeofNEBoolean"; - TypeFacts[TypeFacts["TypeofNESymbol"] = 4096] = "TypeofNESymbol"; - TypeFacts[TypeFacts["TypeofNEObject"] = 8192] = "TypeofNEObject"; - TypeFacts[TypeFacts["TypeofNEFunction"] = 16384] = "TypeofNEFunction"; - TypeFacts[TypeFacts["TypeofNEHostObject"] = 32768] = "TypeofNEHostObject"; - TypeFacts[TypeFacts["EQUndefined"] = 65536] = "EQUndefined"; - TypeFacts[TypeFacts["EQNull"] = 131072] = "EQNull"; - TypeFacts[TypeFacts["EQUndefinedOrNull"] = 262144] = "EQUndefinedOrNull"; - TypeFacts[TypeFacts["NEUndefined"] = 524288] = "NEUndefined"; - TypeFacts[TypeFacts["NENull"] = 1048576] = "NENull"; - TypeFacts[TypeFacts["NEUndefinedOrNull"] = 2097152] = "NEUndefinedOrNull"; - TypeFacts[TypeFacts["Truthy"] = 4194304] = "Truthy"; - TypeFacts[TypeFacts["Falsy"] = 8388608] = "Falsy"; - TypeFacts[TypeFacts["All"] = 16777215] = "All"; - // The following members encode facts about particular kinds of types for use in the getTypeFacts function. - // The presence of a particular fact means that the given test is true for some (and possibly all) values - // of that kind of type. - TypeFacts[TypeFacts["BaseStringStrictFacts"] = 3735041] = "BaseStringStrictFacts"; - TypeFacts[TypeFacts["BaseStringFacts"] = 12582401] = "BaseStringFacts"; - TypeFacts[TypeFacts["StringStrictFacts"] = 16317953] = "StringStrictFacts"; - TypeFacts[TypeFacts["StringFacts"] = 16776705] = "StringFacts"; - TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 12123649] = "EmptyStringStrictFacts"; - TypeFacts[TypeFacts["EmptyStringFacts"] = 12582401] = "EmptyStringFacts"; - TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 7929345] = "NonEmptyStringStrictFacts"; - TypeFacts[TypeFacts["NonEmptyStringFacts"] = 16776705] = "NonEmptyStringFacts"; - TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 3734786] = "BaseNumberStrictFacts"; - TypeFacts[TypeFacts["BaseNumberFacts"] = 12582146] = "BaseNumberFacts"; - TypeFacts[TypeFacts["NumberStrictFacts"] = 16317698] = "NumberStrictFacts"; - TypeFacts[TypeFacts["NumberFacts"] = 16776450] = "NumberFacts"; - TypeFacts[TypeFacts["ZeroNumberStrictFacts"] = 12123394] = "ZeroNumberStrictFacts"; - TypeFacts[TypeFacts["ZeroNumberFacts"] = 12582146] = "ZeroNumberFacts"; - TypeFacts[TypeFacts["NonZeroNumberStrictFacts"] = 7929090] = "NonZeroNumberStrictFacts"; - TypeFacts[TypeFacts["NonZeroNumberFacts"] = 16776450] = "NonZeroNumberFacts"; - TypeFacts[TypeFacts["BaseBigIntStrictFacts"] = 3734276] = "BaseBigIntStrictFacts"; - TypeFacts[TypeFacts["BaseBigIntFacts"] = 12581636] = "BaseBigIntFacts"; - TypeFacts[TypeFacts["BigIntStrictFacts"] = 16317188] = "BigIntStrictFacts"; - TypeFacts[TypeFacts["BigIntFacts"] = 16775940] = "BigIntFacts"; - TypeFacts[TypeFacts["ZeroBigIntStrictFacts"] = 12122884] = "ZeroBigIntStrictFacts"; - TypeFacts[TypeFacts["ZeroBigIntFacts"] = 12581636] = "ZeroBigIntFacts"; - TypeFacts[TypeFacts["NonZeroBigIntStrictFacts"] = 7928580] = "NonZeroBigIntStrictFacts"; - TypeFacts[TypeFacts["NonZeroBigIntFacts"] = 16775940] = "NonZeroBigIntFacts"; - TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 3733256] = "BaseBooleanStrictFacts"; - TypeFacts[TypeFacts["BaseBooleanFacts"] = 12580616] = "BaseBooleanFacts"; - TypeFacts[TypeFacts["BooleanStrictFacts"] = 16316168] = "BooleanStrictFacts"; - TypeFacts[TypeFacts["BooleanFacts"] = 16774920] = "BooleanFacts"; - TypeFacts[TypeFacts["FalseStrictFacts"] = 12121864] = "FalseStrictFacts"; - TypeFacts[TypeFacts["FalseFacts"] = 12580616] = "FalseFacts"; - TypeFacts[TypeFacts["TrueStrictFacts"] = 7927560] = "TrueStrictFacts"; - TypeFacts[TypeFacts["TrueFacts"] = 16774920] = "TrueFacts"; - TypeFacts[TypeFacts["SymbolStrictFacts"] = 7925520] = "SymbolStrictFacts"; - TypeFacts[TypeFacts["SymbolFacts"] = 16772880] = "SymbolFacts"; - TypeFacts[TypeFacts["ObjectStrictFacts"] = 7888800] = "ObjectStrictFacts"; - TypeFacts[TypeFacts["ObjectFacts"] = 16736160] = "ObjectFacts"; - TypeFacts[TypeFacts["FunctionStrictFacts"] = 7880640] = "FunctionStrictFacts"; - TypeFacts[TypeFacts["FunctionFacts"] = 16728000] = "FunctionFacts"; - TypeFacts[TypeFacts["UndefinedFacts"] = 9830144] = "UndefinedFacts"; - TypeFacts[TypeFacts["NullFacts"] = 9363232] = "NullFacts"; - TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts"; - TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts"; - })(TypeFacts || (TypeFacts = {})); - var typeofEQFacts = ts.createMapFromTemplate({ - string: 1 /* TypeofEQString */, - number: 2 /* TypeofEQNumber */, - bigint: 4 /* TypeofEQBigInt */, - boolean: 8 /* TypeofEQBoolean */, - symbol: 16 /* TypeofEQSymbol */, - undefined: 65536 /* EQUndefined */, - object: 32 /* TypeofEQObject */, - function: 64 /* TypeofEQFunction */ - }); - var typeofNEFacts = ts.createMapFromTemplate({ - string: 256 /* TypeofNEString */, - number: 512 /* TypeofNENumber */, - bigint: 1024 /* TypeofNEBigInt */, - boolean: 2048 /* TypeofNEBoolean */, - symbol: 4096 /* TypeofNESymbol */, - undefined: 524288 /* NEUndefined */, - object: 8192 /* TypeofNEObject */, - function: 16384 /* TypeofNEFunction */ - }); + var suggestionDiagnostics = ts.createDiagnosticCollection(); var typeofTypesByName = ts.createMapFromTemplate({ string: stringType, number: numberType, @@ -32168,71 +32759,8 @@ var ts; var comparableRelation = ts.createMap(); var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); - var TypeSystemPropertyName; - (function (TypeSystemPropertyName) { - TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; - TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; - TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; - TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; - TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; - })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); - var CheckMode; - (function (CheckMode) { - CheckMode[CheckMode["Normal"] = 0] = "Normal"; - CheckMode[CheckMode["Contextual"] = 1] = "Contextual"; - CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; - CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive"; - CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; - CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; - })(CheckMode || (CheckMode = {})); - var ContextFlags; - (function (ContextFlags) { - ContextFlags[ContextFlags["None"] = 0] = "None"; - ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; - })(ContextFlags || (ContextFlags = {})); - var AccessFlags; - (function (AccessFlags) { - AccessFlags[AccessFlags["None"] = 0] = "None"; - AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; - AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; - AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; - AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; - })(AccessFlags || (AccessFlags = {})); - var CallbackCheck; - (function (CallbackCheck) { - CallbackCheck[CallbackCheck["None"] = 0] = "None"; - CallbackCheck[CallbackCheck["Bivariant"] = 1] = "Bivariant"; - CallbackCheck[CallbackCheck["Strict"] = 2] = "Strict"; - })(CallbackCheck || (CallbackCheck = {})); - var MappedTypeModifiers; - (function (MappedTypeModifiers) { - MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly"; - MappedTypeModifiers[MappedTypeModifiers["ExcludeReadonly"] = 2] = "ExcludeReadonly"; - MappedTypeModifiers[MappedTypeModifiers["IncludeOptional"] = 4] = "IncludeOptional"; - MappedTypeModifiers[MappedTypeModifiers["ExcludeOptional"] = 8] = "ExcludeOptional"; - })(MappedTypeModifiers || (MappedTypeModifiers = {})); - var ExpandingFlags; - (function (ExpandingFlags) { - ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; - ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; - ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; - ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; - })(ExpandingFlags || (ExpandingFlags = {})); - var MembersOrExportsResolutionKind; - (function (MembersOrExportsResolutionKind) { - MembersOrExportsResolutionKind["resolvedExports"] = "resolvedExports"; - MembersOrExportsResolutionKind["resolvedMembers"] = "resolvedMembers"; - })(MembersOrExportsResolutionKind || (MembersOrExportsResolutionKind = {})); - var UnusedKind; - (function (UnusedKind) { - UnusedKind[UnusedKind["Local"] = 0] = "Local"; - UnusedKind[UnusedKind["Parameter"] = 1] = "Parameter"; - })(UnusedKind || (UnusedKind = {})); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); - var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; function getJsxNamespace(location) { @@ -32244,7 +32772,7 @@ var ts; } var jsxPragma = file.pragmas.get("jsx"); if (jsxPragma) { - var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; // TODO: GH#18217 + var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; file.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion); if (file.localJsxFactory) { return file.localJsxNamespace = getFirstIdentifier(file.localJsxFactory).escapedText; @@ -32297,11 +32825,11 @@ var ts; diagnostics.add(diagnostic); } else { - suggestionDiagnostics.add(diagnostic.file.fileName, __assign({}, diagnostic, { category: ts.DiagnosticCategory.Suggestion })); + suggestionDiagnostics.add(__assign(__assign({}, diagnostic), { category: ts.DiagnosticCategory.Suggestion })); } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { - addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); + addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { var diagnostic = error(location, message, arg0, arg1, arg2, arg3); @@ -32323,35 +32851,35 @@ var ts; function getExcludedSymbolFlags(flags) { var result = 0; if (flags & 2 /* BlockScopedVariable */) - result |= 67220415 /* BlockScopedVariableExcludes */; + result |= 111551 /* BlockScopedVariableExcludes */; if (flags & 1 /* FunctionScopedVariable */) - result |= 67220414 /* FunctionScopedVariableExcludes */; + result |= 111550 /* FunctionScopedVariableExcludes */; if (flags & 4 /* Property */) result |= 0 /* PropertyExcludes */; if (flags & 8 /* EnumMember */) - result |= 68008959 /* EnumMemberExcludes */; + result |= 900095 /* EnumMemberExcludes */; if (flags & 16 /* Function */) - result |= 67219887 /* FunctionExcludes */; + result |= 110991 /* FunctionExcludes */; if (flags & 32 /* Class */) - result |= 68008383 /* ClassExcludes */; + result |= 899503 /* ClassExcludes */; if (flags & 64 /* Interface */) - result |= 67897736 /* InterfaceExcludes */; + result |= 788872 /* InterfaceExcludes */; if (flags & 256 /* RegularEnum */) - result |= 68008191 /* RegularEnumExcludes */; + result |= 899327 /* RegularEnumExcludes */; if (flags & 128 /* ConstEnum */) - result |= 68008831 /* ConstEnumExcludes */; + result |= 899967 /* ConstEnumExcludes */; if (flags & 512 /* ValueModule */) result |= 110735 /* ValueModuleExcludes */; if (flags & 8192 /* Method */) - result |= 67212223 /* MethodExcludes */; + result |= 103359 /* MethodExcludes */; if (flags & 32768 /* GetAccessor */) - result |= 67154879 /* GetAccessorExcludes */; + result |= 46015 /* GetAccessorExcludes */; if (flags & 65536 /* SetAccessor */) - result |= 67187647 /* SetAccessorExcludes */; + result |= 78783 /* SetAccessorExcludes */; if (flags & 262144 /* TypeParameter */) - result |= 67635688 /* TypeParameterExcludes */; + result |= 526824 /* TypeParameterExcludes */; if (flags & 524288 /* TypeAlias */) - result |= 67897832 /* TypeAliasExcludes */; + result |= 788968 /* TypeAliasExcludes */; if (flags & 2097152 /* Alias */) result |= 2097152 /* AliasExcludes */; return result; @@ -32574,7 +33102,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 286 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -32604,8 +33132,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 67220415 /* Value */); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 67220415 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* Value */); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -32632,17 +33160,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 187 /* BindingElement */) { + if (declaration.kind === 188 /* 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, 187 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 188 /* 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, 238 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 239 /* VariableDeclaration */), usage); } - else if (declaration.kind === 238 /* VariableDeclaration */) { + else if (declaration.kind === 239 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -32665,12 +33193,12 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 258 /* ExportSpecifier */ || (usage.parent.kind === 255 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 259 /* ExportSpecifier */ || (usage.parent.kind === 256 /* 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 === 255 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 256 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -32678,9 +33206,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 220 /* VariableStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 221 /* VariableStatement */: + case 227 /* ForStatement */: + case 229 /* 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, container)) { @@ -32701,16 +33229,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 155 /* PropertyDeclaration */ && + current.parent.kind === 156 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 157 /* MethodDeclaration */) { + if (declaration.kind === 158 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 156 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -32731,14 +33259,14 @@ var ts; return "quit"; } switch (node.kind) { - case 198 /* ArrowFunction */: - case 155 /* PropertyDeclaration */: + case 199 /* ArrowFunction */: + case 156 /* PropertyDeclaration */: return true; - case 219 /* Block */: + case 220 /* Block */: switch (node.parent.kind) { - case 159 /* GetAccessor */: - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 158 /* MethodDeclaration */: + case 161 /* SetAccessor */: return true; default: return false; @@ -32784,12 +33312,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 & 67897832 /* Type */ && lastLocation.kind !== 297 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 299 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 152 /* Parameter */ || - lastLocation.kind === 151 /* TypeParameter */ + lastLocation.kind === 153 /* Parameter */ || + lastLocation.kind === 152 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -32806,13 +33334,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 === 152 /* Parameter */ || + lastLocation.kind === 153 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 176 /* ConditionalType */) { + else if (location.kind === 177 /* 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; @@ -32827,14 +33355,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 286 /* SourceFile */ || ts.isAmbientModule(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 */)) { @@ -32858,7 +33386,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 258 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 259 /* ExportSpecifier */)) { break; } } @@ -32872,12 +33400,12 @@ var ts; } } break; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 155 /* PropertyDeclaration */: + case 156 /* 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 @@ -32887,20 +33415,20 @@ var ts; if (!ts.hasModifier(location, 32 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 67220415 /* Value */)) { + if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) { // Remember the property node, it will be used later to report appropriate error propertyWithInvalidInitializer = location; } } } break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* 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! - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 67897832 /* Type */)) { + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -32915,7 +33443,7 @@ var ts; } break loop; } - if (location.kind === 210 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 211 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -32923,11 +33451,11 @@ var ts; } } break; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. if (lastLocation === location.expression && location.parent.token === 87 /* ExtendsKeyword */) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 67897832 /* Type */))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -32943,34 +33471,34 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 242 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 243 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67897832 /* Type */)) { + 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); return undefined; } } break; - case 198 /* ArrowFunction */: + case 199 /* 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 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -32983,7 +33511,7 @@ var ts; } } break; - case 153 /* Decorator */: + case 154 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -32992,7 +33520,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 === 152 /* Parameter */) { + if (location.parent && location.parent.kind === 153 /* Parameter */) { location = location.parent; } // @@ -33007,24 +33535,25 @@ 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 === 241 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 242 /* ClassDeclaration */)) { location = location.parent; } break; - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; - case 152 /* Parameter */: + case 153 /* Parameter */: if (lastLocation && lastLocation === location.initializer) { associatedDeclarationForContainingInitializer = location; } break; - case 187 /* BindingElement */: + case 188 /* BindingElement */: if (lastLocation && lastLocation === location.initializer) { var root = ts.getRootDeclaration(location); - if (root.kind === 152 /* Parameter */) { + if (root.kind === 153 /* Parameter */) { associatedDeclarationForContainingInitializer = location; } } @@ -33044,7 +33573,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 285 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 286 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -33110,21 +33639,21 @@ var ts; // we want to check for block-scoped if (errorLocation && (meaning & 2 /* BlockScopedVariable */ || - ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 67220415 /* Value */) === 67220415 /* Value */))) { + ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 67220415 /* Value */) === 67220415 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } // If we're in a parameter initializer, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 67220415 /* Value */) === 67220415 /* Value */) { + if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializer); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself @@ -33140,10 +33669,10 @@ var ts; return result; } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 198 /* ArrowFunction */ && location.kind !== 197 /* FunctionExpression */) { + if (location.kind !== 199 /* ArrowFunction */ && location.kind !== 198 /* 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 === 155 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 156 /* PropertyDeclaration */ && !ts.hasModifier(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; @@ -33156,12 +33685,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: // For `namespace N { N; }` + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 246 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -33173,7 +33702,7 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 151 /* TypeParameter */) { + if (decl.kind === 152 /* 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 @@ -33229,9 +33758,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -33241,9 +33770,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 67220415 /* Value */ : 0); + var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* Value */ : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -33262,8 +33791,8 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (67897832 /* Type */ & ~1920 /* Namespace */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~67897832 /* Type */ & 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1920 /* Namespace */)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here, ts.unescapeLeadingUnderscores(name)); return true; @@ -33272,12 +33801,12 @@ var ts; return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 /* Value */ & ~1024 /* NamespaceModule */)) { + if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) { if (name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never") { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 /* Type */ & ~67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { var message = isES2015OrLaterConstructorName(name) ? ts.Diagnostics._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 @@ -33301,15 +33830,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 /* Value */ & ~1024 /* NamespaceModule */ & ~67897832 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */ & ~788968 /* Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (67897832 /* Type */ & ~1024 /* NamespaceModule */ & ~67220415 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~67897832 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + else if (meaning & (788968 /* Type */ & ~1024 /* NamespaceModule */ & ~111551 /* Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~788968 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -33319,10 +33848,14 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { 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 === 244 /* EnumDeclaration */) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 245 /* EnumDeclaration */); }); if (declaration === undefined) - return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); + return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); @@ -33355,13 +33888,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return node; - case 251 /* ImportClause */: + case 252 /* ImportClause */: return node.parent; - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return node.parent.parent; - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -33371,7 +33904,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 261 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -33472,7 +34005,7 @@ var ts; if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (67897832 /* Type */ | 1920 /* Namespace */)) { + if (valueSymbol.flags & (788968 /* Type */ | 1920 /* Namespace */)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -33562,7 +34095,7 @@ var ts; if (ts.isClassExpression(expression)) { return checkExpression(expression).symbol; } - var aliasLike = resolveEntityName(expression, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); + var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } @@ -33572,20 +34105,20 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 258 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 255 /* ExportAssignment */: - case 205 /* BinaryExpression */: + case 259 /* ExportSpecifier */: + return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); + case 256 /* ExportAssignment */: + case 206 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -33596,7 +34129,7 @@ var ts; * OR Is a JSContainer which may merge an alias with a local declaration */ function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */; } + if (excludes === void 0) { excludes = 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */; } if (!symbol) return false; return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* Assignment */); @@ -33630,7 +34163,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 67220415 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); + ((target.flags & 111551 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -33646,17 +34179,15 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 255 /* ExportAssignment */) { - // export default - checkExpressionCached(node.expression); - } - else if (node.kind === 258 /* ExportSpecifier */) { - // export { } or export { as foo } - checkExpressionCached(node.propertyName || node.name); - } - else if (ts.isInternalModuleImportEqualsDeclaration(node)) { - // import foo = - checkExpressionCached(node.moduleReference); + // We defer checking of the reference of an `import =` until the import itself is referenced, + // This way a chain of imports can be elided if ultimately the final input is only used in a type + // position. + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + var target = resolveSymbol(symbol); + if (target === unknownSymbol || target.flags & 111551 /* Value */) { + // import foo = + checkExpressionCached(node.moduleReference); + } } } } @@ -33672,14 +34203,14 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 73 /* Identifier */ || entityName.parent.kind === 149 /* QualifiedName */) { + if (entityName.kind === 73 /* Identifier */ || entityName.parent.kind === 150 /* 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 === 249 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 250 /* ImportEqualsDeclaration */); + return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { @@ -33692,7 +34223,7 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 67220415 /* Value */ : 0); + var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; if (name.kind === 73 /* Identifier */) { var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name)); @@ -33702,9 +34233,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 149 /* QualifiedName */ || name.kind === 190 /* PropertyAccessExpression */) { - var left = name.kind === 149 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 149 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 150 /* QualifiedName */ || name.kind === 191 /* PropertyAccessExpression */) { + var left = name.kind === 150 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 150 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -33795,6 +34326,20 @@ var ts; undefined; return initializer || decl; } + /** + * Get the real symbol of a declaration with an expando initializer. + * + * Normally, declarations have an associated symbol, but when a declaration has an expando + * initializer, the expando's symbol is the one that has all the members merged into it. + */ + function getExpandoSymbol(symbol) { + var decl = symbol.valueDeclaration; + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */) { + return undefined; + } + var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); + return init && getSymbolOfNode(init) || undefined; + } function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0); } @@ -33806,9 +34351,6 @@ var ts; } function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReference === undefined) { - return; - } if (ts.startsWith(moduleReference, "@types/")) { var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1; var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/"); @@ -33937,7 +34479,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 285 /* SourceFile */)) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 286 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -34193,13 +34735,13 @@ var ts; return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? symbol.exportSymbol : symbol); } function symbolIsValue(symbol) { - return !!(symbol.flags & 67220415 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 67220415 /* Value */); + return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 158 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 159 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -34285,12 +34827,12 @@ var ts; } } switch (location.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -34301,7 +34843,7 @@ var ts; } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 67220415 /* Value */ ? 67220415 /* Value */ : 1920 /* Namespace */; + return rightMeaning === 111551 /* Value */ ? 111551 /* Value */ : 1920 /* Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = ts.createMap(); } @@ -34354,7 +34896,7 @@ var ts; && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) // 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, 258 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 259 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -34390,7 +34932,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, 258 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 259 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -34405,10 +34947,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: continue; default: return false; @@ -34419,11 +34961,11 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67897832 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 788968 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); return access.accessibility === 0 /* Accessible */; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67220415 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 111551 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false); return access.accessibility === 0 /* Accessible */; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible) { @@ -34466,7 +35008,7 @@ var ts; // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. var firstDecl = ts.first(symbol.declarations); - if (!ts.length(containers) && meaning & 67220415 /* Value */ && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { + if (!ts.length(containers) && meaning & 111551 /* Value */ && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { if (firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent) && firstDecl === firstDecl.parent.initializer) { containers = [getSymbolOfNode(firstDecl.parent)]; } @@ -34525,10 +35067,10 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 286 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 286 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -34575,21 +35117,21 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 168 /* TypeQuery */ || + if (entityName.parent.kind === 169 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 150 /* ComputedPropertyName */) { + entityName.parent.kind === 151 /* ComputedPropertyName */) { // Typeof value - meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; + meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 149 /* QualifiedName */ || entityName.kind === 190 /* PropertyAccessExpression */ || - entityName.parent.kind === 249 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 150 /* QualifiedName */ || entityName.kind === 191 /* PropertyAccessExpression */ || + entityName.parent.kind === 250 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; } else { // Type Reference or TypeAlias entity = Identifier - meaning = 67897832 /* Type */; + meaning = 788968 /* Type */; } var firstIdentifier = getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); @@ -34631,15 +35173,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 167 /* ConstructorType */ : 166 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 168 /* ConstructorType */ : 167 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 162 /* ConstructSignature */ : 161 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 163 /* ConstructSignature */ : 162 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } @@ -34662,14 +35204,17 @@ var ts; return result; } function getTypeNamesForErrorDisplay(left, right) { - var leftStr = typeToString(left); - var rightStr = typeToString(right); + var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left); + var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right); if (leftStr === rightStr) { leftStr = typeToString(left, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); rightStr = typeToString(right, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); } return [leftStr, rightStr]; } + function symbolValueDeclarationIsContextSensitive(symbol) { + return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0 /* None */; } return flags & 9469291 /* NodeBuilderFlagsMask */; @@ -34761,14 +35306,14 @@ var ts; } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 67897832 /* Type */); + var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */); var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), /*typeArguments*/ undefined)); return enumLiteralName; } if (type.flags & 1056 /* EnumLike */) { - return symbolToTypeNode(type.symbol, context, 67897832 /* Type */); + return symbolToTypeNode(type.symbol, context, 788968 /* Type */); } if (type.flags & 128 /* StringLiteral */) { context.approximateLength += (type.value.length + 2); @@ -34791,7 +35336,7 @@ var ts; if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 67220415 /* Value */); + return symbolToTypeNode(type.symbol, context, 111551 /* Value */); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); @@ -34854,14 +35399,14 @@ var ts; } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. return type.symbol - ? symbolToTypeNode(type.symbol, context, 67897832 /* Type */) + ? symbolToTypeNode(type.symbol, context, 788968 /* Type */) : ts.createTypeReferenceNode(ts.createIdentifier("?"), /*typeArguments*/ undefined); } if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 67897832 /* Type */, typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); } if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; @@ -34870,7 +35415,7 @@ var ts; } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 174 /* UnionType */ : 175 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 175 /* UnionType */ : 176 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -34911,6 +35456,36 @@ var ts; if (type.flags & 33554432 /* Substitution */) { return typeToTypeNodeHelper(type.typeVariable, context); } + if (type.flags & 134217728 /* StructuralTag */) { + var innerType = type.type; + if (innerType.flags & 2097152 /* Intersection */) { + // If some inner type of the intersection has an alias when hoisted out, (attempt to) hoist out all of the aliasable things + if (ts.some(innerType.types, function (t) { return !!getStructuralTagForType(t).aliasSymbol; })) { + var aliasingTypes = []; + var nonAliasingTypes = []; + for (var _i = 0, _a = innerType.types; _i < _a.length; _i++) { + var t = _a[_i]; + var taggedVersion = getStructuralTagForType(t); + if (taggedVersion.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(taggedVersion.aliasSymbol, context.enclosingDeclaration))) { + aliasingTypes.push(taggedVersion); + } + else { + nonAliasingTypes.push(t); + } + } + if (ts.length(aliasingTypes)) { + if (ts.length(nonAliasingTypes)) { + aliasingTypes.push(getStructuralTagForType(getIntersectionType(nonAliasingTypes))); + } + // Do note: this can make an intersection become nested within another intersection - this _is_ handled correctly + // during emit, so is fine (and honestly is more clear, since it groups all the tags together) + return ts.createUnionOrIntersectionTypeNode(176 /* IntersectionType */, ts.map(aliasingTypes, function (t) { return typeToTypeNodeHelper(t, context); })); + } + } + } + context.approximateLength += 4; + return ts.createTypeOperatorNode(148 /* TagKeyword */, typeToTypeNodeHelper(innerType, context)); + } return ts.Debug.fail("Should be unreachable."); function createMappedTypeNodeFromType(type) { ts.Debug.assert(!!(type.flags & 524288 /* Object */)); @@ -34940,21 +35515,21 @@ var ts; id = (isConstructorObject ? "+" : "") + getSymbolId(symbol); if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. - var isInstanceType = type === getInferredClassType(symbol) ? 67897832 /* Type */ : 67220415 /* Value */; + var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 /* Type */ : 111551 /* Value */; 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 === 210 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 211 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { - return symbolToTypeNode(symbol, context, 67220415 /* Value */); + return symbolToTypeNode(symbol, context, 111551 /* Value */); } else if (context.visitedTypes && context.visitedTypes.has(typeId)) { // If type is an anonymous type literal in a type alias declaration, use type alias name var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags - return symbolToTypeNode(typeAlias, context, 67897832 /* Type */); + return symbolToTypeNode(typeAlias, context, 788968 /* Type */); } else { return createElidedInformationPlaceholder(context); @@ -34991,12 +35566,12 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 285 /* SourceFile */ || declaration.parent.kind === 246 /* ModuleBlock */; + return declaration.parent.kind === 286 /* SourceFile */ || declaration.parent.kind === 247 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedTypes && context.visitedTypes.has(typeId))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // TODO: GH#18217 // And the build is going to succeed without visibility error or there is no structural fallback allowed + (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } @@ -35012,12 +35587,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 166 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 167 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 167 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 168 /* ConstructorType */, context); return signatureNode; } } @@ -35087,7 +35662,7 @@ var ts; var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_2 = context.flags; context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var ref = symbolToTypeNode(parent, context, 67897832 /* Type */, typeArgumentSlice); + var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice); context.flags = flags_2; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -35100,7 +35675,7 @@ var ts; } var flags = context.flags; context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var finalRef = symbolToTypeNode(type.symbol, context, 67897832 /* Type */, typeArgumentNodes); + var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* Type */, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -35152,11 +35727,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 161 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 162 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 162 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 163 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; @@ -35217,7 +35792,7 @@ var ts; trackComputedName(decl.name, saveEnclosingDeclaration, context); } } - var propertyName = symbolToName(propertySymbol, context, 67220415 /* Value */, /*expectsIdentifier*/ true); + var propertyName = symbolToName(propertySymbol, context, 111551 /* Value */, /*expectsIdentifier*/ true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(56 /* QuestionToken */) : undefined; @@ -35225,7 +35800,7 @@ var ts; var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 156 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 157 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; if (propertySymbol.valueDeclaration) { @@ -35321,7 +35896,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 158 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 159 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -35365,9 +35940,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 152 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 153 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 306 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 308 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -35377,13 +35952,12 @@ var ts; var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(25 /* DotDotDotToken */) : undefined; - var name = parameterDeclaration - ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 73 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 149 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : - cloneBindingName(parameterDeclaration.name) : - ts.symbolName(parameterSymbol) - : ts.symbolName(parameterSymbol); + var name = parameterDeclaration ? parameterDeclaration.name ? + parameterDeclaration.name.kind === 73 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 150 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + cloneBindingName(parameterDeclaration.name) : + ts.symbolName(parameterSymbol) : + ts.symbolName(parameterSymbol); var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */; var questionToken = isOptional ? ts.createToken(56 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( @@ -35399,7 +35973,7 @@ var ts; } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 187 /* BindingElement */) { + if (clone.kind === 188 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); @@ -35411,9 +35985,9 @@ var ts; return; // get symbol of the first identifier of the entityName var firstIdentifier = getFirstIdentifier(node.expression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 67220415 /* Value */); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { @@ -35530,7 +36104,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 285 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 286 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -35566,7 +36140,7 @@ var ts; // using the `baseUrl` compiler option (which we would otherwise never use in declaration emit) and a non-relative // specifier preference var moduleResolverHost = context.tracker.moduleResolverHost; - var specifierCompilerOptions = isBundle_1 ? __assign({}, compilerOptions, { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; + var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, host.getSourceFiles(), { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative" }, host.redirectTargetsMap)); links.specifierCache = links.specifierCache || ts.createMap(); links.specifierCache.set(contextFile.path, specifier); @@ -35575,7 +36149,7 @@ var ts; } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - var isTypeOf = meaning === 67220415 /* Value */; + var isTypeOf = meaning === 111551 /* Value */; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; @@ -35654,7 +36228,7 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context) { - return !!resolveName(context.enclosingDeclaration, escapedName, 67897832 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + return !!resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); } function typeParameterToName(type, context) { if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { @@ -35663,7 +36237,7 @@ var ts; return cached; } } - var result = symbolToName(type.symbol, context, 67897832 /* Type */, /*expectsIdentifier*/ true); + var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = 0; @@ -35709,9 +36283,6 @@ var ts; function createExpressionFromSymbolChain(chain, index) { var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; - if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { - return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); - } if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; } @@ -35720,6 +36291,9 @@ var ts; context.flags ^= 16777216 /* InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); + if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); + } var canUsePropertyAccess = ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); @@ -35797,8 +36371,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 178 /* ParenthesizedType */; }); - if (node.kind === 243 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 179 /* ParenthesizedType */; }); + if (node.kind === 244 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -35806,11 +36380,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 246 /* ModuleBlock */ && + node.parent.kind === 247 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 286 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -35848,9 +36422,9 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - var name_2 = ts.getNameOfDeclaration(declaration); - if (name_2) { + var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; }); // Try using a declaration with a name, first + var name_2 = declaration && ts.getNameOfDeclaration(declaration); + if (declaration && name_2) { if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } @@ -35863,17 +36437,20 @@ var ts; } return ts.declarationNameToString(name_2); } - if (declaration.parent && declaration.parent.kind === 238 /* VariableDeclaration */) { + if (!declaration) { + declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway + } + if (declaration.parent && declaration.parent.kind === 239 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 211 /* ClassExpression */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 210 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 211 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -35890,27 +36467,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 307 /* 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 187 /* BindingElement */: + case 188 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 238 /* VariableDeclaration */: + case 239 /* 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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 240 /* FunctionDeclaration */: - case 244 /* EnumDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 246 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 241 /* FunctionDeclaration */: + case 245 /* EnumDeclaration */: + case 250 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -35918,53 +36496,54 @@ 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 !== 249 /* ImportEqualsDeclaration */ && parent.kind !== 285 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 250 /* ImportEqualsDeclaration */ && parent.kind !== 286 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.hasModifier(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 158 /* Constructor */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 152 /* Parameter */: - case 246 /* ModuleBlock */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 165 /* TypeReference */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 178 /* ParenthesizedType */: + case 159 /* Constructor */: + case 163 /* ConstructSignature */: + case 162 /* CallSignature */: + case 164 /* IndexSignature */: + case 153 /* Parameter */: + case 247 /* ModuleBlock */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 170 /* TypeLiteral */: + case 166 /* TypeReference */: + case 171 /* ArrayType */: + case 172 /* TupleType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: + case 179 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: + case 252 /* ImportClause */: + case 253 /* NamespaceImport */: + case 255 /* ImportSpecifier */: return false; // Type parameters are always visible - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: // Source file and namespace export are always visible - case 285 /* SourceFile */: - case 248 /* NamespaceExportDeclaration */: + // falls through + case 286 /* SourceFile */: + case 249 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return false; default: return false; @@ -35973,11 +36552,11 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 255 /* ExportAssignment */) { - exportSymbol = resolveName(node, node.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); + if (node.parent && node.parent.kind === 256 /* ExportAssignment */) { + exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 258 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + else if (node.parent.kind === 259 /* ExportSpecifier */) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; if (exportSymbol) { @@ -35998,7 +36577,7 @@ var ts; // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); if (importSymbol) { buildVisibleNodeList(importSymbol.declarations); } @@ -36062,8 +36641,10 @@ var ts; } return ts.Debug.assertNever(propertyName); } - // Pop an entry from the type resolution stack and return its associated result value. The result value will - // be true if no circularities were detected, or false if a circularity was found. + /** + * Pop an entry from the type resolution stack and return its associated result value. The result value will + * be true if no circularities were detected, or false if a circularity was found. + */ function popTypeResolution() { resolutionTargets.pop(); resolutionPropertyNames.pop(); @@ -36072,12 +36653,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 238 /* VariableDeclaration */: - case 239 /* VariableDeclarationList */: - case 254 /* ImportSpecifier */: - case 253 /* NamedImports */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + case 239 /* VariableDeclaration */: + case 240 /* VariableDeclarationList */: + case 255 /* ImportSpecifier */: + case 254 /* NamedImports */: + case 253 /* NamespaceImport */: + case 252 /* ImportClause */: return false; default: return true; @@ -36110,7 +36691,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 150 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 151 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); @@ -36162,7 +36743,7 @@ var ts; if (parentAccess && parentAccess.flowNode) { var propName = getDestructuringPropertyName(node); if (propName) { - var result = ts.createNode(191 /* ElementAccessExpression */, node.pos, node.end); + var result = ts.createNode(192 /* ElementAccessExpression */, node.pos, node.end); result.parent = node; result.expression = parentAccess; var literal = ts.createNode(10 /* StringLiteral */, node.pos, node.end); @@ -36177,23 +36758,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 187 /* BindingElement */: - case 276 /* PropertyAssignment */: + case 188 /* BindingElement */: + case 277 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ancestor.initializer; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 187 /* BindingElement */ && parent.kind === 185 /* ObjectBindingPattern */) { + if (node.kind === 188 /* BindingElement */ && parent.kind === 186 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 276 /* PropertyAssignment */ || node.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.kind === 277 /* PropertyAssignment */ || node.kind === 278 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -36215,7 +36796,7 @@ var ts; parentType = getNonNullableType(parentType); } var type; - if (pattern.kind === 185 /* ObjectBindingPattern */) { + if (pattern.kind === 186 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -36287,26 +36868,26 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 188 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 189 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function isParameterOfContextuallyTypedFunction(node) { - return node.kind === 152 /* Parameter */ && - (node.parent.kind === 197 /* FunctionExpression */ || node.parent.kind === 198 /* ArrowFunction */) && + return node.kind === 153 /* Parameter */ && + (node.parent.kind === 198 /* FunctionExpression */ || node.parent.kind === 199 /* ArrowFunction */) && !!getContextualType(node.parent); } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 227 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 228 /* 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 === 228 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 229 /* 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, @@ -36325,7 +36906,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 238 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 239 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no @@ -36339,11 +36920,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 152 /* Parameter */) { + if (declaration.kind === 153 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 160 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 159 /* GetAccessor */); + if (func.kind === 161 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 160 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -36553,9 +37134,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 === 158 /* Constructor */ || - thisContainer.kind === 240 /* FunctionDeclaration */ || - (thisContainer.kind === 197 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 159 /* Constructor */ || + thisContainer.kind === 241 /* FunctionDeclaration */ || + (thisContainer.kind === 198 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -36630,7 +37211,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 187 /* BindingElement */ && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 188 /* BindingElement */ && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -36653,7 +37234,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 185 /* ObjectBindingPattern */ + return pattern.kind === 186 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -36692,7 +37273,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 152 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 153 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -36754,7 +37335,7 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 255 /* ExportAssignment */) { + if (declaration.kind === 256 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } else if (ts.isInJSFile(declaration) && @@ -36818,7 +37399,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 160 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -36845,8 +37426,8 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 160 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 160 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 161 /* SetAccessor */); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -36876,7 +37457,9 @@ var ts; // Otherwise, fall back to 'any'. else { if (setter) { - errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); + 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 existed getter as we are current checking either setter or getter in this function"); @@ -36889,7 +37472,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 160 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -36905,19 +37488,10 @@ var ts; if (!links.type) { var jsDeclaration = ts.getDeclarationOfExpando(symbol.valueDeclaration); if (jsDeclaration) { - var jsSymbol = getSymbolOfNode(jsDeclaration); - if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { - symbol = cloneSymbol(symbol); + var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration)); + if (merged) { // note:we overwrite links because we just cloned the symbol - links = symbol; - if (ts.hasEntries(jsSymbol.exports)) { - symbol.exports = symbol.exports || ts.createSymbolTable(); - mergeSymbolTable(symbol.exports, jsSymbol.exports); - } - if (ts.hasEntries(jsSymbol.members)) { - symbol.members = symbol.members || ts.createSymbolTable(); - mergeSymbolTable(symbol.members, jsSymbol.members); - } + symbol = links = merged; } } originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol); @@ -36929,8 +37503,8 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 205 /* BinaryExpression */ || - declaration.kind === 190 /* PropertyAccessExpression */ && declaration.parent.kind === 205 /* BinaryExpression */) { + else if (declaration.kind === 206 /* BinaryExpression */ || + declaration.kind === 191 /* PropertyAccessExpression */ && declaration.parent.kind === 206 /* BinaryExpression */) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -36969,7 +37543,7 @@ var ts; // 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 & 67220415 /* Value */ + links.type = targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) : errorType; } @@ -36997,7 +37571,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 152 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 153 /* 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 @@ -37078,39 +37652,50 @@ var ts; function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; // TODO: GH#18217 Use SourceFile kind check instead + if (node && ts.isBinaryExpression(node)) { + // prototype assignments get the outer type parameters of their constructor function + var assignmentKind = ts.getAssignmentDeclarationKind(node); + if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + var symbol = getSymbolOfNode(node.left); + if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { + node = symbol.parent.valueDeclaration; + } + } + } if (!node) { return undefined; } switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 182 /* MappedType */: - case 176 /* ConditionalType */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 157 /* MethodSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 296 /* JSDocFunctionType */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 244 /* TypeAliasDeclaration */: + case 312 /* JSDocTemplateTag */: + case 313 /* JSDocTypedefTag */: + case 307 /* JSDocEnumTag */: + case 306 /* JSDocCallbackTag */: + case 183 /* MappedType */: + case 177 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 182 /* MappedType */) { + if (node.kind === 183 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 176 /* ConditionalType */) { + else if (node.kind === 177 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */ || node.kind === 242 /* InterfaceDeclaration */) && + (node.kind === 242 /* ClassDeclaration */ || node.kind === 211 /* ClassExpression */ || node.kind === 243 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -37118,7 +37703,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 243 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -37127,9 +37712,10 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 241 /* ClassDeclaration */ || - node.kind === 210 /* ClassExpression */ || + if (node.kind === 243 /* InterfaceDeclaration */ || + node.kind === 242 /* ClassDeclaration */ || + node.kind === 211 /* ClassExpression */ || + isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -37160,7 +37746,7 @@ var ts; var constraint = getBaseConstraintOfType(type); return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } - return isJSConstructorType(type); + return false; } function getBaseTypeNodeOfClass(type) { return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); @@ -37255,9 +37841,7 @@ var ts; var baseTypeNode = getBaseTypeNodeOfClass(type); var typeArgs = typeArgumentsFromTypeReferenceNode(baseTypeNode); var baseType; - var originalBaseType = isJSConstructorType(baseConstructorType) ? baseConstructorType : - baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : - undefined; + var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the @@ -37268,9 +37852,6 @@ var ts; else if (baseConstructorType.flags & 1 /* Any */) { baseType = baseConstructorType; } - else if (isJSConstructorType(baseConstructorType)) { - baseType = !baseTypeNode.typeArguments && getJSClassType(baseConstructorType.symbol) || anyType; - } else { // The class derives from a "class-like" constructor function, check that we have at least one construct signature // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere @@ -37323,7 +37904,7 @@ var ts; 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 === 242 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 243 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -37359,7 +37940,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242 /* InterfaceDeclaration */) { + if (declaration.kind === 243 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -37368,7 +37949,7 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 67897832 /* Type */, /*ignoreErrors*/ true); + var baseSymbol = resolveEntityName(node.expression, 788968 /* Type */, /*ignoreErrors*/ true); if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } @@ -37381,9 +37962,15 @@ var ts; } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); + var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; - var type = links.declaredType = createObjectType(kind, symbol); + var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + if (merged) { + // note:we overwrite links because we just cloned the symbol + symbol = links = merged; + } + var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type @@ -37415,9 +38002,10 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return errorType; } - var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 243 /* TypeAliasDeclaration */; - }); + var declaration = ts.find(symbol.declarations, ts.isTypeAlias); + if (!declaration) { + return ts.Debug.fail("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; @@ -37433,7 +38021,7 @@ var ts; } else { type = errorType; - error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + error(ts.isJSDocEnumTag(declaration) ? declaration : declaration.name || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } links.declaredType = type; } @@ -37443,7 +38031,7 @@ var ts; if (expr.kind === 10 /* StringLiteral */) { return true; } - else if (expr.kind === 205 /* BinaryExpression */) { + else if (expr.kind === 206 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -37457,12 +38045,12 @@ var ts; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return true; - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return expr.operator === 39 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; case 73 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -37476,7 +38064,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 245 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && member.initializer.kind === 10 /* StringLiteral */) { @@ -37503,7 +38091,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 245 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -37587,11 +38175,11 @@ var ts; case 142 /* UndefinedKeyword */: case 97 /* NullKeyword */: case 133 /* NeverKeyword */: - case 183 /* LiteralType */: + case 184 /* LiteralType */: return true; - case 170 /* ArrayType */: + case 171 /* ArrayType */: return isThislessType(node.elementType); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -37617,7 +38205,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 158 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 159 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -37633,14 +38221,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -37750,7 +38338,7 @@ var ts; else { symbol.declarations.push(member); } - if (symbolFlags & 67220415 /* Value */) { + if (symbolFlags & 111551 /* Value */) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -38012,7 +38600,7 @@ var ts; var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; // TODO: GH#18217 + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -38056,8 +38644,9 @@ var ts; } var result; for (var i = 0; i < signatureLists.length; i++) { - // Allow matching non-generic signatures to have excess parameters and different return types - var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true); + // Allow matching non-generic signatures to have excess parameters and different return types. + // Prefer matching this types if possible. + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true); if (!match) { return undefined; } @@ -38081,7 +38670,7 @@ var ts; for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { var signature = _a[_i]; // Only process signatures with parameter lists that aren't already in the result list - if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true)) { + if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true)) { var unionSignatures = findMatchingSignatures(signatureLists, signature, i); if (unionSignatures) { var s = signature; @@ -38090,7 +38679,7 @@ var ts; var thisParameter = signature.thisParameter; var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; }); if (firstThisParameterOfUnionSignatures) { - var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType; }), 2 /* Subtype */); + var thisType = getIntersectionType(ts.mapDefined(unionSignatures, function (sig) { return sig.thisParameter && getTypeOfSymbol(sig.thisParameter); })); thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType); } s = createUnionSignature(signature, unionSignatures); @@ -38134,8 +38723,8 @@ var ts; } // 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 - // permissive when calling, for now, we'll union the `this` types just like the overlapping-union-signature check does - var thisType = getUnionType([getTypeOfSymbol(left), getTypeOfSymbol(right)], 2 /* Subtype */); + // permissive when calling, for now, we'll intersect the `this` types just like we do for param types in union signatures. + var thisType = getIntersectionType([getTypeOfSymbol(left), getTypeOfSymbol(right)]); return createSymbolWithType(left, thisType); } function combineUnionParameters(left, right) { @@ -38289,7 +38878,7 @@ var ts; * Converts an AnonymousType to a ResolvedType. */ function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; + var symbol = getMergedSymbol(type.symbol); if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); @@ -38345,14 +38934,18 @@ var ts; // will never be observed because a qualified name can't reference signatures. if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); - type.constructSignatures = ts.filter(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration); }); } // And likewise for construct signatures for classes if (symbol.flags & 32 /* Class */) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)); + var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* Function */) { + constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes) : + undefined; })); + } if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); + constructSignatures = getDefaultConstructSignatures(classType_1); } type.constructSignatures = constructSignatures; } @@ -38495,7 +39088,7 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 180 /* TypeOperator */ && + return constraintDeclaration.kind === 181 /* TypeOperator */ && constraintDeclaration.operator === 130 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { @@ -38509,7 +39102,7 @@ var ts; else { // Otherwise, get the declared constraint type, and if the constraint type is a type parameter, // get the constraint of that type parameter. If the resulting type is an indexed type 'keyof T', - // the modifiers type is T. Otherwise, the modifiers type is {}. + // the modifiers type is T. Otherwise, the modifiers type is unknown. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; @@ -38563,9 +39156,16 @@ var ts; else if (type.flags & 2097152 /* Intersection */) { resolveIntersectionTypeMembers(type); } + else if (type.flags & 134217728 /* StructuralTag */) { + resolveStructuralTagTypeMembers(type); + } } return type; } + function resolveStructuralTagTypeMembers(type) { + // Explicitly do nothing - structured tags, despite "containing structure" (in their argument), do not have any visible structure. + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { if (type.flags & 524288 /* Object */) { @@ -38880,6 +39480,9 @@ var ts; if (t.flags & 33554432 /* Substitution */) { return getBaseConstraint(t.substitute); } + if (t.flags & 134217728 /* StructuralTag */) { + return unknownType; + } return t; } } @@ -39126,7 +39729,7 @@ var ts; return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 137887744 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; } @@ -39140,7 +39743,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 137887744 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* String */ ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -39199,10 +39802,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 === 294 /* JSDocOptionalType */ + node.type && node.type.kind === 295 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 295 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -39236,7 +39839,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 295 /* JSDocOptionalType */; } function createIdentifierTypePredicate(parameterName, parameterIndex, type) { return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -39308,7 +39911,7 @@ var ts; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; // Include parameter symbol instead of property symbol in the signature if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 67220415 /* Value */, undefined, undefined, /*isUse*/ false); + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } if (i === 0 && paramSymbol.escapedName === "this" /* This */) { @@ -39318,7 +39921,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 183 /* LiteralType */) { + if (type && type.kind === 184 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -39332,16 +39935,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 === 159 /* GetAccessor */ || declaration.kind === 160 /* SetAccessor */) && + if ((declaration.kind === 160 /* GetAccessor */ || declaration.kind === 161 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = declaration.kind === 160 /* GetAccessor */ ? 161 /* SetAccessor */ : 160 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 158 /* Constructor */ ? + var classType = declaration.kind === 159 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -39401,11 +40004,11 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return node.name.kind === 150 /* ComputedPropertyName */ + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + return node.name.kind === 151 /* ComputedPropertyName */ && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -39495,7 +40098,6 @@ var ts; var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) : getReturnTypeFromAnnotation(signature.declaration) || - isJSConstructor(signature.declaration) && getJSClassType(getSymbolOfNode(signature.declaration)) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); if (!popTypeResolution()) { if (signature.declaration) { @@ -39521,7 +40123,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 158 /* Constructor */) { + if (declaration.kind === 159 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -39531,12 +40133,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 159 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 160 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 160 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 161 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -39626,7 +40228,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 === 158 /* Constructor */ || kind === 162 /* ConstructSignature */ || kind === 167 /* ConstructorType */; + var isConstructor = kind === 159 /* Constructor */ || kind === 163 /* ConstructSignature */ || kind === 168 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -39667,7 +40269,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 151 /* TypeParameter */); + var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 152 /* TypeParameter */); return decl && ts.getEffectiveConstraintOfTypeParameter(decl); } function getInferredTypeParameterConstraint(typeParameter) { @@ -39675,13 +40277,13 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 177 /* InferType */) { + if (declaration.parent.kind === 178 /* 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 grandParent = declaration.parent.parent; - if (grandParent.kind === 165 /* TypeReference */) { + if (grandParent.kind === 166 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -39706,7 +40308,7 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter // declaration, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 152 /* Parameter */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 153 /* Parameter */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -39730,7 +40332,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 151 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 152 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -39807,13 +40409,13 @@ var ts; var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent); - var diag = minTypeArgumentCount === typeParameters.length - ? missingAugmentsTag - ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : missingAugmentsTag - ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; + var diag = minTypeArgumentCount === typeParameters.length ? + missingAugmentsTag ? + ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + missingAugmentsTag ? + ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { @@ -39852,9 +40454,9 @@ var ts; var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { - error(node, minTypeArgumentCount === typeParameters.length - ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); + error(node, minTypeArgumentCount === typeParameters.length ? + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } return getTypeAliasInstantiation(symbol, typeArguments); @@ -39863,9 +40465,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -39876,34 +40478,23 @@ var ts; } return undefined; } - function resolveTypeReferenceName(typeReferenceName, meaning) { + function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) { if (!typeReferenceName) { return unknownSymbol; } - return resolveEntityName(typeReferenceName, meaning) || unknownSymbol; + return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. if (symbol === unknownSymbol) { return errorType; } - var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); - if (type) { - return type; + symbol = getExpandoSymbol(symbol) || symbol; + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); } - // JS enums are 'string' or 'number', not an enum type. - var enumTag = ts.isInJSFile(node) && symbol.valueDeclaration && ts.getJSDocEnumTag(symbol.valueDeclaration); - if (enumTag) { - var links = getNodeLinks(enumTag); - if (!pushTypeResolution(enumTag, 5 /* EnumTagType */)) { - return errorType; - } - var type_4 = enumTag.typeExpression ? getTypeFromTypeNode(enumTag.typeExpression) : errorType; - if (!popTypeResolution()) { - type_4 = errorType; - error(node, ts.Diagnostics.Enum_type_0_circularly_references_itself, symbolToString(symbol)); - } - return (links.resolvedEnumType = type_4); + if (symbol.flags & 524288 /* TypeAlias */) { + return getTypeFromTypeAliasReference(node, symbol, typeArguments); } // Get type from reference to named type that cannot be generic (enum or type parameter) var res = tryGetDeclaredTypeOfSymbol(symbol); @@ -39912,55 +40503,31 @@ var ts; res.flags & 262144 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } - if (!(symbol.flags & 67220415 /* Value */ && isJSDocTypeReference(node))) { - return errorType; - } - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; + if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + var jsdocType = getTypeFromJSAlias(node, symbol); + if (jsdocType) { + return jsdocType; + } + else { + // Resolve the type reference as a Type for the purpose of reporting errors. + resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */); + return getTypeOfSymbol(symbol); + } } - // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(getTypeReferenceName(node), 67897832 /* Type */); - return getTypeOfSymbol(symbol); + return errorType; } /** - * A jsdoc TypeReference may have resolved to a value (as opposed to a type). If - * the symbol is a constructor function, return the inferred class type; otherwise, - * the type of this reference is just the type of the value we resolved to. + * A JSdoc TypeReference may be to a value imported from commonjs. + * These should really be aliases, but this special-case code fakes alias resolution + * by producing a type from a value. */ - function getJSDocTypeReference(node, symbol, typeArguments) { - // In the case of an assignment of a function expression (binary expressions, variable declarations, etc.), we will get the - // correct instance type for the symbol on the LHS by finding the type for RHS. For example if we want to get the type of the symbol `foo`: - // var foo = function() {} - // We will find the static type of the assigned anonymous function. - var staticType = getTypeOfSymbol(symbol); - var instanceType = staticType.symbol && - staticType.symbol !== symbol && // Make sure this is an assignment like expression by checking that symbol -> type -> symbol doesn't roundtrips. - getTypeReferenceTypeWorker(node, staticType.symbol, typeArguments); // Get the instance type of the RHS symbol. - if (instanceType) { - return getSymbolLinks(symbol).resolvedJSDocType = instanceType; - } - } - function getTypeReferenceTypeWorker(node, symbol, typeArguments) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (symbol.valueDeclaration && symbol.valueDeclaration.parent && ts.isBinaryExpression(symbol.valueDeclaration.parent)) { - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; - } - } - return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); - } - if (symbol.flags & 524288 /* TypeAlias */) { - return getTypeFromTypeAliasReference(node, symbol, typeArguments); - } - if (symbol.flags & 16 /* Function */ && - isJSDocTypeReference(node) && - isJSConstructor(symbol.valueDeclaration)) { - var resolved = resolveStructuredTypeMembers(getTypeOfSymbol(symbol)); - if (resolved.callSignatures.length === 1) { - return getReturnTypeOfSignature(resolved.callSignatures[0]); - } + function getTypeFromJSAlias(node, symbol) { + var valueType = getTypeOfSymbol(symbol); + var typeType = valueType.symbol && + valueType.symbol !== symbol && // Make sure this is a commonjs export by checking that symbol -> type -> symbol doesn't roundtrip. + getTypeReferenceType(node, valueType.symbol); + if (typeType) { + return getSymbolLinks(symbol).resolvedJSDocType = typeType; } } function getSubstitutionType(typeVariable, substitute) { @@ -39979,7 +40546,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 171 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 172 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -39988,9 +40555,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 297 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 299 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 176 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 177 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -40001,7 +40568,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 165 /* TypeReference */ || node.kind === 184 /* ImportType */); + return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 166 /* TypeReference */ || node.kind === 185 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -40038,10 +40605,10 @@ var ts; return globalFunctionType; case "Array": case "array": - return !typeArgs || !typeArgs.length ? anyArrayType : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined; case "Promise": case "promise": - return !typeArgs || !typeArgs.length ? createPromiseType(anyType) : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined; case "Object": if (typeArgs && typeArgs.length === 2) { if (ts.isJSDocIndexSignature(node)) { @@ -40053,7 +40620,7 @@ var ts; return anyType; } checkNoTypeArguments(node); - return anyType; + return !noImplicitAny ? anyType : undefined; } } } @@ -40066,10 +40633,19 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - var meaning = 67897832 /* Type */; + var meaning = 788968 /* Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); - meaning |= 67220415 /* Value */; + if (!type) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, /*ignoreErrors*/ true); + if (symbol === unknownSymbol) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551 /* Value */); + } + else { + resolveTypeReferenceName(getTypeReferenceName(node), meaning); // Resolve again to mark errors, if any + } + type = getTypeReferenceType(node, symbol); + } } if (!type) { symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning); @@ -40102,9 +40678,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: return declaration; } } @@ -40124,10 +40700,10 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67220415 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67897832 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { // Don't track references for global symbols anyway, so value if `isReference` is arbitrary @@ -40196,7 +40772,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 67897832 /* Type */, /*diagnostic*/ undefined); + var symbol = getGlobalSymbol(name, 788968 /* Type */, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -40306,8 +40882,8 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 173 /* RestType */ ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 172 /* OptionalType */ && n !== restElement_1; }) + 1; + var restElement_1 = lastElement && lastElement.kind === 174 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 173 /* OptionalType */ && n !== restElement_1; }) + 1; var elementTypes = ts.map(node.elementTypes, function (n) { var type = getTypeFromTypeNode(n); return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; @@ -40350,7 +40926,7 @@ var ts; // We ignore 'never' types in unions if (!(flags & 131072 /* Never */)) { includes |= flags & 68943871 /* IncludesMask */; - if (flags & 66846720 /* StructuredOrInstantiable */) + if (flags & 201064448 /* StructuredOrInstantiable */) includes |= 262144 /* IncludesStructuredOrInstantiable */; if (type === wildcardType) includes |= 4194304 /* IncludesWildcard */; @@ -40482,7 +41058,7 @@ var ts; neverType; } } - return getUnionTypeFromSortedList(typeSet, includes & 66994211 /* NotPrimitiveUnion */ ? 0 : 131072 /* PrimitiveUnion */, aliasSymbol, aliasTypeArguments); + return getUnionTypeFromSortedList(typeSet, includes & 201211939 /* NotPrimitiveUnion */ ? 0 : 131072 /* PrimitiveUnion */, aliasSymbol, aliasTypeArguments); } function getUnionTypePredicate(signatures) { var first; @@ -40552,10 +41128,10 @@ var ts; } return links.resolvedType; } - function addTypeToIntersection(typeSet, includes, type) { + function addTypeToIntersection(typeSet, includes, type, tagSet) { var flags = type.flags; if (flags & 2097152 /* Intersection */) { - return addTypesToIntersection(typeSet, includes, type.types); + return addTypesToIntersection(typeSet, includes, type.types, tagSet); } if (isEmptyAnonymousObjectType(type)) { if (!(includes & 8388608 /* IncludesEmptyObject */)) { @@ -40568,6 +41144,9 @@ var ts; if (type === wildcardType) includes |= 4194304 /* IncludesWildcard */; } + else if (flags & 134217728 /* StructuralTag */) { + tagSet.set(type.id.toString(), type); + } else if ((strictNullChecks || !(flags & 98304 /* Nullable */)) && !typeSet.has(type.id.toString())) { if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) { // We have seen two distinct unit types which means we should reduce to an @@ -40582,10 +41161,27 @@ var ts; } // Add the given types to the given type set. Order is preserved, freshness is removed from literal // types, duplicates are removed, and nested types of the given kind are flattened into the set. - function addTypesToIntersection(typeSet, includes, types) { + function addTypesToIntersection(typeSet, includes, types, tagSet) { + var isTopLevel = !tagSet; + tagSet = tagSet || ts.createMap(); for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { var type = types_8[_i]; - includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); + includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type), tagSet); + } + if (isTopLevel && tagSet.size) { + var tag = void 0; + if (tagSet.size === 1) { + tag = tagSet.values().next().value; + } + else { + var tagTypes_1 = []; + tagSet.forEach(function (t) { return tagTypes_1.push(t.type); }); + tag = getStructuralTagForType(getIntersectionType(tagTypes_1)); + if (tag.flags & 1048576 /* Union */) { + includes |= 1048576 /* Union */; + } + } + typeSet.set(tag.id.toString(), tag); } return includes; } @@ -40622,6 +41218,15 @@ var ts; } return true; } + function extractIrreducible(types, flag) { + if (ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); })) { + for (var i = 0; i < types.length; i++) { + types[i] = filterType(types[i], function (t) { return !(t.flags & flag); }); + } + return true; + } + return false; + } // If the given list of types contains more than one union of primitive types, replace the // first with a union containing an intersection of those primitive types, then remove the // other unions and return true. Otherwise, do nothing and return false. @@ -40740,6 +41345,12 @@ var ts; // reduced we'll never reduce again, so this occurs at most once. result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } + else if (extractIrreducible(typeSet, 32768 /* Undefined */)) { + result = getUnionType([getIntersectionType(typeSet), undefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + } + else if (extractIrreducible(typeSet, 65536 /* Null */)) { + result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + } else { // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain. @@ -40855,9 +41466,16 @@ var ts; case 134 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; + case 148 /* TagKeyword */: + var aliasSymbol = getAliasSymbolForTypeNode(node); + var aliasParams = getTypeArgumentsForAliasSymbol(aliasSymbol); + links.resolvedType = getStructuralTagForType(getTypeFromTypeNode(node.type), aliasSymbol, aliasParams); + break; + default: + throw ts.Debug.assertNever(node.operator); } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function createIndexedAccessType(objectType, indexType) { var type = createType(8388608 /* IndexedAccess */); @@ -40865,6 +41483,26 @@ var ts; type.indexType = indexType; return type; } + function getStructuralTagForType(type, aliasSymbol, aliasTypeArguments) { + if (typeof aliasSymbol === "number") { + aliasSymbol = undefined; + } + var tid = "" + getTypeId(type); + if (structuralTags.has(tid)) { + return structuralTags.get(tid); + } + if (type.flags & 1048576 /* Union */) { + var union = getUnionType(ts.map(type.types, getStructuralTagForType), 2 /* Subtype */, aliasSymbol, aliasTypeArguments); + structuralTags.set(tid, union); + return union; + } + var tag = createType(134217728 /* StructuralTag */); + tag.type = type; + tag.aliasSymbol = aliasSymbol; + tag.aliasTypeArguments = aliasTypeArguments; + structuralTags.set(tid, tag); + return tag; + } /** * Returns if a type is or consists of a JSLiteral object type * In addition to objects which are directly literals, @@ -40893,7 +41531,7 @@ var ts; return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 192 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -40904,7 +41542,7 @@ var ts; undefined; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 192 /* ElementAccessExpression */ ? accessNode : undefined; var propName = getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); @@ -41041,13 +41679,10 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 191 /* ElementAccessExpression */ - ? accessNode.argumentExpression - : accessNode.kind === 181 /* IndexedAccessType */ - ? accessNode.indexType - : accessNode.kind === 150 /* ComputedPropertyName */ - ? accessNode.expression - : accessNode; + return accessNode.kind === 192 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 182 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 151 /* ComputedPropertyName */ ? accessNode.expression : + accessNode; } function isGenericObjectType(type) { return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 131072 /* GenericMappedType */); @@ -41172,7 +41807,7 @@ var ts; // object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in // an expression. This is to preserve backwards compatibility. For example, an element access 'this["foo"]' // has always been resolved eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 181 /* IndexedAccessType */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 182 /* IndexedAccessType */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -41384,7 +42019,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 67220415 /* Value */ : node.flags & 2097152 /* JSDoc */ ? 67220415 /* Value */ | 67897832 /* Type */ : 67897832 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 2097152 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { @@ -41407,14 +42042,14 @@ var ts; getNodeLinks(current.parent).resolvedSymbol = next; currentNamespace = next; } - resolveImportSymbolType(node, links, currentNamespace, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning); } else { if (moduleSymbol.flags & targetMeaning) { - resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 67220415 /* Value */ + var errorMessage = targetMeaning === 111551 /* Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -41423,16 +42058,16 @@ var ts; } } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 67220415 /* Value */) { - return links.resolvedType = getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias + if (meaning === 111551 /* Value */) { + return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { - return links.resolvedType = getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol + return getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol } } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { @@ -41456,7 +42091,11 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined; + var host = node.parent; + while (ts.isParenthesizedTypeNode(host)) { + host = host.parent; + } + return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; } function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; @@ -41645,12 +42284,26 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 242 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 243 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 158 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } + // inside x.prototype = { ... } + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; + } + // /** @return {this} */ + // x.prototype.m = function() { ... } + var host = node.flags & 2097152 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; + } + // inside constructor function C() { ... } + if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType; + } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); return errorType; } @@ -41664,8 +42317,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 121 /* AnyKeyword */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 291 /* JSDocAllType */: + case 292 /* JSDocUnknownType */: return anyType; case 144 /* UnknownKeyword */: return unknownType; @@ -41689,63 +42342,63 @@ var ts; return neverType; case 137 /* ObjectKeyword */: return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 179 /* ThisType */: + case 180 /* ThisType */: case 101 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 183 /* LiteralType */: + case 184 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return getTypeFromTypeReference(node); - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return booleanType; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 171 /* TupleType */: + case 172 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 172 /* OptionalType */: + case 173 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 174 /* UnionType */: + case 175 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 175 /* IntersectionType */: + case 176 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 292 /* JSDocNullableType */: + case 293 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 294 /* JSDocOptionalType */: + case 295 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 178 /* ParenthesizedType */: - case 173 /* RestType */: - case 293 /* JSDocNonNullableType */: - case 289 /* JSDocTypeExpression */: + case 179 /* ParenthesizedType */: + case 174 /* RestType */: + case 294 /* JSDocNonNullableType */: + case 290 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 296 /* JSDocVariadicType */: + case 297 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 295 /* JSDocFunctionType */: - case 299 /* JSDocSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 170 /* TypeLiteral */: + case 300 /* JSDocTypeLiteral */: + case 296 /* JSDocFunctionType */: + case 301 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 182 /* MappedType */: + case 183 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 177 /* InferType */: + case 178 /* InferType */: return getTypeFromInferTypeNode(node); - case 184 /* ImportType */: + case 185 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -41874,7 +42527,7 @@ var ts; } function instantiateSymbol(symbol, mapper) { var links = getSymbolLinks(symbol); - if (links.type && !maybeTypeOfKind(links.type, 524288 /* Object */ | 63176704 /* Instantiable */)) { + if (links.type && !maybeTypeOfKind(links.type, 524288 /* Object */ | 63176704 /* Instantiable */ | 134217728 /* StructuralTag */)) { // If the type of the symbol is already resolved, and if that type could not possibly // be affected by instantiation, simply return the symbol itself. return symbol; @@ -41954,8 +42607,9 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 149 /* QualifiedName */ || - node.parent.kind === 165 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 150 /* QualifiedName */ || + node.parent.kind === 166 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 185 /* 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 @@ -41964,7 +42618,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 219 /* Block */ || n.kind === 176 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 220 /* Block */ || n.kind === 177 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -41973,12 +42627,12 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 179 /* ThisType */: + case 180 /* ThisType */: return !!tp.isThisType; case 73 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return true; } return !!ts.forEachChild(node, containsReference); @@ -42172,6 +42826,10 @@ var ts; return sub; } } + if (flags & 134217728 /* StructuralTag */) { + var newType = instantiateType(type.type, mapper); + return newType !== type ? getStructuralTagForType(newType, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; + } return type; } function getPermissiveInstantiation(type) { @@ -42200,35 +42858,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 !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return node.operatorToken.kind === 55 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 268 /* JsxAttribute */: { + case 269 /* 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 271 /* JsxExpression */: { + case 272 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -42248,7 +42906,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 198 /* ArrowFunction */) { + if (node.kind !== 199 /* 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); @@ -42260,7 +42918,7 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !!node.body && node.body.kind !== 219 /* Block */ && isContextSensitive(node.body); + return !!node.body && node.body.kind !== 220 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -42363,23 +43021,23 @@ var ts; return true; } switch (node.kind) { - case 271 /* JsxExpression */: - case 196 /* ParenthesizedExpression */: + case 272 /* JsxExpression */: + case 197 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (node.operatorToken.kind) { case 60 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -42551,7 +43209,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -42560,9 +43218,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 266 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -42636,7 +43294,7 @@ var ts; var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName); var childrenTargetType = getIndexedAccessType(target, getLiteralType(childrenPropName)); var diagnostic = ts.Diagnostics._0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2; - invalidTextDiagnostic = __assign({}, diagnostic, { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); + invalidTextDiagnostic = __assign(__assign({}, diagnostic), { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); } return invalidTextDiagnostic; } @@ -42704,11 +43362,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 160 /* SetAccessor */: return [3 /*break*/, 2]; - case 159 /* GetAccessor */: return [3 /*break*/, 2]; - case 157 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 277 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 276 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 161 /* SetAccessor */: return [3 /*break*/, 2]; + case 160 /* GetAccessor */: return [3 /*break*/, 2]; + case 158 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 278 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 277 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -42780,8 +43438,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 157 /* MethodDeclaration */ && - kind !== 156 /* MethodSignature */ && kind !== 158 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 158 /* MethodDeclaration */ && + kind !== 157 /* MethodSignature */ && kind !== 159 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -42829,15 +43487,17 @@ var ts; result &= related; } if (!ignoreReturnTypes) { - // If a signature reolution is already in-flight, skip issuing a circularity error + // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly - var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType : (target.declaration && isJSConstructor(target.declaration)) ? - getJSClassType(target.declaration.symbol) : getReturnTypeOfSignature(target); + var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType + : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(target.declaration.symbol) + : getReturnTypeOfSignature(target); if (targetReturnType === voidType) { return result; } - var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType : (source.declaration && isJSConstructor(source.declaration)) ? - getJSClassType(source.declaration.symbol) : getReturnTypeOfSignature(source); + var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType + : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(source.declaration.symbol) + : getReturnTypeOfSignature(source); // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions var targetTypePredicate = getTypePredicateOfSignature(target); if (targetTypePredicate) { @@ -43023,7 +43683,7 @@ var ts; return related === 1 /* Succeeded */; } } - if (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */) { + if (source.flags & 201064448 /* StructuredOrInstantiable */ || target.flags & 201064448 /* StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; @@ -43084,7 +43744,7 @@ var ts; } var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); if (relatedInfo) { - ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInfo)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInfo)); } if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -43129,8 +43789,8 @@ var ts; reportError(message, sourceType, targetType); } function tryElaborateErrorsForPrimitivesAndObjects(source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); + var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source); + var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target); if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || @@ -43223,7 +43883,7 @@ var ts; isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); - var isPerformingExcessPropertyChecks = (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); + var isPerformingExcessPropertyChecks = !isApparentIntersectionConstituent && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); if (isPerformingExcessPropertyChecks) { var discriminantType = target.flags & 1048576 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { @@ -43233,11 +43893,11 @@ var ts; return 0 /* False */; } } - if (relation !== comparableRelation && !isApparentIntersectionConstituent && + var isPerformingCommonPropertyChecks = relation !== comparableRelation && !isApparentIntersectionConstituent && source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType && target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) && - (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)) && - !hasCommonProperties(source, target, isComparingJsxAttributes)) { + (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); + if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var calls = getSignaturesOfType(source, 0 /* Call */); var constructs = getSignaturesOfType(source, 1 /* Construct */); @@ -43259,16 +43919,16 @@ var ts; // and we need to handle "each" relations before "some" relations for the same kind of type. if (source.flags & 1048576 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)) : + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), isIntersectionConstituent) : eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)); } else { if (target.flags & 1048576 /* Union */) { result = typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { // Validate against excess props using the original `source` var discriminantType = findMatchingDiscriminantType(source, target) || filterPrimitivesIfContainsNonPrimitive(target); - if (!propertiesRelatedTo(source, discriminantType, reportErrors, /*excludedProperties*/ undefined)) { + if (!propertiesRelatedTo(source, discriminantType, reportErrors, /*excludedProperties*/ undefined, isIntersectionConstituent)) { return 0 /* False */; } } @@ -43276,9 +43936,9 @@ var ts; else if (target.flags & 2097152 /* Intersection */) { isIntersectionConstituent = true; // set here to affect the following trio of checks result = typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { // Validate against excess props using the original `source` - if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined)) { + if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, /*isIntersectionConstituent*/ false)) { return 0 /* False */; } } @@ -43297,9 +43957,9 @@ var ts; // // - For a primitive type or type parameter (such as 'number = A & B') there is no point in // breaking the intersection apart. - result = someTypeRelatedToType(source, target, /*reportErrors*/ false); + result = someTypeRelatedToType(source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ true); } - if (!result && (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */)) { + if (!result && (source.flags & 201064448 /* StructuredOrInstantiable */ || target.flags & 201064448 /* StructuredOrInstantiable */)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { errorInfo = saveErrorInfo; } @@ -43566,14 +44226,14 @@ var ts; } return result; } - function someTypeRelatedToType(source, target, reportErrors) { + function someTypeRelatedToType(source, target, reportErrors, isIntersectionConstituent) { var sourceTypes = source.types; if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, isIntersectionConstituent); if (related) { return related; } @@ -43593,7 +44253,7 @@ var ts; } return result; } - function typeArgumentsRelatedTo(sources, targets, variances, reportErrors) { + function typeArgumentsRelatedTo(sources, targets, variances, reportErrors, isIntersectionConstituent) { if (sources === void 0) { sources = ts.emptyArray; } if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } @@ -43620,10 +44280,10 @@ var ts; related = relation === identityRelation ? isRelatedTo(s, t, /*reportErrors*/ false) : compareTypesIdentical(s, t); } else if (variance === 1 /* Covariant */) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } else if (variance === 2 /* Contravariant */) { - related = isRelatedTo(t, s, reportErrors); + related = isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } else if (variance === 3 /* Bivariant */) { // In the bivariant case we first compare contravariantly without reporting @@ -43632,16 +44292,16 @@ var ts; // which is generally easier to reason about. related = isRelatedTo(t, s, /*reportErrors*/ false); if (!related) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } else { // In the invariant case we first compare covariantly, and only when that // succeeds do we proceed to compare contravariantly. Thus, error elaboration // will typically be based on the covariant check. - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); if (related) { - related &= isRelatedTo(t, s, reportErrors); + related &= isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } if (!related) { @@ -43771,6 +44431,9 @@ var ts; if (flags & 33554432 /* Substitution */) { return isRelatedTo(source.substitute, target.substitute, /*reportErrors*/ false); } + if (flags & 134217728 /* StructuralTag */) { + return isRelatedTo(source.type, target.type, /*reportErrors*/ false); + } return 0 /* False */; } var result; @@ -43784,7 +44447,7 @@ var ts; source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) { var variances = getAliasVariances(source.aliasSymbol); - var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances); + var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -43870,6 +44533,12 @@ var ts; } } } + else if (target.flags & 134217728 /* StructuralTag */) { + if (source.flags & 134217728 /* StructuralTag */) { + return isRelatedTo(source.type, target.type, reportErrors); + } + return 0 /* False */; + } 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. @@ -43913,9 +44582,19 @@ var ts; // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. - if (isTypeIdenticalTo(source.extendsType, target.extendsType) && + var sourceParams = source.root.inferTypeParameters; + var sourceExtends = source.extendsType; + var mapper = void 0; + if (sourceParams) { + // If the source has infer type parameters, we instantiate them in the context of the target + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedTo); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 64 /* NoConstraints */ | 128 /* AlwaysStrict */); + sourceExtends = instantiateType(sourceExtends, ctx.mapper); + mapper = ctx.mapper; + } + if (isTypeIdenticalTo(sourceExtends, target.extendsType) && (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { - if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } if (result) { @@ -43968,7 +44647,7 @@ var ts; // type references (which are intended by be compared structurally). Obtain the variance // information for the type parameters and relate the type arguments accordingly. var variances = getVariances(source.target); - var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances); + var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -43996,7 +44675,7 @@ var ts; if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 524288 /* Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; - result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined); + result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, isIntersectionConstituent); if (result) { result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); if (result) { @@ -44031,8 +44710,8 @@ var ts; } } return 0 /* False */; - function relateVariances(sourceTypeArguments, targetTypeArguments, variances) { - if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors)) { + function relateVariances(sourceTypeArguments, targetTypeArguments, variances, isIntersectionConstituent) { + if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, isIntersectionConstituent)) { return result; } if (ts.some(variances, function (v) { return !!(v & 24 /* AllowsStructuralFallback */); })) { @@ -44157,7 +44836,7 @@ var ts; if (sourceProperty === targetProperty) return "continue"; // We compare the source property to the target in the context of a single discriminant type. - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, /*isIntersectionConstituent*/ false); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -44187,7 +44866,7 @@ var ts; var result = -1 /* True */; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties); + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, /*isIntersectionConstituent*/ false); if (result) { result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false); if (result) { @@ -44222,7 +44901,7 @@ var ts; } return result || properties; } - function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); var source = getTypeOfSourceProperty(sourceProp); if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { @@ -44262,10 +44941,10 @@ var ts; return result_7; } else { - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } - function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { @@ -44303,7 +44982,7 @@ var ts; return 0 /* False */; } // If the target comes from a partial union prop, allow `undefined` in the target type - var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors); + var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); @@ -44326,7 +45005,7 @@ var ts; } return related; } - function propertiesRelatedTo(source, target, reportErrors, excludedProperties) { + function propertiesRelatedTo(source, target, reportErrors, excludedProperties, isIntersectionConstituent) { if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } @@ -44342,7 +45021,7 @@ var ts; } if (props.length === 1) { var propName = symbolToString(unmatchedProperty); - reportError.apply(void 0, [ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName].concat(getTypeNamesForErrorDisplay(source, target))); + reportError.apply(void 0, __spreadArrays([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target))); if (ts.length(unmatchedProperty.declarations)) { associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); } @@ -44415,7 +45094,7 @@ var ts; if (!(targetProp.flags & 4194304 /* Prototype */)) { var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp && sourceProp !== targetProp) { - var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors); + var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, isIntersectionConstituent); if (!related) { return 0 /* False */; } @@ -44594,7 +45273,7 @@ var ts; if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U } // if T is related to U. - return (kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); // TODO: GH#18217 + return kind === 0 /* String */ ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) : 0 /* False */; } if (isObjectTypeWithInferableIndex(source)) { var related = -1 /* True */; @@ -44650,23 +45329,27 @@ var ts; } } function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue) { - var match; + // undefined=unknown, true=discriminated, false=not discriminated + // The state of each type progresses from left to right. Discriminated types stop at 'true'. + var discriminable = target.types.map(function (_) { return undefined; }); for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; + var i = 0; for (var _b = 0, _c = target.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, propertyName); if (targetType && related(getDiscriminatingType(), targetType)) { - if (match) { - if (type === match) - continue; // Finding multiple fields which discriminate to the same type is fine - return defaultValue; - } - match = type; + discriminable[i] = discriminable[i] === undefined ? true : discriminable[i]; + } + else { + discriminable[i] = false; } + i++; } } - return match || defaultValue; + var match = discriminable.indexOf(/*searchElement*/ true); + // make sure exactly 1 matches before returning it + return match === -1 || discriminable.indexOf(/*searchElement*/ true, match + 1) !== -1 ? defaultValue : target.types[match]; } /** * A type is 'weak' if it is an object type with at least one optional property @@ -44869,6 +45552,9 @@ var ts; // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least 5 // levels, but unequal at some level beyond that. + // In addition, this will also detect when an indexed access has been chained off of 5 or more times (which is essentially + // the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding false positives + // for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`). function isDeeplyNestedType(type, stack, depth) { // We track all object types that have an associated symbol (representing the origin of the type) if (depth >= 5 && type.flags & 524288 /* Object */) { @@ -44885,8 +45571,30 @@ var ts; } } } + if (depth >= 5 && type.flags & 8388608 /* IndexedAccess */) { + var root = getRootObjectTypeFromIndexedAccessChain(type); + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (getRootObjectTypeFromIndexedAccessChain(t) === root) { + count++; + if (count >= 5) + return true; + } + } + } return false; } + /** + * Gets the leftmost object type in a chain of indexed accesses, eg, in A[P][Q], returns A + */ + function getRootObjectTypeFromIndexedAccessChain(type) { + var t = type; + while (t.flags & 8388608 /* IndexedAccess */) { + t = t.objectType; + } + return t; + } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; } @@ -45248,8 +45956,8 @@ var ts; * with no call or construct signatures. */ function isObjectTypeWithInferableIndex(type) { - return type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && - !typeHasCallOrConstructSignatures(type); + return !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); @@ -45468,17 +46176,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 205 /* BinaryExpression */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 206 /* BinaryExpression */: + case 156 /* PropertyDeclaration */: + case 155 /* 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 152 /* Parameter */: + case 153 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 67897832 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || + (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, ts.declarationNameToString(param.name)); @@ -45488,23 +46196,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 187 /* BindingElement */: + case 188 /* 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 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 1 /* 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); @@ -45518,7 +46226,7 @@ var ts; wideningKind === 1 /* 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 182 /* MappedType */: + case 183 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -45639,10 +46347,11 @@ var ts; function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); return !!(type.flags & 63176704 /* Instantiable */ || + type.flags & 134217728 /* StructuralTag */ && couldContainTypeVariables(type.type) || objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, 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 */ || - type.flags & 3145728 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { @@ -45797,8 +46506,7 @@ var ts; var visited; var bivariant = false; var propagationType; - var inferenceCount = 0; - var inferenceIncomplete = false; + var inferencePriority = 256 /* MaxValue */; var allowComplexConstraintInference = true; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { @@ -45821,50 +46529,57 @@ var ts; inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); return; } - if (source.flags & 1048576 /* Union */ && target.flags & 1048576 /* Union */ && !(source.flags & 1024 /* EnumLiteral */ && target.flags & 1024 /* EnumLiteral */) || - source.flags & 2097152 /* Intersection */ && target.flags & 2097152 /* Intersection */) { - // Source and target are both unions or both intersections. If source and target - // are the same type, just relate each constituent type to itself. - if (source === target) { - for (var _i = 0, _a = source.types; _i < _a.length; _i++) { - var t = _a[_i]; - inferFromTypes(t, t); - } - return; - } - // Find each source constituent type that has an identically matching target constituent - // type, and for each such type infer from the type to itself. When inferring from a - // type to itself we effectively find all type parameter occurrences within that type - // and infer themselves as their type arguments. We have special handling for numeric - // and string literals because the number and string types are not represented as unions - // of all their possible values. - var matchingTypes = void 0; - for (var _b = 0, _c = source.types; _b < _c.length; _b++) { - var t = _c[_b]; - var matched = findMatchedType(t, target); - if (matched) { - (matchingTypes || (matchingTypes = [])).push(matched); - inferFromTypes(matched, matched); - } - } - // Next, to improve the quality of inferences, reduce the source and target types by - // removing the identically matched constituents. For example, when inferring from - // 'string | string[]' to 'string | T' we reduce the types to 'string[]' and 'T'. - if (matchingTypes) { - var s = removeTypesFromUnionOrIntersection(source, matchingTypes); - var t = removeTypesFromUnionOrIntersection(target, matchingTypes); - if (!(s && t)) - return; - source = s; - target = t; + if (source === target && source.flags & 3145728 /* UnionOrIntersection */) { + // When source and target are the same union or intersection type, just relate each constituent + // type to itself. + for (var _i = 0, _a = source.types; _i < _a.length; _i++) { + var t = _a[_i]; + inferFromTypes(t, t); } + return; } - else if (target.flags & 1048576 /* Union */ && !(target.flags & 1024 /* EnumLiteral */) || target.flags & 2097152 /* Intersection */) { - var matched = findMatchedType(source, target); - if (matched) { - inferFromTypes(matched, matched); + if (target.flags & 1048576 /* Union */) { + // First, infer between identically matching source and target constituents and remove the + // matching types. + var _b = inferFromMatchingTypes(source.flags & 1048576 /* Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + // Next, infer between closely matching source and target constituents and remove + // the matching types. Types closely match when they are instantiations of the same + // object type or instantiations of the same type alias. + var _c = inferFromMatchingTypes(tempSources, tempTargets, isTypeCloselyMatchedBy), sources = _c[0], targets = _c[1]; + if (targets.length === 0) { return; } + target = getUnionType(targets); + if (sources.length === 0) { + // All source constituents have been matched and there is nothing further to infer from. + // However, simply making no inferences is undesirable because it could ultimately mean + // inferring a type parameter constraint. Instead, make a lower priority inference from + // the full source to whatever remains in the target. For example, when inferring from + // string to 'string | T', make a lower priority inference of string for T. + var savePriority = priority; + priority |= 1 /* NakedTypeVariable */; + inferFromTypes(source, target); + priority = savePriority; + return; + } + source = getUnionType(sources); + } + else if (target.flags & 2097152 /* Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + // We reduce intersection types only when they contain naked type parameters. For example, when + // inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and + // infer { extra: any } for T. But when inferring to 'string[] & Iterable' we want to keep the + // string[] on the source side and infer string for T. + // Likewise, we consider a homomorphic mapped type constrainted to the target type parameter as similar to a "naked type variable" + // in such scenarios. + if (!(source.flags & 1048576 /* Union */)) { + // Infer between identically matching source and target constituents and remove the matching types. + var _d = inferFromMatchingTypes(source.flags & 2097152 /* Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + if (sources.length === 0 || targets.length === 0) { + return; + } + source = getIntersectionType(sources); + target = getIntersectionType(targets); + } } else if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) { target = getActualTypeVariable(target); @@ -45909,7 +46624,7 @@ var ts; clearCachedInferences(inferences); } } - inferenceCount++; + inferencePriority = Math.min(inferencePriority, priority); return; } else { @@ -45940,6 +46655,9 @@ var ts; inferFromTypes(source.type, target.type); contravariant = !contravariant; } + else if (source.flags & 134217728 /* StructuralTag */ && target.flags & 134217728 /* StructuralTag */) { + inferFromTypes(source.type, target.type); + } else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; @@ -45966,11 +46684,17 @@ var ts; else if (target.flags & 3145728 /* UnionOrIntersection */) { inferToMultipleTypes(source, target.types, target.flags); } + else if (target.flags & 134217728 /* StructuralTag */ && source.flags & 2097152 /* Intersection */) { + var tagsOnly = getIntersectionType(ts.filter(source.types, function (t) { return !!(t.flags & 134217728 /* StructuralTag */); })); + if (tagsOnly !== source) { + inferFromTypes(tagsOnly, target); + } + } else if (source.flags & 1048576 /* Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; - for (var _d = 0, sourceTypes_3 = sourceTypes; _d < sourceTypes_3.length; _d++) { - var sourceType = sourceTypes_3[_d]; + for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { + var sourceType = sourceTypes_3[_e]; inferFromTypes(sourceType, target); } } @@ -46000,15 +46724,36 @@ var ts; } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; - var count = visited && visited.get(key); - if (count !== undefined) { - inferenceCount += count; + var status = visited && visited.get(key); + if (status !== undefined) { + inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = ts.createMap())).set(key, 0); - var startCount = inferenceCount; + (visited || (visited = ts.createMap())).set(key, -1 /* Circularity */); + var saveInferencePriority = inferencePriority; + inferencePriority = 256 /* MaxValue */; action(source, target); - visited.set(key, inferenceCount - startCount); + visited.set(key, inferencePriority); + inferencePriority = Math.min(inferencePriority, saveInferencePriority); + } + function inferFromMatchingTypes(sources, targets, matches) { + var matchedSources; + var matchedTargets; + for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { + var t = targets_1[_i]; + for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) { + var s = sources_1[_a]; + if (matches(s, t)) { + inferFromTypes(s, t); + matchedSources = ts.appendIfUnique(matchedSources, s); + matchedTargets = ts.appendIfUnique(matchedTargets, t); + } + } + } + return [ + matchedSources ? ts.filter(sources, function (t) { return !ts.contains(matchedSources, t); }) : sources, + matchedTargets ? ts.filter(targets, function (t) { return !ts.contains(matchedTargets, t); }) : targets, + ]; } function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; @@ -46048,31 +46793,34 @@ var ts; var nakedTypeVariable = void 0; var sources = source.flags & 1048576 /* Union */ ? source.types : [source]; var matched_1 = new Array(sources.length); - var saveInferenceIncomplete = inferenceIncomplete; - inferenceIncomplete = false; + var inferenceCircularity = false; // First infer to types that are not naked type variables. For each source type we - // track whether inferences were made from that particular type to some target. - for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { - var t = targets_1[_i]; + // track whether inferences were made from that particular type to some target with + // equal priority (i.e. of equal quality) to what we would infer for a naked type + // parameter. + for (var _i = 0, targets_2 = targets; _i < targets_2.length; _i++) { + var t = targets_2[_i]; if (getInferenceInfoForType(t)) { nakedTypeVariable = t; typeVariableCount++; } else { for (var i = 0; i < sources.length; i++) { - var count = inferenceCount; + var saveInferencePriority = inferencePriority; + inferencePriority = 256 /* MaxValue */; inferFromTypes(sources[i], t); - if (count !== inferenceCount) + if (inferencePriority === priority) matched_1[i] = true; + inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* Circularity */; + inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } } - var inferenceComplete = !inferenceIncomplete; - inferenceIncomplete = inferenceIncomplete || saveInferenceIncomplete; - // If the target has a single naked type variable and inference completed (meaning we - // explored the types fully), create a union of the source types from which no inferences - // have been made so far and infer from that union to the naked type variable. - if (typeVariableCount === 1 && inferenceComplete) { + // If the target has a single naked type variable and no inference circularities were + // encountered above (meaning we explored the types fully), create a union of the source + // types from which no inferences have been made so far and infer from that union to the + // naked type variable. + if (typeVariableCount === 1 && !inferenceCircularity) { var unmatched = ts.flatMap(sources, function (s, i) { return matched_1[i] ? undefined : s; }); if (unmatched.length) { inferFromTypes(getUnionType(unmatched), nakedTypeVariable); @@ -46084,8 +46832,8 @@ var ts; // We infer from types that are not naked type variables first so that inferences we // make from nested naked type variables and given slightly higher priority by virtue // of being first in the candidates array. - for (var _a = 0, targets_2 = targets; _a < targets_2.length; _a++) { - var t = targets_2[_a]; + for (var _a = 0, targets_3 = targets; _a < targets_3.length; _a++) { + var t = targets_3[_a]; if (getInferenceInfoForType(t)) { typeVariableCount++; } @@ -46101,8 +46849,8 @@ var ts; if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { var savePriority = priority; priority |= 1 /* NakedTypeVariable */; - for (var _b = 0, targets_3 = targets; _b < targets_3.length; _b++) { - var t = targets_3[_b]; + for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { + var t = targets_4[_b]; if (getInferenceInfoForType(t)) { inferFromTypes(source, t); } @@ -46176,7 +46924,7 @@ var ts; var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { if (ts.contains(symbolStack, symbol)) { - inferenceIncomplete = true; + inferencePriority = -1 /* Circularity */; return; } (symbolStack || (symbolStack = [])).push(symbol); @@ -46260,7 +47008,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 === 157 /* MethodDeclaration */ || kind === 156 /* MethodSignature */ || kind === 158 /* Constructor */; + bivariant = bivariant || kind === 158 /* MethodDeclaration */ || kind === 157 /* MethodSignature */ || kind === 159 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -46286,46 +47034,12 @@ var ts; } } } - function isMatchableType(type) { - // We exclude non-anonymous object types because some frameworks (e.g. Ember) rely on the ability to - // infer between types that don't witness their type variables. Such types would otherwise be eliminated - // because they appear identical. - return !(type.flags & 524288 /* Object */) || !!(ts.getObjectFlags(type) & 16 /* Anonymous */); + function isTypeOrBaseIdenticalTo(s, t) { + return isTypeIdenticalTo(s, t) || !!(s.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) && isTypeIdenticalTo(getBaseTypeOfLiteralType(s), t); } - function typeMatchedBySomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; - if (t === type || isMatchableType(t) && isMatchableType(type) && isTypeIdenticalTo(t, type)) { - return true; - } - } - return false; - } - function findMatchedType(type, target) { - if (typeMatchedBySomeType(type, target.types)) { - return type; - } - if (type.flags & (256 /* NumberLiteral */ | 128 /* StringLiteral */) && target.flags & 1048576 /* Union */) { - var base = getBaseTypeOfLiteralType(type); - if (typeMatchedBySomeType(base, target.types)) { - return base; - } - } - return undefined; - } - /** - * Return a new union or intersection type computed by removing a given set of types - * from a given union or intersection type. - */ - function removeTypesFromUnionOrIntersection(type, typesToRemove) { - var reducedTypes = []; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (!typeMatchedBySomeType(t, typesToRemove)) { - reducedTypes.push(t); - } - } - return reducedTypes.length ? type.flags & 1048576 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes) : undefined; + function isTypeCloselyMatchedBy(s, t) { + return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || + s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); @@ -46464,7 +47178,7 @@ var ts; case "AsyncIterator": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later; default: - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 278 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -46476,7 +47190,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), + resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), /*excludeGlobals*/ false, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; } return links.resolvedSymbol; @@ -46485,7 +47199,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 168 /* TypeQuery */ ? true : n.kind === 73 /* Identifier */ || n.kind === 149 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 169 /* TypeQuery */ ? true : n.kind === 73 /* Identifier */ || n.kind === 150 /* 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 @@ -46500,11 +47214,11 @@ var ts; return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; case 101 /* ThisKeyword */: return "0"; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 215 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -46515,24 +47229,24 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 196 /* ParenthesizedExpression */: - case 214 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: + case 215 /* NonNullExpression */: return isMatchingReference(source, target.expression); } switch (source.kind) { case 73 /* Identifier */: return target.kind === 73 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 238 /* VariableDeclaration */ || target.kind === 187 /* BindingElement */) && + (target.kind === 239 /* VariableDeclaration */ || target.kind === 188 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 101 /* ThisKeyword */: return target.kind === 101 /* ThisKeyword */; case 99 /* SuperKeyword */: return target.kind === 99 /* SuperKeyword */; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 215 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); @@ -46540,7 +47254,7 @@ var ts; return false; } function getAccessedPropertyName(access) { - return access.kind === 190 /* PropertyAccessExpression */ ? access.name.escapedText : + return access.kind === 191 /* PropertyAccessExpression */ ? access.name.escapedText : ts.isStringLiteral(access.argumentExpression) || ts.isNumericLiteral(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } @@ -46624,7 +47338,7 @@ var ts; } } } - if (callExpression.expression.kind === 190 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 191 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -46673,8 +47387,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; result |= getTypeFacts(t); } return result; @@ -46779,15 +47493,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 188 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 189 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 277 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 205 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 228 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 206 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 229 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -46804,21 +47518,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return stringType; - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return undefinedType; - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -46826,7 +47540,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 185 /* ObjectBindingPattern */ ? + var type = pattern.kind === 186 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -46844,35 +47558,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 227 /* ForInStatement */) { + if (node.parent.parent.kind === 228 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.parent.kind === 229 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 238 /* VariableDeclaration */ ? + return node.kind === 239 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */ ? + return getConstraintForLocation(node.kind === 239 /* VariableDeclaration */ || node.kind === 188 /* BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } function isEmptyArrayAssignment(node) { - return node.kind === 238 /* VariableDeclaration */ && node.initializer && + return node.kind === 239 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 187 /* BindingElement */ && node.parent.kind === 205 /* BinaryExpression */ && + node.kind !== 188 /* BindingElement */ && node.parent.kind === 206 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (node.operatorToken.kind) { case 60 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -46884,13 +47598,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 196 /* ParenthesizedExpression */ || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */ && parent.left === node || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 197 /* ParenthesizedExpression */ || + parent.kind === 206 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */ && parent.left === node || + parent.kind === 206 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 273 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -46912,7 +47626,7 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 273 /* CaseClause */) { if (clause.expression.kind === 10 /* StringLiteral */) { witnesses.push(clause.expression.text); continue; @@ -46996,8 +47710,7 @@ var ts; return mapType(typeWithPrimitives, function (t) { return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */) : t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : - t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : - t; + t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -47049,8 +47762,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -47073,11 +47786,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 190 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 192 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 191 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 191 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 193 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 192 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 205 /* BinaryExpression */ && + parent.parent.kind === 206 /* BinaryExpression */ && parent.parent.operatorToken.kind === 60 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -47115,7 +47828,7 @@ var ts; if (flowAnalysisDisabled) { return errorType; } - if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943 /* Narrowable */)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 268188671 /* Narrowable */)) { return declaredType; } var sharedFlowStart = sharedFlowCount; @@ -47126,7 +47839,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 (reference.parent && reference.parent.kind === 214 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (reference.parent && reference.parent.kind === 215 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -47223,8 +47936,8 @@ var ts; // Check if we should continue with the control flow of the containing function. var container = flow.container; if (container && container !== flowContainer && - reference.kind !== 190 /* PropertyAccessExpression */ && - reference.kind !== 191 /* ElementAccessExpression */ && + reference.kind !== 191 /* PropertyAccessExpression */ && + reference.kind !== 192 /* ElementAccessExpression */ && reference.kind !== 101 /* ThisKeyword */) { flow = container.flowNode; continue; @@ -47277,14 +47990,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 === 197 /* FunctionExpression */ || init.kind === 198 /* ArrowFunction */)) { + if (init && (init.kind === 198 /* FunctionExpression */ || init.kind === 199 /* 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 === 227 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 228 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference @@ -47293,7 +48006,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 192 /* CallExpression */ ? + var expr = node.kind === 193 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -47301,7 +48014,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 193 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -47354,7 +48067,7 @@ var ts; else if (isMatchingReferenceDiscriminant(expr, type)) { type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); } - else if (expr.kind === 200 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 201 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else if (containsMatchingReferenceDiscriminant(reference, expr)) { @@ -47529,10 +48242,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 201 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 201 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -47610,7 +48323,7 @@ var ts; return type; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { - // We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands + // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { // For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the @@ -47892,16 +48605,16 @@ var ts; case 73 /* Identifier */: case 101 /* ThisKeyword */: case 99 /* SuperKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: if (expr.operator === 52 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -47937,9 +48650,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 246 /* ModuleBlock */ || - node.kind === 285 /* SourceFile */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 247 /* ModuleBlock */ || + node.kind === 286 /* SourceFile */ || + node.kind === 156 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -47961,7 +48674,7 @@ var ts; if (node.kind === 73 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 152 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 153 /* Parameter */) { symbol.isAssigned = true; } } @@ -47976,7 +48689,7 @@ var ts; /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 152 /* Parameter */ && + declaration.kind === 153 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -47984,10 +48697,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 190 /* PropertyAccessExpression */ || - parent.kind === 192 /* CallExpression */ && parent.expression === node || - parent.kind === 191 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 187 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 191 /* PropertyAccessExpression */ || + parent.kind === 193 /* CallExpression */ && parent.expression === node || + parent.kind === 192 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 188 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); @@ -48002,8 +48715,11 @@ var ts; } return type; } + function isExportOrExportExpression(location) { + return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); + } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 67220415 /* Value */) && !isInTypeQuery(location) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && ((compilerOptions.preserveConstEnums && isExportOrExportExpression(location)) || !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol)))) { markAliasSymbolAsReferenced(symbol); } } @@ -48021,7 +48737,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 198 /* ArrowFunction */) { + if (container.kind === 199 /* 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.hasModifier(container, 256 /* Async */)) { @@ -48042,7 +48758,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 241 /* ClassDeclaration */ + if (declaration.kind === 242 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -48054,14 +48770,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 210 /* ClassExpression */) { + else if (declaration.kind === 211 /* 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 !== 285 /* SourceFile */) { + while (container.kind !== 286 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 155 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 156 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -48110,7 +48826,7 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 152 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 153 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -48119,8 +48835,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 === 197 /* FunctionExpression */ || - flowContainer.kind === 198 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 198 /* FunctionExpression */ || + flowContainer.kind === 199 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -48128,10 +48844,10 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 258 /* ExportSpecifier */) || - node.parent.kind === 214 /* NonNullExpression */ || - declaration.kind === 238 /* VariableDeclaration */ && declaration.exclamationToken || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 259 /* ExportSpecifier */) || + node.parent.kind === 215 /* NonNullExpression */ || + declaration.kind === 239 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 4194304 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -48166,7 +48882,7 @@ var ts; if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 275 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 276 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -48189,7 +48905,7 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container) && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 240 /* VariableDeclarationList */).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -48207,8 +48923,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 226 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container && + if (container.kind === 227 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 240 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -48226,7 +48942,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 196 /* ParenthesizedExpression */) { + while (current.parent.kind === 197 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -48234,7 +48950,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 203 /* PrefixUnaryExpression */ || current.parent.kind === 204 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 204 /* PrefixUnaryExpression */ || current.parent.kind === 205 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; } @@ -48247,7 +48963,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 155 /* PropertyDeclaration */ || container.kind === 158 /* Constructor */) { + if (container.kind === 156 /* PropertyDeclaration */ || container.kind === 159 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -48315,37 +49031,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 158 /* Constructor */) { + if (container.kind === 159 /* 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 === 198 /* ArrowFunction */) { + if (container.kind === 199 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 245 /* ModuleDeclaration */: + case 246 /* 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 244 /* EnumDeclaration */: + case 245 /* 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 158 /* Constructor */: + case 159 /* 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 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: if (ts.hasModifier(container, 32 /* Static */)) { 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 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -48384,10 +49100,8 @@ var ts; if (isInJS && className) { var classSymbol = checkExpression(className).symbol; if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { - var classType = getJSClassType(classSymbol); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(classSymbol).thisType; + return getFlowTypeOfReference(node, classType); } } // Check if it's a constructor definition, can be either a variable decl or function decl @@ -48395,12 +49109,10 @@ var ts; // * /** @constructor */ function [name]() { ... } // * /** @constructor */ var x = function() { ... } else if (isInJS && - (container.kind === 197 /* FunctionExpression */ || container.kind === 240 /* FunctionDeclaration */) && + (container.kind === 198 /* FunctionExpression */ || container.kind === 241 /* FunctionDeclaration */) && ts.getJSDocClassTag(container)) { - var classType = getJSClassType(getMergedSymbol(container.symbol)); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType; + return getFlowTypeOfReference(node, classType); } var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { @@ -48431,7 +49143,7 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 197 /* FunctionExpression */ && + if (container.kind === 198 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -48441,16 +49153,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 157 /* MethodDeclaration */ && - container.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 158 /* MethodDeclaration */ && + container.parent.kind === 190 /* 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 === 197 /* FunctionExpression */ && - container.parent.kind === 276 /* PropertyAssignment */ && - container.parent.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 198 /* FunctionExpression */ && + container.parent.kind === 277 /* PropertyAssignment */ && + container.parent.parent.kind === 190 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -48458,7 +49170,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 === 197 /* FunctionExpression */ && + else if (container.kind === 198 /* 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") && @@ -48483,7 +49195,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 295 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 296 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -48497,15 +49209,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 152 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 153 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 192 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 193 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); 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 === 198 /* ArrowFunction */) { + while (container && container.kind === 199 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -48518,14 +49230,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 150 /* ComputedPropertyName */; }); - if (current && current.kind === 150 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 151 /* ComputedPropertyName */; }); + if (current && current.kind === 151 /* 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 === 189 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 190 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -48533,7 +49245,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 158 /* Constructor */) { + if (!isCallExpression && container.kind === 159 /* 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.hasModifier(container, 32 /* Static */) || isCallExpression) { @@ -48602,7 +49314,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 === 157 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 158 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -48616,7 +49328,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 189 /* ObjectLiteralExpression */) { + if (container.parent.kind === 190 /* 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; @@ -48637,7 +49349,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 158 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 159 /* 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; @@ -48652,7 +49364,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 === 158 /* Constructor */; + return container.kind === 159 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -48660,21 +49372,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 === 189 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 190 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */; + return container.kind === 158 /* MethodDeclaration */ || + container.kind === 157 /* MethodSignature */ || + container.kind === 160 /* GetAccessor */ || + container.kind === 161 /* SetAccessor */; } else { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */ || - container.kind === 155 /* PropertyDeclaration */ || - container.kind === 154 /* PropertySignature */ || - container.kind === 158 /* Constructor */; + return container.kind === 158 /* MethodDeclaration */ || + container.kind === 157 /* MethodSignature */ || + container.kind === 160 /* GetAccessor */ || + container.kind === 161 /* SetAccessor */ || + container.kind === 156 /* PropertyDeclaration */ || + container.kind === 155 /* PropertySignature */ || + container.kind === 159 /* Constructor */; } } } @@ -48682,10 +49394,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 157 /* MethodDeclaration */ || - func.kind === 159 /* GetAccessor */ || - func.kind === 160 /* SetAccessor */) && func.parent.kind === 189 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 197 /* FunctionExpression */ && func.parent.kind === 276 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 158 /* MethodDeclaration */ || + func.kind === 160 /* GetAccessor */ || + func.kind === 161 /* SetAccessor */) && func.parent.kind === 190 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 198 /* FunctionExpression */ && func.parent.kind === 277 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -48697,7 +49409,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 199 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -48724,7 +49436,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 276 /* PropertyAssignment */) { + if (literal.parent.kind !== 277 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -48738,9 +49450,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent.kind === 206 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */) { var target = parent.left; - if (target.kind === 190 /* PropertyAccessExpression */ || target.kind === 191 /* ElementAccessExpression */) { + if (target.kind === 191 /* PropertyAccessExpression */ || target.kind === 192 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -48804,9 +49516,9 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 152 /* Parameter */: + case 153 /* Parameter */: return getContextuallyTypedParameterType(declaration, /*forCache*/ false); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return getContextualTypeForBindingElement(declaration); // By default, do nothing and return undefined - only parameters and binding elements have context implied by a parent } @@ -48896,6 +49608,15 @@ var ts; } return false; } + function getContextualIterationType(kind, functionDecl) { + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */); + var contextualReturnType = getContextualReturnType(functionDecl); + if (contextualReturnType) { + return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) + || undefined; + } + return undefined; + } function getContextualReturnType(functionDecl) { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed @@ -48927,7 +49648,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 194 /* TaggedTemplateExpression */) { + if (template.parent.kind === 195 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -48989,7 +49710,7 @@ var ts; } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 67220415 /* Value */, undefined, id.escapedText, /*isUse*/ true); + var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated) { @@ -49040,7 +49761,7 @@ var ts; return substituteIndexedMappedType(t, propertyNameType); } } - else if (t.flags & 3670016 /* StructuredType */) { + else if (t.flags & 137887744 /* StructuredType */) { var prop = getPropertyOfType(t, name); if (prop) { return getTypeOfSymbol(prop); @@ -49160,26 +49881,29 @@ var ts; case 73 /* Identifier */: case 142 /* UndefinedKeyword */: return true; - case 190 /* PropertyAccessExpression */: - case 196 /* ParenthesizedExpression */: + case 191 /* PropertyAccessExpression */: + case 197 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 271 /* JsxExpression */: + case 272 /* 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 === 276 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 277 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 268 /* 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.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 269 /* 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 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. function getApparentTypeOfContextualType(node, contextFlags) { - var contextualType = instantiateContextualType(getContextualType(node, contextFlags), node, contextFlags); - if (contextualType) { - var apparentType = mapType(contextualType, getApparentType, /*noReductions*/ true); + var contextualType = ts.isObjectLiteralMethod(node) ? + getContextualTypeForObjectLiteralMethod(node, contextFlags) : + getContextualType(node, contextFlags); + var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); + if (instantiatedType) { + var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); if (apparentType.flags & 1048576 /* Union */) { if (ts.isObjectLiteralExpression(node)) { return discriminateContextualTypeByObjectMembers(node, apparentType); @@ -49217,7 +49941,7 @@ var ts; // are classified as instantiable (i.e. it doesn't instantiate object types), and (b) it performs // no reductions on instantiated union types. function instantiateInstantiableTypes(type, mapper) { - if (type.flags & 63176704 /* Instantiable */) { + if (type.flags & (63176704 /* Instantiable */ | 134217728 /* StructuralTag */)) { return instantiateType(type, mapper); } if (type.flags & 1048576 /* Union */) { @@ -49255,58 +49979,58 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 187 /* BindingElement */: + case 239 /* VariableDeclaration */: + case 153 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 188 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 198 /* ArrowFunction */: - case 231 /* ReturnStatement */: + case 199 /* ArrowFunction */: + case 232 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent); - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (parent.expression.kind === 93 /* ImportKeyword */) { return stringType; } /* falls through */ - case 193 /* NewExpression */: + case 194 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 188 /* ArrayLiteralExpression */: { + case 189 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 217 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 207 /* TemplateExpression */); + case 218 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 208 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 196 /* ParenthesizedExpression */: { + case 197 /* 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 271 /* JsxExpression */: + case 272 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: + case 269 /* JsxAttribute */: + case 271 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -49461,7 +50185,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 197 /* FunctionExpression */ || node.kind === 198 /* ArrowFunction */; + return node.kind === 198 /* FunctionExpression */ || node.kind === 199 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -49475,14 +50199,12 @@ 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 !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = ts.isObjectLiteralMethod(node) ? - getContextualTypeForObjectLiteralMethod(node, 1 /* Signature */) : - getApparentTypeOfContextualType(node, 1 /* Signature */); + var type = getApparentTypeOfContextualType(node, 1 /* Signature */); if (!type) { return undefined; } @@ -49491,8 +50213,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var current = types_13[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -49522,8 +50244,8 @@ var ts; return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); } function hasDefaultValue(node) { - return (node.kind === 187 /* BindingElement */ && !!node.initializer) || - (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */); + return (node.kind === 188 /* BindingElement */ && !!node.initializer) || + (node.kind === 206 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -49535,7 +50257,7 @@ var ts; var inConstContext = isConstContext(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 209 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 210 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -49560,12 +50282,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 209 /* SpreadElement */) { + if (index < elementCount - 1 && e.kind === 210 /* SpreadElement */) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 209 /* SpreadElement */; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 210 /* SpreadElement */; var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". @@ -49607,7 +50329,7 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return isNumericComputedName(name); case 73 /* Identifier */: return isNumericLiteralName(name.escapedText); @@ -49697,7 +50419,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 185 /* ObjectBindingPattern */ || contextualType.pattern.kind === 189 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 186 /* ObjectBindingPattern */ || contextualType.pattern.kind === 190 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -49712,13 +50434,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 150 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 151 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 276 /* PropertyAssignment */ || - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 277 /* PropertyAssignment */ || + memberDecl.kind === 278 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 276 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 277 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 278 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -49741,8 +50463,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 === 276 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 277 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 277 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 278 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -49767,7 +50489,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 278 /* SpreadAssignment */) { + else if (memberDecl.kind === 279 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -49793,7 +50515,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 === 159 /* GetAccessor */ || memberDecl.kind === 160 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 160 /* GetAccessor */ || memberDecl.kind === 161 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -49853,7 +50575,13 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (3 /* AnyOrUnknown */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || + if (type.flags & 63176704 /* Instantiable */) { + var constraint = getBaseConstraintOfType(type); + if (constraint !== undefined) { + return isValidSpreadType(constraint); + } + } + return !!(type.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 134217728 /* StructuralTag */ | 58982400 /* InstantiableNonPrimitive */) || getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } @@ -49946,7 +50674,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 270 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 271 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -49969,7 +50697,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 261 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 262 /* 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); @@ -50043,7 +50771,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 67897832 /* Type */); + var typeSymbol = exports && getSymbol(exports, name, 788968 /* Type */); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** @@ -50117,7 +50845,7 @@ var ts; */ function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 67897832 /* Type */); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* Type */); // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute @@ -50141,7 +50869,7 @@ var ts; } function getJsxLibraryManagedAttributes(jsxNamespace) { // JSX.LibraryManagedAttributes [symbol] - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67897832 /* Type */); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* Type */); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -50293,13 +51021,13 @@ var ts; var reactRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var reactNamespace = getJsxNamespace(node); var reactLocation = isNodeOpeningLikeElement ? node.tagName : node; - var reactSym = resolveName(reactLocation, reactNamespace, 67220415 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); + var reactSym = resolveName(reactLocation, reactNamespace, 111551 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); if (reactSym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not react as there wont be error being emitted reactSym.isReferenced = 67108863 /* All */; - // If react symbol is alias, mark it as referenced - if (reactSym.flags & 2097152 /* Alias */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { + // If react symbol is alias, mark it as refereced + if (reactSym.flags & 2097152 /* Alias */) { markAliasSymbolAsReferenced(reactSym); } } @@ -50388,7 +51116,7 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 149 /* QualifiedName */ ? node.right : node.kind === 184 /* ImportType */ ? node : node.name; + var errorNode = node.kind === 150 /* QualifiedName */ ? node.right : node.kind === 185 /* ImportType */ ? node : node.name; if (ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */) { // Synthetic property with private constituent property error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); @@ -50523,7 +51251,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } function isMethodAccessForCall(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */) { + while (node.parent.kind === 197 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -50589,7 +51317,7 @@ var ts; // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (node.kind !== 191 /* ElementAccessExpression */ && node.kind !== 190 /* PropertyAccessExpression */ || + if (node.kind !== 192 /* ElementAccessExpression */ && node.kind !== 191 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; @@ -50603,7 +51331,7 @@ var ts; var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 158 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 159 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -50624,7 +51352,7 @@ var ts; } function checkPropertyNotUsedBeforeDeclaration(prop, node, right) { var valueDeclaration = prop.valueDeclaration; - if (!valueDeclaration) { + if (!valueDeclaration || ts.getSourceFileOfNode(node).isDeclarationFile) { return; } var diagnosticMessage; @@ -50634,8 +51362,8 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 241 /* ClassDeclaration */ && - node.parent.kind !== 165 /* TypeReference */ && + else if (valueDeclaration.kind === 242 /* ClassDeclaration */ && + node.parent.kind !== 166 /* TypeReference */ && !(valueDeclaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -50647,22 +51375,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return true; - case 276 /* PropertyAssignment */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 278 /* SpreadAssignment */: - case 150 /* ComputedPropertyName */: - case 217 /* TemplateSpan */: - case 271 /* JsxExpression */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 263 /* JsxOpeningElement */: - case 212 /* ExpressionWithTypeArguments */: - case 274 /* HeritageClause */: + case 277 /* PropertyAssignment */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 279 /* SpreadAssignment */: + case 151 /* ComputedPropertyName */: + case 218 /* TemplateSpan */: + case 272 /* JsxExpression */: + case 269 /* JsxAttribute */: + case 270 /* JsxAttributes */: + case 271 /* JsxSpreadAttribute */: + case 264 /* JsxOpeningElement */: + case 213 /* ExpressionWithTypeArguments */: + case 275 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -50702,7 +51430,7 @@ var ts; if (containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; - if (!getPropertyOfType(subtype, propNode.escapedText)) { + if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0 /* String */)) { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); break; } @@ -50740,7 +51468,7 @@ var ts; return prop !== undefined && prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 32 /* Static */); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { - return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67220415 /* Value */); + return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551 /* Value */); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -50835,16 +51563,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return isValidPropertyAccessWithType(node, node.expression.kind === 99 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 184 /* ImportType */: + case 185 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 190 /* PropertyAccessExpression */ && node.expression.kind === 99 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 191 /* PropertyAccessExpression */ && node.expression.kind === 99 /* 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) { @@ -50861,7 +51589,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer.kind === 240 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -50890,7 +51618,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 227 /* ForInStatement */ && + if (node.kind === 228 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -50907,20 +51635,6 @@ var ts; var exprType = checkNonNullExpression(node.expression); var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; - if (!indexExpression) { - var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 193 /* NewExpression */ && node.parent.expression === node) { - var start = ts.skipTrivia(sourceFile.text, node.expression.end); - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - return errorType; - } var indexType = checkExpression(indexExpression); if (objectType === errorType || objectType === silentNeverType) { return objectType; @@ -50980,13 +51694,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 195 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 153 /* Decorator */) { + else if (node.kind !== 154 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -51050,7 +51764,7 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 209 /* SpreadElement */ || arg.kind === 216 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 210 /* SpreadElement */ || arg.kind === 217 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -51064,9 +51778,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 === 194 /* TaggedTemplateExpression */) { + if (node.kind === 195 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 207 /* TemplateExpression */) { + if (node.template.kind === 208 /* 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. @@ -51081,7 +51795,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 153 /* Decorator */) { + else if (node.kind === 154 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -51096,7 +51810,7 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 193 /* NewExpression */); + ts.Debug.assert(node.kind === 194 /* NewExpression */); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -51189,7 +51903,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 !== 153 /* Decorator */) { + if (node.kind !== 154 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -51232,7 +51946,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 !== 211 /* OmittedExpression */) { + if (arg.kind !== 212 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -51256,7 +51970,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 arg.kind === 216 /* SyntheticExpression */ ? + return arg.kind === 217 /* SyntheticExpression */ ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0 /* Normal */)); } @@ -51331,12 +52045,12 @@ var ts; if (ts.isJsxOpeningLikeElement(node)) { if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 193 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 194 /* 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. @@ -51346,7 +52060,7 @@ var ts; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; @@ -51354,7 +52068,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 !== 211 /* OmittedExpression */) { + if (arg.kind !== 212 /* 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), @@ -51364,7 +52078,7 @@ var ts; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } } @@ -51374,7 +52088,7 @@ var ts; if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, /*containingMessageChain*/ undefined, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(errorNode, spreadType, restType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } return undefined; @@ -51395,15 +52109,15 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 193 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 190 /* PropertyAccessExpression */ || callee.kind === 191 /* ElementAccessExpression */) { + if (callee.kind === 191 /* PropertyAccessExpression */ || callee.kind === 192 /* ElementAccessExpression */) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(216 /* SyntheticExpression */, parent.pos, parent.end); + var result = ts.createNode(217 /* SyntheticExpression */, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; @@ -51413,17 +52127,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 195 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 207 /* TemplateExpression */) { + if (template.kind === 208 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 153 /* Decorator */) { + if (node.kind === 154 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -51453,30 +52167,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* 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 152 /* Parameter */: + case 153 /* 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 === 158 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 159 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* 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 !== 155 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 156 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -51490,17 +52204,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return 1; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return 2; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* 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 152 /* Parameter */: + case 153 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -51625,8 +52339,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, fallbackError) { - var isTaggedTemplate = node.kind === 194 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 153 /* Decorator */; + var isTaggedTemplate = node.kind === 195 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 154 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; @@ -51688,7 +52402,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 === 192 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 193 /* 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 @@ -52224,8 +52938,8 @@ var ts; if (apparentType.flags & 1048576 /* Union */) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var constituent = types_15[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var constituent = types_14[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -52323,16 +53037,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 152 /* Parameter */: + case 153 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -52376,8 +53090,8 @@ var ts; var exports = namespace && getExportsOfSymbol(namespace); // We fake up a SFC signature for each intrinsic, however a more specific per-element signature drawn from the JSX declaration // file would probably be preferable. - var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 67897832 /* Type */); - var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 67897832 /* Type */, node); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node); var declaration = ts.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.createKeywordTypeNode(121 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; @@ -52425,16 +53139,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 192 /* CallExpression */: + case 193 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 153 /* Decorator */: + case 154 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -52485,43 +53199,45 @@ var ts; return true; // If the symbol of the node has members, treat it like a constructor. var symbol = getSymbolOfNode(func); - return !!symbol && (symbol.members !== undefined || symbol.exports !== undefined && symbol.exports.get("prototype") !== undefined); + return !!symbol && ts.hasEntries(symbol.members); } return false; } - function isJSConstructorType(type) { - if (type.flags & 524288 /* Object */) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); - } - return false; - } - function getJSClassType(symbol) { - var inferred; - if (isJSConstructor(symbol.valueDeclaration)) { - inferred = getInferredClassType(symbol); + function mergeJSSymbols(target, source) { + if (source && (ts.hasEntries(source.exports) || ts.hasEntries(source.members))) { + var links = getSymbolLinks(source); + if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) { + var inferred = isTransientSymbol(target) ? target : cloneSymbol(target); + inferred.exports = inferred.exports || ts.createSymbolTable(); + inferred.members = inferred.members || ts.createSymbolTable(); + inferred.flags |= source.flags & 32 /* Class */; + if (ts.hasEntries(source.exports)) { + mergeSymbolTable(inferred.exports, source.exports); + } + if (ts.hasEntries(source.members)) { + mergeSymbolTable(inferred.members, source.members); + } + (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred); + return inferred; + } + return links.inferredClassSymbol.get("" + getSymbolId(target)); } - var assigned = getAssignedClassType(symbol); - return assigned && inferred ? - getIntersectionType([inferred, assigned]) : - assigned || inferred; } - function getAssignedClassType(symbol) { - var decl = symbol.valueDeclaration; + function getAssignedClassSymbol(decl) { var assignmentSymbol = decl && decl.parent && (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype"); var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration); - return init ? getWidenedType(checkExpressionCached(init)) : undefined; + return init ? getSymbolOfNode(init) : undefined; } function getAssignedJSPrototype(node) { if (!node.parent) { return false; } var parent = node.parent; - while (parent && parent.kind === 190 /* PropertyAccessExpression */) { + while (parent && parent.kind === 191 /* PropertyAccessExpression */) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 60 /* EqualsToken */) { @@ -52529,13 +53245,6 @@ var ts; return ts.isObjectLiteralExpression(right) && right; } } - function getInferredClassType(symbol) { - var links = getSymbolLinks(symbol); - if (!links.inferredClassType) { - links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol) || emptySymbols, ts.emptyArray, ts.emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined); - } - return links.inferredClassType; - } /** * Syntactically and semantically checks a call or new expression. * @param node The call/new expression to be checked. @@ -52553,12 +53262,12 @@ var ts; if (node.expression.kind === 99 /* SuperKeyword */) { return voidType; } - if (node.kind === 193 /* NewExpression */) { + if (node.kind === 194 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 158 /* Constructor */ && - declaration.kind !== 162 /* ConstructSignature */ && - declaration.kind !== 167 /* ConstructorType */ && + declaration.kind !== 159 /* Constructor */ && + declaration.kind !== 163 /* ConstructSignature */ && + declaration.kind !== 168 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -52606,7 +53315,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } function checkImportCallExpression(node) { // Check grammar of dynamic import @@ -52666,7 +53375,7 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } @@ -52675,9 +53384,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 240 /* FunctionDeclaration */ + ? 241 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 238 /* VariableDeclaration */ + ? 239 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -52704,18 +53413,18 @@ var ts; case 9 /* BigIntLiteral */: case 103 /* TrueKeyword */: case 88 /* FalseKeyword */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return true; - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; return op === 39 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || op === 38 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -52765,7 +53474,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 === 158 /* Constructor */) { + else if (container.kind === 159 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -52775,8 +53484,8 @@ var ts; } } function checkImportMetaProperty(node) { - if (languageVersion < 99 /* ESNext */ || moduleKind < ts.ModuleKind.ESNext) { - error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options); + if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) { + error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system); } var file = ts.getSourceFileOfNode(node); ts.Debug.assert(!!(file.flags & 1048576 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); @@ -52966,7 +53675,7 @@ var ts; links.type = contextualType; var decl = parameter.valueDeclaration; if (decl.name.kind !== 73 /* Identifier */) { - // if inference didn't come up with anything but {}, fall back to the binding pattern if present. + // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(decl.name); } @@ -53020,7 +53729,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 219 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 220 /* 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 @@ -53092,7 +53801,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* Next */, func) || unknownType, isAsync); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -53206,14 +53915,14 @@ var ts; if (!node.possiblyExhaustive) { return false; } - if (node.expression.kind === 200 /* TypeOfExpression */) { + if (node.expression.kind === 201 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); // This cast is safe because the switch is possibly exhaustive and does not contain a default case, so there can be no undefined. var witnesses = getSwitchClauseTypeOfWitnesses(node); // notEqualFacts states that the type of the switched value is not equal to every type in the switch. var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true); - var type_5 = getBaseConstraintOfType(operandType) || operandType; - return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); + var type_4 = getBaseConstraintOfType(operandType) || operandType; + return !!(filterType(type_4, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -53229,7 +53938,7 @@ var ts; if (!(func.flags & 128 /* HasImplicitReturn */)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 233 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 234 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -53272,11 +53981,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return true; - case 157 /* MethodDeclaration */: - return func.parent.kind === 189 /* ObjectLiteralExpression */; + case 158 /* MethodDeclaration */: + return func.parent.kind === 190 /* ObjectLiteralExpression */; default: return false; } @@ -53302,7 +54011,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 156 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 219 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 157 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 220 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -53335,7 +54044,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 /* 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)) { @@ -53355,7 +54064,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 197 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 198 /* FunctionExpression */) { checkGrammarForGenerator(node); } var type = getTypeOfSymbol(getMergedSymbol(node.symbol)); @@ -53409,7 +54118,7 @@ var ts; type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -53422,7 +54131,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 219 /* Block */) { + if (node.body.kind === 220 /* Block */) { checkSourceElement(node.body); } else { @@ -53503,11 +54212,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) && + (expr.kind === 191 /* PropertyAccessExpression */ || expr.kind === 192 /* ElementAccessExpression */) && expr.expression.kind === 101 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 158 /* Constructor */)) { + if (!(func && func.kind === 159 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -53520,13 +54229,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) { + if (expr.kind === 191 /* PropertyAccessExpression */ || expr.kind === 192 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); if (node.kind === 73 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 252 /* NamespaceImport */; + return !!declaration && declaration.kind === 253 /* NamespaceImport */; } } } @@ -53535,7 +54244,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 73 /* Identifier */ && node.kind !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 73 /* Identifier */ && node.kind !== 191 /* PropertyAccessExpression */ && node.kind !== 192 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -53544,7 +54253,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 190 /* PropertyAccessExpression */ && expr.kind !== 191 /* ElementAccessExpression */) { + if (expr.kind !== 191 /* PropertyAccessExpression */ && expr.kind !== 192 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -53573,7 +54282,7 @@ var ts; var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); var func = ts.getContainingFunction(node); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 159 /* 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); @@ -53586,7 +54295,11 @@ var ts; } } var operandType = checkExpression(node.expression); - return checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + var awaitedType = checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + if (awaitedType === operandType && awaitedType !== errorType && !(operandType.flags & 3 /* AnyOrUnknown */)) { + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); + } + return awaitedType; } function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); @@ -53620,7 +54333,7 @@ var ts; } if (node.operator === 38 /* PlusToken */) { if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { - error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(operandType)); + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } @@ -53671,8 +54384,8 @@ var ts; } if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -53761,7 +54474,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 276 /* PropertyAssignment */ || property.kind === 277 /* ShorthandPropertyAssignment */) { + if (property.kind === 277 /* PropertyAssignment */ || property.kind === 278 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -53774,9 +54487,9 @@ var ts; } var elementType = getIndexedAccessType(objectLiteralType, exprType, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 277 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 278 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 278 /* SpreadAssignment */) { + else if (property.kind === 279 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -53819,8 +54532,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 211 /* OmittedExpression */) { - if (element.kind !== 209 /* SpreadElement */) { + if (element.kind !== 212 /* OmittedExpression */) { + if (element.kind !== 210 /* SpreadElement */) { var indexType = getLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused @@ -53838,7 +54551,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 205 /* BinaryExpression */ && restExpression.operatorToken.kind === 60 /* EqualsToken */) { + if (restExpression.kind === 206 /* BinaryExpression */ && restExpression.operatorToken.kind === 60 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -53854,7 +54567,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 277 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 278 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -53870,21 +54583,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 205 /* BinaryExpression */ && target.operatorToken.kind === 60 /* EqualsToken */) { + if (target.kind === 206 /* BinaryExpression */ && target.operatorToken.kind === 60 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 189 /* ObjectLiteralExpression */) { + if (target.kind === 190 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 188 /* ArrayLiteralExpression */) { + if (target.kind === 189 /* 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 === 278 /* SpreadAssignment */ ? + var error = target.parent.kind === 279 /* 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; if (checkReferenceExpression(target, error)) { @@ -53906,8 +54619,8 @@ var ts; case 73 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 194 /* TaggedTemplateExpression */: - case 207 /* TemplateExpression */: + case 195 /* TaggedTemplateExpression */: + case 208 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: @@ -53915,27 +54628,27 @@ var ts; case 88 /* FalseKeyword */: case 97 /* NullKeyword */: case 142 /* UndefinedKeyword */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 200 /* TypeOfExpression */: - case 214 /* NonNullExpression */: - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: + case 198 /* FunctionExpression */: + case 211 /* ClassExpression */: + case 199 /* ArrowFunction */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: + case 201 /* TypeOfExpression */: + case 215 /* NonNullExpression */: + case 263 /* JsxSelfClosingElement */: + case 262 /* JsxElement */: return true; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -53947,9 +54660,9 @@ var ts; } return false; // Some forms listed here for clarity - case 201 /* VoidExpression */: // Explicit opt-out - case 195 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 213 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 202 /* VoidExpression */: // Explicit opt-out + case 196 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 214 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -53965,7 +54678,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 60 /* EqualsToken */ && (left.kind === 189 /* ObjectLiteralExpression */ || left.kind === 188 /* ArrayLiteralExpression */)) { + if (operator === 60 /* EqualsToken */ && (left.kind === 190 /* ObjectLiteralExpression */ || left.kind === 189 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 101 /* ThisKeyword */); } var leftType; @@ -54025,7 +54738,7 @@ var ts; resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */)) { + else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { case 48 /* GreaterThanGreaterThanGreaterThanToken */: case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: @@ -54035,7 +54748,7 @@ var ts; } // Exactly one of leftType/rightType is assignable to bigint else { - reportOperatorError(function (awaitedLeft, awaitedRight) { return isTypeAssignableToKind(awaitedLeft, 2112 /* BigIntLike */) && isTypeAssignableToKind(awaitedRight, 2112 /* BigIntLike */); }); + reportOperatorError(bothAreBigIntLike); resultType_1 = errorType; } if (leftOk && rightOk) { @@ -54081,9 +54794,9 @@ var ts; // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 3 /* AnyOrUnknown */; - reportOperatorError(function (awaitedLeft, awaitedRight) { - return isTypeAssignableToKind(awaitedLeft, closeEnoughKind_1) && - isTypeAssignableToKind(awaitedRight, closeEnoughKind_1); + reportOperatorError(function (left, right) { + return isTypeAssignableToKind(left, closeEnoughKind_1) && + isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } @@ -54148,6 +54861,9 @@ var ts; default: return ts.Debug.fail(); } + function bothAreBigIntLike(left, right) { + return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + } function checkAssignmentDeclaration(kind, rightType) { if (kind === 2 /* ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { @@ -54155,7 +54871,7 @@ var ts; var propType = getTypeOfSymbol(prop); if (propType.symbol && propType.symbol.flags & 32 /* Class */) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 67897832 /* Type */, undefined, name, /*isUse*/ false); + var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) { grammarErrorOnNode(symbol.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); return grammarErrorOnNode(prop.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); @@ -54235,17 +54951,23 @@ var ts; } return false; } - function reportOperatorError(awaitedTypesAreCompatible) { + function reportOperatorError(isRelated) { + var _a; var wouldWorkWithAwait = false; var errNode = errorNode || operatorToken; - var _a = getTypeNamesForErrorDisplay(leftType, rightType), leftStr = _a[0], rightStr = _a[1]; - if (awaitedTypesAreCompatible) { + if (isRelated) { var awaitedLeftType = getAwaitedType(leftType); var awaitedRightType = getAwaitedType(rightType); wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType) && !!(awaitedLeftType && awaitedRightType) - && awaitedTypesAreCompatible(awaitedLeftType, awaitedRightType); + && isRelated(awaitedLeftType, awaitedRightType); + } + var effectiveLeft = leftType; + var effectiveRight = rightType; + if (!wouldWorkWithAwait && isRelated) { + _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1]; } + var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1]; if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) { errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); } @@ -54267,6 +54989,17 @@ var ts; return undefined; } } + function getBaseTypesIfUnrelated(leftType, rightType, isRelated) { + var effectiveLeft = leftType; + var effectiveRight = rightType; + var leftBase = getBaseTypeOfLiteralType(leftType); + var rightBase = getBaseTypeOfLiteralType(rightType); + if (!isRelated(leftBase, rightBase)) { + effectiveLeft = leftBase; + effectiveRight = rightBase; + } + return [effectiveLeft, effectiveRight]; + } function isYieldExpressionInClass(node) { var current = node; var parent = node.parent; @@ -54334,12 +55067,7 @@ var ts; return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync) || anyType; } - var contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, contextualReturnType, isAsync) - || anyType; - } - return anyType; + return getContextualIterationType(2 /* Next */, func) || anyType; } function checkConditionalExpression(node, checkMode) { checkTruthinessExpression(node.condition); @@ -54361,7 +55089,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 269 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 270 /* 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; @@ -54400,12 +55128,12 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 195 /* TypeAssertionExpression */ || node.kind === 213 /* AsExpression */; + return node.kind === 196 /* TypeAssertionExpression */ || node.kind === 214 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, /*cache*/ true); - var padded = ts.isParameter(declaration) && declaration.name.kind === 186 /* ArrayBindingPattern */ && + var padded = ts.isParameter(declaration) && declaration.name.kind === 187 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || @@ -54430,7 +55158,7 @@ var ts; var elementTypes = arity ? type.typeArguments.slice() : []; for (var i = arity; i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 187 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 188 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); @@ -54482,7 +55210,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -54493,7 +55221,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -54636,7 +55364,7 @@ var ts; var expr = ts.skipParentheses(node); // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (expr.kind === 192 /* CallExpression */ && expr.expression.kind !== 99 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (expr.kind === 193 /* CallExpression */ && expr.expression.kind !== 99 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var funcType = checkNonNullExpression(expr.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -54686,10 +55414,11 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 191 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 168 /* TypeQuery */ && node.parent.exprName === node)); + var ok = (node.parent.kind === 191 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 192 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 73 /* Identifier */ || node.kind === 150 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 169 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 259 /* ExportSpecifier */ && (compilerOptions.preserveConstEnums || node.flags & 4194304 /* Ambient */)); // 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); } @@ -54709,7 +55438,18 @@ var ts; return checkExpression(node.expression, checkMode); } function checkExpressionWorker(node, checkMode, forceTuple) { - switch (node.kind) { + var kind = node.kind; + if (cancellationToken) { + // 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 211 /* ClassExpression */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + cancellationToken.throwIfCancellationRequested(); + } + } + switch (kind) { case 73 /* Identifier */: return checkIdentifier(node); case 101 /* ThisKeyword */: @@ -54731,78 +55471,78 @@ var ts; return trueType; case 88 /* FalseKeyword */: return falseType; - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return checkQualifiedName(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (node.expression.kind === 93 /* ImportKeyword */) { return checkImportCallExpression(node); } - /* falls through */ - case 193 /* NewExpression */: + // falls through + case 194 /* NewExpression */: return checkCallExpression(node, checkMode); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return checkClassExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: return checkAssertion(node); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: return checkNonNullAssertion(node); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return checkMetaProperty(node); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return checkDeleteExpression(node); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return checkVoidExpression(node); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return checkAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 211 /* OmittedExpression */: + case 212 /* OmittedExpression */: return undefinedWideningType; - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return checkYieldExpression(node); - case 216 /* SyntheticExpression */: + case 217 /* SyntheticExpression */: return node.type; - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 261 /* JsxElement */: + case 262 /* JsxElement */: return checkJsxElement(node, checkMode); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return checkJsxFragment(node); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 263 /* JsxOpeningElement */: + case 264 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -54839,7 +55579,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 158 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 159 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -54850,10 +55590,10 @@ 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 === 158 /* Constructor */ || func.kind === 162 /* ConstructSignature */ || func.kind === 167 /* ConstructorType */) { + if (func.kind === 159 /* Constructor */ || func.kind === 163 /* ConstructSignature */ || func.kind === 168 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 199 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -54909,13 +55649,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 198 /* ArrowFunction */: - case 161 /* CallSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 166 /* FunctionType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 199 /* ArrowFunction */: + case 162 /* CallSignature */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 167 /* FunctionType */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -54933,7 +55673,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 === 186 /* ArrayBindingPattern */ || name.kind === 185 /* ObjectBindingPattern */) { + else if (name.kind === 187 /* ArrayBindingPattern */ || name.kind === 186 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -54942,13 +55682,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 164 /* 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 === 166 /* FunctionType */ || node.kind === 240 /* FunctionDeclaration */ || node.kind === 167 /* ConstructorType */ || - node.kind === 161 /* CallSignature */ || node.kind === 158 /* Constructor */ || - node.kind === 162 /* ConstructSignature */) { + else if (node.kind === 167 /* FunctionType */ || node.kind === 241 /* FunctionDeclaration */ || node.kind === 168 /* ConstructorType */ || + node.kind === 162 /* CallSignature */ || node.kind === 159 /* Constructor */ || + node.kind === 163 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -54978,10 +55718,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 161 /* CallSignature */: + case 162 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -55011,28 +55751,21 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 163 /* IndexSignature */ && node.kind !== 295 /* JSDocFunctionType */) { + if (node.kind !== 164 /* IndexSignature */ && node.kind !== 296 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } } function checkClassForDuplicateDeclarations(node) { - var Declaration; - (function (Declaration) { - Declaration[Declaration["Getter"] = 1] = "Getter"; - Declaration[Declaration["Setter"] = 2] = "Setter"; - Declaration[Declaration["Method"] = 4] = "Method"; - Declaration[Declaration["Property"] = 3] = "Property"; - })(Declaration || (Declaration = {})); var instanceNames = ts.createUnderscoreEscapedMap(); var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 158 /* Constructor */) { + if (member.kind === 159 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; - if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { - addName(instanceNames, param.name, param.name.escapedText, 3 /* Property */); + if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { + addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); } } } @@ -55043,17 +55776,17 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 159 /* GetAccessor */: - addName(names, name, memberName, 1 /* Getter */); + case 160 /* GetAccessor */: + addName(names, name, memberName, 1 /* GetAccessor */); break; - case 160 /* SetAccessor */: - addName(names, name, memberName, 2 /* Setter */); + case 161 /* SetAccessor */: + addName(names, name, memberName, 2 /* SetAccessor */); break; - case 155 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* Property */); + case 156 /* PropertyDeclaration */: + addName(names, name, memberName, 3 /* GetOrSetAccessor */); break; - case 157 /* MethodDeclaration */: - addName(names, name, memberName, 4 /* Method */); + case 158 /* MethodDeclaration */: + addName(names, name, memberName, 8 /* Method */); break; } } @@ -55062,8 +55795,8 @@ var ts; function addName(names, location, name, meaning) { var prev = names.get(name); if (prev) { - if (prev & 4 /* Method */) { - if (meaning !== 4 /* Method */) { + if (prev & 8 /* Method */) { + if (meaning !== 8 /* Method */) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } } @@ -55115,7 +55848,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154 /* PropertySignature */) { + if (member.kind === 155 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -55140,7 +55873,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 243 /* 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 @@ -55195,7 +55928,7 @@ var ts; 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.hasModifier(node, 128 /* Abstract */) && node.kind === 157 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 158 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -55220,7 +55953,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 155 /* PropertyDeclaration */ && + return n.kind === 156 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -55250,7 +55983,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 223 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -55275,7 +56008,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 160 /* GetAccessor */) { if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -55285,13 +56018,13 @@ 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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(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 === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = node.kind === 160 /* GetAccessor */ ? 161 /* SetAccessor */ : 160 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -55309,7 +56042,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 160 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -55357,7 +56090,7 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 165 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 166 /* 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); } var type = getTypeFromTypeReference(node); @@ -55405,7 +56138,7 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 173 /* RestType */) { + if (e.kind === 174 /* RestType */) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; @@ -55414,7 +56147,7 @@ var ts; error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 172 /* OptionalType */) { + else if (e.kind === 173 /* OptionalType */) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -55435,7 +56168,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 191 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 192 /* 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)); } @@ -55486,7 +56219,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 176 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 177 /* 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); @@ -55503,9 +56236,9 @@ var ts; var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 242 /* InterfaceDeclaration */ && - n.parent.kind !== 241 /* ClassDeclaration */ && - n.parent.kind !== 210 /* ClassExpression */ && + if (n.parent.kind !== 243 /* InterfaceDeclaration */ && + n.parent.kind !== 242 /* ClassDeclaration */ && + n.parent.kind !== 211 /* ClassExpression */ && n.flags & 4194304 /* 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 @@ -55596,7 +56329,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */) && + var reportError = (node.kind === 158 /* MethodDeclaration */ || node.kind === 157 /* MethodSignature */) && ts.hasModifier(node, 32 /* Static */) !== ts.hasModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -55631,11 +56364,12 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; + var hasNonAmbientClass = false; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 242 /* InterfaceDeclaration */ || node.parent.kind === 169 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 243 /* InterfaceDeclaration */ || node.parent.kind === 170 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -55646,7 +56380,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 240 /* FunctionDeclaration */ || node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */ || node.kind === 158 /* Constructor */) { + if ((node.kind === 242 /* ClassDeclaration */ || node.kind === 211 /* ClassExpression */) && !inAmbientContext) { + hasNonAmbientClass = true; + } + if (node.kind === 241 /* FunctionDeclaration */ || node.kind === 158 /* MethodDeclaration */ || node.kind === 157 /* MethodSignature */ || node.kind === 159 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -55687,6 +56424,15 @@ var ts; error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Duplicate_function_implementation); }); } + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */) { + // A non-ambient class cannot be an implementation for a non-constructor function/class merge + // TODO: The below just replicates our older error from when classes and functions were + // entirely unable to merge - a more helpful message like "Class declaration cannot implement overload list" + // might be warranted. :shrug: + ts.forEach(declarations, function (declaration) { + addDuplicateDeclarationError(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), ts.filter(declarations, function (d) { return d !== declaration; })); + }); + } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && !ts.hasModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { @@ -55708,13 +56454,6 @@ var ts; } } } - var DeclarationSpaces; - (function (DeclarationSpaces) { - DeclarationSpaces[DeclarationSpaces["None"] = 0] = "None"; - DeclarationSpaces[DeclarationSpaces["ExportValue"] = 1] = "ExportValue"; - DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; - DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; - })(DeclarationSpaces || (DeclarationSpaces = {})); function checkExportsOnMergedDeclarations(node) { if (!produceDiagnostics) { return; @@ -55775,40 +56514,42 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - // A jsdoc typedef and callback are, by definition, type aliases - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + // A jsdoc typedef and callback are, by definition, type aliases. + // falls through + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: return 2 /* ExportType */; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 285 /* SourceFile */: + case 286 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; } d = d.expression; - /* falls through */ - // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + // The below options all declare an Alias, which is allowed to merge with other values within the importing module. + // falls through + case 250 /* ImportEqualsDeclaration */: + case 253 /* NamespaceImport */: + case 252 /* ImportClause */: var result_8 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_8 |= getDeclarationSpaces(d); }); return result_8; - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 240 /* FunctionDeclaration */: - case 254 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 239 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 241 /* FunctionDeclaration */: + case 255 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); @@ -55877,9 +56618,6 @@ var ts; */ function checkAwaitedType(type, errorNode, diagnosticMessage, arg0) { var awaitedType = getAwaitedType(type, errorNode, diagnosticMessage, arg0); - if (awaitedType === type && !(type.flags & 3 /* AnyOrUnknown */)) { - addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(errorNode, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); - } return awaitedType || errorType; } function getAwaitedType(type, errorNode, diagnosticMessage, arg0) { @@ -56038,7 +56776,7 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67220415 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { if (promiseConstructorName.kind === 73 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { @@ -56061,7 +56799,7 @@ var ts; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 67220415 /* Value */); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -56080,24 +56818,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 152 /* Parameter */: + case 153 /* 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 155 /* PropertyDeclaration */: + case 156 /* 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 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -56118,7 +56856,7 @@ var ts; if (!typeName) return; var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 73 /* Identifier */ ? 67897832 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 73 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -56143,23 +56881,23 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 176 /* IntersectionType */: + case 175 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return node.typeName; } } } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var typeNode = types_17[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var typeNode = types_16[_i]; + while (typeNode.kind === 179 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 133 /* NeverKeyword */) { @@ -56211,14 +56949,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 152 /* Parameter */) { + if (node.kind === 153 /* 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 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -56227,23 +56965,23 @@ var ts; } } break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - var otherKind = node.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + var otherKind = node.kind === 160 /* GetAccessor */ ? 161 /* SetAccessor */ : 160 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 157 /* MethodDeclaration */: + case 158 /* 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 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 152 /* Parameter */: + case 153 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -56306,7 +57044,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 === 149 /* 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 === 150 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -56341,7 +57079,7 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return node; - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -56354,7 +57092,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 151 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -56383,7 +57121,7 @@ var ts; } } } - var body = node.kind === 156 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 157 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -56425,42 +57163,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 285 /* SourceFile */: - case 245 /* ModuleDeclaration */: - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 286 /* SourceFile */: + case 246 /* ModuleDeclaration */: + case 220 /* Block */: + case 248 /* CaseBlock */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 159 /* Constructor */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 177 /* InferType */: + case 178 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -56480,11 +57218,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 157 /* MethodDeclaration */: - case 155 /* PropertyDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - if (member.kind === 160 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 158 /* MethodDeclaration */: + case 156 /* PropertyDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + if (member.kind === 161 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -56493,7 +57231,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 158 /* Constructor */: + case 159 /* Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { @@ -56501,8 +57239,8 @@ var ts; } } break; - case 163 /* IndexSignature */: - case 218 /* SemicolonClassElement */: + case 164 /* IndexSignature */: + case 219 /* SemicolonClassElement */: // Can't be private break; default: @@ -56529,7 +57267,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 177 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 178 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) // Whole @template tag @@ -56599,7 +57337,7 @@ var ts; var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -56614,7 +57352,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 252 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 253 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -56632,7 +57370,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 === 238 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 239 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 239 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 240 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -56653,7 +57391,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 === 220 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 221 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -56667,22 +57405,22 @@ var ts; switch (name.kind) { case 73 /* Identifier */: return ts.idText(name); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 251 /* ImportClause */ || node.kind === 254 /* ImportSpecifier */ || node.kind === 252 /* NamespaceImport */; + return node.kind === 252 /* ImportClause */ || node.kind === 255 /* ImportSpecifier */ || node.kind === 253 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 251 /* ImportClause */ ? decl : decl.kind === 252 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 252 /* ImportClause */ ? decl : decl.kind === 253 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 219 /* Block */) { + if (node.kind === 220 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -56712,12 +57450,12 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 155 /* PropertyDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 157 /* MethodDeclaration */ || - node.kind === 156 /* MethodSignature */ || - node.kind === 159 /* GetAccessor */ || - node.kind === 160 /* SetAccessor */) { + if (node.kind === 156 /* PropertyDeclaration */ || + node.kind === 155 /* PropertySignature */ || + node.kind === 158 /* MethodDeclaration */ || + node.kind === 157 /* MethodSignature */ || + node.kind === 160 /* GetAccessor */ || + node.kind === 161 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -56726,7 +57464,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 152 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 153 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -56777,7 +57515,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 === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 286 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -56792,7 +57530,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 === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 286 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(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)); } @@ -56827,7 +57565,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 === 238 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 239 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -56839,17 +57577,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 239 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 220 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 240 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 221 /* 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 === 219 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 246 /* ModuleBlock */ || - container.kind === 245 /* ModuleDeclaration */ || - container.kind === 285 /* SourceFile */); + (container.kind === 220 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 247 /* ModuleBlock */ || + container.kind === 246 /* ModuleDeclaration */ || + container.kind === 286 /* 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 @@ -56879,18 +57617,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 187 /* BindingElement */) { - if (node.parent.kind === 185 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (node.kind === 188 /* BindingElement */) { + if (node.parent.kind === 186 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 150 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -56911,19 +57649,19 @@ var ts; } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 186 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 187 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 152 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 153 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 227 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 228 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -56960,7 +57698,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 227 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 228 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -56986,10 +57724,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */) { + if (node.kind !== 156 /* PropertyDeclaration */ && node.kind !== 155 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 239 /* VariableDeclaration */ || node.kind === 188 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -56998,7 +57736,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 155 /* PropertyDeclaration */ || nextDeclaration.kind === 154 /* PropertySignature */ + var message = nextDeclaration.kind === 156 /* PropertyDeclaration */ || nextDeclaration.kind === 155 /* 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); @@ -57008,8 +57746,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 152 /* Parameter */ && right.kind === 238 /* VariableDeclaration */) || - (left.kind === 238 /* VariableDeclaration */ && right.kind === 152 /* Parameter */)) { + if ((left.kind === 153 /* Parameter */ && right.kind === 239 /* VariableDeclaration */) || + (left.kind === 239 /* VariableDeclaration */ && right.kind === 153 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -57048,7 +57786,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkTruthinessExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 221 /* EmptyStatement */) { + if (node.thenStatement.kind === 222 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -57075,12 +57813,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 240 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 240 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -57114,14 +57852,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 === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 240 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 189 /* ArrayLiteralExpression */ || varExpr.kind === 190 /* 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. @@ -57153,7 +57891,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 === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 240 /* 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); @@ -57167,7 +57905,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 === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 189 /* ArrayLiteralExpression */ || varExpr.kind === 190 /* 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)) { @@ -57831,12 +58569,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 === 160 /* SetAccessor */) { + if (func.kind === 161 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 158 /* Constructor */) { + else if (func.kind === 159 /* 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); } @@ -57854,7 +58592,7 @@ var ts; } } } - else if (func.kind !== 158 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 159 /* 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); } @@ -57883,7 +58621,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 === 273 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 274 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -57895,7 +58633,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 272 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 273 /* 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. @@ -57924,7 +58662,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 234 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 235 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -58031,8 +58769,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 === 205 /* BinaryExpression */ || - name.kind === 150 /* ComputedPropertyName */ || + (propDeclaration.kind === 206 /* BinaryExpression */ || + name.kind === 151 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -58109,7 +58847,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 165 /* TypeReference */) { + if (node.kind === 166 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -58358,7 +59096,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 241 /* ClassDeclaration */ || d.kind === 242 /* InterfaceDeclaration */; + return d.kind === 242 /* ClassDeclaration */ || d.kind === 243 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -58377,7 +59115,7 @@ var ts; // derived class instance member variables and accessors, but not by other kinds of members. // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfType(baseType); - for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { + basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); if (base.flags & 4194304 /* Prototype */) { @@ -58386,53 +59124,64 @@ var ts; var derived = getTargetSymbol(getPropertyOfObjectType(type, base.escapedName)); // TODO: GH#18217 var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base); ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); - if (derived) { - // In order to resolve whether the inherited method was overridden in the base class or not, - // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* - // type declaration, derived and base resolve to the same symbol even in the case of generic classes. - if (derived === base) { - // derived class inherits base without override/redeclaration - var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); - // It is an error to inherit an abstract member without implementing it or being declared abstract. - // If there is no declaration for the derived class (as in the case of class expressions), - // then the class cannot be declared abstract. - if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 210 /* ClassExpression */) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); - } - else { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + // In order to resolve whether the inherited method was overridden in the base class or not, + // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* + // type declaration, derived and base resolve to the same symbol even in the case of generic classes. + if (derived === base) { + // derived class inherits base without override/redeclaration + var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); + // It is an error to inherit an abstract member without implementing it or being declared abstract. + // If there is no declaration for the derived class (as in the case of class expressions), + // then the class cannot be declared abstract. + if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { + // 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]; + if (otherBaseType === baseType) + continue; + var baseSymbol = getPropertyOfObjectType(otherBaseType, base.escapedName); + var derivedElsewhere = baseSymbol && getTargetSymbol(baseSymbol); + if (derivedElsewhere && derivedElsewhere !== base) { + continue basePropertyCheck; } } - } - else { - // derived overrides base. - var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { - // either base or derived property is private - not override, skip it - continue; - } - if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; + if (derivedClassDecl.kind === 211 /* ClassExpression */) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } - var errorMessage = void 0; - if (isPrototypeProperty(base)) { - if (derived.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } - else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); } - else if (base.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + } + else { + // derived overrides base. + var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); + if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + // either base or derived property is private - not override, skip it + continue; + } + if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { + // method is overridden with method or property/accessor is overridden with property/accessor - correct case + continue; + } + var errorMessage = void 0; + if (isPrototypeProperty(base)) { + if (derived.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } - error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } + else if (base.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } @@ -58489,7 +59238,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 155 /* PropertyDeclaration */ && + return node.kind === 156 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -58513,7 +59262,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 243 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -58618,7 +59367,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -58628,7 +59377,7 @@ var ts; } } break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -58656,7 +59405,7 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return evaluate(expr.expression); case 73 /* Identifier */: var identifier = expr; @@ -58664,20 +59413,18 @@ var ts; return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: + case 191 /* 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 === 190 /* PropertyAccessExpression */) { + if (ex.kind === 191 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { - var argument = ex.argumentExpression; - ts.Debug.assert(ts.isLiteralExpression(argument)); - name = ts.escapeLeadingUnderscores(argument.text); + name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text); } return evaluateEnumMember(expr, type.symbol, name); } @@ -58703,8 +59450,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 73 /* Identifier */ || - node.kind === 190 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 191 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.kind === 191 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 192 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && node.argumentExpression.kind === 10 /* StringLiteral */; } function checkEnumDeclaration(node) { @@ -58739,7 +59486,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 !== 244 /* EnumDeclaration */) { + if (declaration.kind !== 245 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -58762,8 +59509,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 241 /* ClassDeclaration */ || - (declaration.kind === 240 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 242 /* ClassDeclaration */ || + (declaration.kind === 241 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304 /* Ambient */)) { return declaration; } @@ -58826,7 +59573,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, 241 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 242 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -58876,23 +59623,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* 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]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 256 /* ExportAssignment */: + case 257 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 239 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -58903,12 +59650,12 @@ var ts; break; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 240 /* FunctionDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 241 /* FunctionDeclaration */: + case 243 /* InterfaceDeclaration */: + case 246 /* ModuleDeclaration */: + case 244 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -58931,12 +59678,12 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return node; - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: do { node = node.left; } while (node.kind !== 73 /* Identifier */); return node; - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 73 /* Identifier */); @@ -58953,9 +59700,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 256 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 247 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 286 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 257 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -58977,26 +59724,27 @@ var ts; function checkAliasSymbol(node) { var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); - if (target !== unknownSymbol) { - // For external modules symbol represent local symbol for an alias. + var shouldSkipWithJSExpandoTargets = symbol.flags & 67108864 /* Assignment */; + if (!shouldSkipWithJSExpandoTargets && target !== unknownSymbol) { + // For external modules symbol represents local symbol for an alias. // This local symbol will merge any other local declarations (excluding other aliases) // and symbol.flags will contains combined representation for all merged declaration. // Based on symbol.flags we can compute a set of excluded meanings (meaning that resolved alias should not have, // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export* // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). - var excludedMeanings = (symbol.flags & (67220415 /* Value */ | 1048576 /* ExportValue */) ? 67220415 /* Value */ : 0) | - (symbol.flags & 67897832 /* Type */ ? 67897832 /* Type */ : 0) | + var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | + (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 258 /* ExportSpecifier */ ? + var message = node.kind === 259 /* 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 === 258 /* ExportSpecifier */ - && !(target.flags & 67220415 /* Value */) + && node.kind === 259 /* ExportSpecifier */ + && !(target.flags & 111551 /* Value */) && !(node.flags & 4194304 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); } @@ -59022,7 +59770,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 253 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -59046,17 +59794,17 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 261 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 67220415 /* Value */) { + if (target.flags & 111551 /* Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name var moduleName = getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 67220415 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { + if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 67897832 /* Type */) { + if (target.flags & 788968 /* Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } @@ -59082,10 +59830,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 246 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 247 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 247 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 286 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -59102,7 +59850,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 285 /* SourceFile */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 245 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 286 /* SourceFile */ || node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 246 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -59116,13 +59864,17 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) - var symbol = resolveName(exportedName, exportedName.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || 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 { markExportAsReferenced(node); + var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) { + checkExpressionCached(node.propertyName || node.name); + } } } } @@ -59131,8 +59883,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 286 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 246 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -59146,7 +59898,17 @@ var ts; grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 73 /* Identifier */) { - markExportAsReferenced(node); + var id = node.expression; + var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); + if (sym) { + markAliasReferenced(sym, id); + // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`) + var target = sym.flags & 2097152 /* Alias */ ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551 /* Value */) { + // However if it is a value, we need to check it's being used correctly + checkExpressionCached(node.expression); + } + } if (ts.getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression, /*setVisibility*/ true); } @@ -59215,14 +59977,6 @@ var ts; links.exportsChecked = true; } } - function isNotAccessor(declaration) { - // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks - return !ts.isAccessor(declaration); - } - function isNotOverload(declaration) { - return (declaration.kind !== 240 /* FunctionDeclaration */ && declaration.kind !== 157 /* MethodDeclaration */) || - !!declaration.body; - } function checkSourceElement(node) { if (node) { var saveCurrentNode = currentNode; @@ -59244,158 +59998,159 @@ 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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 241 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return checkTypeParameter(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return checkParameter(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return checkPropertyDeclaration(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: return checkSignatureDeclaration(node); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: return checkMethodDeclaration(node); - case 158 /* Constructor */: + case 159 /* Constructor */: return checkConstructorDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return checkAccessorDeclaration(node); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return checkTypeReferenceNode(node); - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return checkTypePredicate(node); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return checkTypeQuery(node); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return checkTypeLiteral(node); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return checkArrayType(node); - case 171 /* TupleType */: + case 172 /* TupleType */: return checkTupleType(node); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 178 /* ParenthesizedType */: - case 172 /* OptionalType */: - case 173 /* RestType */: + case 179 /* ParenthesizedType */: + case 173 /* OptionalType */: + case 174 /* RestType */: return checkSourceElement(node.type); - case 179 /* ThisType */: + case 180 /* ThisType */: return checkThisType(node); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: return checkTypeOperator(node); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return checkConditionalType(node); - case 177 /* InferType */: + case 178 /* InferType */: return checkInferType(node); - case 184 /* ImportType */: + case 185 /* ImportType */: return checkImportType(node); - case 301 /* JSDocAugmentsTag */: + case 303 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 309 /* JSDocTypeTag */: + case 311 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 306 /* JSDocParameterTag */: + case 308 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: - case 298 /* JSDocTypeLiteral */: + case 294 /* JSDocNonNullableType */: + case 293 /* JSDocNullableType */: + case 291 /* JSDocAllType */: + case 292 /* JSDocUnknownType */: + case 300 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 296 /* JSDocVariadicType */: + case 297 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 289 /* JSDocTypeExpression */: + case 290 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 182 /* MappedType */: + case 183 /* MappedType */: return checkMappedType(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 220 /* Block */: + case 247 /* ModuleBlock */: return checkBlock(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return checkVariableStatement(node); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return checkExpressionStatement(node); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return checkIfStatement(node); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return checkDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return checkWhileStatement(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return checkForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return checkForInStatement(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return checkForOfStatement(node); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 230 /* ContinueStatement */: + case 231 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return checkReturnStatement(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return checkWithStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return checkSwitchStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return checkLabeledStatement(node); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return checkThrowStatement(node); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return checkTryStatement(node); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return checkBindingElement(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return checkClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return checkImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return checkExportDeclaration(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return checkExportAssignment(node); - case 221 /* EmptyStatement */: - case 237 /* DebuggerStatement */: + case 222 /* EmptyStatement */: + case 238 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 259 /* MissingDeclaration */: + case 260 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -59490,23 +60245,23 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 261 /* JsxElement */: + case 262 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -59636,35 +60391,35 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; // falls through - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - // falls through // this fall-through is necessary because we would like to handle - // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. + // falls through + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!isStatic) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67897832 /* Type */); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -59712,11 +60467,11 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 151 /* TypeParameter */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 152 /* TypeParameter */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 245 /* EnumDeclaration */: return true; default: return false; @@ -59724,16 +60479,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 150 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 165 /* TypeReference */; + return node.parent.kind === 166 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 190 /* PropertyAccessExpression */) { + while (node.parent.kind === 191 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 212 /* ExpressionWithTypeArguments */; + return node.parent.kind === 213 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -59761,13 +60516,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 149 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 150 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 249 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 250 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 255 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 256 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -59793,7 +60548,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 184 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 185 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -59803,7 +60558,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 190 /* PropertyAccessExpression */ && + entityName.parent.kind === 191 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -59811,17 +60566,17 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 255 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 256 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, - /*all meanings*/ 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); + /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); if (success && success !== unknownSymbol) { return success; } } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 249 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 250 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -59839,11 +60594,11 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 212 /* ExpressionWithTypeArguments */) { - meaning = 67897832 /* Type */; + if (entityName.parent.kind === 213 /* ExpressionWithTypeArguments */) { + meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { - meaning |= 67220415 /* Value */; + meaning |= 111551 /* Value */; } } else { @@ -59855,10 +60610,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 306 /* JSDocParameterTag */) { + if (entityName.parent.kind === 308 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 151 /* TypeParameter */ && entityName.parent.parent.kind === 310 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 152 /* TypeParameter */ && entityName.parent.parent.kind === 312 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -59873,14 +60628,14 @@ var ts; var symbol = getIntrinsicTagSymbol(entityName.parent); return symbol === unknownSymbol ? undefined : symbol; } - return resolveEntityName(entityName, 67220415 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); + return resolveEntityName(entityName, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 190 /* PropertyAccessExpression */ || entityName.kind === 149 /* QualifiedName */) { + else if (entityName.kind === 191 /* PropertyAccessExpression */ || entityName.kind === 150 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 190 /* PropertyAccessExpression */) { + if (entityName.kind === 191 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -59890,17 +60645,17 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 165 /* TypeReference */ ? 67897832 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 166 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - if (entityName.parent.kind === 164 /* TypePredicate */) { + if (entityName.parent.kind === 165 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -59923,8 +60678,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 187 /* BindingElement */ && - grandParent.kind === 185 /* ObjectBindingPattern */ && + else if (parent.kind === 188 /* BindingElement */ && + grandParent.kind === 186 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -59935,8 +60690,8 @@ var ts; } switch (node.kind) { case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 191 /* PropertyAccessExpression */: + case 150 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 101 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); @@ -59950,14 +60705,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 179 /* ThisType */: + case 180 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; case 99 /* SuperKeyword */: return checkExpression(node).symbol; case 125 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 158 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 159 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -59968,7 +60723,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 === 250 /* ImportDeclaration */ || node.parent.kind === 256 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 251 /* ImportDeclaration */ || node.parent.kind === 257 /* 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); @@ -59990,7 +60745,7 @@ var ts; case 37 /* EqualsGreaterThanToken */: case 77 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 184 /* ImportType */: + case 185 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; case 86 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; @@ -59999,8 +60754,8 @@ var ts; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 277 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 67220415 /* Value */ | 2097152 /* Alias */); + if (location && location.kind === 278 /* ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; } @@ -60008,7 +60763,7 @@ var ts; function getExportSpecifierLocalTargetSymbol(node) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } function getTypeOfNode(node) { if (node.flags & 8388608 /* InWithStatement */) { @@ -60067,27 +60822,27 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 189 /* ObjectLiteralExpression */ || expr.kind === 188 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 190 /* ObjectLiteralExpression */ || expr.kind === 189 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 228 /* ForOfStatement */) { + if (expr.parent.kind === 229 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 205 /* BinaryExpression */) { + if (expr.parent.kind === 206 /* 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 === 276 /* 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); + if (expr.parent.kind === 277 /* PropertyAssignment */) { + var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); + var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType; + var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex); } // Array literal assignment - array destructuring pattern var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); @@ -60131,7 +60886,7 @@ var ts; case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: @@ -60188,7 +60943,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 191 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -60209,13 +60964,13 @@ var ts; // for export assignments - check if resolved symbol for RHS is itself a value // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 67220415 /* Value */) + ? !!(moduleSymbol.flags & 111551 /* Value */) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 67220415 /* Value */); + return s && !!(s.flags & 111551 /* Value */); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -60244,7 +60999,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 285 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 286 /* 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. @@ -60264,7 +61019,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 67220415 /* Value */)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -60272,7 +61027,7 @@ var ts; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 276 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { @@ -60281,7 +61036,7 @@ var ts; var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { + if (resolveName(container.parent, symbol.escapedName, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } @@ -60303,7 +61058,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 === 219 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 220 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -60344,26 +61099,25 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 250 /* ImportEqualsDeclaration */: + case 252 /* ImportClause */: + case 253 /* NamespaceImport */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 255 /* ExportAssignment */: - return node.expression - && node.expression.kind === 73 /* Identifier */ - ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) - : true; + case 256 /* ExportAssignment */: + return node.expression && node.expression.kind === 73 /* Identifier */ ? + isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : + true; } return false; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 285 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 286 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -60377,7 +61131,7 @@ var ts; } // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true - return !!(target.flags & 67220415 /* Value */) && + return !!(target.flags & 111551 /* Value */) && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -60391,7 +61145,7 @@ var ts; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 if (target && ts.getModifierFlags(node) & 1 /* Export */ && - target.flags & 67220415 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { + target.flags & 111551 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -60445,7 +61199,7 @@ var ts; if (!symbol || !(symbol.flags & 16 /* Function */)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 67220415 /* Value */ && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -60464,15 +61218,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 279 /* EnumMember */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 280 /* EnumMember */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 279 /* EnumMember */) { + if (node.kind === 280 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -60499,9 +61253,9 @@ var ts; return ts.TypeReferenceSerializationKind.Unknown; } // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. - var valueSymbol = resolveEntityName(typeName, 67220415 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 67897832 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (valueSymbol && valueSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { @@ -60606,7 +61360,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + return resolveName(location, reference.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -60627,7 +61381,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 67220415 /* Value */, enclosing, /*flags*/ undefined, tracker) + var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse(); return enumResult || ts.createLiteral(type.value); } @@ -60708,12 +61462,12 @@ var ts; getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 160 /* SetAccessor */ ? 159 /* GetAccessor */ : 160 /* SetAccessor */; + var otherKind = accessor.kind === 161 /* SetAccessor */ ? 160 /* GetAccessor */ : 161 /* 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 === 160 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 159 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 161 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 160 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -60729,7 +61483,7 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 212 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 274 /* HeritageClause */; + return node.parent && node.parent.kind === 213 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 275 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -60740,9 +61494,9 @@ var ts; // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = 67897832 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 73 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 190 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { - meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; + var meaning = 788968 /* Type */ | 1920 /* Namespace */; + if ((node.kind === 73 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 191 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -60792,7 +61546,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 285 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 286 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -60820,12 +61574,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 245 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 246 /* 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, 285 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 286 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -60965,7 +61719,7 @@ var ts; for (var helper = 1 /* FirstEmitHelper */; helper <= 131072 /* LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 67220415 /* Value */); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); if (!symbol) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); } @@ -61014,14 +61768,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 157 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 158 /* 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 === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */) { + else if (node.kind === 160 /* GetAccessor */ || node.kind === 161 /* 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); @@ -61039,16 +61793,16 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 134 /* ReadonlyKeyword */) { - if (node.kind === 154 /* PropertySignature */ || node.kind === 156 /* MethodSignature */) { + if (node.kind === 155 /* PropertySignature */ || node.kind === 157 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 164 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 78 /* ConstKeyword */: - if (node.kind !== 244 /* EnumDeclaration */) { + if (node.kind !== 245 /* EnumDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(78 /* ConstKeyword */)); } break; @@ -61068,7 +61822,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 === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 286 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -61091,10 +61845,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 286 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 153 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -61107,7 +61861,7 @@ var ts; if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */ && node.kind !== 163 /* IndexSignature */ && node.kind !== 152 /* Parameter */) { + else if (node.kind !== 156 /* PropertyDeclaration */ && node.kind !== 155 /* PropertySignature */ && node.kind !== 164 /* IndexSignature */ && node.kind !== 153 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report 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); } @@ -61127,17 +61881,17 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 153 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; case 81 /* DefaultKeyword */: - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 286 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 246 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; @@ -61149,13 +61903,13 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 153 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 246 /* ModuleBlock */) { + else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 247 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -61165,14 +61919,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 241 /* ClassDeclaration */) { - if (node.kind !== 157 /* MethodDeclaration */ && - node.kind !== 155 /* PropertyDeclaration */ && - node.kind !== 159 /* GetAccessor */ && - node.kind !== 160 /* SetAccessor */) { + if (node.kind !== 242 /* ClassDeclaration */) { + if (node.kind !== 158 /* MethodDeclaration */ && + node.kind !== 156 /* PropertyDeclaration */ && + node.kind !== 160 /* GetAccessor */ && + node.kind !== 161 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 241 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 242 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -61191,7 +61945,7 @@ var ts; else if (flags & 2 /* Ambient */ || node.parent.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 153 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -61199,7 +61953,7 @@ var ts; break; } } - if (node.kind === 158 /* Constructor */) { + if (node.kind === 159 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -61214,13 +61968,13 @@ var ts; } return false; } - else if ((node.kind === 250 /* ImportDeclaration */ || node.kind === 249 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 251 /* ImportDeclaration */ || node.kind === 250 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 153 /* Parameter */ && (flags & 92 /* 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 === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 153 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -61241,37 +61995,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 245 /* ModuleDeclaration */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 152 /* Parameter */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 159 /* Constructor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 164 /* IndexSignature */: + case 246 /* ModuleDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 257 /* ExportDeclaration */: + case 256 /* ExportAssignment */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 153 /* Parameter */: return false; default: - if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 286 /* SourceFile */) { return false; } switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 122 /* AsyncKeyword */); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 119 /* AbstractKeyword */); - case 242 /* InterfaceDeclaration */: - case 220 /* VariableStatement */: - case 243 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 221 /* VariableStatement */: + case 244 /* TypeAliasDeclaration */: return true; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 78 /* ConstKeyword */); default: ts.Debug.fail(); @@ -61284,10 +62038,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -61350,7 +62104,7 @@ var ts; ts.addRelatedInfo(error(parameter, ts.Diagnostics.This_parameter_is_not_allowed_with_use_strict_directive), ts.createDiagnosticForNode(useStrictDirective_1, ts.Diagnostics.use_strict_directive_used_here)); }); var diagnostics_1 = nonSimpleParameters.map(function (parameter, index) { return (index === 0 ? ts.createDiagnosticForNode(parameter, ts.Diagnostics.Non_simple_parameter_declared_here) : ts.createDiagnosticForNode(parameter, ts.Diagnostics.and_here)); }); - ts.addRelatedInfo.apply(void 0, [error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)].concat(diagnostics_1)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)], diagnostics_1)); return true; } } @@ -61438,7 +62192,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 === 211 /* OmittedExpression */) { + if (arg.kind === 212 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -61515,20 +62269,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 150 /* ComputedPropertyName */) { + if (node.kind !== 151 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 205 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 206 /* 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 === 240 /* FunctionDeclaration */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 157 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 241 /* FunctionDeclaration */ || + node.kind === 198 /* FunctionExpression */ || + node.kind === 158 /* MethodDeclaration */); if (node.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -61544,17 +62298,10 @@ var ts; return !!exclamationToken && grammarErrorOnNode(exclamationToken, message); } function checkGrammarObjectLiteralExpression(node, inDestructuring) { - var Flags; - (function (Flags) { - Flags[Flags["Property"] = 1] = "Property"; - Flags[Flags["GetAccessor"] = 2] = "GetAccessor"; - Flags[Flags["SetAccessor"] = 4] = "SetAccessor"; - Flags[Flags["GetOrSetAccessor"] = 6] = "GetOrSetAccessor"; - })(Flags || (Flags = {})); var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */) { + if (prop.kind === 279 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -61565,11 +62312,11 @@ var ts; continue; } var name = prop.name; - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 151 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 277 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 278 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -61578,7 +62325,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 157 /* MethodDeclaration */) { + if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 158 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -61593,24 +62340,25 @@ 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 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); - /* tslint:disable:no-switch-case-fall-through */ - case 276 /* PropertyAssignment */: + // falls through + case 277 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name); } - // falls through - case 157 /* MethodDeclaration */: - currentKind = 1 /* Property */; + currentKind = 4 /* PropertyAssignment */; + break; + case 158 /* MethodDeclaration */: + currentKind = 8 /* Method */; break; - case 159 /* GetAccessor */: - currentKind = 2 /* GetAccessor */; + case 160 /* GetAccessor */: + currentKind = 1 /* GetAccessor */; break; - case 160 /* SetAccessor */: - currentKind = 4 /* SetAccessor */; + case 161 /* SetAccessor */: + currentKind = 2 /* SetAccessor */; break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); @@ -61624,11 +62372,11 @@ var ts; seen.set(effectiveName, currentKind); } else { - if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { + if ((currentKind & 12 /* PropertyAssignmentOrMethod */) && (existingKind & 12 /* PropertyAssignmentOrMethod */)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 6 /* GetOrSetAccessor */) && (existingKind & 6 /* GetOrSetAccessor */)) { - if (existingKind !== 6 /* GetOrSetAccessor */ && currentKind !== existingKind) { + else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) { + if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -61646,7 +62394,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 270 /* JsxSpreadAttribute */) { + if (attr.kind === 271 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -61656,7 +62404,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 271 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 272 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -61670,14 +62418,14 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 228 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 229 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { // use of 'for-await-of' in non-async function var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 159 /* 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); @@ -61688,7 +62436,7 @@ var ts; return false; } } - if (forInOrOfStatement.initializer.kind === 239 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 240 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -61703,20 +62451,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 228 /* 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 === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 228 /* 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 === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 228 /* 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); @@ -61726,42 +62474,38 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - var kind = accessor.kind; - if (languageVersion < 1 /* ES5 */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (accessor.flags & 4194304 /* Ambient */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); - } - else if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { - return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + if (!(accessor.flags & 4194304 /* Ambient */)) { + if (languageVersion < 1 /* ES5 */) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { + return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + } } - else if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { + if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - else if (accessor.typeParameters) { + if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 159 /* GetAccessor */ ? + if (!doesAccessorHaveCorrectParameterCount(accessor)) { + return grammarErrorOnNode(accessor.name, accessor.kind === 160 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 160 /* SetAccessor */) { + if (accessor.kind === 161 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } - else { - var parameter = accessor.parameters[0]; - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); - } - else if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); - } - else if (parameter.initializer) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); - } + var parameter = ts.Debug.assertDefined(ts.getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion."); + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); + } + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); + } + if (parameter.initializer) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); } } return false; @@ -61771,10 +62515,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 === 159 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 160 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 159 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 160 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -61785,7 +62529,7 @@ var ts; } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: var decl = parent; if (decl.name.kind !== 73 /* Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); @@ -61797,13 +62541,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: if (!ts.hasModifier(parent, 32 /* Static */) || !ts.hasModifier(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 154 /* PropertySignature */: + case 155 /* PropertySignature */: if (!ts.hasModifier(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); } @@ -61813,7 +62557,7 @@ var ts; } } else if (node.operator === 134 /* ReadonlyKeyword */) { - if (node.type.kind !== 170 /* ArrayType */ && node.type.kind !== 171 /* TupleType */) { + if (node.type.kind !== 171 /* ArrayType */ && node.type.kind !== 172 /* TupleType */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(140 /* SymbolKeyword */)); } } @@ -61827,8 +62571,8 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 157 /* MethodDeclaration */) { - if (node.parent.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 158 /* MethodDeclaration */) { + if (node.parent.kind === 190 /* 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 === 122 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -61856,14 +62600,14 @@ var ts; if (node.flags & 4194304 /* 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 === 157 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 158 /* 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 === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 243 /* 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 === 169 /* TypeLiteral */) { + else if (node.parent.kind === 170 /* 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); } } @@ -61874,11 +62618,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 234 /* LabeledStatement */: + case 235 /* 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 === 229 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 230 /* 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); @@ -61886,8 +62630,8 @@ var ts; return false; } break; - case 233 /* SwitchStatement */: - if (node.kind === 230 /* BreakStatement */ && !node.label) { + case 234 /* SwitchStatement */: + if (node.kind === 231 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -61902,13 +62646,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 230 /* BreakStatement */ + var message = node.kind === 231 /* 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 === 230 /* BreakStatement */ + var message = node.kind === 231 /* 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); @@ -61932,12 +62676,12 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 10 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.kind === 204 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.kind === 204 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -61967,7 +62711,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 227 /* ForInStatement */ && node.parent.parent.kind !== 228 /* ForOfStatement */) { + if (node.parent.parent.kind !== 228 /* ForInStatement */ && node.parent.parent.kind !== 229 /* ForOfStatement */) { if (node.flags & 4194304 /* Ambient */) { checkAmbientInitializer(node); } @@ -61980,7 +62724,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 220 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 221 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && @@ -62042,15 +62786,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 224 /* IfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 233 /* WithStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: return false; - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -62131,7 +62875,7 @@ var ts; return true; } } - else if (node.parent.kind === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 243 /* 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; } @@ -62139,7 +62883,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 169 /* TypeLiteral */) { + else if (node.parent.kind === 170 /* 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; } @@ -62168,13 +62912,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 243 /* TypeAliasDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 256 /* ExportDeclaration */ || - node.kind === 255 /* ExportAssignment */ || - node.kind === 248 /* NamespaceExportDeclaration */ || + if (node.kind === 243 /* InterfaceDeclaration */ || + node.kind === 244 /* TypeAliasDeclaration */ || + node.kind === 251 /* ImportDeclaration */ || + node.kind === 250 /* ImportEqualsDeclaration */ || + node.kind === 257 /* ExportDeclaration */ || + node.kind === 256 /* ExportAssignment */ || + node.kind === 249 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -62183,7 +62927,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 === 220 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 221 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -62196,13 +62940,9 @@ var ts; } function checkGrammarStatementInAmbientContext(node) { if (node.flags & 4194304 /* Ambient */) { - // An accessors is already reported about the ambient context - if (ts.isAccessor(node.parent)) { - return getNodeLinks(node).hasReportedStatementInAmbientContext = true; - } // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); - if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { + if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } // We are either parented by another statement, or some sort of block. @@ -62210,7 +62950,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 === 219 /* Block */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 220 /* Block */ || node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 286 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -62232,10 +62972,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, 183 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 184 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 279 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 280 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -62244,8 +62984,27 @@ var ts; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + // Realism (size) checking + checkNumericLiteralValueSize(node); return false; } + function checkNumericLiteralValueSize(node) { + // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint + // Literals with 15 or fewer characters aren't long enough to reach past 2^53 - 1 + // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway + if (node.numericLiteralFlags & 16 /* Scientific */ || node.text.length <= 15 || node.text.indexOf(".") !== -1) { + return; + } + // We can't rely on the runtime to accurately store and compare extremely large numeric values + // Even for internal use, we use getTextOfNode: https://github.com/microsoft/TypeScript/issues/33298 + // Thus, if the runtime claims a too-large number is lower than Number.MAX_SAFE_INTEGER, + // it's likely addition operations on it will fail too + var apparentValue = +ts.getTextOfNode(node); + if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) { + return; + } + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers)); + } function checkGrammarBigIntLiteral(node) { var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); @@ -62300,11 +63059,19 @@ var ts; } } ts.createTypeChecker = createTypeChecker; + function isNotAccessor(declaration) { + // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks + return !ts.isAccessor(declaration); + } + function isNotOverload(declaration) { + return (declaration.kind !== 241 /* FunctionDeclaration */ && declaration.kind !== 158 /* 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 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -62312,21 +63079,20 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 251 /* ImportClause */: // For default import - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: // For rename import `x as y` + case 252 /* ImportClause */: // For default import + case 250 /* ImportEqualsDeclaration */: + case 253 /* NamespaceImport */: + case 255 /* ImportSpecifier */: // For rename import `x as y` return true; case 73 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 254 /* ImportSpecifier */; + return decl.parent.kind === 255 /* ImportSpecifier */; default: return false; } } var JsxNames; (function (JsxNames) { - // tslint:disable variable-name JsxNames.JSX = "JSX"; JsxNames.IntrinsicElements = "IntrinsicElements"; JsxNames.ElementClass = "ElementClass"; @@ -62336,7 +63102,6 @@ var ts; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; - // tslint:enable variable-name })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { @@ -62407,6 +63172,7 @@ var ts; if (typeof value === "number") { return createNumericLiteral(value + ""); } + // eslint-disable-next-line no-in-operator if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n"); } @@ -62599,7 +63365,7 @@ var ts; ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(149 /* QualifiedName */); + var node = createSynthesizedNode(150 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -62618,7 +63384,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(150 /* ComputedPropertyName */); + var node = createSynthesizedNode(151 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -62631,7 +63397,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(151 /* TypeParameter */); + var node = createSynthesizedNode(152 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -62647,7 +63413,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(152 /* Parameter */); + var node = createSynthesizedNode(153 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -62671,7 +63437,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(153 /* Decorator */); + var node = createSynthesizedNode(154 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -62684,7 +63450,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(154 /* PropertySignature */); + var node = createSynthesizedNode(155 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -62704,7 +63470,7 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(155 /* PropertyDeclaration */); + var node = createSynthesizedNode(156 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62728,7 +63494,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(156 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(157 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -62745,7 +63511,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(157 /* MethodDeclaration */); + var node = createSynthesizedNode(158 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -62773,7 +63539,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(158 /* Constructor */); + var node = createSynthesizedNode(159 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -62793,7 +63559,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(159 /* GetAccessor */); + var node = createSynthesizedNode(160 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62816,7 +63582,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(160 /* SetAccessor */); + var node = createSynthesizedNode(161 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62837,7 +63603,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(161 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(162 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -62845,7 +63611,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(162 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(163 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -62853,7 +63619,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(163 /* IndexSignature */); + var node = createSynthesizedNode(164 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -62893,7 +63659,7 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(164 /* TypePredicate */); + var node = createSynthesizedNode(165 /* TypePredicate */); node.parameterName = asName(parameterName); node.type = type; return node; @@ -62907,7 +63673,7 @@ var ts; } ts.updateTypePredicateNode = updateTypePredicateNode; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(165 /* TypeReference */); + var node = createSynthesizedNode(166 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -62921,7 +63687,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(166 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(167 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -62929,7 +63695,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(167 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(168 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -62937,7 +63703,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(168 /* TypeQuery */); + var node = createSynthesizedNode(169 /* TypeQuery */); node.exprName = exprName; return node; } @@ -62949,7 +63715,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(169 /* TypeLiteral */); + var node = createSynthesizedNode(170 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -62961,7 +63727,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(170 /* ArrayType */); + var node = createSynthesizedNode(171 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -62973,7 +63739,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(171 /* TupleType */); + var node = createSynthesizedNode(172 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -62985,7 +63751,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(172 /* OptionalType */); + var node = createSynthesizedNode(173 /* OptionalType */); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -62997,7 +63763,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(173 /* RestType */); + var node = createSynthesizedNode(174 /* RestType */); node.type = type; return node; } @@ -63009,7 +63775,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(174 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(175 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -63017,7 +63783,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(175 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(176 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -63036,7 +63802,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(176 /* ConditionalType */); + var node = createSynthesizedNode(177 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -63054,7 +63820,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(177 /* InferType */); + var node = createSynthesizedNode(178 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -63066,7 +63832,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(184 /* ImportType */); + var node = createSynthesizedNode(185 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = ts.parenthesizeTypeParameters(typeArguments); @@ -63084,7 +63850,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(178 /* ParenthesizedType */); + var node = createSynthesizedNode(179 /* ParenthesizedType */); node.type = type; return node; } @@ -63096,11 +63862,11 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(179 /* ThisType */); + return createSynthesizedNode(180 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(180 /* TypeOperator */); + var node = createSynthesizedNode(181 /* TypeOperator */); node.operator = typeof operatorOrType === "number" ? operatorOrType : 130 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; @@ -63111,7 +63877,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(181 /* IndexedAccessType */); + var node = createSynthesizedNode(182 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -63125,7 +63891,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(182 /* MappedType */); + var node = createSynthesizedNode(183 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -63143,7 +63909,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(183 /* LiteralType */); + var node = createSynthesizedNode(184 /* LiteralType */); node.literal = literal; return node; } @@ -63156,7 +63922,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(185 /* ObjectBindingPattern */); + var node = createSynthesizedNode(186 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63168,7 +63934,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(186 /* ArrayBindingPattern */); + var node = createSynthesizedNode(187 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63180,7 +63946,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(187 /* BindingElement */); + var node = createSynthesizedNode(188 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -63199,7 +63965,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(188 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(189 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -63213,7 +63979,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(189 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(190 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -63227,7 +63993,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(190 /* PropertyAccessExpression */); + var node = createSynthesizedNode(191 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072 /* NoIndentation */); @@ -63244,7 +64010,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(191 /* ElementAccessExpression */); + var node = createSynthesizedNode(192 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -63258,7 +64024,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(192 /* CallExpression */); + var node = createSynthesizedNode(193 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -63274,7 +64040,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(193 /* NewExpression */); + var node = createSynthesizedNode(194 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -63290,7 +64056,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(194 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(195 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -63313,7 +64079,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(195 /* TypeAssertionExpression */); + var node = createSynthesizedNode(196 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -63327,7 +64093,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(196 /* ParenthesizedExpression */); + var node = createSynthesizedNode(197 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -63339,7 +64105,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(197 /* FunctionExpression */); + var node = createSynthesizedNode(198 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -63363,7 +64129,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(198 /* ArrowFunction */); + var node = createSynthesizedNode(199 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); @@ -63385,7 +64151,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(199 /* DeleteExpression */); + var node = createSynthesizedNode(200 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63397,7 +64163,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(200 /* TypeOfExpression */); + var node = createSynthesizedNode(201 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63409,7 +64175,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(201 /* VoidExpression */); + var node = createSynthesizedNode(202 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63421,7 +64187,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(202 /* AwaitExpression */); + var node = createSynthesizedNode(203 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63433,7 +64199,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(203 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(204 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -63446,7 +64212,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(204 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(205 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -63459,7 +64225,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(205 /* BinaryExpression */); + var node = createSynthesizedNode(206 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -63476,7 +64242,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(206 /* ConditionalExpression */); + var node = createSynthesizedNode(207 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); @@ -63496,7 +64262,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(207 /* TemplateExpression */); + var node = createSynthesizedNode(208 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -63509,32 +64275,91 @@ var ts; : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createTemplateHead(text) { - var node = createSynthesizedNode(15 /* TemplateHead */); + var rawTextScanner; + var invalidValueSentinel = {}; + function getCookedText(kind, rawText) { + if (!rawTextScanner) { + rawTextScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + } + switch (kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + rawTextScanner.setText("`" + rawText + "`"); + break; + case 15 /* TemplateHead */: + rawTextScanner.setText("`" + rawText + "${"); + break; + case 16 /* TemplateMiddle */: + rawTextScanner.setText("}" + rawText + "${"); + break; + case 17 /* TemplateTail */: + rawTextScanner.setText("}" + rawText + "`"); + break; + } + var token = rawTextScanner.scan(); + if (token === 23 /* CloseBracketToken */) { + token = rawTextScanner.reScanTemplateToken(); + } + if (rawTextScanner.isUnterminated()) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + var tokenValue; + switch (token) { + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + tokenValue = rawTextScanner.getTokenValue(); + break; + } + if (rawTextScanner.scan() !== 1 /* EndOfFileToken */) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + rawTextScanner.setText(undefined); + return tokenValue; + } + function createTemplateLiteralLikeNode(kind, text, rawText) { + var node = createSynthesizedNode(kind); + node.text = text; + if (rawText === undefined || text === rawText) { + node.rawText = rawText; + } + else { + var cooked = getCookedText(kind, rawText); + if (typeof cooked === "object") { + return ts.Debug.fail("Invalid raw text"); + } + ts.Debug.assert(text === cooked, "Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'."); + node.rawText = rawText; + } + return node; + } + function createTemplateHead(text, rawText) { + var node = createTemplateLiteralLikeNode(15 /* TemplateHead */, text, rawText); node.text = text; return node; } ts.createTemplateHead = createTemplateHead; - function createTemplateMiddle(text) { - var node = createSynthesizedNode(16 /* TemplateMiddle */); + function createTemplateMiddle(text, rawText) { + var node = createTemplateLiteralLikeNode(16 /* TemplateMiddle */, text, rawText); node.text = text; return node; } ts.createTemplateMiddle = createTemplateMiddle; - function createTemplateTail(text) { - var node = createSynthesizedNode(17 /* TemplateTail */); + function createTemplateTail(text, rawText) { + var node = createTemplateLiteralLikeNode(17 /* TemplateTail */, text, rawText); node.text = text; return node; } ts.createTemplateTail = createTemplateTail; - function createNoSubstitutionTemplateLiteral(text) { - var node = createSynthesizedNode(14 /* NoSubstitutionTemplateLiteral */); - node.text = text; + function createNoSubstitutionTemplateLiteral(text, rawText) { + var node = createTemplateLiteralLikeNode(14 /* NoSubstitutionTemplateLiteral */, text, rawText); return node; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(208 /* YieldExpression */); + var node = createSynthesizedNode(209 /* YieldExpression */); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; @@ -63548,7 +64373,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(209 /* SpreadElement */); + var node = createSynthesizedNode(210 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -63560,7 +64385,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(210 /* ClassExpression */); + var node = createSynthesizedNode(211 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63581,11 +64406,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(211 /* OmittedExpression */); + return createSynthesizedNode(212 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(212 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(213 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -63599,7 +64424,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(213 /* AsExpression */); + var node = createSynthesizedNode(214 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -63613,7 +64438,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(214 /* NonNullExpression */); + var node = createSynthesizedNode(215 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -63625,7 +64450,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(215 /* MetaProperty */); + var node = createSynthesizedNode(216 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -63639,7 +64464,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(217 /* TemplateSpan */); + var node = createSynthesizedNode(218 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -63653,12 +64478,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(218 /* SemicolonClassElement */); + return createSynthesizedNode(219 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(219 /* Block */); + var block = createSynthesizedNode(220 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -63672,7 +64497,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(220 /* VariableStatement */); + var node = createSynthesizedNode(221 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -63687,11 +64512,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(221 /* EmptyStatement */); + return createSynthesizedNode(222 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(222 /* ExpressionStatement */); + var node = createSynthesizedNode(223 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -63707,7 +64532,7 @@ var ts; /** @deprecated Use `updateExpressionStatement` instead. */ ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(223 /* IfStatement */); + var node = createSynthesizedNode(224 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -63723,7 +64548,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(224 /* DoStatement */); + var node = createSynthesizedNode(225 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; return node; @@ -63737,7 +64562,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(225 /* WhileStatement */); + var node = createSynthesizedNode(226 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -63751,7 +64576,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(226 /* ForStatement */); + var node = createSynthesizedNode(227 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -63769,7 +64594,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(227 /* ForInStatement */); + var node = createSynthesizedNode(228 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -63785,7 +64610,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(228 /* ForOfStatement */); + var node = createSynthesizedNode(229 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -63803,7 +64628,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(229 /* ContinueStatement */); + var node = createSynthesizedNode(230 /* ContinueStatement */); node.label = asName(label); return node; } @@ -63815,7 +64640,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(230 /* BreakStatement */); + var node = createSynthesizedNode(231 /* BreakStatement */); node.label = asName(label); return node; } @@ -63827,7 +64652,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(231 /* ReturnStatement */); + var node = createSynthesizedNode(232 /* ReturnStatement */); node.expression = expression; return node; } @@ -63839,7 +64664,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(232 /* WithStatement */); + var node = createSynthesizedNode(233 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -63853,7 +64678,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(233 /* SwitchStatement */); + var node = createSynthesizedNode(234 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -63867,7 +64692,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(234 /* LabeledStatement */); + var node = createSynthesizedNode(235 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); return node; @@ -63881,7 +64706,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(235 /* ThrowStatement */); + var node = createSynthesizedNode(236 /* ThrowStatement */); node.expression = expression; return node; } @@ -63893,7 +64718,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(236 /* TryStatement */); + var node = createSynthesizedNode(237 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -63909,11 +64734,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(237 /* DebuggerStatement */); + return createSynthesizedNode(238 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(238 /* VariableDeclaration */); + var node = createSynthesizedNode(239 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -63930,7 +64755,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* VariableDeclarationList */); + var node = createSynthesizedNode(240 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -63943,7 +64768,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(240 /* FunctionDeclaration */); + var node = createSynthesizedNode(241 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -63969,7 +64794,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(241 /* ClassDeclaration */); + var node = createSynthesizedNode(242 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63991,7 +64816,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(242 /* InterfaceDeclaration */); + var node = createSynthesizedNode(243 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64013,7 +64838,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(243 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(244 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64033,7 +64858,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(244 /* EnumDeclaration */); + var node = createSynthesizedNode(245 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64052,7 +64877,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(245 /* ModuleDeclaration */); + var node = createSynthesizedNode(246 /* ModuleDeclaration */); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -64071,7 +64896,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(246 /* ModuleBlock */); + var node = createSynthesizedNode(247 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -64083,7 +64908,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(247 /* CaseBlock */); + var node = createSynthesizedNode(248 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -64095,7 +64920,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(248 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(249 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -64107,7 +64932,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(249 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(250 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64125,7 +64950,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ImportDeclaration */); + var node = createSynthesizedNode(251 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -64143,7 +64968,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(251 /* ImportClause */); + var node = createSynthesizedNode(252 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -64157,7 +64982,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(252 /* NamespaceImport */); + var node = createSynthesizedNode(253 /* NamespaceImport */); node.name = name; return node; } @@ -64169,7 +64994,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(253 /* NamedImports */); + var node = createSynthesizedNode(254 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -64181,7 +65006,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(254 /* ImportSpecifier */); + var node = createSynthesizedNode(255 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -64195,7 +65020,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(255 /* ExportAssignment */); + var node = createSynthesizedNode(256 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -64212,7 +65037,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(256 /* ExportDeclaration */); + var node = createSynthesizedNode(257 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -64230,7 +65055,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(257 /* NamedExports */); + var node = createSynthesizedNode(258 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -64242,7 +65067,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(258 /* ExportSpecifier */); + var node = createSynthesizedNode(259 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -64257,7 +65082,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(260 /* ExternalModuleReference */); + var node = createSynthesizedNode(261 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -64271,14 +65096,14 @@ var ts; // JSDoc /* @internal */ function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(289 /* JSDocTypeExpression */); + var node = createSynthesizedNode(290 /* JSDocTypeExpression */); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; /* @internal */ function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(309 /* JSDocTypeTag */, "type"); + var tag = createJSDocTag(311 /* JSDocTypeTag */, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64286,7 +65111,7 @@ var ts; ts.createJSDocTypeTag = createJSDocTypeTag; /* @internal */ function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(307 /* JSDocReturnTag */, "returns"); + var tag = createJSDocTag(309 /* JSDocReturnTag */, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64294,14 +65119,14 @@ var ts; ts.createJSDocReturnTag = createJSDocReturnTag; /** @internal */ function createJSDocThisTag(typeExpression) { - var tag = createJSDocTag(308 /* JSDocThisTag */, "this"); + var tag = createJSDocTag(310 /* JSDocThisTag */, "this"); tag.typeExpression = typeExpression; return tag; } ts.createJSDocThisTag = createJSDocThisTag; /* @internal */ function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(306 /* JSDocParameterTag */, "param"); + var tag = createJSDocTag(308 /* JSDocParameterTag */, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -64311,7 +65136,7 @@ var ts; ts.createJSDocParamTag = createJSDocParamTag; /* @internal */ function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(297 /* JSDocComment */); + var node = createSynthesizedNode(299 /* JSDocComment */); node.comment = comment; node.tags = tags; return node; @@ -64325,7 +65150,7 @@ var ts; } // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(261 /* JsxElement */); + var node = createSynthesizedNode(262 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -64341,7 +65166,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(262 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(263 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64357,7 +65182,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(263 /* JsxOpeningElement */); + var node = createSynthesizedNode(264 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64373,7 +65198,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(264 /* JsxClosingElement */); + var node = createSynthesizedNode(265 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -64385,7 +65210,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(265 /* JsxFragment */); + var node = createSynthesizedNode(266 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -64407,11 +65232,11 @@ var ts; } ts.updateJsxText = updateJsxText; function createJsxOpeningFragment() { - return createSynthesizedNode(266 /* JsxOpeningFragment */); + return createSynthesizedNode(267 /* JsxOpeningFragment */); } ts.createJsxOpeningFragment = createJsxOpeningFragment; function createJsxJsxClosingFragment() { - return createSynthesizedNode(267 /* JsxClosingFragment */); + return createSynthesizedNode(268 /* JsxClosingFragment */); } ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment; function updateJsxFragment(node, openingFragment, children, closingFragment) { @@ -64423,7 +65248,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(268 /* JsxAttribute */); + var node = createSynthesizedNode(269 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -64437,7 +65262,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(269 /* JsxAttributes */); + var node = createSynthesizedNode(270 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -64449,7 +65274,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(270 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(271 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -64461,7 +65286,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(271 /* JsxExpression */); + var node = createSynthesizedNode(272 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -64475,7 +65300,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(272 /* CaseClause */); + var node = createSynthesizedNode(273 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -64489,7 +65314,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(273 /* DefaultClause */); + var node = createSynthesizedNode(274 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -64501,7 +65326,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(274 /* HeritageClause */); + var node = createSynthesizedNode(275 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -64514,7 +65339,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(275 /* CatchClause */); + var node = createSynthesizedNode(276 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -64529,7 +65354,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(276 /* PropertyAssignment */); + var node = createSynthesizedNode(277 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -64544,7 +65369,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(277 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(278 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -64558,7 +65383,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(278 /* SpreadAssignment */); + var node = createSynthesizedNode(279 /* SpreadAssignment */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -64571,7 +65396,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(279 /* EnumMember */); + var node = createSynthesizedNode(280 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -64592,7 +65417,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(285 /* SourceFile */); + var updated = createSynthesizedNode(286 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -64676,7 +65501,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(314 /* NotEmittedStatement */); + var node = createSynthesizedNode(316 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -64688,7 +65513,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(318 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(320 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -64700,7 +65525,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(317 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(319 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -64715,7 +65540,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(315 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(317 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -64731,7 +65556,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 316 /* CommaListExpression */) { + if (node.kind === 318 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { @@ -64741,7 +65566,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(316 /* CommaListExpression */); + var node = createSynthesizedNode(318 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -64754,7 +65579,7 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(286 /* Bundle */); + var node = ts.createNode(287 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -64785,7 +65610,7 @@ var ts; ], function (helper) { return helper.name; })); } function createUnparsedSource() { - var node = ts.createNode(287 /* UnparsedSource */); + var node = ts.createNode(288 /* UnparsedSource */); node.prologues = ts.emptyArray; node.referencedFiles = ts.emptyArray; node.libReferenceDirectives = ts.emptyArray; @@ -64917,10 +65742,10 @@ var ts; } function mapBundleFileSectionKindToSyntaxKind(kind) { switch (kind) { - case "prologue" /* Prologue */: return 280 /* UnparsedPrologue */; - case "prepend" /* Prepend */: return 281 /* UnparsedPrepend */; - case "internal" /* Internal */: return 283 /* UnparsedInternalText */; - case "text" /* Text */: return 282 /* UnparsedText */; + case "prologue" /* Prologue */: return 281 /* UnparsedPrologue */; + case "prepend" /* Prepend */: return 282 /* UnparsedPrepend */; + case "internal" /* Internal */: return 284 /* UnparsedInternalText */; + case "text" /* Text */: return 283 /* UnparsedText */; case "emitHelpers" /* EmitHelpers */: case "no-default-lib" /* NoDefaultLib */: case "reference" /* Reference */: @@ -64938,14 +65763,14 @@ var ts; return node; } function createUnparsedSyntheticReference(section, parent) { - var node = ts.createNode(284 /* UnparsedSyntheticReference */, section.pos, section.end); + var node = ts.createNode(285 /* UnparsedSyntheticReference */, section.pos, section.end); node.parent = parent; node.data = section.data; node.section = section; return node; } function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { - var node = ts.createNode(288 /* InputFiles */); + var node = ts.createNode(289 /* InputFiles */); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -64991,8 +65816,8 @@ var ts; node.declarationMapPath = declarationMapPath; node.declarationMapText = declarationMapTextOrBuildInfoPath; node.javascriptPath = javascriptPath; - node.declarationPath = declarationPath, - node.buildInfoPath = buildInfoPath; + node.declarationPath = declarationPath; + node.buildInfoPath = buildInfoPath; node.buildInfo = buildInfo; node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } @@ -65135,7 +65960,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 === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -65200,7 +66025,6 @@ var ts; return node; } ts.setSourceMapRange = setSourceMapRange; - // tslint:disable-next-line variable-name var SourceMapSource; /** * Create an external source map source file reference @@ -65486,9 +66310,9 @@ var ts; ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createFunctionCall(func, thisArg, argumentsList, location) { return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ thisArg - ].concat(argumentsList)), location); + ], argumentsList)), location); } ts.createFunctionCall = createFunctionCall; function createFunctionApply(func, thisArg, argumentsExpression, location) { @@ -65589,29 +66413,34 @@ var ts; } ts.createExpressionForJsxFragment = createExpressionForJsxFragment; // Helpers - function getHelperName(name) { + /** + * Gets an identifier for the name of an *unscoped* emit helper. + */ + function getUnscopedHelperName(name) { return ts.setEmitFlags(ts.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } - ts.getHelperName = getHelperName; + ts.getUnscopedHelperName = getUnscopedHelperName; ts.valuesHelper = { name: "typescript:values", + importName: "__values", scoped: false, - text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };" + text: "\n var __values = (this && this.__values) || function(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n };" }; function createValuesHelper(context, expression, location) { context.requestEmitHelper(ts.valuesHelper); - return ts.setTextRange(ts.createCall(getHelperName("__values"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__values"), /*typeArguments*/ undefined, [expression]), location); } ts.createValuesHelper = createValuesHelper; ts.readHelper = { name: "typescript:read", + importName: "__read", scoped: false, text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };" }; function createReadHelper(context, iteratorRecord, count, location) { context.requestEmitHelper(ts.readHelper); - return ts.setTextRange(ts.createCall(getHelperName("__read"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__read"), /*typeArguments*/ undefined, count !== undefined ? [iteratorRecord, ts.createLiteral(count)] : [iteratorRecord]), location); @@ -65619,24 +66448,26 @@ var ts; ts.createReadHelper = createReadHelper; ts.spreadHelper = { name: "typescript:spread", + importName: "__spread", scoped: false, text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" }; function createSpreadHelper(context, argumentList, location) { context.requestEmitHelper(ts.readHelper); context.requestEmitHelper(ts.spreadHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spread"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spread"), /*typeArguments*/ undefined, argumentList), location); } ts.createSpreadHelper = createSpreadHelper; ts.spreadArraysHelper = { name: "typescript:spreadArrays", + importName: "__spreadArrays", scoped: false, text: "\n var __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n };" }; function createSpreadArraysHelper(context, argumentList, location) { context.requestEmitHelper(ts.spreadArraysHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spreadArrays"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spreadArrays"), /*typeArguments*/ undefined, argumentList), location); } ts.createSpreadArraysHelper = createSpreadArraysHelper; @@ -65658,7 +66489,7 @@ var ts; ts.createForOfBindingStatement = createForOfBindingStatement; function insertLeadingStatement(dest, source) { if (ts.isBlock(dest)) { - return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray([source].concat(dest.statements)), dest.statements)); + return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray(__spreadArrays([source], dest.statements)), dest.statements)); } else { return ts.createBlock(ts.createNodeArray([dest, source]), /*multiLine*/ true); @@ -65669,7 +66500,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 234 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 235 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -65688,13 +66519,13 @@ var ts; case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -65721,7 +66552,7 @@ var ts; } else { switch (callee.kind) { - case 190 /* PropertyAccessExpression */: { + case 191 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -65734,7 +66565,7 @@ var ts; } break; } - case 191 /* ElementAccessExpression */: { + case 192 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -65791,14 +66622,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -66105,9 +66936,9 @@ var ts; function ensureUseStrict(statements) { var foundUseStrict = findUseStrictPrologue(statements); if (!foundUseStrict) { - return ts.setTextRange(ts.createNodeArray([ + return ts.setTextRange(ts.createNodeArray(__spreadArrays([ startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) - ].concat(statements)), statements); + ], statements)), statements); } return statements; } @@ -66124,7 +66955,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 === 196 /* ParenthesizedExpression */) { + if (skipped.kind === 197 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -66158,10 +66989,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(205 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(205 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(206 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(206 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 198 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 199 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -66173,7 +67004,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 208 /* YieldExpression */) { + && operand.kind === 209 /* YieldExpression */) { return false; } return true; @@ -66261,22 +67092,20 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { + if (node.kind === 206 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0 /* Unknown */; + var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind : + 0 /* Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(206 /* ConditionalExpression */, 56 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(207 /* ConditionalExpression */, 56 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -66311,8 +67140,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: + case 211 /* ClassExpression */: + case 198 /* FunctionExpression */: needsParens = true; } } @@ -66328,9 +67157,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 192 /* CallExpression */: + case 193 /* CallExpression */: return ts.createParen(expression); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -66353,7 +67182,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 193 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 194 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -66391,7 +67220,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(205 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(206 /* BinaryExpression */, 27 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -66402,29 +67231,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 197 /* FunctionExpression */ || kind === 198 /* ArrowFunction */) { + if (kind === 198 /* FunctionExpression */ || kind === 199 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 189 /* ObjectLiteralExpression */ || leftmostExpressionKind === 197 /* FunctionExpression */) { + if (leftmostExpressionKind === 190 /* ObjectLiteralExpression */ || leftmostExpressionKind === 198 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 176 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 177 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -66432,9 +67261,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 168 /* TypeQuery */: - case 180 /* TypeOperator */: - case 177 /* InferType */: + case 169 /* TypeQuery */: + case 181 /* TypeOperator */: + case 178 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -66460,28 +67289,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: node = node.operand; continue; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: node = node.left; continue; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: node = node.condition; continue; - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: node = node.tag; continue; - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 213 /* AsExpression */: - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: - case 214 /* NonNullExpression */: - case 315 /* PartiallyEmittedExpression */: + case 214 /* AsExpression */: + case 192 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 215 /* NonNullExpression */: + case 317 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -66490,15 +67319,15 @@ var ts; } ts.getLeftmostExpression = getLeftmostExpression; function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 189 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 190 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 316 /* CommaListExpression */; + return node.kind === 206 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 318 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -66511,13 +67340,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 214 /* NonNullExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: + case 215 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -66542,7 +67371,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 214 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 215 /* NonNullExpression */) { node = node.expression; } return node; @@ -66550,11 +67379,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 196 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 195 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 213 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 214 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 315 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 197 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 196 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 214 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 215 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 317 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -66572,7 +67401,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 196 /* ParenthesizedExpression */ + return node.kind === 197 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -66597,6 +67426,60 @@ var ts; return emitNode && emitNode.externalHelpersModuleName; } ts.getExternalHelpersModuleName = getExternalHelpersModuleName; + function hasRecordedExternalHelpers(sourceFile) { + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = parseNode && parseNode.emitNode; + return !!emitNode && (!!emitNode.externalHelpersModuleName || !!emitNode.externalHelpers); + } + ts.hasRecordedExternalHelpers = hasRecordedExternalHelpers; + function createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault) { + if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + var namedBindings = void 0; + var moduleKind = ts.getEmitModuleKind(compilerOptions); + if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) { + // use named imports + var helpers = ts.getEmitHelpers(sourceFile); + if (helpers) { + var helperNames = []; + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; + if (!helper.scoped) { + var importName = helper.importName; + if (importName) { + ts.pushIfUnique(helperNames, importName); + } + } + } + if (ts.some(helperNames)) { + helperNames.sort(ts.compareStringsCaseSensitive); + // Alias the imports if the names are used somewhere in the file. + // NOTE: We don't need to care about global import collisions as this is a module. + namedBindings = ts.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name) + ? ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name)) + : ts.createImportSpecifier(ts.createIdentifier(name), getUnscopedHelperName(name)); })); + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = ts.getOrCreateEmitNode(parseNode); + emitNode.externalHelpers = true; + } + } + } + else { + // use a namespace import + var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar || hasImportDefault); + if (externalHelpersModuleName) { + namedBindings = ts.createNamespaceImport(externalHelpersModuleName); + } + } + if (namedBindings) { + var externalHelpersImportDeclaration = ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, namedBindings), ts.createLiteral(ts.externalHelpersModuleNameText)); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); + return externalHelpersImportDeclaration; + } + } + } + ts.createExternalHelpersImportDeclarationIfNeeded = createExternalHelpersImportDeclarationIfNeeded; function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault) { if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(node, compilerOptions)) { var externalHelpersModuleName = getExternalHelpersModuleName(node); @@ -66611,8 +67494,8 @@ var ts; if (!create) { var helpers = ts.getEmitHelpers(node); if (helpers) { - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; + for (var _i = 0, helpers_3 = helpers; _i < helpers_3.length; _i++) { + var helper = helpers_3[_i]; if (!helper.scoped) { create = true; break; @@ -66637,10 +67520,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 250 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 251 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 256 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 257 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -66759,7 +67642,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -66771,11 +67654,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -66807,12 +67690,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 153 /* Parameter */: + case 188 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 209 /* SpreadElement */: - case 278 /* SpreadAssignment */: + case 210 /* SpreadElement */: + case 279 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -66824,7 +67707,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 187 /* BindingElement */: + case 188 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -66836,7 +67719,7 @@ var ts; : propertyName; } break; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -66848,7 +67731,7 @@ var ts; : propertyName; } break; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -66871,13 +67754,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: + case 189 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -66917,11 +67800,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 187 /* ArrayBindingPattern */: + case 189 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 186 /* ObjectBindingPattern */: + case 190 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -67044,11 +67927,9 @@ var ts; function visitLexicalEnvironment(statements, visitor, context, start, ensureUseStrict) { context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); - if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); - } - var declarations = context.endLexicalEnvironment(); - return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); + if (ensureUseStrict) + statements = ts.ensureUseStrict(statements); // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier + return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment()); } ts.visitLexicalEnvironment = visitLexicalEnvironment; /** @@ -67082,278 +67963,278 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */) || kind === 179 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 149 /* LastToken */) || kind === 180 /* ThisType */) { return node; } switch (kind) { // Names case 73 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 152 /* Parameter */: + case 153 /* Parameter */: return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 153 /* Decorator */: + case 154 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 154 /* PropertySignature */: + case 155 /* PropertySignature */: return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too visitNode(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 156 /* MethodSignature */: + case 157 /* MethodSignature */: return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 158 /* Constructor */: + case 159 /* Constructor */: return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 159 /* GetAccessor */: + case 160 /* GetAccessor */: return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 161 /* CallSignature */: + case 162 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); // Types - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 166 /* FunctionType */: + case 167 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 167 /* ConstructorType */: + case 168 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 171 /* TupleType */: + case 172 /* TupleType */: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 172 /* OptionalType */: + case 173 /* OptionalType */: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 173 /* RestType */: + case 174 /* RestType */: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174 /* UnionType */: + case 175 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 175 /* IntersectionType */: + case 176 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 177 /* InferType */: + case 178 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 184 /* ImportType */: + case 185 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 182 /* MappedType */: + case 183 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 183 /* LiteralType */: + case 184 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 186 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 213 /* AsExpression */: + case 214 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 219 /* Block */: + case 220 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 229 /* ContinueStatement */: + case 230 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 230 /* BreakStatement */: + case 231 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 253 /* NamedImports */: + case 254 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 257 /* NamedExports */: + case 258 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 258 /* ExportSpecifier */: + case 259 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 261 /* JsxElement */: + case 262 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 263 /* JsxOpeningElement */: + case 264 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 272 /* CaseClause */: + case 273 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 279 /* EnumMember */: + case 280 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 285 /* SourceFile */: + case 286 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -67395,58 +68276,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 149 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 164 /* TypePredicate */ && kind <= 183 /* LiteralType */)) { + if ((kind >= 165 /* TypePredicate */ && kind <= 184 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 218 /* SemicolonClassElement */: - case 221 /* EmptyStatement */: - case 211 /* OmittedExpression */: - case 237 /* DebuggerStatement */: - case 314 /* NotEmittedStatement */: + case 219 /* SemicolonClassElement */: + case 222 /* EmptyStatement */: + case 212 /* OmittedExpression */: + case 238 /* DebuggerStatement */: + case 316 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 152 /* Parameter */: + case 153 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 153 /* Decorator */: + case 154 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 154 /* PropertySignature */: + case 155 /* PropertySignature */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67455,12 +68336,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 158 /* Constructor */: + case 159 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 159 /* GetAccessor */: + case 160 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67468,7 +68349,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67476,50 +68357,50 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 187 /* BindingElement */: + case 188 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 192 /* CallExpression */: + case 193 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 193 /* NewExpression */: + case 194 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -67527,123 +68408,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 196 /* ParenthesizedExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: + case 200 /* DeleteExpression */: + case 201 /* TypeOfExpression */: + case 202 /* VoidExpression */: + case 203 /* AwaitExpression */: + case 209 /* YieldExpression */: + case 210 /* SpreadElement */: + case 215 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 213 /* AsExpression */: + case 214 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 219 /* Block */: + case 220 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 223 /* IfStatement */: + case 224 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 224 /* DoStatement */: + case 225 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 225 /* WhileStatement */: - case 232 /* WithStatement */: + case 226 /* WhileStatement */: + case 233 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 226 /* ForStatement */: + case 227 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 232 /* ReturnStatement */: + case 236 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 236 /* TryStatement */: + case 237 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67652,7 +68533,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67660,140 +68541,140 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.members, cbNodes, result); break; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 251 /* ImportClause */: + case 252 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 254 /* NamedImports */: + case 258 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // Module references - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 261 /* JsxElement */: + case 262 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 272 /* CaseClause */: + case 273 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 275 /* CatchClause */: + case 276 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 279 /* EnumMember */: + case 280 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 285 /* SourceFile */: + case 286 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -67866,7 +68747,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 212 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 213 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -67939,19 +68820,20 @@ var ts; exit(); return sourceIndex; } + /* eslint-disable boolean-trivia, no-null/no-null */ function setSourceContent(sourceIndex, content) { enter(); if (content !== null) { if (!sourcesContent) sourcesContent = []; while (sourcesContent.length < sourceIndex) { - // tslint:disable-next-line:no-null-keyword boolean-trivia sourcesContent.push(null); } sourcesContent[sourceIndex] = content; } exit(); } + /* eslint-enable boolean-trivia, no-null/no-null */ function addName(name) { enter(); if (!nameToNameIndexMap) @@ -68154,12 +69036,11 @@ var ts; } } ts.tryGetSourceMappingURL = tryGetSourceMappingURL; + /* eslint-disable no-null/no-null */ function isStringOrNull(x) { - // tslint:disable-next-line:no-null-keyword return typeof x === "string" || x === null; } function isRawSourceMap(x) { - // tslint:disable-next-line:no-null-keyword return x !== null && typeof x === "object" && x.version === 3 @@ -68171,6 +69052,7 @@ var ts; && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString)); } ts.isRawSourceMap = isRawSourceMap; + /* eslint-enable no-null/no-null */ function tryParseRawSourceMap(text) { try { var parsed = JSON.parse(text); @@ -68539,7 +69421,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 285 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 286 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -68581,25 +69463,31 @@ var ts; var hasExportDefault = false; var exportEquals; var hasExportStarsToExportValues = false; - var hasImportStarOrImportDefault = false; + var hasImportStar = false; + var hasImportDefault = false; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); - hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); + if (!hasImportStar && getImportNeedsImportStarHelper(node)) { + hasImportStar = true; + } + if (!hasImportDefault && getImportNeedsImportDefaultHelper(node)) { + hasImportDefault = true; + } break; - case 249 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + case 250 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 261 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -68629,13 +69517,13 @@ var ts; } } break; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -68643,7 +69531,7 @@ var ts; } } break; - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -68663,7 +69551,7 @@ var ts; } } break; - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -68685,12 +69573,8 @@ var ts; break; } } - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault); - var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault); if (externalHelpersImportDeclaration) { - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); externalImports.unshift(externalHelpersImportDeclaration); } return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames, externalHelpersImportDeclaration: externalHelpersImportDeclaration }; @@ -68765,7 +69649,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 223 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -68829,7 +69713,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 155 /* PropertyDeclaration */ + return member.kind === 156 /* PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; @@ -69278,6 +70162,7 @@ var ts; } ts.restHelper = { name: "typescript:rest", + importName: "__rest", scoped: false, text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n };" }; @@ -69302,7 +70187,7 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), + return ts.createCall(ts.getUnscopedHelperName("__rest"), /*typeArguments*/ undefined, [ value, ts.setTextRange(ts.createArrayLiteral(propertyNames), location) @@ -69355,8 +70240,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(191 /* PropertyAccessExpression */); + context.enableSubstitution(192 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -69382,14 +70267,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 286 /* Bundle */) { + if (node.kind === 287 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288 /* InputFiles */) { + if (prepend.kind === 289 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -69440,16 +70325,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 246 /* ModuleBlock */: - case 219 /* Block */: + case 286 /* SourceFile */: + case 248 /* CaseBlock */: + case 247 /* ModuleBlock */: + case 220 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 241 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -69461,7 +70346,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 === 241 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 242 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -69504,10 +70389,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 256 /* ExportAssignment */: + case 257 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -69528,13 +70413,13 @@ var ts; return node; } switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -69554,11 +70439,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 256 /* ExportDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 251 /* ImportClause */ || - (node.kind === 249 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 260 /* ExternalModuleReference */)) { + if (node.kind === 257 /* ExportDeclaration */ || + node.kind === 251 /* ImportDeclaration */ || + node.kind === 252 /* ImportClause */ || + (node.kind === 250 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 261 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -69582,19 +70467,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: return visitConstructor(node); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 164 /* IndexSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 158 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 218 /* SemicolonClassElement */: + case 219 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -69632,14 +70517,15 @@ var ts; case 78 /* ConstKeyword */: case 126 /* DeclareKeyword */: case 134 /* ReadonlyKeyword */: - // TypeScript accessibility and readonly modifiers are elided. - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 169 /* TypeLiteral */: - case 164 /* TypePredicate */: - case 151 /* TypeParameter */: + // TypeScript accessibility and readonly modifiers are elided + // falls through + case 171 /* ArrayType */: + case 172 /* TupleType */: + case 173 /* OptionalType */: + case 174 /* RestType */: + case 170 /* TypeLiteral */: + case 165 /* TypePredicate */: + case 152 /* TypeParameter */: case 121 /* AnyKeyword */: case 144 /* UnknownKeyword */: case 124 /* BooleanKeyword */: @@ -69648,40 +70534,43 @@ var ts; case 133 /* NeverKeyword */: case 107 /* VoidKeyword */: case 140 /* SymbolKeyword */: - case 167 /* ConstructorType */: - case 166 /* FunctionType */: - case 168 /* TypeQuery */: - case 165 /* TypeReference */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 178 /* ParenthesizedType */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: + case 168 /* ConstructorType */: + case 167 /* FunctionType */: + case 169 /* TypeQuery */: + case 166 /* TypeReference */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: + case 177 /* ConditionalType */: + case 179 /* ParenthesizedType */: + case 180 /* ThisType */: + case 181 /* TypeOperator */: + case 182 /* IndexedAccessType */: + case 183 /* MappedType */: + case 184 /* LiteralType */: // TypeScript type nodes are elided. - case 163 /* IndexSignature */: + // falls through + case 164 /* IndexSignature */: // TypeScript index signatures are elided. - case 153 /* Decorator */: + // falls through + case 154 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 243 /* TypeAliasDeclaration */: + // falls through + case 244 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 155 /* PropertyDeclaration */: + case 156 /* 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 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 158 /* Constructor */: + case 159 /* Constructor */: return visitConstructor(node); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -69691,7 +70580,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -69701,35 +70590,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 159 /* GetAccessor */: + case 160 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 152 /* Parameter */: + case 153 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -69739,35 +70628,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return visitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -70071,7 +70960,7 @@ var ts; var members = []; var constructor = ts.getFirstConstructorWithBody(node); var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (parametersWithPropertyAssignments) { for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) { var parameter = parametersWithPropertyAssignments_1[_i]; @@ -70177,12 +71066,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -70335,7 +71224,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 155 /* PropertyDeclaration */ + ? member.kind === 156 /* 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`. ? ts.createVoidZero() @@ -70458,10 +71347,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 155 /* PropertyDeclaration */; + return kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */ + || kind === 156 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -70471,7 +71360,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 158 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -70482,12 +71371,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return true; } return false; @@ -70504,15 +71393,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 153 /* Parameter */: return serializeTypeNode(node.type); - case 160 /* SetAccessor */: - case 159 /* GetAccessor */: + case 161 /* SetAccessor */: + case 160 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 157 /* MethodDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 158 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -70549,7 +71438,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 159 /* GetAccessor */) { + if (container && node.kind === 160 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -70599,26 +71488,26 @@ var ts; case 97 /* NullKeyword */: case 133 /* NeverKeyword */: return ts.createVoidZero(); - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: return ts.createIdentifier("Function"); - case 170 /* ArrayType */: - case 171 /* TupleType */: + case 171 /* ArrayType */: + case 172 /* TupleType */: return ts.createIdentifier("Array"); - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: case 124 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); case 139 /* StringKeyword */: return ts.createIdentifier("String"); case 137 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 183 /* LiteralType */: + case 184 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: return ts.createIdentifier("String"); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); case 9 /* BigIntLiteral */: @@ -70637,26 +71526,26 @@ var ts; return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return serializeTypeReferenceNode(node); - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 176 /* IntersectionType */: + case 175 /* UnionType */: return serializeTypeList(node.types); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: if (node.operator === 134 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 168 /* TypeQuery */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 169 /* TypeLiteral */: + case 169 /* TypeQuery */: + case 182 /* IndexedAccessType */: + case 183 /* MappedType */: + case 170 /* TypeLiteral */: case 121 /* AnyKeyword */: case 144 /* UnknownKeyword */: - case 179 /* ThisType */: - case 184 /* ImportType */: + case 180 /* ThisType */: + case 185 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -70667,9 +71556,9 @@ var ts; // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var typeNode = types_18[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var typeNode = types_17[_i]; + while (typeNode.kind === 179 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 133 /* NeverKeyword */) { @@ -70784,7 +71673,7 @@ var ts; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. return name; - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -70918,7 +71807,7 @@ var ts; } function transformConstructorBody(body, constructor) { var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (!ts.some(parametersWithPropertyAssignments)) { return ts.visitFunctionBody(body, visitor, context); } @@ -71331,12 +72220,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 285 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 286 /* 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 === 244 /* EnumDeclaration */) { + if (node.kind === 245 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -71461,7 +72350,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 246 /* ModuleBlock */) { + if (body.kind === 247 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -71507,13 +72396,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 (body.kind !== 246 /* ModuleBlock */) { + if (body.kind !== 247 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 246 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -71554,7 +72443,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 252 /* NamespaceImport */) { + if (node.kind === 253 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -71786,16 +72675,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(73 /* Identifier */); - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); + context.enableSubstitution(278 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(245 /* ModuleDeclaration */); + context.enableEmitNotification(246 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 245 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 246 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 244 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 245 /* EnumDeclaration */; } /** * Hook for node emit. @@ -71856,9 +72745,9 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return substituteExpressionIdentifier(node); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -71896,9 +72785,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 !== 285 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 245 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 244 /* EnumDeclaration */); + if (container && container.kind !== 286 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 246 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 245 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -71948,18 +72837,19 @@ var ts; } } context.requestEmitHelper(ts.decorateHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray), location); } ts.decorateHelper = { name: "typescript:decorate", + importName: "__decorate", scoped: false, priority: 2, text: "\n var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n };" }; function createMetadataHelper(context, metadataKey, metadataValue) { context.requestEmitHelper(ts.metadataHelper); - return ts.createCall(ts.getHelperName("__metadata"), + return ts.createCall(ts.getUnscopedHelperName("__metadata"), /*typeArguments*/ undefined, [ ts.createLiteral(metadataKey), metadataValue @@ -71967,13 +72857,14 @@ var ts; } ts.metadataHelper = { name: "typescript:metadata", + importName: "__metadata", scoped: false, priority: 3, text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(ts.paramHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__param"), /*typeArguments*/ undefined, [ ts.createLiteral(parameterOffset), expression @@ -71981,6 +72872,7 @@ var ts; } ts.paramHelper = { name: "typescript:param", + importName: "__param", scoped: false, priority: 4, text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" @@ -72034,11 +72926,11 @@ var ts; if (!(node.transformFlags & 1048576 /* ContainsClassFields */)) return node; switch (node.kind) { - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return visitClassExpression(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); } return ts.visitEachChild(node, visitor, context); @@ -72050,20 +72942,20 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 158 /* MethodDeclaration */: // Visit the name of the member (if it's a computed property name). return ts.visitEachChild(node, classElementVisitor, context); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 218 /* SemicolonClassElement */: + case 219 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -72073,7 +72965,7 @@ var ts; var savedPendingStatements = pendingStatements; pendingStatements = []; var visitedNode = ts.visitEachChild(node, visitor, context); - var statement = ts.some(pendingStatements) ? [visitedNode].concat(pendingStatements) : + var statement = ts.some(pendingStatements) ? __spreadArrays([visitedNode], pendingStatements) : visitedNode; pendingStatements = savedPendingStatements; return statement; @@ -72243,7 +73135,7 @@ var ts; if (constructor && constructor.body) { var parameterPropertyDeclarationCount = 0; for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) { - if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]))) { + if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) { parameterPropertyDeclarationCount++; } else { @@ -72425,6 +73317,7 @@ var ts; var hasSuperElementAccess; /** A set of node IDs for generated super accessors (variable statements). */ var substitutedSuperAccessors = []; + var topLevel; // Save the previous transformation hooks. var previousOnEmitNode = context.onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; @@ -72436,10 +73329,23 @@ var ts; if (node.isDeclarationFile) { return node; } + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitor(node) { if ((node.transformFlags & 32 /* ContainsES2017 */) === 0) { return node; @@ -72448,26 +73354,32 @@ var ts; case 122 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return visitAwaitExpression(node); - case 157 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 240 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: - return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 241 /* FunctionDeclaration */: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 198 /* FunctionExpression */: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 199 /* ArrowFunction */: return visitArrowFunction(node); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 159 /* Constructor */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -72475,27 +73387,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 219 /* Block */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 232 /* WithStatement */: - case 234 /* LabeledStatement */: + case 220 /* Block */: + case 234 /* SwitchStatement */: + case 248 /* CaseBlock */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: + case 237 /* TryStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 224 /* IfStatement */: + case 233 /* WithStatement */: + case 235 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -72696,7 +73608,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 === 198 /* ArrowFunction */; + var isArrowFunction = node.kind === 199 /* 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 @@ -72719,7 +73631,7 @@ var ts; if (!isArrowFunction) { var statements = []; var statementOffset = ts.addPrologue(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); - statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); + statements.push(ts.createReturn(createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. @@ -72746,7 +73658,7 @@ var ts; result = block; } else { - var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); + var expression = createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); @@ -72787,17 +73699,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(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(193 /* CallExpression */); + context.enableSubstitution(191 /* PropertyAccessExpression */); + context.enableSubstitution(192 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(242 /* ClassDeclaration */); + context.enableEmitNotification(158 /* MethodDeclaration */); + context.enableEmitNotification(160 /* GetAccessor */); + context.enableEmitNotification(161 /* SetAccessor */); + context.enableEmitNotification(159 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(221 /* VariableStatement */); } } /** @@ -72845,11 +73757,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -72873,19 +73785,19 @@ var ts; ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 242 /* ClassDeclaration */ + || kind === 159 /* Constructor */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -72945,11 +73857,12 @@ var ts; ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; ts.awaiterHelper = { name: "typescript:awaiter", + importName: "__awaiter", scoped: false, priority: 5, text: "\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };" }; - function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { + function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression( /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), @@ -72959,9 +73872,9 @@ var ts; /*type*/ undefined, body); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; - return ts.createCall(ts.getHelperName("__awaiter"), + return ts.createCall(ts.getUnscopedHelperName("__awaiter"), /*typeArguments*/ undefined, [ - ts.createThis(), + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), generatorFunc @@ -72995,9 +73908,11 @@ var ts; context.onEmitNode = onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; + var exportedVariableStatement = false; var enabledSubstitutions; var enclosingFunctionFlags; var enclosingSuperContainerFlags = 0; + var topLevel; /** Keeps track of property names accessed on super (`super.x`) within async functions. */ var capturedSuperProperties; /** Whether the async function contains an element access on super (`super[x]`). */ @@ -73009,6 +73924,8 @@ var ts; if (node.isDeclarationFile) { return node; } + exportedVariableStatement = false; + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -73025,63 +73942,80 @@ var ts; } return node; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitorWorker(node, noDestructuringValue) { if ((node.transformFlags & 16 /* ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return visitAwaitExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return visitYieldExpression(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitReturnStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitLabeledStatement(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClause(node); - case 238 /* VariableDeclaration */: + case 221 /* VariableStatement */: + return visitVariableStatement(node); + case 239 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return visitVoidExpression(node); - case 158 /* Constructor */: - return visitConstructorDeclaration(node); - case 157 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - return visitGetAccessorDeclaration(node); - case 160 /* SetAccessor */: - return visitSetAccessorDeclaration(node); - case 240 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: - return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 159 /* Constructor */: + return doOutsideOfTopLevel(visitConstructorDeclaration, node); + case 158 /* MethodDeclaration */: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 160 /* GetAccessor */: + return doOutsideOfTopLevel(visitGetAccessorDeclaration, node); + case 161 /* SetAccessor */: + return doOutsideOfTopLevel(visitSetAccessorDeclaration, node); + case 241 /* FunctionDeclaration */: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 198 /* FunctionExpression */: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 199 /* ArrowFunction */: return visitArrowFunction(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return visitParameter(node); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return visitExpressionStatement(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -73114,7 +74048,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 228 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 229 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -73126,7 +74060,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 === 278 /* SpreadAssignment */) { + if (e.kind === 279 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -73135,7 +74069,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 276 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 277 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -73169,7 +74103,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 !== 189 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 190 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } var expression = objects[0]; @@ -73214,23 +74148,44 @@ var ts; var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { - block = ts.updateBlock(block, [ + block = ts.updateBlock(block, __spreadArrays([ ts.createVariableStatement(/*modifiers*/ undefined, visitedBindings) - ].concat(block.statements)); + ], block.statements)); } return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, /*type*/ undefined, /*initializer*/ undefined), block); } return ts.visitEachChild(node, visitor, context); } + function visitVariableStatement(node) { + if (ts.hasModifier(node, 1 /* Export */)) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = true; + var visited = ts.visitEachChild(node, visitor, context); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return ts.visitEachChild(node, visitor, context); + } /** * Visits a VariableDeclaration node with a binding pattern. * * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { + if (exportedVariableStatement) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = false; + var visited = visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ true); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ false); + } + 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 & 8192 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */); + return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, + /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); } @@ -73448,7 +74403,7 @@ var ts; /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))))); + /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !topLevel)); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); @@ -73514,17 +74469,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(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(193 /* CallExpression */); + context.enableSubstitution(191 /* PropertyAccessExpression */); + context.enableSubstitution(192 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(242 /* ClassDeclaration */); + context.enableEmitNotification(158 /* MethodDeclaration */); + context.enableEmitNotification(160 /* GetAccessor */); + context.enableEmitNotification(161 /* SetAccessor */); + context.enableEmitNotification(159 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(221 /* VariableStatement */); } } /** @@ -73572,11 +74527,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -73600,19 +74555,19 @@ var ts; ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 242 /* ClassDeclaration */ + || kind === 159 /* Constructor */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -73628,65 +74583,69 @@ var ts; ts.transformES2018 = transformES2018; ts.assignHelper = { name: "typescript:assign", + importName: "__assign", scoped: false, priority: 1, text: "\n var __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n };" }; function createAssignHelper(context, attributesSegments) { if (context.getCompilerOptions().target >= 2 /* ES2015 */) { - return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), - /*typeArguments*/ undefined, attributesSegments); + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } context.requestEmitHelper(ts.assignHelper); - return ts.createCall(ts.getHelperName("__assign"), + return ts.createCall(ts.getUnscopedHelperName("__assign"), /*typeArguments*/ undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; ts.awaitHelper = { name: "typescript:await", + importName: "__await", scoped: false, text: "\n var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }" }; function createAwaitHelper(context, expression) { context.requestEmitHelper(ts.awaitHelper); - return ts.createCall(ts.getHelperName("__await"), /*typeArguments*/ undefined, [expression]); + return ts.createCall(ts.getUnscopedHelperName("__await"), /*typeArguments*/ undefined, [expression]); } ts.asyncGeneratorHelper = { name: "typescript:asyncGenerator", + importName: "__asyncGenerator", scoped: false, text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n };" }; - function createAsyncGeneratorHelper(context, generatorFunc) { + function createAsyncGeneratorHelper(context, generatorFunc, hasLexicalThis) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */; - return ts.createCall(ts.getHelperName("__asyncGenerator"), + return ts.createCall(ts.getUnscopedHelperName("__asyncGenerator"), /*typeArguments*/ undefined, [ - ts.createThis(), + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), ts.createIdentifier("arguments"), generatorFunc ]); } ts.asyncDelegator = { name: "typescript:asyncDelegator", + importName: "__asyncDelegator", scoped: false, text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\n };" }; function createAsyncDelegatorHelper(context, expression, location) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncDelegator); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncDelegator"), /*typeArguments*/ undefined, [expression]), location); } ts.asyncValues = { name: "typescript:asyncValues", + importName: "__asyncValues", scoped: false, text: "\n var __asyncValues = (this && this.__asyncValues) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n };" }; function createAsyncValuesHelper(context, expression, location) { context.requestEmitHelper(ts.asyncValues); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncValues"), /*typeArguments*/ undefined, [expression]), location); } })(ts || (ts = {})); @@ -73706,7 +74665,7 @@ var ts; return node; } switch (node.kind) { - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -73775,13 +74734,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 261 /* JsxElement */: + case 262 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -73791,13 +74750,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return visitJsxExpression(node); - case 261 /* JsxElement */: + case 262 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -73872,7 +74831,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 271 /* JsxExpression */) { + else if (node.kind === 272 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -73966,7 +74925,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 261 /* JsxElement */) { + if (node.kind === 262 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -74272,7 +75231,7 @@ var ts; return node; } switch (node.kind) { - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74485,13 +75444,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 231 /* ReturnStatement */ + && node.kind === 232 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */))) + || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 220 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -74513,63 +75472,63 @@ var ts; switch (node.kind) { case 117 /* StaticKeyword */: return undefined; // elide static keyword - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return visitClassExpression(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return visitParameter(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return visitArrowFunction(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return visitFunctionExpression(node); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return visitVariableDeclaration(node); case 73 /* Identifier */: return visitIdentifier(node); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return visitCaseBlock(node); - case 219 /* Block */: + case 220 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitLabeledStatement(node); - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return visitExpressionStatement(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClause(node); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return visitNewExpression(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -74580,28 +75539,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return visitTemplateExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return visitYieldExpression(node); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return visitSpreadElement(node); case 99 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); case 101 /* ThisKeyword */: return visitThisKeyword(node); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return visitMetaProperty(node); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -74692,14 +75651,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 === 230 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 231 /* 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 === 230 /* BreakStatement */) { + if (node.kind === 231 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -74710,7 +75669,7 @@ var ts; } } else { - if (node.kind === 230 /* BreakStatement */) { + if (node.kind === 231 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -75106,11 +76065,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 231 /* ReturnStatement */) { + if (statement.kind === 232 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 223 /* IfStatement */) { + else if (statement.kind === 224 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -75118,7 +76077,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 219 /* Block */) { + else if (statement.kind === 220 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -75316,7 +76275,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 199 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, ts.createThis()); return true; } @@ -75337,22 +76296,22 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return statements; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 158 /* Constructor */: + case 159 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 198 /* 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 = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 95 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); @@ -75384,20 +76343,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 218 /* SemicolonClassElement */: + case 219 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 158 /* Constructor */: + case 159 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -75585,7 +76544,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 === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 241 /* FunctionDeclaration */ || node.kind === 198 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -75629,7 +76588,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 198 /* ArrowFunction */); + ts.Debug.assert(node.kind === 199 /* 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 @@ -75697,9 +76656,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -75718,9 +76677,9 @@ var ts; // expression. If we are in a state where we do not need the destructuring value, // we pass that information along to the children that care about it. switch (node.expression.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -75929,14 +76888,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -76124,7 +77083,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 150 /* ComputedPropertyName */) { + if (property.name.kind === 151 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -76245,11 +77204,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 226 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 227 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 228 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 224 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 225 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 227 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 228 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 229 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 225 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 226 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -76274,11 +77233,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 240 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -76677,20 +77636,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -76766,7 +77725,7 @@ var ts; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); - return ts.updateBlock(block, [statement].concat(transformedStatements)); + return ts.updateBlock(block, __spreadArrays([statement], transformedStatements)); } /** * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a @@ -76797,7 +77756,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 160 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -77034,7 +77993,7 @@ var ts; // [output] // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray(__spreadArrays([ts.createVoidZero()], node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), /*typeArguments*/ undefined, []); } return ts.visitEachChild(node, visitor, context); @@ -77198,13 +78157,16 @@ var ts; // Find original source text, since we need to emit the raw strings of the tagged template. // The raw strings contain the (escaped) strings of what the user wrote. // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), - // thus we need to remove those characters. - // First template piece starts with "`", others with "}" - // Last template piece ends with "`", others with "${" - var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; - text = text.substring(1, text.length - (isLast ? 1 : 2)); + var text = node.rawText; + if (text === undefined) { + text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), + // thus we need to remove those characters. + // First template piece starts with "`", others with "}" + // Last template piece ends with "`", others with "${" + var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; + text = text.substring(1, text.length - (isLast ? 1 : 2)); + } // Newline normalization: // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's // and LineTerminatorSequences are normalized to for both TV and TRV. @@ -77295,10 +78257,8 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ - && !isExpressionOfCall - ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") - : ts.createFileLevelUniqueName("_super"); + return hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") : + ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { if (node.keywordToken === 96 /* NewKeyword */ && node.name.escapedText === "target") { @@ -77344,13 +78304,13 @@ var ts; if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; context.enableSubstitution(101 /* ThisKeyword */); - context.enableEmitNotification(158 /* Constructor */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(198 /* ArrowFunction */); - context.enableEmitNotification(197 /* FunctionExpression */); - context.enableEmitNotification(240 /* FunctionDeclaration */); + context.enableEmitNotification(159 /* Constructor */); + context.enableEmitNotification(158 /* MethodDeclaration */); + context.enableEmitNotification(160 /* GetAccessor */); + context.enableEmitNotification(161 /* SetAccessor */); + context.enableEmitNotification(199 /* ArrowFunction */); + context.enableEmitNotification(198 /* FunctionExpression */); + context.enableEmitNotification(241 /* FunctionDeclaration */); } } /** @@ -77391,10 +78351,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 238 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 239 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -77476,11 +78436,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 222 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 223 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 192 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 193 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -77488,7 +78448,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 209 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 210 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -77498,7 +78458,7 @@ var ts; ts.transformES2015 = transformES2015; function createExtendsHelper(context, name) { context.requestEmitHelper(ts.extendsHelper); - return ts.createCall(ts.getHelperName("__extends"), + return ts.createCall(ts.getUnscopedHelperName("__extends"), /*typeArguments*/ undefined, [ name, ts.createFileLevelUniqueName("_super") @@ -77506,7 +78466,7 @@ var ts; } function createTemplateObjectHelper(context, cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); - return ts.createCall(ts.getHelperName("__makeTemplateObject"), + return ts.createCall(ts.getUnscopedHelperName("__makeTemplateObject"), /*typeArguments*/ undefined, [ cooked, raw @@ -77514,12 +78474,14 @@ var ts; } ts.extendsHelper = { name: "typescript:extends", + importName: "__extends", scoped: false, priority: 0, text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; ts.templateObjectHelper = { name: "typescript:makeTemplateObject", + importName: "__makeTemplateObject", scoped: false, priority: 0, text: "\n var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n };" @@ -77541,15 +78503,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(263 /* JsxOpeningElement */); - context.enableEmitNotification(264 /* JsxClosingElement */); - context.enableEmitNotification(262 /* JsxSelfClosingElement */); + context.enableEmitNotification(264 /* JsxOpeningElement */); + context.enableEmitNotification(265 /* JsxClosingElement */); + context.enableEmitNotification(263 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(276 /* PropertyAssignment */); + context.enableSubstitution(191 /* PropertyAccessExpression */); + context.enableSubstitution(277 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -77568,9 +78530,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 265 /* JsxClosingElement */: + case 263 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -77902,13 +78864,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 224 /* DoStatement */: + case 225 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return visitWhileStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return visitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -77921,24 +78883,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return visitFunctionExpression(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatement(node); - case 230 /* BreakStatement */: + case 231 /* BreakStatement */: return visitBreakStatement(node); - case 229 /* ContinueStatement */: + case 230 /* ContinueStatement */: return visitContinueStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 131072 /* ContainsYield */) { @@ -77959,21 +78921,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return visitConditionalExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return visitYieldExpression(node); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -77986,9 +78948,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -78216,7 +79178,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -78228,7 +79190,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -78454,13 +79416,13 @@ var ts; temp = declareLocal(); var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements); emitAssignment(temp, ts.createArrayLiteral(leadingElement - ? [leadingElement].concat(initialElements) : initialElements)); + ? __spreadArrays([leadingElement], initialElements) : initialElements)); leadingElement = undefined; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return temp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { var hasAssignedTemp = temp !== undefined; @@ -78469,7 +79431,7 @@ var ts; } emitAssignment(temp, hasAssignedTemp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); + : ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine)); leadingElement = undefined; expressions = []; } @@ -78604,35 +79566,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 219 /* Block */: + case 220 /* Block */: return transformAndEmitBlock(node); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return transformAndEmitIfStatement(node); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return transformAndEmitDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return transformAndEmitForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 229 /* ContinueStatement */: + case 230 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 230 /* BreakStatement */: + case 231 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return transformAndEmitWithStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -79062,7 +80024,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 273 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 274 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -79075,7 +80037,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 273 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -79248,11 +80210,10 @@ var ts; return node; } function cacheExpression(node) { - var temp; if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { return node; } - temp = ts.createTempVariable(hoistVariableDeclaration); + var temp = ts.createTempVariable(hoistVariableDeclaration); emitAssignment(temp, node, /*location*/ node); return temp; } @@ -80213,7 +81174,7 @@ var ts; ts.transformGenerators = transformGenerators; function createGeneratorHelper(context, body) { context.requestEmitHelper(ts.generatorHelper); - return ts.createCall(ts.getHelperName("__generator"), + return ts.createCall(ts.getUnscopedHelperName("__generator"), /*typeArguments*/ undefined, [ts.createThis(), body]); } // The __generator helper is used by down-level transformations to emulate the runtime @@ -80277,6 +81238,7 @@ var ts; // For examples of how these are used, see the comments in ./transformers/generators.ts ts.generatorHelper = { name: "typescript:generator", + importName: "__generator", scoped: false, priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" @@ -80304,11 +81266,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(206 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(204 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(205 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(278 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(286 /* 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. @@ -80406,14 +81368,14 @@ var ts; // define(moduleName?, ["module1", "module2"], function ... var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createExpressionStatement(ts.createCall(define, - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ + /*typeArguments*/ undefined, __spreadArrays((moduleName ? [moduleName] : []), [ // Add the dependency array argument: // // ["require", "exports", module1", "module2", ...] - ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : [ + ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : __spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), // Add the module body function argument: // // function (require, exports, module1, module2) ... @@ -80423,10 +81385,10 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ + /*typeParameters*/ undefined, __spreadArrays([ ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), + ], importAliasNames), /*type*/ undefined, transformAsynchronousModuleBody(node)) ]))) ]), @@ -80461,11 +81423,11 @@ var ts; ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ - ts.createArrayLiteral([ + /*typeArguments*/ undefined, __spreadArrays((moduleName ? [moduleName] : []), [ + ts.createArrayLiteral(__spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), ts.createIdentifier("factory") ]))) ]))) @@ -80493,10 +81455,10 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ + /*typeParameters*/ undefined, __spreadArrays([ ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), + ], importAliasNames), /*type*/ undefined, transformAsynchronousModuleBody(node)) ])) ]), @@ -80636,23 +81598,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return visitExportDeclaration(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitExportAssignment(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return visitClassDeclaration(node); - case 317 /* MergeDeclarationMarker */: + case 319 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 318 /* EndOfDeclarationMarker */: + case 320 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -80679,24 +81641,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -80811,7 +81773,7 @@ var ts; var promise = ts.createNew(ts.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getHelperName("__importStar")]); + return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getUnscopedHelperName("__importStar")]); } return promise; } @@ -80825,7 +81787,7 @@ var ts; var requireCall = ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - requireCall = ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); + requireCall = ts.createCall(ts.getUnscopedHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); } var func; if (languageVersion >= 2 /* ES2015 */) { @@ -80859,11 +81821,11 @@ var ts; } if (ts.getImportNeedsImportStarHelper(node)) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); } if (ts.getImportNeedsImportDefaultHelper(node)) { context.requestEmitHelper(ts.importDefaultHelper); - return ts.createCall(ts.getHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); } return innerExpr; } @@ -81174,7 +82136,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 221 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -81229,10 +82191,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 254 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -81431,7 +82393,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -81495,10 +82457,10 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return substituteBinaryExpression(node); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -81519,7 +82481,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 286 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -81594,7 +82556,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 /* PostfixUnaryExpression */ + var expression = node.kind === 205 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 /* PlusPlusToken */ ? 61 /* PlusEqualsToken */ : 62 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; @@ -81635,7 +82597,7 @@ var ts; function createExportStarHelper(context, module) { var compilerOptions = context.getCompilerOptions(); return compilerOptions.importHelpers - ? ts.createCall(ts.getHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]) + ? ts.createCall(ts.getUnscopedHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]) : ts.createCall(ts.createIdentifier("__export"), /*typeArguments*/ undefined, [module]); } // emit helper for dynamic import @@ -81647,12 +82609,14 @@ var ts; // emit helper for `import * as Name from "foo"` ts.importStarHelper = { name: "typescript:commonjsimportstar", + importName: "__importStar", scoped: false, text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};" }; // emit helper for `import Name from "foo"` ts.importDefaultHelper = { name: "typescript:commonjsimportdefault", + importName: "__importDefault", scoped: false, text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};" }; @@ -81670,15 +82634,17 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(278 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(206 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(204 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(205 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(216 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(286 /* 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. var noSubstitutionMap = []; // Set of nodes for which substitution rules should be ignored for each file. + var contextObjectMap = []; // The context object associated with a source file. var currentSourceFile; // The current file. var moduleInfo; // ExternalModuleInfo for the current file. var exportFunction; // The export function for the current file. @@ -81717,7 +82683,7 @@ var ts; // existing identifiers. exportFunction = ts.createUniqueName("exports"); exportFunctionsMap[id] = exportFunction; - contextObject = ts.createUniqueName("context"); + contextObject = contextObjectMap[id] = ts.createUniqueName("context"); // Add the body of the module. var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups); @@ -81895,7 +82861,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 256 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 257 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -81920,7 +82886,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 256 /* ExportDeclaration */) { + if (externalImport.kind !== 257 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -81998,19 +82964,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -82060,15 +83026,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -82244,7 +83210,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 === 285 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 286 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -82308,7 +83274,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 === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 221 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -82370,10 +83336,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 254 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -82553,43 +83519,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatement(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatement(node); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return visitWhileStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitLabeledStatement(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return visitWithStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return visitCaseBlock(node); - case 272 /* CaseClause */: + case 273 /* CaseClause */: return visitCaseClause(node); - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: return visitDefaultClause(node); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return visitTryStatement(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClause(node); - case 219 /* Block */: + case 220 /* Block */: return visitBlock(node); - case 317 /* MergeDeclarationMarker */: + case 319 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 318 /* EndOfDeclarationMarker */: + case 320 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -82836,7 +83802,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 285 /* SourceFile */; + return container !== undefined && container.kind === 286 /* SourceFile */; } else { return false; @@ -82869,12 +83835,13 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; exportFunction = exportFunctionsMap[id]; noSubstitution = noSubstitutionMap[id]; + contextObject = contextObjectMap[id]; if (noSubstitution) { delete noSubstitutionMap[id]; } @@ -82882,6 +83849,7 @@ var ts; currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; + contextObject = undefined; noSubstitution = undefined; } else { @@ -82917,7 +83885,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -82953,11 +83921,13 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return substituteBinaryExpression(node); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); + case 216 /* MetaProperty */: + return substituteMetaProperty(node); } return node; } @@ -83049,14 +84019,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 /* PostfixUnaryExpression */ + var expression = node.kind === 205 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(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 === 204 /* PostfixUnaryExpression */) { + if (node.kind === 205 /* PostfixUnaryExpression */) { expression = node.operator === 44 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -83066,6 +84036,12 @@ var ts; } return node; } + function substituteMetaProperty(node) { + if (ts.isImportMeta(node)) { + return ts.createPropertyAccess(contextObject, ts.createIdentifier("meta")); + } + return node; + } /** * Gets the exports of a name. * @@ -83078,7 +84054,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 286 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -83117,24 +84093,20 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(285 /* SourceFile */); + context.enableEmitNotification(286 /* SourceFile */); context.enableSubstitution(73 /* Identifier */); - var currentSourceFile; + var helperNameSubstitutions; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { return node; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); - if (externalHelpersModuleName) { + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(node, compilerOptions); + if (externalHelpersImportDeclaration) { var statements = []; var statementOffset = ts.addPrologue(statements, node.statements); - var tslibImport = ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); - ts.addEmitFlags(tslibImport, 67108864 /* NeverApplyImportHelper */); - ts.append(statements, tslibImport); + ts.append(statements, externalHelpersImportDeclaration); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } @@ -83146,10 +84118,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -83170,9 +84142,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { if (ts.isSourceFile(node)) { - currentSourceFile = node; + helperNameSubstitutions = ts.createMap(); previousOnEmitNode(hint, node, emitCallback); - currentSourceFile = undefined; + helperNameSubstitutions = undefined; } else { previousOnEmitNode(hint, node, emitCallback); @@ -83189,19 +84161,18 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (ts.isIdentifier(node) && hint === 1 /* Expression */) { - return substituteExpressionIdentifier(node); + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* HelperName */) { + return substituteHelperName(node); } return node; } - function substituteExpressionIdentifier(node) { - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { - var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); - if (externalHelpersModuleName) { - return ts.createPropertyAccess(externalHelpersModuleName, node); - } + function substituteHelperName(node) { + var name = ts.idText(node); + var substitution = helperNameSubstitutions.get(name); + if (!substitution) { + helperNameSubstitutions.set(name, substitution = ts.createFileLevelUniqueName(name)); } - return node; + return substitution; } } ts.transformES2015Module = transformES2015Module; @@ -83257,7 +84228,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 242 /* 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 : @@ -83286,7 +84257,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 242 /* 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 : @@ -83312,7 +84283,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node) && ts.hasModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8 /* Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -83333,7 +84304,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 === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 239 /* VariableDeclaration */ || node.kind === 188 /* 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 : @@ -83342,8 +84313,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 === 155 /* PropertyDeclaration */ || node.kind === 190 /* PropertyAccessExpression */ || node.kind === 154 /* PropertySignature */ || - (node.kind === 152 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 156 /* PropertyDeclaration */ || node.kind === 191 /* PropertyAccessExpression */ || node.kind === 155 /* PropertySignature */ || + (node.kind === 153 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -83352,7 +84323,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 === 241 /* ClassDeclaration */ || node.kind === 152 /* Parameter */) { + else if (node.parent.kind === 242 /* ClassDeclaration */ || node.kind === 153 /* 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 : @@ -83377,7 +84348,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 161 /* 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.hasModifier(node, 32 /* Static */)) { @@ -83416,26 +84387,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 162 /* ConstructSignature */: + case 163 /* 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 161 /* CallSignature */: + case 162 /* 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 163 /* IndexSignature */: + case 164 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -83443,7 +84414,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 242 /* 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 : @@ -83457,7 +84428,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 240 /* FunctionDeclaration */: + case 241 /* 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 : @@ -83482,30 +84453,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 158 /* Constructor */: + case 159 /* 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 162 /* ConstructSignature */: - case 167 /* ConstructorType */: + case 163 /* ConstructSignature */: + case 168 /* 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 161 /* CallSignature */: + case 162 /* 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 163 /* IndexSignature */: + case 164 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -83513,7 +84484,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 === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 242 /* 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 : @@ -83526,8 +84497,8 @@ 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 240 /* FunctionDeclaration */: - case 166 /* FunctionType */: + case 241 /* FunctionDeclaration */: + case 167 /* 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 : @@ -83541,39 +84512,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 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 182 /* MappedType */: + case 183 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 168 /* ConstructorType */: + case 163 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 161 /* CallSignature */: + case 162 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.hasModifier(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 === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 242 /* 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 166 /* FunctionType */: - case 240 /* FunctionDeclaration */: + case 167 /* FunctionType */: + case 241 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -83588,7 +84559,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + if (node.parent.parent.kind === 242 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 110 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -83639,7 +84610,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 152 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 153 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -83700,6 +84671,7 @@ var ts; var currentSourceFile; var refs; var libs; + var emittedImports; // must be declared in container so it can be `undefined` while transformer's first pass var resolver = context.getEmitResolver(); var options = context.getCompilerOptions(); var newLine = ts.getNewLineCharacter(options); @@ -83789,10 +84761,10 @@ var ts; return ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createNamedExports([]), /*moduleSpecifier*/ undefined); } function transformRoot(node) { - if (node.kind === 285 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 286 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { return node; } - if (node.kind === 286 /* Bundle */) { + if (node.kind === 287 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); @@ -83822,7 +84794,7 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288 /* InputFiles */) { + if (prepend.kind === 289 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -83862,9 +84834,9 @@ var ts; var statements = ts.visitNodes(node.statements, visitDeclarationStatements); var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); refs.forEach(referenceVisitor); - var emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { - combinedStatements = ts.setTextRange(ts.createNodeArray(combinedStatements.concat([createEmptyExports()])), combinedStatements); + combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [createEmptyExports()])), combinedStatements); } var updated = ts.updateSourceFileNode(node, combinedStatements, /*isDeclarationFile*/ true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences()); updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit; @@ -83906,6 +84878,15 @@ 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, host.getSourceFiles(), + /*preferences*/ undefined, host.redirectTargetsMap); + if (!ts.pathIsRelative(specifier)) { + // If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration + // via a non-relative name, emit a type reference directive to that non-relative name, rather than + // a relative path to the declaration file + recordTypeReferenceDirectivesIfNecessary([specifier]); + return; + } var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); if (ts.startsWith(fileName, "./") && ts.hasExtension(fileName)) { @@ -83946,7 +84927,7 @@ var ts; return name; } else { - if (name.kind === 186 /* ArrayBindingPattern */) { + if (name.kind === 187 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -83954,20 +84935,20 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 211 /* OmittedExpression */) { + if (elem.kind === 212 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); } } - function ensureParameter(p, modifierMask) { + function ensureParameter(p, modifierMask, type) { var oldDiag; if (!suppressNewDiagnosticContexts) { oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } var newParam = ts.updateParameter(p, - /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(56 /* QuestionToken */)) : undefined, ensureType(p, p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param + /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(56 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -83992,7 +84973,7 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 152 /* Parameter */ && + var shouldUseResolverType = node.kind === 153 /* Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { @@ -84001,7 +84982,7 @@ var ts; if (!ts.getParseTreeNode(node)) { return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(121 /* AnyKeyword */); } - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 161 /* 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 ts.createKeywordTypeNode(121 /* AnyKeyword */); @@ -84012,12 +84993,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 239 /* VariableDeclaration */ || node.kind === 188 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 152 /* Parameter */ - || node.kind === 155 /* PropertyDeclaration */ - || node.kind === 154 /* PropertySignature */) { + if (node.kind === 153 /* Parameter */ + || node.kind === 156 /* PropertyDeclaration */ + || node.kind === 155 /* 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)); @@ -84034,20 +85015,20 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 241 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 243 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 245 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 250 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: + case 256 /* ExportAssignment */: return false; } return false; @@ -84074,6 +85055,33 @@ var ts; } return ts.createNodeArray(newParams, params.hasTrailingComma); } + function updateAccessorParamsList(input, isPrivate) { + var newParams; + if (!isPrivate) { + var thisParameter = ts.getThisParameter(input); + if (thisParameter) { + newParams = [ensureParameter(thisParameter)]; + } + } + if (ts.isSetAccessorDeclaration(input)) { + var newValueParameter = void 0; + if (!isPrivate) { + var valueParameter = ts.getSetAccessorValueParameter(input); + if (valueParameter) { + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + newValueParameter = ensureParameter(valueParameter, /*modifierMask*/ undefined, accessorType); + } + } + if (!newValueParameter) { + newValueParameter = ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "value"); + } + newParams = ts.append(newParams, newValueParameter); + } + return ts.createNodeArray(newParams || ts.emptyArray); + } function ensureTypeParams(node, params) { return ts.hasModifier(node, 8 /* Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } @@ -84101,7 +85109,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 245 /* ModuleDeclaration */ && parent.kind !== 184 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 246 /* ModuleDeclaration */ && parent.kind !== 185 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -84121,7 +85129,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 261 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -84148,7 +85156,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 253 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -84240,6 +85248,11 @@ var ts; enclosingDeclaration = input; } var oldDiag = getSymbolAccessibilityDiagnostic; + // Setup diagnostic-related flags before first potential `cleanup` call, otherwise + // We'd see a TDZ violation at runtime + var canProduceDiagnostic = ts.canProduceDiagnostics(input); + var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 170 /* TypeLiteral */ || input.kind === 183 /* MappedType */) && input.parent.kind !== 244 /* TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { if (ts.hasModifier(input, 8 /* Private */)) { @@ -84248,76 +85261,87 @@ var ts; return cleanup(ts.createProperty(/*decorators*/ undefined, ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); } } - var canProdiceDiagnostic = ts.canProduceDiagnostics(input); - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input); } if (ts.isTypeQueryNode(input)) { checkEntityNameVisibility(input.exprName, enclosingDeclaration); } - var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 169 /* TypeLiteral */ || input.kind === 182 /* MappedType */) && input.parent.kind !== 243 /* TypeAliasDeclaration */); if (shouldEnterSuppressNewDiagnosticsContextContext) { // We stop making new diagnostic contexts within object literal types. Unless it's an object type on the RHS of a type alias declaration. Then we do. suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 212 /* ExpressionWithTypeArguments */: { + case 213 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 165 /* TypeReference */: { + case 166 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 158 /* Constructor */: { + case 159 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(158 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + var ctor = ts.createSignatureDeclaration(159 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), // TODO: GH#18217 isPrivate ? undefined : updateParamsList(input, input.parameters, 0 /* None */), /*type*/ undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 157 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(156 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 158 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(157 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 159 /* GetAccessor */: { + case 160 /* GetAccessor */: { + // For now, only emit class accessors as accessors if they were already declared in an ambient context. + if (input.flags & 4194304 /* Ambient */) { + var isPrivate = ts.hasModifier(input, 8 /* Private */); + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + return cleanup(ts.updateGetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, + /*body*/ undefined)); + } var newNode = ensureAccessor(input); return cleanup(newNode); } - case 160 /* SetAccessor */: { + case 161 /* SetAccessor */: { + // For now, only emit class accessors as accessors if they were already declared in an ambient context. + if (input.flags & 4194304 /* Ambient */) { + return cleanup(ts.updateSetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8 /* Private */)), + /*body*/ undefined)); + } var newNode = ensureAccessor(input); return cleanup(newNode); } - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return cleanup(ts.updateProperty(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 154 /* PropertySignature */: + case 155 /* PropertySignature */: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 156 /* MethodSignature */: { + case 157 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 161 /* CallSignature */: { + case 162 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 163 /* IndexSignature */: { + case 164 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(121 /* AnyKeyword */))); } - case 238 /* VariableDeclaration */: { + case 239 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -84325,13 +85349,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(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 151 /* TypeParameter */: { + case 152 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 176 /* ConditionalType */: { + case 177 /* 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); @@ -84343,13 +85367,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 166 /* FunctionType */: { + case 167 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 167 /* ConstructorType */: { + case 168 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 184 /* ImportType */: { + case 185 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -84359,13 +85383,13 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { - if (returnValue && canProdiceDiagnostic && ts.hasDynamicName(input)) { + if (returnValue && canProduceDiagnostic && ts.hasDynamicName(input)) { checkName(input); } if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; } - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } if (shouldEnterSuppressNewDiagnosticsContextContext) { @@ -84378,7 +85402,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 157 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 158 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -84388,7 +85412,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 256 /* ExportDeclaration */: { + case 257 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -84397,7 +85421,7 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 255 /* ExportAssignment */: { + case 256 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; @@ -84438,10 +85462,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249 /* ImportEqualsDeclaration */: { + case 250 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 250 /* ImportDeclaration */: { + case 251 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -84462,14 +85486,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 243 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 244 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 242 /* InterfaceDeclaration */: { + case 243 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 240 /* FunctionDeclaration */: { + case 241 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -84517,10 +85541,10 @@ var ts; return clean; } } - case 245 /* ModuleDeclaration */: { + case 246 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 246 /* ModuleBlock */) { + if (inner && inner.kind === 247 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; @@ -84536,7 +85560,7 @@ var ts; // 3. Some things are exported, some are not, and there's no marker - add an empty marker if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) { if (needsScopeFixMarker) { - lateStatements = ts.createNodeArray(lateStatements.concat([createEmptyExports()])); + lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [createEmptyExports()])); } else { lateStatements = ts.visitNodes(lateStatements, stripExportModifiers); @@ -84563,7 +85587,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 241 /* ClassDeclaration */: { + case 242 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -84634,10 +85658,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 220 /* VariableStatement */: { + case 221 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 244 /* EnumDeclaration */: { + case 245 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -84656,7 +85680,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 245 /* ModuleDeclaration */) { + if (input.kind === 246 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -84677,7 +85701,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 211 /* OmittedExpression */) { + if (e.kind === 212 /* OmittedExpression */) { return; } if (e.name) { @@ -84727,24 +85751,33 @@ var ts; function ensureModifierFlags(node) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 285 /* SourceFile */; + var parentIsFile = node.parent.kind === 286 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; } return maskModifierFlags(node, mask, additions); } - function ensureAccessor(node) { - var accessors = resolver.getAllAccessorDeclarations(node); - if (node.kind !== accessors.firstAccessor.kind) { - return; - } + function getTypeAnnotationFromAllAccessorDeclarations(node, accessors) { var accessorType = getTypeAnnotationFromAccessor(node); - if (!accessorType && accessors.secondAccessor) { + if (!accessorType && node !== accessors.firstAccessor) { + accessorType = getTypeAnnotationFromAccessor(accessors.firstAccessor); + // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message + getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.firstAccessor); + } + if (!accessorType && accessors.secondAccessor && node !== accessors.secondAccessor) { accessorType = getTypeAnnotationFromAccessor(accessors.secondAccessor); // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.secondAccessor); } + return accessorType; + } + function ensureAccessor(node) { + var accessors = resolver.getAllAccessorDeclarations(node); + if (node.kind !== accessors.firstAccessor.kind) { + return; + } + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(node, accessors); var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); if (leadingsSyntheticCommentRanges) { @@ -84755,7 +85788,7 @@ var ts; if (lines.length > 1) { var lastLines = lines.slice(1); var indentation_1 = ts.guessIndentation(lastLines); - text = [lines[0]].concat(ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); + text = __spreadArrays([lines[0]], ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); } ts.addSyntheticLeadingComment(prop, range.kind, text, range.hasTrailingNewLine); } @@ -84775,7 +85808,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 243 /* InterfaceDeclaration */) { return true; } return false; @@ -84800,7 +85833,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 159 /* GetAccessor */ + return accessor.kind === 160 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -84809,52 +85842,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return !ts.hasModifier(node, 8 /* Private */); - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 153 /* Parameter */: + case 239 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 220 /* VariableStatement */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 241 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 243 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 245 /* EnumDeclaration */: + case 221 /* VariableStatement */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: + case 256 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 238 /* VariableDeclaration */: - case 151 /* TypeParameter */: - case 212 /* ExpressionWithTypeArguments */: - case 165 /* TypeReference */: - case 176 /* ConditionalType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 184 /* ImportType */: + case 163 /* ConstructSignature */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 164 /* IndexSignature */: + case 239 /* VariableDeclaration */: + case 152 /* TypeParameter */: + case 213 /* ExpressionWithTypeArguments */: + case 166 /* TypeReference */: + case 177 /* ConditionalType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 185 /* ImportType */: return true; } return false; @@ -84983,7 +86016,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(319 /* Count */); + var enabledSyntaxKindFeatures = new Array(321 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -85190,7 +86223,7 @@ var ts; var statements; if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) { if (lexicalEnvironmentFunctionDeclarations) { - statements = lexicalEnvironmentFunctionDeclarations.slice(); + statements = __spreadArrays(lexicalEnvironmentFunctionDeclarations); } if (lexicalEnvironmentVariableDeclarations) { var statement = ts.createVariableStatement( @@ -85268,15 +86301,15 @@ var ts; * If an array, the full list of source files to emit. * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) { + if (forceDtsEmit === void 0) { forceDtsEmit = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { var prepends = host.getPrependNodes(); if (sourceFiles.length || prepends.length) { var bundle = ts.createBundle(sourceFiles, prepends); - var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); + var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle); if (result) { return result; } @@ -85286,7 +86319,7 @@ var ts; if (!onlyBuildInfo) { for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { var sourceFile = sourceFiles_1[_a]; - var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); + var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile); if (result) { return result; } @@ -85339,7 +86372,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 286 /* Bundle */) { + if (sourceFile.kind === 287 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -85397,6 +86430,8 @@ var ts; } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; function getOutputJSFileName(inputFileName, configFile, ignoreCase) { + if (configFile.options.emitDeclarationOnly) + return undefined; var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ? ".json" /* Json */ : @@ -85428,7 +86463,7 @@ var ts; addOutput(js); if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) continue; - if (configFile.options.sourceMap) { + if (js && configFile.options.sourceMap) { addOutput(js + ".map"); } if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { @@ -85457,6 +86492,11 @@ var ts; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase); if (jsFilePath) return jsFilePath; + if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + continue; + if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { + return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + } } var buildInfoPath = getOutputPathForBuildInfo(configFile.options); if (buildInfoPath) @@ -85466,7 +86506,7 @@ var ts; ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo) { + function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) { var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers; var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; @@ -85480,7 +86520,7 @@ var ts; var exportedModulesFromDeclarationEmit; // Emit each output file enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), forceDtsEmit, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -85618,7 +86658,7 @@ var ts; }); var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit; emitSkipped = emitSkipped || declBlocked; - if (!declBlocked || emitOnlyDtsFiles) { + 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, @@ -85626,12 +86666,8 @@ var ts; mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 285 /* SourceFile */) { - // Improved narrowing in master/3.6 makes this cast unnecessary, triggering a lint rule. - // But at the same time, the LKG (3.5) necessitates it because it doesn’t narrow. - // Once the LKG is updated to 3.6, this comment, the cast to `SourceFile`, and the - // tslint directive can be all be removed. - var sourceFile = declarationTransform.transformed[0]; // tslint:disable-line + if (forceDtsEmit && declarationTransform.transformed[0].kind === 286 /* SourceFile */) { + var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } } @@ -85653,8 +86689,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 286 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 285 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 287 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 286 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -85695,7 +86731,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 285 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 286 /* 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 @@ -85805,7 +86841,7 @@ var ts; }; function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) { var sourceFiles = bundle.sourceFiles.map(function (fileName) { - var sourceFile = ts.createNode(285 /* SourceFile */, 0, 0); + var sourceFile = ts.createNode(286 /* SourceFile */, 0, 0); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = ""; sourceFile.statements = ts.createNodeArray(); @@ -85817,7 +86853,7 @@ var ts; sourceFile.text = prologueInfo.text; sourceFile.end = prologueInfo.text.length; sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { - var statement = ts.createNode(222 /* ExpressionStatement */, directive.pos, directive.end); + var statement = ts.createNode(223 /* ExpressionStatement */, directive.pos, directive.end); statement.expression = ts.createNode(10 /* StringLiteral */, directive.expression.pos, directive.expression.end); statement.expression.text = directive.expression.text; return statement; @@ -85856,7 +86892,7 @@ var ts; var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); }); var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host); var emitHost = { - getPrependNodes: ts.memoize(function () { return prependNodes.concat([ownPrependInput]); }), + getPrependNodes: ts.memoize(function () { return __spreadArrays(prependNodes, [ownPrependInput]); }), getCanonicalFileName: host.getCanonicalFileName, getCommonSourceDirectory: function () { return ts.getNormalizedAbsolutePath(buildInfo.bundle.commonSourceDirectory, buildInfoDirectory); }, getCompilerOptions: function () { return config.options; }, @@ -85910,6 +86946,7 @@ var ts; useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: ts.returnUndefined, getSourceFileFromReference: ts.returnUndefined, + redirectTargetsMap: ts.createMultiMap() }; emitFiles(ts.notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers)); @@ -85990,9 +87027,9 @@ var ts; break; } switch (node.kind) { - case 285 /* SourceFile */: return printFile(node); - case 286 /* Bundle */: return printBundle(node); - case 287 /* UnparsedSource */: return printUnparsedSource(node); + case 286 /* SourceFile */: return printFile(node); + case 287 /* Bundle */: return printBundle(node); + case 288 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -86174,7 +87211,7 @@ var ts; } function setWriter(_writer, _sourceMapGenerator) { if (_writer && printerOptions.omitTrailingSemicolon) { - _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + _writer = ts.getTrailingSemicolonDeferringWriter(_writer); } writer = _writer; // TODO: GH#18217 sourceMapGenerator = _sourceMapGenerator; @@ -86228,12 +87265,12 @@ var ts; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 285 /* SourceFile */) { + if (!commentsDisabled && node.kind !== 286 /* SourceFile */) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 285 /* SourceFile */ && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 286 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through @@ -86270,272 +87307,272 @@ var ts; case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node); - case 287 /* UnparsedSource */: - case 281 /* UnparsedPrepend */: + case 288 /* UnparsedSource */: + case 282 /* UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 280 /* UnparsedPrologue */: + case 281 /* UnparsedPrologue */: return writeUnparsedNode(node); - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 283 /* UnparsedText */: + case 284 /* UnparsedInternalText */: return emitUnparsedTextLike(node); - case 284 /* UnparsedSyntheticReference */: + case 285 /* UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Identifiers case 73 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return emitQualifiedName(node); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return emitTypeParameter(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return emitParameter(node); - case 153 /* Decorator */: + case 154 /* Decorator */: return emitDecorator(node); // Type members - case 154 /* PropertySignature */: + case 155 /* PropertySignature */: return emitPropertySignature(node); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 156 /* MethodSignature */: + case 157 /* MethodSignature */: return emitMethodSignature(node); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 158 /* Constructor */: + case 159 /* Constructor */: return emitConstructor(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return emitAccessorDeclaration(node); - case 161 /* CallSignature */: + case 162 /* CallSignature */: return emitCallSignature(node); - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: return emitConstructSignature(node); - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: return emitIndexSignature(node); // Types - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return emitTypePredicate(node); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return emitTypeReference(node); - case 166 /* FunctionType */: + case 167 /* FunctionType */: return emitFunctionType(node); - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 167 /* ConstructorType */: + case 168 /* ConstructorType */: return emitConstructorType(node); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return emitTypeQuery(node); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return emitTypeLiteral(node); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return emitArrayType(node); - case 171 /* TupleType */: + case 172 /* TupleType */: return emitTupleType(node); - case 172 /* OptionalType */: + case 173 /* OptionalType */: return emitOptionalType(node); - case 174 /* UnionType */: + case 175 /* UnionType */: return emitUnionType(node); - case 175 /* IntersectionType */: + case 176 /* IntersectionType */: return emitIntersectionType(node); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return emitConditionalType(node); - case 177 /* InferType */: + case 178 /* InferType */: return emitInferType(node); - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return emitParenthesizedType(node); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 179 /* ThisType */: + case 180 /* ThisType */: return emitThisType(); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: return emitTypeOperator(node); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 182 /* MappedType */: + case 183 /* MappedType */: return emitMappedType(node); - case 183 /* LiteralType */: + case 184 /* LiteralType */: return emitLiteralType(node); - case 184 /* ImportType */: + case 185 /* ImportType */: return emitImportTypeNode(node); - case 290 /* JSDocAllType */: + case 291 /* JSDocAllType */: writePunctuation("*"); return; - case 291 /* JSDocUnknownType */: + case 292 /* JSDocUnknownType */: writePunctuation("?"); return; - case 292 /* JSDocNullableType */: + case 293 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 293 /* JSDocNonNullableType */: + case 294 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 294 /* JSDocOptionalType */: + case 295 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 173 /* RestType */: - case 296 /* JSDocVariadicType */: + case 174 /* RestType */: + case 297 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 186 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return emitBindingElement(node); // Misc - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return emitTemplateSpan(node); - case 218 /* SemicolonClassElement */: + case 219 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 219 /* Block */: + case 220 /* Block */: return emitBlock(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return emitVariableStatement(node); - case 221 /* EmptyStatement */: + case 222 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return emitExpressionStatement(node); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return emitIfStatement(node); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return emitDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return emitWhileStatement(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return emitForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return emitForInStatement(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return emitForOfStatement(node); - case 229 /* ContinueStatement */: + case 230 /* ContinueStatement */: return emitContinueStatement(node); - case 230 /* BreakStatement */: + case 231 /* BreakStatement */: return emitBreakStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return emitReturnStatement(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return emitWithStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return emitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return emitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return emitThrowStatement(node); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return emitTryStatement(node); - case 237 /* DebuggerStatement */: + case 238 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return emitClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return emitModuleBlock(node); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return emitCaseBlock(node); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return emitImportDeclaration(node); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return emitImportClause(node); - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return emitNamespaceImport(node); - case 253 /* NamedImports */: + case 254 /* NamedImports */: return emitNamedImports(node); - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return emitImportSpecifier(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return emitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return emitExportDeclaration(node); - case 257 /* NamedExports */: + case 258 /* NamedExports */: return emitNamedExports(node); - case 258 /* ExportSpecifier */: + case 259 /* ExportSpecifier */: return emitExportSpecifier(node); - case 259 /* MissingDeclaration */: + case 260 /* MissingDeclaration */: return; // Module references - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: + case 264 /* JsxOpeningElement */: + case 267 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 264 /* JsxClosingElement */: - case 267 /* JsxClosingFragment */: + case 265 /* JsxClosingElement */: + case 268 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return emitJsxAttribute(node); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return emitJsxAttributes(node); - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 272 /* CaseClause */: + case 273 /* CaseClause */: return emitCaseClause(node); - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: return emitDefaultClause(node); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: return emitHeritageClause(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 279 /* EnumMember */: + case 280 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: + case 314 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 308 /* JSDocThisTag */: - case 305 /* JSDocEnumTag */: + case 309 /* JSDocReturnTag */: + case 311 /* JSDocTypeTag */: + case 310 /* JSDocThisTag */: + case 307 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); - case 301 /* JSDocAugmentsTag */: + case 303 /* JSDocAugmentsTag */: return emitJSDocAugmentsTag(node); - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 311 /* JSDocTypedefTag */: + case 313 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 304 /* JSDocCallbackTag */: + case 306 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); - case 299 /* JSDocSignature */: + case 301 /* JSDocSignature */: return emitJSDocSignature(node); - case 298 /* JSDocTypeLiteral */: + case 300 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 303 /* JSDocClassTag */: - case 300 /* JSDocTag */: + case 305 /* JSDocClassTag */: + case 302 /* JSDocTag */: return emitJSDocSimpleTag(node); - case 297 /* JSDocComment */: + case 299 /* JSDocComment */: return emitJSDoc(node); // Transformation nodes (ignored) } @@ -86572,71 +87609,71 @@ var ts; writeTokenNode(node, writeKeyword); return; // Expressions - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return emitCallExpression(node); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return emitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return emitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return emitArrowFunction(node); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return emitDeleteExpression(node); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return emitVoidExpression(node); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return emitAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return emitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return emitConditionalExpression(node); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return emitTemplateExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return emitYieldExpression(node); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return emitSpreadExpression(node); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return emitClassExpression(node); - case 211 /* OmittedExpression */: + case 212 /* OmittedExpression */: return; - case 213 /* AsExpression */: + case 214 /* AsExpression */: return emitAsExpression(node); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: return emitNonNullExpression(node); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 261 /* JsxElement */: + case 262 /* JsxElement */: return emitJsxElement(node); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: return emitCommaList(node); } } @@ -86664,8 +87701,8 @@ var ts; var helpers = getSortedEmitHelpers(sourceFile); if (!helpers) continue; - for (var _c = 0, helpers_3 = helpers; _c < helpers_3.length; _c++) { - var helper = helpers_3[_c]; + for (var _c = 0, helpers_4 = helpers; _c < helpers_4.length; _c++) { + var helper = helpers_4[_c]; if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) { bundledHelpers.set(helper.name, true); (result || (result = [])).push(helper.name); @@ -86676,7 +87713,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 286 /* Bundle */ ? node : undefined; + var bundle = node.kind === 287 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -86685,12 +87722,12 @@ var ts; for (var i = 0; i < numNodes; i++) { var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node; var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile; - var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.hasRecordedExternalHelpers(sourceFile)); var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit; var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode); if (helpers) { - for (var _a = 0, helpers_4 = helpers; _a < helpers_4.length; _a++) { - var helper = helpers_4[_a]; + for (var _a = 0, helpers_5 = helpers; _a < helpers_5.length; _a++) { + var helper = helpers_5[_a]; if (!helper.scoped) { // Skip the helper if it can be skipped and the noEmitHelpers compiler // option is set, or if it can be imported and the importHelpers compiler @@ -86776,7 +87813,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 282 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 283 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -86845,7 +87882,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 295 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 296 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -86907,7 +87944,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 159 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 160 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -87314,7 +88351,7 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 203 /* PrefixUnaryExpression */ + return operand.kind === 204 /* PrefixUnaryExpression */ && ((node.operator === 38 /* PlusToken */ && (operand.operator === 38 /* PlusToken */ || operand.operator === 44 /* PlusPlusToken */)) || (node.operator === 39 /* MinusToken */ && (operand.operator === 39 /* MinusToken */ || operand.operator === 45 /* MinusMinusToken */))); } @@ -87443,7 +88480,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); emitTokenWithComment(84 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 223 /* IfStatement */) { + if (node.elseStatement.kind === 224 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -87469,7 +88506,7 @@ var ts; writeLineOrSpace(node); } emitWhileClause(node, node.statement.end); - writePunctuation(";"); + writeTrailingSemicolon(); } function emitWhileStatement(node) { emitWhileClause(node, node.pos); @@ -87506,7 +88543,7 @@ var ts; emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(148 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(149 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -87514,7 +88551,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 240 /* VariableDeclarationList */) { emit(node); } else { @@ -87629,7 +88666,7 @@ var ts; writeKeyword("function"); emit(node.asteriskToken); writeSpace(); - emitIdentifierName(node.name); // TODO: GH#18217 + emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } function emitBlockCallback(_hint, body) { @@ -87809,7 +88846,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 245 /* ModuleDeclaration */) { + while (body.kind === 246 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -88130,7 +89167,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 309 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 311 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -88164,7 +89201,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 290 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -88183,7 +89220,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 298 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 300 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -88317,8 +89354,8 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } - for (var _d = 0, types_19 = types; _d < types_19.length; _d++) { - var directive = types_19[_d]; + for (var _d = 0, types_18 = types; _d < types_18.length; _d++) { + var directive = types_18[_d]; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) @@ -88961,7 +89998,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 197 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -89026,81 +90063,81 @@ var ts; if (!node) return; switch (node.kind) { - case 219 /* Block */: + case 220 /* Block */: ts.forEach(node.statements, generateNames); break; - case 234 /* LabeledStatement */: - case 232 /* WithStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 235 /* LabeledStatement */: + case 233 /* WithStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: generateNames(node.statement); break; - case 223 /* IfStatement */: + case 224 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 227 /* ForStatement */: + case 229 /* ForOfStatement */: + case 228 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 236 /* TryStatement */: + case 237 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 275 /* CatchClause */: + case 276 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: generateNames(node.declarationList); break; - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: + case 239 /* VariableDeclaration */: + case 153 /* Parameter */: + case 188 /* BindingElement */: + case 242 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: generateNames(node.importClause); break; - case 251 /* ImportClause */: + case 252 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 253 /* NamedImports */: + case 254 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -89109,12 +90146,12 @@ var ts; if (!node) return; switch (node.kind) { - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -89172,7 +90209,7 @@ var ts; if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (local && local.flags & (67220415 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { + if (local && local.flags & (111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { return false; } } @@ -89296,23 +90333,23 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 255 /* ExportAssignment */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 256 /* ExportAssignment */: return generateNameForExportDefault(); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return generateNameForClassExpression(); - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -89359,7 +90396,7 @@ var ts; hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 314 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 316 /* 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 */; @@ -89383,7 +90420,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 240 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -89640,7 +90677,7 @@ var ts; 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 !== 314 /* NotEmittedStatement */ + if (node.kind !== 316 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -89653,7 +90690,7 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 314 /* NotEmittedStatement */ + if (node.kind !== 316 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); @@ -90021,6 +91058,9 @@ var ts; var createFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile); var createFilePathWatcher = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher; var createDirectoryWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory); + if (watchLogLevel === WatchLogLevel.Verbose && ts.sysLog === ts.noop) { + ts.sysLog = function (s) { return log(s); }; + } return { watchFile: function (host, file, callback, pollingInterval, detailInfo1, detailInfo2) { return createFileWatcher(host, file, callback, pollingInterval, /*passThrough*/ undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo); @@ -90376,7 +91416,7 @@ var ts; } ts.changeCompilerHostLikeToUseCache = changeCompilerHostLikeToUseCache; function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { - var diagnostics = program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (ts.getEmitDeclarations(program.getCompilerOptions())) { ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } @@ -90565,8 +91605,8 @@ var ts; } var resolutions = []; var cache = ts.createMap(); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name = names_1[_i]; + for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { + var name = names_2[_i]; var result = void 0; if (cache.has(name)) { result = cache.get(name); @@ -90653,7 +91693,7 @@ var ts; } ts.isProgramUptoDate = isProgramUptoDate; function getConfigFileParsingDiagnostics(configFileParseResult) { - return configFileParseResult.options.configFile ? configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : + return configFileParseResult.options.configFile ? __spreadArrays(configFileParseResult.options.configFile.parseDiagnostics, configFileParseResult.errors) : configFileParseResult.errors; } ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; @@ -90683,7 +91723,6 @@ var ts; var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217 var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; var oldProgram = createProgramOptions.oldProgram; - var program; var processingDefaultLibFiles; var processingOtherFiles; var files; @@ -90692,6 +91731,8 @@ var ts; var noDiagnosticsTypeChecker; var classifiableNames; var ambientModuleNameToUnmodifiedFileName = ts.createMap(); + // Todo:: Use this to report why file was included in --extendedDiagnostics + var refFileMap; var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -90727,7 +91768,7 @@ var ts; var resolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference).map(function (resolved) { + resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).map(function (resolved) { // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName. if (!resolved || resolved.extension !== undefined) { return resolved; @@ -90744,7 +91785,7 @@ var ts; } var resolveTypeReferenceDirectiveNamesWorker; if (host.resolveTypeReferenceDirectives) { - resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference); }; + resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); }; } else { var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 @@ -90774,7 +91815,10 @@ var ts; var projectReferenceRedirects; var mapFromFileToProjectReferenceRedirects; var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); - var structuralIsReused = tryReuseStructureFromOldProgram(); + // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks + // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. + var structuralIsReused; + structuralIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const if (structuralIsReused !== 2 /* Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -90861,12 +91905,13 @@ var ts; } // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; - program = { + var program = { getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFileByPath: getSourceFileByPath, getSourceFiles: function () { return files; }, getMissingFilePaths: function () { return missingFilePaths; }, + getRefFileMap: function () { return refFileMap; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, getOptionsDiagnostics: getOptionsDiagnostics, @@ -91298,6 +92343,7 @@ var ts; return oldProgram.structureIsReused = 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); + refFileMap = oldProgram.getRefFileMap(); // update fileName -> file mapping for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) { var newSourceFile = newSourceFiles_1[_f]; @@ -91320,7 +92366,7 @@ var ts; return oldProgram.structureIsReused = 2 /* Completely */; } function getEmitHost(writeFileCallback) { - return __assign({ getPrependNodes: getPrependNodes, + return __assign(__assign({ getPrependNodes: getPrependNodes, getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { // Use local caches @@ -91331,7 +92377,7 @@ var ts; return false; // Before falling back to the host return host.fileExists(f); - } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); } }); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); }, redirectTargetsMap: redirectTargetsMap }); } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!options.out && !options.outFile); @@ -91387,15 +92433,15 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.has(toPath(emitFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) { var declarationDiagnostics = []; - if (!emitOnlyDtsFiles) { + if (!forceDtsEmit) { if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; } @@ -91403,7 +92449,7 @@ var ts; // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we // get any preEmit diagnostics, not just the ones if (options.noEmitOnError) { - var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (diagnostics.length === 0 && ts.getEmitDeclarations(program.getCompilerOptions())) { declarationDiagnostics = program.getDeclarationDiagnostics(/*sourceFile*/ undefined, cancellationToken); } @@ -91427,7 +92473,8 @@ var ts; // checked is to not pass the file to getEmitResolver. var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, + /*onlyBuildInfo*/ false, forceDtsEmit); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -91569,22 +92616,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 152 /* Parameter */: - case 155 /* PropertyDeclaration */: + case 153 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 238 /* VariableDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: + case 239 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -91592,41 +92639,41 @@ var ts; } } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 110 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 213 /* AsExpression */: + case 214 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -91639,28 +92686,28 @@ 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 241 /* ClassDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // falls through - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 220 /* VariableStatement */); + return checkModifiers(parent.modifiers, parent.kind === 221 /* VariableStatement */); } break; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { @@ -91672,18 +92719,19 @@ var ts; return; } break; - case 152 /* Parameter */: + case 153 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 213 /* ExpressionWithTypeArguments */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 195 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -91874,7 +92922,7 @@ var ts; } function collectDynamicImportOrRequireCalls(file) { var r = /import|require/g; - while (r.exec(file.text) !== null) { + while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null var node = getNodeAtPosition(file, r.lastIndex); if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { imports = ts.append(imports, node.arguments[0]); @@ -91955,24 +93003,18 @@ var ts; } } /** This has side effects through `findSourceFile`. */ - function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId); }, // TODO: GH#18217 + function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, // TODO: GH#18217 function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined - ? ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(args)) : ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(args))); - }, refFile); + return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args))); + }, refFile && refFile.file); } - function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile) { + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { var redirect = Object.create(redirectTarget); @@ -91995,7 +93037,7 @@ var ts; return redirect; } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId) { + function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) { var originalFileName = fileName; if (filesByName.has(path)) { var file_1 = filesByName.get(path); @@ -92012,7 +93054,7 @@ var ts; var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory); var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory); if (checkedAbsolutePath !== inputAbsolutePath) { - reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile); } } // If the file was previously found via a node_modules search, but is now being processed as a root file, @@ -92036,6 +93078,7 @@ var ts; processImportedModules(file_1); } } + addFileToRefFileMap(file_1 || undefined, refFile); return file_1 || undefined; } var redirectedPath; @@ -92057,14 +93100,7 @@ var ts; } } // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }, shouldCreateNewSourceFile); + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { return fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); }, shouldCreateNewSourceFile); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); @@ -92095,7 +93131,7 @@ var ts; // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case var existingFile = filesByNameIgnoreCase.get(pathLowerCase); if (existingFile) { - reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile); } else { filesByNameIgnoreCase.set(pathLowerCase, file); @@ -92118,8 +93154,18 @@ var ts; processingOtherFiles.push(file); } } + addFileToRefFileMap(file, refFile); return file; } + function addFileToRefFileMap(file, refFile) { + if (refFile && file) { + (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, { + kind: refFile.kind, + index: refFile.index, + file: refFile.file.path + }); + } + } function addFileToFilesByName(file, path, redirectedPath) { if (redirectedPath) { filesByName.set(redirectedPath, file); @@ -92208,9 +93254,17 @@ var ts; return projectReferenceRedirects.get(projectReferencePath) || undefined; } function processReferencedFiles(file, isDefaultLib) { - ts.forEach(file.referencedFiles, function (ref) { + ts.forEach(file.referencedFiles, function (ref, index) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); - processSourceFile(referencedFileName, isDefaultLib, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, + /*ignoreNoDefaultLib*/ false, + /*packageId*/ undefined, { + kind: ts.RefFileKind.ReferenceFile, + index: index, + file: file, + pos: ref.pos, + end: ref.end + }); }); } function processTypeReferenceDirectives(file) { @@ -92226,10 +93280,16 @@ var ts; // store resolved type directive on the file var fileName = ref.fileName.toLocaleLowerCase(); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); - processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); + processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { + kind: ts.RefFileKind.TypeReferenceDirective, + index: i, + file: file, + pos: ref.pos, + end: ref.end + }); } } - function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { + function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) { // If we already found this library as a primary reference - nothing to do var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { @@ -92241,7 +93301,7 @@ var ts; currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); // TODO: GH#18217 } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -92251,8 +93311,7 @@ var ts; if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, // TODO: GH#18217 - ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); } } // don't overwrite previous resolution result @@ -92260,14 +93319,14 @@ var ts; } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); } } if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--; } else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); @@ -92285,20 +93344,20 @@ var ts; var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts"); var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; - fileProcessingDiagnostics.add(createDiagnostic(file, libReference.pos, libReference.end, message, libName, suggestion)); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion)); } }); } - function createDiagnostic(refFile, refPos, refEnd, message) { + function createRefFileDiagnostic(refFile, message) { var args = []; - for (var _i = 4; _i < arguments.length; _i++) { - args[_i - 4] = arguments[_i]; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; } - if (refFile === undefined || refPos === undefined || refEnd === undefined) { - return ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)); + if (!refFile) { + return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)); } else { - return ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, message].concat(args)); + return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args)); } } function getCanonicalFileName(fileName) { @@ -92345,7 +93404,15 @@ var ts; else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, file, pos, file.imports[i].end, resolution.packageId); + findSourceFile(resolvedFileName, path, + /*isDefaultLib*/ false, + /*ignoreNoDefaultLib*/ false, { + kind: ts.RefFileKind.Import, + index: i, + file: file, + pos: pos, + end: file.imports[i].end + }, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -92364,12 +93431,15 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + var rootPaths; for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { var sourceFile = sourceFiles_2[_i]; if (!sourceFile.isDeclarationFile) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory)); + if (!rootPaths) + rootPaths = ts.arrayToSet(rootNames, toPath); + addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory); allFilesBelongToPath = false; } } @@ -92463,17 +93533,20 @@ var ts; else if (options.incremental && !options.outFile && !options.out && !options.configFilePath) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified)); } + if (options.noEmit && ts.isIncrementalCompilation(options)) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", options.incremental ? "incremental" : "composite"); + } verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { - var rootPaths = rootNames.map(toPath); + var rootPaths = ts.arrayToSet(rootNames, toPath); for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { var file = files_3[_i]; // Ignore file that is not emitted if (!ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) continue; - if (rootPaths.indexOf(file.path) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || "")); + if (!rootPaths.has(file.path)) { + addProgramDiagnosticAtRefPath(file, rootPaths, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || ""); } } } @@ -92655,6 +93728,39 @@ var ts; } } } + function addProgramDiagnosticAtRefPath(file, rootPaths, message) { + var _a, _b; + var args = []; + for (var _i = 3; _i < arguments.length; _i++) { + args[_i - 3] = arguments[_i]; + } + var refPaths = refFileMap && refFileMap.get(file.path); + var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) || + ts.elementAt(refPaths, 0); + if (refPathToReportErrorOn) { + var refFile = ts.Debug.assertDefined(getSourceFileByPath(refPathToReportErrorOn.file)); + var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index; + var pos = void 0, end = void 0; + switch (kind) { + case ts.RefFileKind.Import: + pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos); + end = refFile.imports[index].end; + break; + case ts.RefFileKind.ReferenceFile: + (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end); + break; + case ts.RefFileKind.TypeReferenceDirective: + (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end); + break; + default: + return ts.Debug.assertNever(kind); + } + programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args))); + } + else { + programDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); + } + } function verifyProjectReferences() { var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { @@ -92758,7 +93864,7 @@ var ts; } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { - _compilerOptionsObjectLiteralSyntax = null; // tslint:disable-line:no-null-keyword + _compilerOptionsObjectLiteralSyntax = null; // eslint-disable-line no-null/no-null var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); if (jsonObjectLiteral) { for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) { @@ -92914,9 +94020,9 @@ var ts; /*@internal*/ var ts; (function (ts) { - function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers) { + function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit); return { outputFiles: outputFiles, emitSkipped: emitResult.emitSkipped, exportedModulesFromDeclarationEmit: emitResult.exportedModulesFromDeclarationEmit }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); @@ -93162,11 +94268,19 @@ var ts; } } else { - var emitOutput = ts.getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken); - if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { - latestSignature = computeHash(emitOutput.outputFiles[0].text); + var emitOutput_1 = ts.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; + 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(firstDts_1.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { - updateExportedModules(sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache); + updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); } } else { @@ -93372,6 +94486,11 @@ var ts; /*@internal*/ var ts; (function (ts) { + var BuilderFileEmit; + (function (BuilderFileEmit) { + BuilderFileEmit[BuilderFileEmit["DtsOnly"] = 0] = "DtsOnly"; + BuilderFileEmit[BuilderFileEmit["Full"] = 1] = "Full"; + })(BuilderFileEmit = ts.BuilderFileEmit || (ts.BuilderFileEmit = {})); function hasSameKeys(map1, map2) { // Has same size and every key is present in both maps return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); @@ -93409,7 +94528,8 @@ var ts; ts.copyEntries(changedFilesSet, state.changedFilesSet); } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; + state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice(); + state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind); state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; } } @@ -93455,7 +94575,7 @@ var ts; }); if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - addToAffectedFilesPendingEmit(state, newProgram.getSourceFiles().map(function (f) { return f.path; })); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.path, 1 /* Full */); }); ts.Debug.assert(state.seenAffectedFiles === undefined); state.seenAffectedFiles = ts.createMap(); } @@ -93483,7 +94603,7 @@ var ts; } function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); } /** * Releases program and other related not needed properties @@ -93509,7 +94629,8 @@ var ts; newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState); newState.program = state.program; newState.compilerOptions = state.compilerOptions; - newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit; + newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); + newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind); newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles); newState.programEmitComplete = state.programEmitComplete; @@ -93541,7 +94662,6 @@ var ts; handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash); return affectedFile; } - seenAffectedFiles.set(affectedFile.path, true); affectedFilesIndex++; } // Remove the changed file from the change set @@ -93587,13 +94707,18 @@ var ts; var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap()); for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) { var affectedFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]); - if (affectedFile && !seenEmittedFiles.has(affectedFile.path)) { - // emit this file - state.affectedFilesPendingEmitIndex = i; - return affectedFile; + if (affectedFile) { + var seenKind = seenEmittedFiles.get(affectedFile.path); + var emitKind = ts.Debug.assertDefined(ts.Debug.assertDefined(state.affectedFilesPendingEmitKind).get(affectedFile.path)); + if (seenKind === undefined || seenKind < emitKind) { + // emit this file + state.affectedFilesPendingEmitIndex = i; + return { affectedFile: affectedFile, emitKind: emitKind }; + } } } state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; state.affectedFilesPendingEmitIndex = undefined; } return undefined; @@ -93637,7 +94762,7 @@ var ts; ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.assertDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, [path]); + addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); } } } @@ -93731,7 +94856,7 @@ var ts; * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly */ - function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit) { + function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) { if (isBuildInfoEmit) { state.emittedBuildInfo = true; } @@ -93741,6 +94866,9 @@ var ts; } else { state.seenAffectedFiles.set(affected.path, true); + if (emitKind !== undefined) { + (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, emitKind); + } if (isPendingEmit) { state.affectedFilesPendingEmitIndex++; } @@ -93752,8 +94880,15 @@ var ts; /** * Returns the result with affected file */ - function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); + function toAffectedFileResult(state, result, affected) { + doneWithAffectedFile(state, affected); + return { result: result, affected: affected }; + } + /** + * Returns the result with affected file + */ + function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } /** @@ -93878,7 +95013,7 @@ var ts; } function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? relativeToBuildInfo(file.path) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.path) : undefined }); } var BuilderProgramKind; (function (BuilderProgramKind) { @@ -93976,22 +95111,24 @@ var ts; */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var emitKind = 1 /* Full */; var isPendingEmitFile = false; if (!affected) { if (!state.compilerOptions.out && !state.compilerOptions.outFile) { - affected = getNextAffectedFilePendingEmit(state); - if (!affected) { + var pendingAffectedFile = getNextAffectedFilePendingEmit(state); + if (!pendingAffectedFile) { if (state.emittedBuildInfo) { return undefined; } var affected_1 = ts.Debug.assertDefined(state.program); - return toAffectedFileResult(state, + return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } + (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind); isPendingEmitFile = true; } else { @@ -94004,10 +95141,10 @@ var ts; affected = program; } } - return toAffectedFileResult(state, + return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers), affected, isPendingEmitFile); + ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); } /** * Emits the JavaScript and declaration files. @@ -94063,7 +95200,7 @@ var ts; } // Add file to affected file pending emit to handle for later emit time if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - addToAffectedFilesPendingEmit(state, [affected.path]); + addToAffectedFilesPendingEmit(state, affected.path, 1 /* Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -94095,7 +95232,7 @@ var ts; } // When semantic builder asks for diagnostics of the whole program, // ensure that all the affected files are handled - // tslint:disable-next-line no-empty + // eslint-disable-next-line no-empty while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) { } var diagnostics; @@ -94107,8 +95244,14 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; - function addToAffectedFilesPendingEmit(state, affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit); + function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) { + if (!state.affectedFilesPendingEmit) + state.affectedFilesPendingEmit = []; + if (!state.affectedFilesPendingEmitKind) + state.affectedFilesPendingEmitKind = ts.createMap(); + var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit); + state.affectedFilesPendingEmit.push(affectedFilePendingEmit); + state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind); // affectedFilesPendingEmitIndex === undefined // - means the emit state.affectedFilesPendingEmit was undefined before adding current affected files // so start from 0 as array would be affectedFilesPendingEmit @@ -94144,7 +95287,7 @@ var ts; compilerOptions: convertFromReusableCompilerOptions(program.options, toAbsolutePath), referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), - semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return ts.isString(value) ? value : value[0]; }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), + 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]; }), hasReusableDiagnostic: true }; return { @@ -94270,15 +95413,27 @@ var ts; // ignore "/user", "c:/users" or "c:/folderAtRoot" return false; } - if (dirPath.charCodeAt(0) !== 47 /* slash */ && - dirPath.substr(rootLength, nextDirectorySeparator).search(/users/i) === -1) { + var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + if (isNonDirectorySeparatorRoot && + dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths + pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart + nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1); + if (nextDirectorySeparator === -1) { + // ignore "//vda1cs4850/c$/folderAtRoot" + return false; + } + pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1); + } + if (isNonDirectorySeparatorRoot && + pathPartForUserCheck.search(/users\//i) !== 0) { // Paths like c:/folderAtRoot/subFolder are allowed return true; } for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) { searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1; if (searchIndex === 0) { - // Folder isnt at expected minimun levels + // Folder isnt at expected minimum levels return false; } } @@ -94443,8 +95598,8 @@ var ts; !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path : !!redirectedReference; var seenNamesInFile = ts.createMap(); - for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name = names_2[_i]; + for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { + var name = names_3[_i]; var resolution = resolutionsInFile.get(name); // Resolution is valid if it is present and not invalidated if (!seenNamesInFile.has(name) && @@ -94524,7 +95679,7 @@ var ts; if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { // Ensure failed look up is normalized path failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); - ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); // tslint:disable-line + ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); var subDirectoryInRoot = failedLookupLocationPath.indexOf(ts.directorySeparator, rootPath.length + 1); if (subDirectoryInRoot !== -1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution @@ -94920,8 +96075,9 @@ var ts; function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, - ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? + 2 /* JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, oldImportSpecifier) { @@ -94950,7 +96106,7 @@ var ts; return [ambient]; var info = getInfo(importingSourceFile.path, host); var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); - var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.fileName, info.getCanonicalFileName, host, redirectTargetsMap); + var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.originalFileName, info.getCanonicalFileName, host, redirectTargetsMap); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); var global = ts.mapDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }); return global.length ? global : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifier(moduleFileName, info, compilerOptions, preferences); }); @@ -94966,7 +96122,7 @@ var ts; var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; var ending = _b.ending, relativePreference = _b.relativePreference; var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; - var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); if (!baseUrl || relativePreference === 0 /* Relative */) { return relativePath; @@ -95041,7 +96197,7 @@ var ts; */ function getAllModulePaths(files, importingFileName, importedFileName, getCanonicalFileName, host, redirectTargetsMap) { var redirects = redirectTargetsMap.get(importedFileName); - var importedFileNames = redirects ? redirects.concat([importedFileName]) : [importedFileName]; + var importedFileNames = redirects ? __spreadArrays(redirects, [importedFileName]) : [importedFileName]; var cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); var links = discoverProbableSymlinks(files, getCanonicalFileName, cwd); @@ -95092,14 +96248,16 @@ var ts; } } } - function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) { + function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) { var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName); if (normalizedTargetPath === undefined) { return undefined; } var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName); var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath; - return ts.removeFileExtension(relativePath); + return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs + ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) + : ts.removeFileExtension(relativePath); } function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; @@ -95531,7 +96689,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); if (result) { result.version = computeHash.call(host, result.text); } @@ -95545,7 +96703,9 @@ var ts; function createProgramHost(system, createProgram) { var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); }); var host = system; - host; // tslint:disable-line no-unused-expression (TODO: `host` is unused!) + // TODO: `host` is unused! + // eslint-disable-next-line no-unused-expressions + host; return { useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; }, getNewLine: function () { return system.newLine; }, @@ -95579,7 +96739,7 @@ var ts; result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); }); }; return result; } @@ -95721,7 +96881,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - return getVersionedSourceFileByPath.apply(void 0, [fileName, toPath(fileName)].concat(args)); + return getVersionedSourceFileByPath.apply(void 0, __spreadArrays([fileName, toPath(fileName)], args)); }; compilerHost.getSourceFileByPath = getVersionedSourceFileByPath; compilerHost.getNewLine = function () { return newLine; }; @@ -95749,10 +96909,22 @@ var ts; /*logChangesWhenResolvingModule*/ false); // Resolve module using host module resolution strategy if provided otherwise use resolution cache to resolve module names compilerHost.resolveModuleNames = host.resolveModuleNames ? - (function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveModuleNames.apply(host, args); + }) : (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }); compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ? - (function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveTypeReferenceDirectives.apply(host, args); + }) : (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; builderProgram = readBuilderProgram(compilerOptions, compilerHost); @@ -95978,13 +97150,19 @@ var ts; reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); switch (reloadLevel) { case ts.ConfigFileProgramReloadLevel.Partial: - return reloadFileNamesFromConfigFile(); + ts.perfLogger.logStartUpdateProgram("PartialConfigReload"); + reloadFileNamesFromConfigFile(); + break; case ts.ConfigFileProgramReloadLevel.Full: - return reloadConfigFile(); + ts.perfLogger.logStartUpdateProgram("FullConfigReload"); + reloadConfigFile(); + break; default: + ts.perfLogger.logStartUpdateProgram("SynchronizeProgram"); synchronizeProgram(); - return; + break; } + ts.perfLogger.logStopUpdateProgram("Done"); } function reloadFileNamesFromConfigFile() { writeLog("Reloading new file names and options"); @@ -96168,6 +97346,16 @@ var ts; function isDeclarationFile(fileName) { return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */); } + /*@internal*/ + function isCircularBuildOrder(buildOrder) { + return !!buildOrder && !!buildOrder.buildOrder; + } + ts.isCircularBuildOrder = isCircularBuildOrder; + /*@internal*/ + function getBuildOrderFromAnyBuildOrder(anyBuildOrder) { + return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder; + } + ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ @@ -96329,11 +97517,14 @@ var ts; var permanentMarks = ts.createMap(); var circularityReportStack = []; var buildOrder; + var circularDiagnostics; for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { var root = roots_1[_i]; visit(root); } - return buildOrder || ts.emptyArray; + return circularDiagnostics ? + { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } : + buildOrder || ts.emptyArray; function visit(configFileName, inCircularContext) { var projPath = toResolvedConfigFilePath(state, configFileName); // Already visited @@ -96342,8 +97533,7 @@ var ts; // Circular if (temporaryMarks.has(projPath)) { if (!inCircularContext) { - // TODO:: Do we report this as error? - reportStatus(state, ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")); + (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n"))); } return; } @@ -96363,12 +97553,35 @@ var ts; } } function getBuildOrder(state) { - return state.buildOrder || - (state.buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }))); + return state.buildOrder || createStateBuildOrder(state); + } + function createStateBuildOrder(state) { + var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); })); + // Clear all to ResolvedConfigFilePaths cache to start fresh + state.resolvedConfigFilePaths.clear(); + var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); }); + var noopOnDelete = { onDeleteValue: ts.noop }; + // Config file cache + ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete); + // Remove watches for the program no longer in the solution + if (state.watch) { + ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher }); + ts.mutateMapSkippingNewValues(state.allWatchedWildcardDirectories, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcherOf); } }); + ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } }); + } + return state.buildOrder = buildOrder; } function getBuildOrderFor(state, project, onlyReferences) { var resolvedProject = project && resolveProjectName(state, project); var buildOrderFromState = getBuildOrder(state); + if (isCircularBuildOrder(buildOrderFromState)) + return buildOrderFromState; if (resolvedProject) { var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject); var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; }); @@ -96376,6 +97589,7 @@ var ts; return undefined; } var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState; + ts.Debug.assert(!isCircularBuildOrder(buildOrder)); ts.Debug.assert(!onlyReferences || resolvedProject !== undefined); ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject); return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder; @@ -96392,7 +97606,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); }), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, getSourceFileWithCache = _a.getSourceFileWithCache, readFileWithCache = _a.readFileWithCache; state.readFileWithCache = readFileWithCache; compilerHost.getSourceFile = getSourceFileWithCache; @@ -96447,7 +97661,7 @@ var ts; reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode); } enableCache(state); - var buildOrder = getBuildOrder(state); + var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state)); buildOrder.forEach(function (configFileName) { return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None); }); @@ -96619,7 +97833,7 @@ var ts; } function getSyntaxDiagnostics(cancellationToken) { ts.Debug.assertDefined(program); - handleDiagnostics(program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); + handleDiagnostics(__spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); } function getSemanticDiagnostics(cancellationToken) { handleDiagnostics(ts.Debug.assertDefined(program).getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic"); @@ -96787,6 +98001,8 @@ var ts; function getNextInvalidatedProject(state, buildOrder, reportQueue) { if (!state.projectPendingBuild.size) return undefined; + if (isCircularBuildOrder(buildOrder)) + return undefined; if (state.currentInvalidatedProject) { // Only if same buildOrder the currentInvalidated project can be sent again return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ? @@ -96843,8 +98059,11 @@ var ts; if (status.type === ts.UpToDateStatusType.UpstreamBlocked) { reportAndStoreErrors(state, projectPath, config.errors); projectPendingBuild.delete(projectPath); - if (options.verbose) - reportStatus(state, ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + if (options.verbose) { + reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built : + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + } continue; } if (status.type === ts.UpToDateStatusType.ContainerOnly) { @@ -97015,10 +98234,12 @@ var ts; continue; } // An upstream project is blocked - if (refStatus.type === ts.UpToDateStatusType.Unbuildable) { + if (refStatus.type === ts.UpToDateStatusType.Unbuildable || + refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) { return { type: ts.UpToDateStatusType.UpstreamBlocked, - upstreamProjectName: ref.path + upstreamProjectName: ref.path, + upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked }; } // If the upstream project is out of date, then so are we (someone shouldn't have asked, though?) @@ -97242,16 +98463,22 @@ var ts; disableCache(state); reportErrorSummary(state, buildOrder); startWatching(state, buildOrder); - return errorProjects ? - successfulProjects ? - ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : - ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : - ts.ExitStatus.Success; + return isCircularBuildOrder(buildOrder) ? + ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped : + errorProjects ? + successfulProjects ? + ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : + ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : + ts.ExitStatus.Success; } function clean(state, project, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; + if (isCircularBuildOrder(buildOrder)) { + reportErrors(state, buildOrder.circularDiagnostics); + return ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped; + } var options = state.options, host = state.host; var filesToDelete = options.dry ? [] : undefined; for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) { @@ -97394,8 +98621,8 @@ var ts; if (!state.watchAllProjectsPending) return; state.watchAllProjectsPending = false; - for (var _i = 0, buildOrder_2 = buildOrder; _i < buildOrder_2.length; _i++) { - var resolved = buildOrder_2[_i]; + for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) { + var resolved = _a[_i]; var resolvedPath = toResolvedConfigFilePath(state, resolved); // Watch this file watchConfigFile(state, resolved, resolvedPath); @@ -97427,6 +98654,7 @@ var ts; }, invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); }, buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); }, + getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); }, }; } function relName(state, path) { @@ -97437,7 +98665,7 @@ var ts; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } - state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args))); + state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); } function reportWatchStatus(state, message) { var args = []; @@ -97445,7 +98673,7 @@ var ts; args[_i - 2] = arguments[_i]; } if (state.hostWithWatch.onWatchStatusChange) { - state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)), state.host.getNewLine(), state.baseCompilerOptions); + state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)), state.host.getNewLine(), state.baseCompilerOptions); } } function reportErrors(_a, errors) { @@ -97463,23 +98691,33 @@ var ts; reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]); } function reportErrorSummary(state, buildOrder) { - if (!state.needsSummary || (!state.watch && !state.host.reportErrorSummary)) + if (!state.needsSummary) return; state.needsSummary = false; + var canReportSummary = state.watch || !!state.host.reportErrorSummary; var diagnostics = state.diagnostics; - // Report errors from the other projects - buildOrder.forEach(function (project) { - var projectPath = toResolvedConfigFilePath(state, project); - if (!state.projectErrorsReported.has(projectPath)) { - reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); - } - }); var totalErrors = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + if (isCircularBuildOrder(buildOrder)) { + reportBuildQueue(state, buildOrder.buildOrder); + reportErrors(state, buildOrder.circularDiagnostics); + if (canReportSummary) + totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics); + } + else { + // Report errors from the other projects + buildOrder.forEach(function (project) { + var projectPath = toResolvedConfigFilePath(state, project); + if (!state.projectErrorsReported.has(projectPath)) { + reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); + } + }); + if (canReportSummary) + diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + } if (state.watch) { reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors); } - else { + else if (state.host.reportErrorSummary) { state.host.reportErrorSummary(totalErrors); } } @@ -97512,13 +98750,16 @@ var ts; case ts.UpToDateStatusType.UpstreamOutOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.UpstreamBlocked: - return reportStatus(state, ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); + return reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built : + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.Unbuildable: return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason); case ts.UpToDateStatusType.TsVersionOutputOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relName(state, configFileName), status.version, ts.version); case ts.UpToDateStatusType.ContainerOnly: // Don't report status on "solution" projects + // falls through case ts.UpToDateStatusType.ComputingUpstream: // Should never leak from getUptoDateStatusWorker break; @@ -97540,7 +98781,6 @@ var ts; (function (ts) { var server; (function (server) { - // tslint:disable variable-name server.ActionSet = "action::set"; server.ActionInvalidate = "action::invalidate"; server.ActionPackageInstalled = "action::packageInstalled"; @@ -98192,37 +99432,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 275 /* CatchClause */: - case 268 /* JsxAttribute */: + case 153 /* Parameter */: + case 188 /* BindingElement */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 276 /* CatchClause */: + case 269 /* JsxAttribute */: return 1 /* Value */; - case 151 /* TypeParameter */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 169 /* TypeLiteral */: + case 152 /* TypeParameter */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 170 /* TypeLiteral */: return 2 /* Type */; - case 311 /* JSDocTypedefTag */: + case 313 /* 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 279 /* EnumMember */: - case 241 /* ClassDeclaration */: + case 280 /* EnumMember */: + case 242 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -98232,26 +99472,26 @@ var ts; else { return 4 /* Namespace */; } - case 244 /* EnumDeclaration */: - case 253 /* NamedImports */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 245 /* EnumDeclaration */: + case 254 /* NamedImports */: + case 255 /* ImportSpecifier */: + case 250 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: + case 256 /* ExportAssignment */: + case 257 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 285 /* SourceFile */: + case 286 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 255 /* ExportAssignment */ || node.parent.kind === 260 /* ExternalModuleReference */) { + else if (node.parent.kind === 256 /* ExportAssignment */ || node.parent.kind === 261 /* ExternalModuleReference */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -98283,11 +99523,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 149 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 249 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 150 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 250 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 150 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -98299,27 +99539,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 149 /* QualifiedName */) { - while (root.parent && root.parent.kind === 149 /* QualifiedName */) { + if (root.parent.kind === 150 /* QualifiedName */) { + while (root.parent && root.parent.kind === 150 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 165 /* TypeReference */ && !isLastClause; + return root.parent.kind === 166 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 190 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 190 /* PropertyAccessExpression */) { + if (root.parent.kind === 191 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 191 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 212 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 274 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 213 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 275 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 241 /* ClassDeclaration */ && root.parent.parent.token === 110 /* ImplementsKeyword */) || - (decl.kind === 242 /* InterfaceDeclaration */ && root.parent.parent.token === 87 /* ExtendsKeyword */); + return (decl.kind === 242 /* ClassDeclaration */ && root.parent.parent.token === 110 /* ImplementsKeyword */) || + (decl.kind === 243 /* InterfaceDeclaration */ && root.parent.parent.token === 87 /* ExtendsKeyword */); } return false; } @@ -98330,15 +99570,15 @@ var ts; switch (node.kind) { case 101 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 179 /* ThisType */: + case 180 /* ThisType */: return true; } switch (node.parent.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return true; - case 184 /* ImportType */: + case 185 /* ImportType */: return !node.parent.isTypeOf; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -98365,7 +99605,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 234 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 235 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -98397,15 +99637,15 @@ var ts; } ts.isTagName = isTagName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 150 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 191 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 245 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 246 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -98415,22 +99655,22 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 279 /* EnumMember */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 245 /* ModuleDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 277 /* PropertyAssignment */: + case 280 /* EnumMember */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 246 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return true; - case 183 /* LiteralType */: - return node.parent.parent.kind === 181 /* IndexedAccessType */; + case 184 /* LiteralType */: + return node.parent.parent.kind === 182 /* IndexedAccessType */; default: return false; } @@ -98454,17 +99694,17 @@ var ts; return undefined; } switch (node.kind) { - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 286 /* SourceFile */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 246 /* ModuleDeclaration */: return node; } } @@ -98472,48 +99712,53 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return "class" /* classElement */; - case 242 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 243 /* TypeAliasDeclaration */: - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 243 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 244 /* TypeAliasDeclaration */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 244 /* EnumDeclaration */: return "enum" /* enumElement */; - case 238 /* VariableDeclaration */: + case 245 /* EnumDeclaration */: return "enum" /* enumElement */; + case 239 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: return "function" /* functionElement */; - case 159 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 160 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 161 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 277 /* PropertyAssignment */: + var initializer = node.initializer; + return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 278 /* ShorthandPropertyAssignment */: + case 279 /* SpreadAssignment */: return "property" /* memberVariableElement */; - case 163 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 162 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 161 /* CallSignature */: return "call" /* callSignatureElement */; - case 158 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 151 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 279 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 152 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 164 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 163 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 162 /* CallSignature */: return "call" /* callSignatureElement */; + case 159 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 152 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 280 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 153 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 250 /* ImportEqualsDeclaration */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: + case 253 /* NamespaceImport */: return "alias" /* alias */; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { @@ -98561,7 +99806,7 @@ var ts; return true; case 73 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 152 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 153 /* Parameter */; default: return false; } @@ -98626,42 +99871,42 @@ var ts; return false; } switch (n.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 185 /* ObjectBindingPattern */: - case 169 /* TypeLiteral */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 247 /* CaseBlock */: - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 190 /* ObjectLiteralExpression */: + case 186 /* ObjectBindingPattern */: + case 170 /* TypeLiteral */: + case 220 /* Block */: + case 247 /* ModuleBlock */: + case 248 /* CaseBlock */: + case 254 /* NamedImports */: + case 258 /* NamedExports */: return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 193 /* NewExpression */: + case 194 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 192 /* CallExpression */: - case 196 /* ParenthesizedExpression */: - case 178 /* ParenthesizedType */: + case 193 /* CallExpression */: + case 197 /* ParenthesizedExpression */: + case 179 /* ParenthesizedType */: return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 198 /* ArrowFunction */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 163 /* ConstructSignature */: + case 162 /* CallSignature */: + case 199 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -98671,65 +99916,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 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 223 /* IfStatement */: + case 224 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 188 /* ArrayLiteralExpression */: - case 186 /* ArrayBindingPattern */: - case 191 /* ElementAccessExpression */: - case 150 /* ComputedPropertyName */: - case 171 /* TupleType */: + case 189 /* ArrayLiteralExpression */: + case 187 /* ArrayBindingPattern */: + case 192 /* ElementAccessExpression */: + case 151 /* ComputedPropertyName */: + case 172 /* TupleType */: return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 226 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 224 /* DoStatement */: + case 225 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; return hasChildOfKind(n, 108 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 200 /* TypeOfExpression */: - case 199 /* DeleteExpression */: - case 201 /* VoidExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: + case 201 /* TypeOfExpression */: + case 200 /* DeleteExpression */: + case 202 /* VoidExpression */: + case 209 /* YieldExpression */: + case 210 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -98908,7 +100153,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 285 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 286 /* 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. @@ -98978,17 +100223,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 272 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 272 /* JsxExpression */) { return true; } //
|
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 264 /* JsxClosingElement */) { + if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 265 /* JsxClosingElement */) { return true; } return false; @@ -99107,12 +100352,14 @@ var ts; nTypeArguments++; break; case 37 /* EqualsGreaterThanToken */: + // falls through case 73 /* Identifier */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 103 /* TrueKeyword */: case 88 /* FalseKeyword */: + // falls through case 105 /* TypeOfKeyword */: case 87 /* ExtendsKeyword */: case 130 /* KeyOfKeyword */: @@ -99174,10 +100421,10 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 165 /* TypeReference */ || node.kind === 192 /* CallExpression */) { + if (node.kind === 166 /* TypeReference */ || node.kind === 193 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 241 /* ClassDeclaration */ || node.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 242 /* ClassDeclaration */ || node.kind === 243 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -99222,18 +100469,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 188 /* ArrayLiteralExpression */ || - node.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 189 /* ArrayLiteralExpression */ || + node.kind === 190 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 205 /* BinaryExpression */ && + if (node.parent.kind === 206 /* BinaryExpression */ && node.parent.left === node && node.parent.operatorToken.kind === 60 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 228 /* ForOfStatement */ && + if (node.parent.kind === 229 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -99241,7 +100488,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 276 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 277 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -99337,7 +100584,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 150 /* ComputedPropertyName */ + return name.kind === 151 /* 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.getTextOfIdentifierOrLiteral(name); @@ -99502,7 +100749,7 @@ var ts; /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 152 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 153 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -99964,15 +101211,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 193 /* NewExpression */: + case 194 /* NewExpression */: return checker.getContextualType(parent); - case 205 /* BinaryExpression */: { + case 206 /* 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 272 /* CaseClause */: + case 273 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -100014,8 +101261,8 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: + case 208 /* TemplateExpression */: + case 195 /* TaggedTemplateExpression */: return true; default: return false; @@ -100055,19 +101302,19 @@ var ts; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; function syntaxUsuallyHasTrailingSemicolon(kind) { - return kind === 220 /* VariableStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 224 /* DoStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 230 /* BreakStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 155 /* PropertyDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */; + return kind === 221 /* VariableStatement */ + || kind === 223 /* ExpressionStatement */ + || kind === 225 /* DoStatement */ + || kind === 230 /* ContinueStatement */ + || kind === 231 /* BreakStatement */ + || kind === 232 /* ReturnStatement */ + || kind === 236 /* ThrowStatement */ + || kind === 238 /* DebuggerStatement */ + || kind === 156 /* PropertyDeclaration */ + || kind === 244 /* TypeAliasDeclaration */ + || kind === 251 /* ImportDeclaration */ + || kind === 250 /* ImportEqualsDeclaration */ + || kind === 257 /* ExportDeclaration */; } ts.syntaxUsuallyHasTrailingSemicolon = syntaxUsuallyHasTrailingSemicolon; function probablyUsesSemicolons(sourceFile) { @@ -100101,6 +101348,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier() { var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false); function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { @@ -100533,10 +101781,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 241 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -100729,6 +101977,11 @@ var ts; return; } } + else if (kind === 2 /* SingleLineCommentTrivia */) { + if (tryClassifyTripleSlashComment(start, width)) { + return; + } + } // Simple comment. Just add as is. pushCommentRange(start, width); } @@ -100749,18 +102002,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 306 /* JSDocParameterTag */: + case 308 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 309 /* JSDocTypeTag */: + case 311 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 307 /* JSDocReturnTag */: + case 309 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -100789,6 +102042,70 @@ var ts; } } } + function tryClassifyTripleSlashComment(start, width) { + var tripleSlashXMLCommentRegEx = /^(\/\/\/\s*)(<)(?:(\S+)((?:[^/]|\/[^>])*)(\/>)?)?/im; + var attributeRegex = /(\S+)(\s*)(=)(\s*)('[^']+'|"[^"]+")/img; + var text = sourceFile.text.substr(start, width); + var match = tripleSlashXMLCommentRegEx.exec(text); + if (!match) { + return false; + } + // Limiting classification to exactly the elements and attributes + // defined in `ts.commentPragmas` would be excessive, but we can avoid + // some obvious false positives (e.g. in XML-like doc comments) by + // checking the element name. + // eslint-disable-next-line no-in-operator + if (!match[3] || !(match[3] in ts.commentPragmas)) { + return false; + } + var pos = start; + pushCommentRange(pos, match[1].length); // /// + pos += match[1].length; + pushClassification(pos, match[2].length, 10 /* punctuation */); // < + pos += match[2].length; + pushClassification(pos, match[3].length, 21 /* jsxSelfClosingTagName */); // element name + pos += match[3].length; + var attrText = match[4]; + var attrPos = pos; + while (true) { + var attrMatch = attributeRegex.exec(attrText); + if (!attrMatch) { + break; + } + var newAttrPos = pos + attrMatch.index; + if (newAttrPos > attrPos) { + pushCommentRange(attrPos, newAttrPos - attrPos); + attrPos = newAttrPos; + } + pushClassification(attrPos, attrMatch[1].length, 22 /* jsxAttribute */); // attribute name + attrPos += attrMatch[1].length; + if (attrMatch[2].length) { + pushCommentRange(attrPos, attrMatch[2].length); // whitespace + attrPos += attrMatch[2].length; + } + pushClassification(attrPos, attrMatch[3].length, 5 /* operator */); // = + attrPos += attrMatch[3].length; + if (attrMatch[4].length) { + pushCommentRange(attrPos, attrMatch[4].length); // whitespace + attrPos += attrMatch[4].length; + } + pushClassification(attrPos, attrMatch[5].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value + attrPos += attrMatch[5].length; + } + pos += match[4].length; + if (pos > attrPos) { + pushCommentRange(attrPos, pos - attrPos); + } + if (match[5]) { + pushClassification(pos, match[5].length, 10 /* punctuation */); // /> + pos += match[5].length; + } + var end = start + width; + if (pos < end) { + pushCommentRange(pos, end - pos); + } + return true; + } function processJSDocTemplateTag(tag) { for (var _i = 0, _a = tag.getChildren(); _i < _a.length; _i++) { var child = _a[_i]; @@ -100847,22 +102164,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 263 /* JsxOpeningElement */: + case 264 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -100891,17 +102208,17 @@ var ts; var parent = token.parent; if (tokenKind === 60 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 238 /* VariableDeclaration */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 152 /* Parameter */ || - parent.kind === 268 /* JsxAttribute */) { + if (parent.kind === 239 /* VariableDeclaration */ || + parent.kind === 156 /* PropertyDeclaration */ || + parent.kind === 153 /* Parameter */ || + parent.kind === 269 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 205 /* BinaryExpression */ || - parent.kind === 203 /* PrefixUnaryExpression */ || - parent.kind === 204 /* PostfixUnaryExpression */ || - parent.kind === 206 /* ConditionalExpression */) { + if (parent.kind === 206 /* BinaryExpression */ || + parent.kind === 204 /* PrefixUnaryExpression */ || + parent.kind === 205 /* PostfixUnaryExpression */ || + parent.kind === 207 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -100915,7 +102232,7 @@ var ts; } else if (tokenKind === 10 /* StringLiteral */) { // TODO: GH#18217 - return token.parent.kind === 268 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 269 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -100931,32 +102248,32 @@ var ts; else if (tokenKind === 73 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 152 /* Parameter */: + case 153 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -101079,11 +102396,11 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { var parent = node.parent; switch (parent.kind) { - case 183 /* LiteralType */: + case 184 /* LiteralType */: switch (parent.parent.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent)), isNewIdentifier: false }; - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -101091,9 +102408,9 @@ var ts; // } // let x: Foo["/*completion position*/"] return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(parent.parent.objectType)); - case 184 /* ImportType */: + case 185 /* ImportType */: return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 174 /* UnionType */: { + case 175 /* UnionType */: { if (!ts.isTypeReferenceNode(parent.parent.parent)) return undefined; var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(parent.parent, parent); @@ -101103,7 +102420,7 @@ var ts; default: return undefined; } - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -101120,7 +102437,7 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(parent.parent)); } return fromContextualType(); - case 191 /* ElementAccessExpression */: { + case 192 /* ElementAccessExpression */: { var _a = parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { // Get all names of properties on the expression @@ -101133,8 +102450,8 @@ var ts; } return undefined; } - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* 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 @@ -101143,9 +102460,9 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 260 /* ExternalModuleReference */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: + case 261 /* 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*/"); @@ -101189,11 +102506,8 @@ var ts; if (!type) return ts.emptyArray; type = ts.skipConstraint(type); - return type.isUnion() - ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) - : type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) - ? [type] - : ts.emptyArray; + return type.isUnion() ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) : + type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; } function nameAndKind(name, kind, extension) { return { name: name, kind: kind, extension: extension }; @@ -101250,7 +102564,7 @@ var ts; return ts.containsPath(rootDirectory, scriptDirectory, basePath, ignoreCase) ? scriptDirectory.substr(rootDirectory.length) : undefined; }); // TODO: GH#18217 // Now find a path for each potential directory that is to be merged with the one containing the script - return ts.deduplicate(rootDirs.map(function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }).concat([scriptDirectory]), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); + return ts.deduplicate(__spreadArrays(rootDirs.map(function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }), [scriptDirectory]), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptDirectory, extensionOptions, compilerOptions, host, exclude) { var basePath = compilerOptions.project || host.getCurrentDirectory(); @@ -101457,7 +102771,7 @@ var ts; var name = trimPrefixAndSuffix(dir); return name === undefined ? undefined : directoryResult(name); }); - return matches.concat(directories); + return __spreadArrays(matches, directories); function trimPrefixAndSuffix(path) { var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix); return inner === undefined ? undefined : removeLeadingDirectorySeparator(inner); @@ -101658,10 +102972,12 @@ var ts; var SortText; (function (SortText) { SortText["LocationPriority"] = "0"; - SortText["SuggestedClassMembers"] = "1"; - SortText["GlobalsOrKeywords"] = "2"; - SortText["AutoImportSuggestions"] = "3"; - SortText["JavascriptIdentifiers"] = "4"; + SortText["OptionalMember"] = "1"; + SortText["MemberDeclaredBySpreadAssignment"] = "2"; + SortText["SuggestedClassMembers"] = "3"; + SortText["GlobalsOrKeywords"] = "4"; + SortText["AutoImportSuggestions"] = "5"; + SortText["JavascriptIdentifiers"] = "6"; })(SortText = Completions.SortText || (Completions.SortText = {})); var SymbolOriginInfoKind; (function (SymbolOriginInfoKind) { @@ -101669,6 +102985,7 @@ var ts; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 1] = "SymbolMemberNoExport"; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 2] = "SymbolMemberExport"; SymbolOriginInfoKind[SymbolOriginInfoKind["Export"] = 3] = "Export"; + SymbolOriginInfoKind[SymbolOriginInfoKind["Promise"] = 4] = "Promise"; })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {})); function originIsSymbolMember(origin) { return origin.kind === 2 /* SymbolMemberExport */ || origin.kind === 1 /* SymbolMemberNoExport */; @@ -101676,6 +102993,9 @@ var ts; function originIsExport(origin) { return origin.kind === 2 /* SymbolMemberExport */ || origin.kind === 3 /* Export */; } + function originIsPromise(origin) { + return origin.kind === 4 /* Promise */; + } var KeywordCompletionFilters; (function (KeywordCompletionFilters) { KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None"; @@ -101836,6 +103156,13 @@ var ts; replacementSpan = ts.createTextSpanFromNode(isJsxInitializer, sourceFile); } } + if (origin && originIsPromise(origin) && propertyAccessToConvert) { + if (insertText === undefined) + insertText = name; + var awaitText = "(await " + propertyAccessToConvert.expression.getText() + ")"; + insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : awaitText + "." + insertText; + replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); + } if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) { return undefined; } @@ -102066,11 +103393,11 @@ var ts; return ts.getContextualTypeFromParent(previousToken, checker); case 60 /* EqualsToken */: switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; @@ -102080,16 +103407,16 @@ var ts; case 75 /* CaseKeyword */: return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 18 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 261 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 262 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); - return argInfo + return argInfo ? // At `,`, treat this as the next argument after the comma. - ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) - : ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) + checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) : + ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) ? // completion at `x ===/**/` should be for the right side - ? checker.getTypeAtLocation(parent.left) - : checker.getContextualType(previousToken); + checker.getTypeAtLocation(parent.left) : + checker.getContextualType(previousToken); } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { @@ -102099,7 +103426,7 @@ 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 === 285 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 286 /* SourceFile */; }); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { var typeChecker = program.getTypeChecker(); @@ -102150,11 +103477,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 290 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 312 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 314 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -102204,7 +103531,7 @@ var ts; if (contextToken.kind === 24 /* DotToken */) { isRightOfDot = true; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; if (node.end === contextToken.pos && @@ -102216,14 +103543,14 @@ var ts; return undefined; } break; - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: node = parent.left; break; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: node = parent.name; break; - case 184 /* ImportType */: - case 215 /* MetaProperty */: + case 185 /* ImportType */: + case 216 /* MetaProperty */: node = parent; break; default: @@ -102236,7 +103563,7 @@ var ts; // // If the tagname is a property access expression, we will then walk up to the top most of property access expression. // Then, try to get a JSX container and its associated attributes type. - if (parent && parent.kind === 190 /* PropertyAccessExpression */) { + if (parent && parent.kind === 191 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } @@ -102244,38 +103571,38 @@ var ts; if (currentToken.parent === location) { switch (currentToken.kind) { case 30 /* GreaterThanToken */: - if (currentToken.parent.kind === 261 /* JsxElement */ || currentToken.parent.kind === 263 /* JsxOpeningElement */) { + if (currentToken.parent.kind === 262 /* JsxElement */ || currentToken.parent.kind === 264 /* JsxOpeningElement */) { location = currentToken; } break; case 42 /* SlashToken */: - if (currentToken.parent.kind === 262 /* JsxSelfClosingElement */) { + if (currentToken.parent.kind === 263 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: if (contextToken.kind === 42 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: - case 263 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 262 /* JsxElement */: + case 264 /* JsxOpeningElement */: if (contextToken.kind === 28 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: switch (previousToken.kind) { case 60 /* EqualsToken */: isJsxInitializer = true; @@ -102350,11 +103677,11 @@ var ts; }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 311 /* JSDocTypedefTag */: + case 308 /* JSDocParameterTag */: + case 314 /* JSDocPropertyTag */: + case 309 /* JSDocReturnTag */: + case 311 /* JSDocTypeTag */: + case 313 /* JSDocTypedefTag */: return true; default: return false; @@ -102398,8 +103725,8 @@ 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 !== 285 /* SourceFile */ && d.kind !== 245 /* ModuleDeclaration */ && d.kind !== 244 /* EnumDeclaration */; })) { - addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); + symbol.declarations.some(function (d) { return d.kind !== 286 /* SourceFile */ && d.kind !== 246 /* ModuleDeclaration */ && d.kind !== 245 /* EnumDeclaration */; })) { + addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node), !!(node.flags & 16384 /* AwaitContext */)); } return; } @@ -102411,11 +103738,12 @@ var ts; return; } if (!isTypeLocation) { - addTypeProperties(typeChecker.getTypeAtLocation(node)); + addTypeProperties(typeChecker.getTypeAtLocation(node), !!(node.flags & 16384 /* AwaitContext */)); } } - function addTypeProperties(type) { + function addTypeProperties(type, insertAwait) { isNewIdentifierLocation = !!type.getStringIndexType(); + var propertyAccess = node.kind === 185 /* 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 @@ -102427,13 +103755,24 @@ var ts; else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 184 /* ImportType */ ? node : node.parent, type, symbol)) { + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) { addPropertySymbol(symbol); } } } + if (insertAwait && preferences.includeCompletionsWithInsertText) { + var promiseType = typeChecker.getPromisedTypeOfPromise(type); + if (promiseType) { + for (var _b = 0, _c = promiseType.getApparentProperties(); _b < _c.length; _b++) { + var symbol = _c[_b]; + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, promiseType, symbol)) { + addPropertySymbol(symbol, /* insertAwait */ true); + } + } + } + } } - function addPropertySymbol(symbol) { + function addPropertySymbol(symbol, insertAwait) { // For a computed property with an accessible name like `Symbol.iterator`, // we'll add a completion for the *name* `Symbol` instead of for the property. // If this is e.g. [Symbol.iterator], add a completion for `Symbol`. @@ -102450,12 +103789,19 @@ var ts; !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) ? { kind: 1 /* SymbolMemberNoExport */ } : { kind: 2 /* SymbolMemberExport */, moduleSymbol: moduleSymbol, isDefaultExport: false }; } else if (preferences.includeCompletionsWithInsertText) { + addPromiseSymbolOriginInfo(symbol); symbols.push(symbol); } } else { + addPromiseSymbolOriginInfo(symbol); symbols.push(symbol); } + function addPromiseSymbolOriginInfo(symbol) { + if (insertAwait && preferences.includeCompletionsWithInsertText && !symbolToOriginInfoMap[ts.getSymbolId(symbol)]) { + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 4 /* Promise */ }; + } + } } /** Given 'a.b.c', returns 'a'. */ function getLeftMostName(e) { @@ -102488,6 +103834,7 @@ var ts; if (!attrsType) return 0 /* Continue */; symbols = filterJsxAttributes(getPropertiesForObjectExpression(attrsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties); + setSortTextToOptionalMember(); completionKind = 3 /* MemberLike */; isNewIdentifierLocation = false; return 1 /* Success */; @@ -102531,7 +103878,7 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; isInSnippetScope = isSnippetScope(scopeNode); var isTypeOnly = isTypeOnlyCompletion(); - var symbolMeanings = (isTypeOnly ? 0 /* None */ : 67220415 /* Value */) | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; + var symbolMeanings = (isTypeOnly ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { var symbol = symbols_2[_i]; @@ -102541,7 +103888,7 @@ var ts; } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 285 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 286 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType) { for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) { @@ -102575,10 +103922,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 285 /* SourceFile */: - case 207 /* TemplateExpression */: - case 271 /* JsxExpression */: - case 219 /* Block */: + case 286 /* SourceFile */: + case 208 /* TemplateExpression */: + case 272 /* JsxExpression */: + case 220 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -102608,7 +103955,7 @@ var ts; } } // expressions are value space (which includes the value namespaces) - return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 67220415 /* Value */); + return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */); }); } function isTypeAssertion() { @@ -102624,27 +103971,27 @@ var ts; function isContextTokenValueLocation(contextToken) { return contextToken && contextToken.kind === 105 /* TypeOfKeyword */ && - (contextToken.parent.kind === 168 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + (contextToken.parent.kind === 169 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { case 57 /* ColonToken */: - return parentKind === 155 /* PropertyDeclaration */ || - parentKind === 154 /* PropertySignature */ || - parentKind === 152 /* Parameter */ || - parentKind === 238 /* VariableDeclaration */ || + return parentKind === 156 /* PropertyDeclaration */ || + parentKind === 155 /* PropertySignature */ || + parentKind === 153 /* Parameter */ || + parentKind === 239 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); case 60 /* EqualsToken */: - return parentKind === 243 /* TypeAliasDeclaration */; + return parentKind === 244 /* TypeAliasDeclaration */; case 120 /* AsKeyword */: - return parentKind === 213 /* AsExpression */; + return parentKind === 214 /* AsExpression */; case 28 /* LessThanToken */: - return parentKind === 165 /* TypeReference */ || - parentKind === 195 /* TypeAssertionExpression */; + return parentKind === 166 /* TypeReference */ || + parentKind === 196 /* TypeAssertionExpression */; case 87 /* ExtendsKeyword */: - return parentKind === 151 /* TypeParameter */; + return parentKind === 152 /* TypeParameter */; } } return false; @@ -102653,7 +104000,7 @@ var ts; function symbolCanBeReferencedAtTypeLocation(symbol, seenModules) { if (seenModules === void 0) { seenModules = ts.createMap(); } var sym = ts.skipAlias(symbol.exportSymbol || symbol, typeChecker); - return !!(sym.flags & 67897832 /* Type */) || + 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); }); @@ -102674,7 +104021,7 @@ var ts; if (resolvedModuleSymbol !== moduleSymbol && // 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`. - ts.some(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) { + ts.every(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) { symbols.push(resolvedModuleSymbol); symbolToSortTextMap[ts.getSymbolId(resolvedModuleSymbol)] = SortText.AutoImportSuggestions; symbolToOriginInfoMap[ts.getSymbolId(resolvedModuleSymbol)] = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: false }; @@ -102753,11 +104100,11 @@ var ts; return true; } if (contextToken.kind === 30 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 263 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 264 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 264 /* JsxClosingElement */ || contextToken.parent.kind === 262 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 261 /* JsxElement */; + if (contextToken.parent.kind === 265 /* JsxClosingElement */ || contextToken.parent.kind === 263 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 262 /* JsxElement */; } } return false; @@ -102768,40 +104115,40 @@ var ts; // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(previousToken)) { case 27 /* CommaToken */: - return containingNodeKind === 192 /* CallExpression */ // func( a, | - || containingNodeKind === 158 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 193 /* NewExpression */ // new C(a, | - || containingNodeKind === 188 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 205 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 166 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 193 /* CallExpression */ // func( a, | + || containingNodeKind === 159 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 194 /* NewExpression */ // new C(a, | + || containingNodeKind === 189 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 206 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 167 /* FunctionType */; // var x: (s: string, list| case 20 /* OpenParenToken */: - return containingNodeKind === 192 /* CallExpression */ // func( | - || containingNodeKind === 158 /* Constructor */ // constructor( | - || containingNodeKind === 193 /* NewExpression */ // new C(a| - || containingNodeKind === 196 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 178 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 193 /* CallExpression */ // func( | + || containingNodeKind === 159 /* Constructor */ // constructor( | + || containingNodeKind === 194 /* NewExpression */ // new C(a| + || containingNodeKind === 197 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 179 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 22 /* OpenBracketToken */: - return containingNodeKind === 188 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 163 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 150 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + return containingNodeKind === 189 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 164 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 151 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 131 /* ModuleKeyword */: // module | case 132 /* NamespaceKeyword */: // namespace | return true; case 24 /* DotToken */: - return containingNodeKind === 245 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 246 /* ModuleDeclaration */; // module A.| case 18 /* OpenBraceToken */: - return containingNodeKind === 241 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 242 /* ClassDeclaration */; // class A{ | case 60 /* EqualsToken */: - return containingNodeKind === 238 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 205 /* BinaryExpression */; // x = a| + return containingNodeKind === 239 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 206 /* BinaryExpression */; // x = a| case 15 /* TemplateHead */: - return containingNodeKind === 207 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 208 /* TemplateExpression */; // `aa ${| case 16 /* TemplateMiddle */: - return containingNodeKind === 217 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 218 /* TemplateSpan */; // `aa ${10} dd ${| case 116 /* PublicKeyword */: case 114 /* PrivateKeyword */: case 115 /* ProtectedKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 156 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -102828,7 +104175,7 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 189 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 190 /* ObjectLiteralExpression */) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2 /* Fail */; @@ -102837,7 +104184,7 @@ var ts; existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 185 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 186 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -102848,12 +104195,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 === 228 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 152 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 229 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 153 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 157 /* MethodDeclaration */ || rootDeclaration.parent.kind === 160 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 158 /* MethodDeclaration */ || rootDeclaration.parent.kind === 161 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -102870,6 +104217,7 @@ var ts; // Add filtered items to the completion list symbols = filterObjectMembersList(typeMembers, ts.Debug.assertDefined(existingMembers)); } + setSortTextToOptionalMember(); return 1 /* Success */; } /** @@ -102895,7 +104243,7 @@ var ts; return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 253 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 254 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -102923,7 +104271,7 @@ var ts; // If you're in an interface you don't want to repeat things from super-interface. So just stop here. if (!ts.isClassLike(decl)) return 1 /* Success */; - var classElement = contextToken.parent; + var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getModifierFlags(classElement) : 0 /* None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier if (contextToken.kind === 73 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { @@ -103017,11 +104365,11 @@ var ts; case 29 /* LessThanSlashToken */: case 42 /* SlashToken */: case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 269 /* JsxAttributes */: - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 262 /* JsxSelfClosingElement */ || parent.kind === 263 /* JsxOpeningElement */)) { + case 191 /* PropertyAccessExpression */: + case 270 /* JsxAttributes */: + case 269 /* JsxAttribute */: + case 271 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 263 /* JsxSelfClosingElement */ || parent.kind === 264 /* JsxOpeningElement */)) { if (contextToken.kind === 30 /* GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); if (!parent.typeArguments || (precedingToken && precedingToken.kind === 42 /* SlashToken */)) @@ -103029,7 +104377,7 @@ var ts; } return parent; } - else if (parent.kind === 268 /* JsxAttribute */) { + else if (parent.kind === 269 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103041,7 +104389,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 === 268 /* JsxAttribute */) || (parent.kind === 270 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 269 /* JsxAttribute */) || (parent.kind === 271 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103051,8 +104399,8 @@ var ts; break; case 19 /* CloseBraceToken */: if (parent && - parent.kind === 271 /* JsxExpression */ && - parent.parent && parent.parent.kind === 268 /* JsxAttribute */) { + parent.kind === 272 /* JsxExpression */ && + parent.parent && parent.parent.kind === 269 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103060,7 +104408,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 270 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 271 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103080,49 +104428,49 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 27 /* CommaToken */: - return containingNodeKind === 238 /* VariableDeclaration */ || - containingNodeKind === 239 /* VariableDeclarationList */ || - containingNodeKind === 220 /* VariableStatement */ || - containingNodeKind === 244 /* EnumDeclaration */ || // enum a { foo, | + return containingNodeKind === 239 /* VariableDeclaration */ || + containingNodeKind === 240 /* VariableDeclarationList */ || + containingNodeKind === 221 /* VariableStatement */ || + containingNodeKind === 245 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 24 /* DotToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 187 /* ArrayBindingPattern */; // var [.| case 57 /* ColonToken */: - return containingNodeKind === 187 /* BindingElement */; // var {x :html| + return containingNodeKind === 188 /* BindingElement */; // var {x :html| case 22 /* OpenBracketToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 187 /* ArrayBindingPattern */; // var [x| case 20 /* OpenParenToken */: - return containingNodeKind === 275 /* CatchClause */ || + return containingNodeKind === 276 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 18 /* OpenBraceToken */: - return containingNodeKind === 244 /* EnumDeclaration */; // enum a { | + return containingNodeKind === 245 /* EnumDeclaration */; // enum a { | case 28 /* LessThanToken */: - return containingNodeKind === 241 /* ClassDeclaration */ || // class A< | - containingNodeKind === 210 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 243 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 242 /* ClassDeclaration */ || // class A< | + containingNodeKind === 211 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 243 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 244 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); case 117 /* StaticKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + return containingNodeKind === 156 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 25 /* DotDotDotToken */: - return containingNodeKind === 152 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 186 /* ArrayBindingPattern */); // var [...z| + return containingNodeKind === 153 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 187 /* ArrayBindingPattern */); // var [...z| case 116 /* PublicKeyword */: case 114 /* PrivateKeyword */: case 115 /* ProtectedKeyword */: - return containingNodeKind === 152 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + return containingNodeKind === 153 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); case 120 /* AsKeyword */: - return containingNodeKind === 254 /* ImportSpecifier */ || - containingNodeKind === 258 /* ExportSpecifier */ || - containingNodeKind === 252 /* NamespaceImport */; + return containingNodeKind === 255 /* ImportSpecifier */ || + containingNodeKind === 259 /* ExportSpecifier */ || + containingNodeKind === 253 /* NamespaceImport */; case 127 /* GetKeyword */: case 138 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); @@ -103183,7 +104531,7 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 158 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 159 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -103202,16 +104550,18 @@ var ts; if (existingMembers.length === 0) { return contextualMemberSymbols; } + var membersDeclaredBySpreadAssignment = ts.createMap(); var existingMemberNames = ts.createUnderscoreEscapedMap(); 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 !== 276 /* PropertyAssignment */ && - m.kind !== 277 /* ShorthandPropertyAssignment */ && - m.kind !== 187 /* BindingElement */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 277 /* PropertyAssignment */ && + m.kind !== 278 /* ShorthandPropertyAssignment */ && + m.kind !== 188 /* BindingElement */ && + m.kind !== 158 /* MethodDeclaration */ && + m.kind !== 160 /* GetAccessor */ && + m.kind !== 161 /* SetAccessor */ && + m.kind !== 279 /* SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -103219,7 +104569,10 @@ var ts; continue; } var existingName = void 0; - if (ts.isBindingElement(m) && m.propertyName) { + if (ts.isSpreadAssignment(m)) { + setMembersDeclaredBySpreadAssignment(m, membersDeclaredBySpreadAssignment); + } + else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list if (m.propertyName.kind === 73 /* Identifier */) { existingName = m.propertyName.escapedText; @@ -103234,7 +104587,40 @@ var ts; } existingMemberNames.set(existingName, true); // TODO: GH#18217 } - return contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + var filteredSymbols = contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; + } + function setMembersDeclaredBySpreadAssignment(declaration, membersDeclaredBySpreadAssignment) { + var expression = declaration.expression; + var symbol = typeChecker.getSymbolAtLocation(expression); + var type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, expression); + var properties = type && type.properties; + if (properties) { + properties.forEach(function (property) { + membersDeclaredBySpreadAssignment.set(property.name, true); + }); + } + } + // Set SortText to OptionalMember if it is an optinoal member + function setSortTextToOptionalMember() { + symbols.forEach(function (m) { + if (m.flags & 16777216 /* Optional */) { + symbolToSortTextMap[ts.getSymbolId(m)] = symbolToSortTextMap[ts.getSymbolId(m)] || SortText.OptionalMember; + } + }); + } + // Set SortText to MemberDeclaredBySpreadAssignment if it is fulfilled by spread assignment + function setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, contextualMemberSymbols) { + if (membersDeclaredBySpreadAssignment.size === 0) { + return; + } + for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) { + var contextualMemberSymbol = contextualMemberSymbols_1[_i]; + if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) { + symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = SortText.MemberDeclaredBySpreadAssignment; + } + } } /** * Filters out completion suggestions for class elements. @@ -103246,10 +104632,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 !== 155 /* PropertyDeclaration */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 156 /* PropertyDeclaration */ && + m.kind !== 158 /* MethodDeclaration */ && + m.kind !== 160 /* GetAccessor */ && + m.kind !== 161 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -103283,17 +104669,23 @@ var ts; */ function filterJsxAttributes(symbols, attributes) { var seenNames = ts.createUnderscoreEscapedMap(); + var membersDeclaredBySpreadAssignment = ts.createMap(); for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) { var attr = attributes_1[_i]; // If this is the current item we are editing right now, do not filter it out if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 268 /* JsxAttribute */) { + if (attr.kind === 269 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } + else if (ts.isJsxSpreadAttribute(attr)) { + setMembersDeclaredBySpreadAssignment(attr, membersDeclaredBySpreadAssignment); + } } - return symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + var filteredSymbols = symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; } function isCurrentlyEditingNode(node) { return node.getStart(sourceFile) <= position && position <= node.getEnd(); @@ -103333,7 +104725,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 74 /* FirstKeyword */; i <= 148 /* LastKeyword */; i++) { + for (var i = 74 /* FirstKeyword */; i <= 149 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -103467,7 +104859,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 313 /* SyntaxList */: + case 315 /* 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); @@ -103662,7 +105054,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 285 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 286 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -103694,16 +105086,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 233 /* SwitchStatement */: - if (statement.kind === 229 /* ContinueStatement */) { + case 234 /* SwitchStatement */: + if (statement.kind === 230 /* ContinueStatement */) { return false; } // falls through - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 226 /* WhileStatement */: + case 225 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -103719,35 +105111,37 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 219 /* Block */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 247 /* ModuleBlock */: + case 286 /* SourceFile */: + case 220 /* Block */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { - return declaration.members.concat([declaration]); + return __spreadArrays(declaration.members, [declaration]); } else { return container.statements; } - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + return __spreadArrays(container.parameters, (ts.isClassLike(container.parent) ? container.parent.members : [])); + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 170 /* TypeLiteral */: var nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & 28 /* AccessibilityModifier */) { + if (modifierFlag & (28 /* AccessibilityModifier */ | 64 /* Readonly */)) { var constructor = ts.find(container.members, ts.isConstructorDeclaration); if (constructor) { - return nodes.concat(constructor.parameters); + return __spreadArrays(nodes, constructor.parameters); } } else if (modifierFlag & 128 /* Abstract */) { - return nodes.concat([container]); + return __spreadArrays(nodes, [container]); } return nodes; default: @@ -103769,7 +105163,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 90 /* ForKeyword */, 108 /* WhileKeyword */, 83 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 224 /* DoStatement */) { + if (loopNode.kind === 225 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 108 /* WhileKeyword */)) { @@ -103789,13 +105183,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -104162,10 +105556,10 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 238 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 239 /* VariableDeclaration */) { var name = parent.name; if (name.kind === 73 /* Identifier */) { directImports.push(name); @@ -104178,20 +105572,20 @@ var ts; break; case 73 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 253 /* 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 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -104201,7 +105595,7 @@ var ts; directImports.push(direct); } break; - case 184 /* ImportType */: + case 185 /* ImportType */: directImports.push(direct); break; default: @@ -104218,7 +105612,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 285 /* SourceFile */ || sourceFileLike.kind === 245 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 286 /* SourceFile */ || sourceFileLike.kind === 246 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -104273,7 +105667,7 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 249 /* ImportEqualsDeclaration */) { + if (decl.kind === 250 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } @@ -104283,7 +105677,7 @@ var ts; handleNamespaceImportLike(decl); return; } - if (decl.kind === 184 /* ImportType */) { + if (decl.kind === 185 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -104298,17 +105692,17 @@ var ts; if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 256 /* ExportDeclaration */) { + if (decl.kind === 257 /* ExportDeclaration */) { searchForNamedImport(decl.exportClause); return; } var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 253 /* NamedImports */: + case 254 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -104358,7 +105752,7 @@ var ts; } } else { - var localSymbol = element.kind === 258 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 259 /* 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); @@ -104387,7 +105781,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 === 285 /* SourceFile */) { + if (searchSourceFile.kind === 286 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -104435,7 +105829,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 === 285 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 286 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -104450,15 +105844,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: { + case 257 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 249 /* ImportEqualsDeclaration */: { + case 250 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -104472,7 +105866,7 @@ var ts; /** * Given a local reference, we might notice that it's an import/export and recursively search for references of that. * If at an import, look locally for the symbol it imports. - * If an an export, look for all imports of it. + * If at an export, look for all imports of it. * This doesn't handle export specifiers; that is done in `getReferencesAtExportSpecifier`. * @param comingFromExport If we are doing a search for all exports, don't bother looking backwards for the imported symbol, since that's the reason we're here. */ @@ -104482,7 +105876,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 190 /* PropertyAccessExpression */) { + if (parent.kind === 191 /* 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) @@ -104604,10 +105998,10 @@ var ts; // If a reference is a class expression, the exported node would be its parent. // If a reference is a variable declaration, the exported node would be the variable statement. function getExportNode(parent, node) { - if (parent.kind === 238 /* VariableDeclaration */) { - var p = parent; - return p.name !== node ? undefined : - p.parent.kind === 275 /* CatchClause */ ? undefined : p.parent.parent.kind === 220 /* VariableStatement */ ? p.parent.parent : undefined; + var declaration = ts.isVariableDeclaration(parent) ? parent : ts.isBindingElement(parent) ? ts.walkUpBindingElementsAndPatterns(parent) : undefined; + if (declaration) { + return parent.name !== node ? undefined : + ts.isCatchClause(declaration.parent) ? undefined : ts.isVariableStatement(declaration.parent.parent) ? declaration.parent.parent : undefined; } else { return parent; @@ -104616,13 +106010,13 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 254 /* ImportSpecifier */: + case 255 /* 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 251 /* ImportClause */: - case 252 /* NamespaceImport */: + case 252 /* ImportClause */: + case 253 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return true; default: @@ -104655,21 +106049,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 193 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 285 /* SourceFile */) { + if (parent.kind === 286 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 246 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 247 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 246 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 260 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 261 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -104771,7 +106165,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -104779,27 +106173,27 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 187 /* BindingElement */: + case 188 /* BindingElement */: return getContextNode(node.parent.parent); - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return node.parent.parent.parent; - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 259 /* ExportSpecifier */: + case 253 /* NamespaceImport */: return node.parent.parent; - case 251 /* ImportClause */: + case 252 /* ImportClause */: return node.parent; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 228 /* ForInStatement */: return { start: node.initializer, end: node.expression }; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -104843,13 +106237,13 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* 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 === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 278 /* ShorthandPropertyAssignment */) { var result_1 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); return result_1; @@ -104934,16 +106328,16 @@ var ts; return { displayParts: displayParts, kind: symbolKind }; } function toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixText) { - return __assign({}, entryToDocumentSpan(entry), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker))); + return __assign(__assign({}, entryToDocumentSpan(entry)), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker))); } FindAllReferences.toRenameLocation = toRenameLocation; function toReferenceEntry(entry) { var documentSpan = entryToDocumentSpan(entry); if (entry.kind === 0 /* Span */) { - return __assign({}, documentSpan, { isWriteAccess: false, isDefinition: false }); + return __assign(__assign({}, documentSpan), { isWriteAccess: false, isDefinition: false }); } var kind = entry.kind, node = entry.node; - return __assign({}, documentSpan, { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 81 /* DefaultKeyword */ + return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 81 /* DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); } @@ -104987,10 +106381,10 @@ var ts; var documentSpan = entryToDocumentSpan(entry); if (entry.kind !== 0 /* Span */) { var node = entry.node; - return __assign({}, documentSpan, implementationKindDisplayParts(node, checker)); + return __assign(__assign({}, documentSpan), implementationKindDisplayParts(node, checker)); } else { - return __assign({}, documentSpan, { kind: "" /* unknown */, displayParts: [] }); + return __assign(__assign({}, documentSpan), { kind: "" /* unknown */, displayParts: [] }); } } function implementationKindDisplayParts(node, checker) { @@ -104998,13 +106392,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 190 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 210 /* ClassExpression */) { + else if (node.kind === 211 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] @@ -105059,46 +106453,46 @@ var ts; if (!!(decl.flags & 4194304 /* Ambient */)) return true; switch (decl.kind) { - case 205 /* BinaryExpression */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 206 /* BinaryExpression */: + case 188 /* BindingElement */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: case 81 /* DefaultKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 258 /* ExportSpecifier */: - case 251 /* ImportClause */: // default import - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 242 /* InterfaceDeclaration */: - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: - case 268 /* JsxAttribute */: - case 245 /* ModuleDeclaration */: - case 248 /* NamespaceExportDeclaration */: - case 252 /* NamespaceImport */: - case 152 /* Parameter */: - case 277 /* ShorthandPropertyAssignment */: - case 243 /* TypeAliasDeclaration */: - case 151 /* TypeParameter */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 259 /* ExportSpecifier */: + case 252 /* ImportClause */: // default import + case 250 /* ImportEqualsDeclaration */: + case 255 /* ImportSpecifier */: + case 243 /* InterfaceDeclaration */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 269 /* JsxAttribute */: + case 246 /* ModuleDeclaration */: + case 249 /* NamespaceExportDeclaration */: + case 253 /* NamespaceImport */: + case 153 /* Parameter */: + case 278 /* ShorthandPropertyAssignment */: + case 244 /* TypeAliasDeclaration */: + case 152 /* TypeParameter */: return true; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return !!decl.body; - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: + case 239 /* VariableDeclaration */: + case 156 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 156 /* MethodSignature */: - case 154 /* PropertySignature */: - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: + case 157 /* MethodSignature */: + case 155 /* PropertySignature */: + case 314 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -105258,10 +106652,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 285 /* SourceFile */: + case 286 /* 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 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(FindAllReferences.nodeEntry(decl.name)); } @@ -105278,21 +106672,32 @@ var ts; var sourceFile = decl.getSourceFile(); if (sourceFilesSet.has(sourceFile.fileName)) { // At `module.exports = ...`, reference node is `module` - var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) - ? decl.left.expression - : ts.isExportAssignment(decl) - ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 86 /* ExportKeyword */, sourceFile)) - : ts.getNameOfDeclaration(decl) || decl; + var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : + ts.isExportAssignment(decl) ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 86 /* ExportKeyword */, sourceFile)) : + ts.getNameOfDeclaration(decl) || decl; references.push(FindAllReferences.nodeEntry(node)); } } } return references.length ? [{ definition: { type: 0 /* Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; } + /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ + function isReadonlyTypeOperator(node) { + return node.kind === 134 /* ReadonlyKeyword */ + && ts.isTypeOperatorNode(node.parent) + && node.parent.operator === 134 /* ReadonlyKeyword */; + } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { if (ts.isTypeKeyword(node.kind)) { - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + // A modifier readonly (like on a property declaration) is not special; + // a readonly type keyword (like `readonly string[]`) is. + if (node.kind === 134 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + return undefined; + } + // Likewise, when we *are* looking for a special keyword, make sure we + // *don’t* include readonly member modifiers. + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 134 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } // Labels if (ts.isJumpStatementTarget(node)) { @@ -105591,7 +106996,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 === 197 /* FunctionExpression */ || valueDeclaration.kind === 210 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 198 /* FunctionExpression */ || valueDeclaration.kind === 211 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -105601,7 +107006,7 @@ var ts; if (flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.find(declarations, function (d) { return ts.hasModifier(d, 8 /* Private */); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 241 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 242 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -105630,7 +107035,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 286 /* 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; @@ -105651,7 +107056,7 @@ var ts; } Core.isSymbolReferencedInFile = isSymbolReferencedInFile; function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) { - var symbol = ts.isParameterPropertyDeclaration(definition.parent) + var symbol = ts.isParameterPropertyDeclaration(definition.parent, definition.parent.parent) ? ts.first(checker.getSymbolsOfParameterPropertyDeclaration(definition.parent, definition.text)) : checker.getSymbolAtLocation(definition); if (!symbol) @@ -105753,11 +107158,13 @@ var ts; return false; } } - function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { + function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken, filter) { var references = ts.flatMap(sourceFiles, function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, ts.tokenToString(keywordKind), sourceFile), function (referenceLocation) { - return referenceLocation.kind === keywordKind ? FindAllReferences.nodeEntry(referenceLocation) : undefined; + if (referenceLocation.kind === keywordKind && (!filter || filter(referenceLocation))) { + return FindAllReferences.nodeEntry(referenceLocation); + } }); }); return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; @@ -105931,7 +107338,7 @@ var ts; } } function addReference(referenceLocation, relatedSymbol, state) { - var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; + var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator var addRef = state.referenceAdder(symbol); if (state.options.implementations) { addImplementationReferences(referenceLocation, addRef, state); @@ -105994,14 +107401,14 @@ var ts; for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var ctrKeyword = ts.findChildOfKind(decl, 125 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 158 /* Constructor */ && !!ctrKeyword); + ts.Debug.assert(decl.kind === 159 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 157 /* MethodDeclaration */) { + if (decl && decl.kind === 158 /* MethodDeclaration */) { var body = decl.body; if (body) { forEachDescendantOfKind(body, 101 /* ThisKeyword */, function (thisKeyword) { @@ -106025,7 +107432,7 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 158 /* Constructor */); + ts.Debug.assert(decl.kind === 159 /* Constructor */); var body = decl.body; if (body) { forEachDescendantOfKind(body, 99 /* SuperKeyword */, function (node) { @@ -106055,7 +107462,7 @@ var ts; if (refNode.kind !== 73 /* Identifier */) { return; } - if (refNode.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 278 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -106075,7 +107482,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 219 /* Block */) { + if (body.kind === 220 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -106103,13 +107510,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 188 /* ArrayLiteralExpression */: + case 199 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 190 /* ObjectLiteralExpression */: + case 211 /* ClassExpression */: + case 189 /* ArrayLiteralExpression */: return true; default: return false; @@ -106162,13 +107569,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -106189,41 +107596,41 @@ var ts; return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 73 /* Identifier */ && node.parent.kind === 152 /* Parameter */ && node.parent.name === node; + return node.kind === 73 /* Identifier */ && node.parent.kind === 153 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 198 /* 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 === 285 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 286 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -106231,19 +107638,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 242 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 285 /* SourceFile */: - return container.kind === 285 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 286 /* SourceFile */: + return container.kind === 286 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -106320,7 +107727,7 @@ var ts; var res = fromRoot(symbol); if (res) return res; - if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) { // For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property). var paramProps = checker.getSymbolsOfParameterPropertyDeclaration(ts.cast(symbol.valueDeclaration, ts.isParameter), symbol.name); ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] @@ -106362,7 +107769,7 @@ var ts; }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 187 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 188 /* BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -106412,11 +107819,10 @@ var ts; } Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations; function isImplementation(node) { - return !!(node.flags & 4194304 /* Ambient */) - ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) - : (ts.isVariableLike(node) ? ts.hasInitializer(node) - : ts.isFunctionLikeDeclaration(node) ? !!node.body - : ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); + return !!(node.flags & 4194304 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : + (ts.isVariableLike(node) ? ts.hasInitializer(node) : + ts.isFunctionLikeDeclaration(node) ? !!node.body : + ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); } function getReferenceEntriesForShorthandPropertyAssignment(node, checker, addReference) { var refSymbol = checker.getSymbolAtLocation(node); @@ -106719,9 +108125,9 @@ var ts; return [sigInfo]; } else { - var defs = getDefinitionFromSymbol(typeChecker, symbol, node) || ts.emptyArray; + var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 99 /* SuperKeyword */ ? [sigInfo].concat(defs) : defs.concat([sigInfo]); + return node.kind === 99 /* SuperKeyword */ ? __spreadArrays([sigInfo], defs) : __spreadArrays(defs, [sigInfo]); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -106729,7 +108135,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 278 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -106889,28 +108295,32 @@ var ts; return true; } switch (declaration.kind) { - case 251 /* ImportClause */: - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportClause */: + case 250 /* ImportEqualsDeclaration */: return true; - case 254 /* ImportSpecifier */: - return declaration.parent.kind === 253 /* NamedImports */; + case 255 /* ImportSpecifier */: + return declaration.parent.kind === 254 /* NamedImports */; default: return false; } } - function getDefinitionFromSymbol(typeChecker, symbol, node) { - return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(symbol.declarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); + function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) { + // There are cases when you extend a function by adding properties to it afterwards, + // we want to strip those extra properties. + // For deduping purposes, we also want to exclude any declarationNodes if provided. + var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); }) || undefined; + return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); function getConstructSignatureDefinition() { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (symbol.flags & 32 /* Class */ && (ts.isNewExpressionTarget(node) || node.kind === 125 /* ConstructorKeyword */)) { - var cls = ts.find(symbol.declarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); + if (symbol.flags & 32 /* Class */ && !(symbol.flags & 16 /* Function */) && (ts.isNewExpressionTarget(node) || node.kind === 125 /* ConstructorKeyword */)) { + var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } } function getCallSignatureDefinition() { return ts.isCallOrNewExpressionTarget(node) || ts.isNameOfFunctionDeclaration(node) - ? getSignatureDefinition(symbol.declarations, /*selectConstructors*/ false) + ? getSignatureDefinition(filteredDeclarations, /*selectConstructors*/ false) : undefined; } function getSignatureDefinition(signatureDeclarations, selectConstructors) { @@ -106918,8 +108328,12 @@ var ts; return undefined; } var declarations = signatureDeclarations.filter(selectConstructors ? ts.isConstructorDeclaration : ts.isFunctionLike); + var declarationsWithBody = declarations.filter(function (d) { return !!d.body; }); + // declarations defined on the global scope can be defined on multiple files. Get all of them. return declarations.length - ? [createDefinitionInfo(ts.find(declarations, function (d) { return !!d.body; }) || ts.last(declarations), typeChecker, symbol, node)] + ? declarationsWithBody.length !== 0 + ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); }) + : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)] : undefined; } } @@ -106972,9 +108386,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 159 /* Constructor */: + case 168 /* ConstructorType */: + case 163 /* ConstructSignature */: return true; default: return false; @@ -107092,11 +108506,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: + case 314 /* JSDocPropertyTag */: return [declaration]; - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -107117,16 +108531,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 301 /* JSDocAugmentsTag */: + case 303 /* JSDocAugmentsTag */: return withNode(tag.class); - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 309 /* JSDocTypeTag */: + case 311 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 314 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -107313,23 +108727,23 @@ var ts; } function getCommentOwnerInfoWorker(commentOwner) { switch (commentOwner.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 156 /* MethodSignature */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 157 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer); - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 154 /* PropertySignature */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 243 /* TypeAliasDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 155 /* PropertySignature */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 244 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 220 /* VariableStatement */: { + case 221 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -107337,14 +108751,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 285 /* SourceFile */: + case 286 /* SourceFile */: return "quit"; - case 245 /* ModuleDeclaration */: + case 246 /* 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 === 245 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 205 /* BinaryExpression */: { + return commentOwner.parent.kind === 246 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 206 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; @@ -107363,14 +108777,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 196 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 197 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return rightHandSide.parameters; - case 210 /* ClassExpression */: { + case 211 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -107432,9 +108846,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 251 /* ImportClause */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportClause */: + case 255 /* ImportSpecifier */: + case 250 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -107444,7 +108858,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 150 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 151 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -107461,7 +108875,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 === 150 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 151 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -107505,6 +108919,7 @@ var ts; (function (ts) { var NavigationBar; (function (NavigationBar) { + var _a; /** * Matches all whitespace characters in a string. Eg: * @@ -107519,6 +108934,11 @@ var ts; * does not match. */ var whiteSpaceRegex = /\s+/g; + /** + * Maximum amount of characters to return + * The amount was choosen arbitrarily. + */ + var maxLength = 150; // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. var curCancellationToken; var curSourceFile; @@ -107529,13 +108949,15 @@ var ts; */ var parentsStack = []; var parent; + var trackedEs5ClassesStack = []; + var trackedEs5Classes; // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. var emptyChildItemArray = []; function getNavigationBarItems(sourceFile, cancellationToken) { curCancellationToken = cancellationToken; curSourceFile = sourceFile; try { - return ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); + return ts.map(primaryNavBarMenuItems(rootNavigationBarNode(sourceFile)), convertToPrimaryNavBarMenuItem); } finally { reset(); @@ -107561,7 +108983,7 @@ var ts; emptyChildItemArray = []; } function nodeText(node) { - return node.getText(curSourceFile); + return cleanText(node.getText(curSourceFile)); } function navigationBarNodeKind(n) { return n.node.kind; @@ -107586,28 +109008,55 @@ var ts; ts.Debug.assert(!parent && !parentsStack.length); return root; } - function addLeafNode(node) { - pushChild(parent, emptyNavigationBarNode(node)); + function addLeafNode(node, name) { + pushChild(parent, emptyNavigationBarNode(node, name)); } - function emptyNavigationBarNode(node) { + function emptyNavigationBarNode(node, name) { return { node: node, - name: ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined, + name: name || (ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined), additionalNodes: undefined, parent: parent, children: undefined, indent: parent.indent + 1 }; } + function addTrackedEs5Class(name) { + if (!trackedEs5Classes) { + trackedEs5Classes = ts.createMap(); + } + trackedEs5Classes.set(name, true); + } + function endNestedNodes(depth) { + for (var i = 0; i < depth; i++) + endNode(); + } + function startNestedNodes(targetNode, entityName) { + var names = []; + while (!ts.isIdentifier(entityName)) { + var name = entityName.name; + entityName = entityName.expression; + if (name.escapedText === "prototype") + continue; + names.push(name); + } + names.push(entityName); + for (var i = names.length - 1; i > 0; i--) { + var name = names[i]; + startNode(targetNode, name); + } + return [names.length - 1, names[0]]; + } /** * Add a new level of NavigationBarNodes. * This pushes to the stack, so you must call `endNode` when you are done adding to this node. */ - function startNode(node) { - var navNode = emptyNavigationBarNode(node); + function startNode(node, name) { + var navNode = emptyNavigationBarNode(node, name); pushChild(parent, navNode); // Save the old parent parentsStack.push(parent); + trackedEs5ClassesStack.push(trackedEs5Classes); parent = navNode; } /** Call after calling `startNode` and adding children to it. */ @@ -107617,46 +109066,48 @@ var ts; sortChildren(parent.children); } parent = parentsStack.pop(); + trackedEs5Classes = trackedEs5ClassesStack.pop(); } - function addNodeWithRecursiveChild(node, child) { - startNode(node); + function addNodeWithRecursiveChild(node, child, name) { + startNode(node, name); addChildrenRecursively(child); endNode(); } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ function addChildrenRecursively(node) { + var _a; curCancellationToken.throwIfCancellationRequested(); if (!node || ts.isToken(node)) { return; } switch (node.kind) { - case 158 /* Constructor */: + case 159 /* 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); // Parameter properties are children of the class, not the constructor. - for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { - var param = _a[_i]; - if (ts.isParameterPropertyDeclaration(param)) { + for (var _i = 0, _b = ctr.parameters; _i < _b.length; _i++) { + var param = _b[_i]; + if (ts.isParameterPropertyDeclaration(param, ctr)) { addLeafNode(param); } } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 157 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 251 /* ImportClause */: + case 252 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -107668,90 +109119,168 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 253 /* NamespaceImport */) { addLeafNode(namedBindings); } else { - for (var _b = 0, _c = namedBindings.elements; _b < _c.length; _b++) { - var element = _c[_b]; + for (var _c = 0, _d = namedBindings.elements; _c < _d.length; _c++) { + var element = _d[_c]; addLeafNode(element); } } } break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: - var _d = node, name = _d.name, initializer = _d.initializer; + case 278 /* ShorthandPropertyAssignment */: + addNodeWithRecursiveChild(node, node.name); + break; + case 279 /* 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 188 /* BindingElement */: + case 277 /* PropertyAssignment */: + case 239 /* VariableDeclaration */: + var _e = node, name = _e.name, initializer = _e.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); } else if (initializer && isFunctionOrClassExpression(initializer)) { - if (initializer.name) { - // Don't add a node for the VariableDeclaration, just for the initializer. - addChildrenRecursively(initializer); - } - else { - // Add a node for the VariableDeclaration, but not for the initializer. - startNode(node); - ts.forEachChild(initializer, addChildrenRecursively); - endNode(); - } + // Add a node for the VariableDeclaration, but not for the initializer. + startNode(node); + ts.forEachChild(initializer, addChildrenRecursively); + endNode(); } else { addNodeWithRecursiveChild(node, initializer); } break; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + var nameNode = node.name; + // If we see a function declaration track as a possible ES5 class + if (nameNode && ts.isIdentifier(nameNode)) { + addTrackedEs5Class(nameNode.text); + } + addNodeWithRecursiveChild(node, node.body); + break; + case 199 /* ArrowFunction */: + case 198 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: startNode(node); - for (var _e = 0, _f = node.members; _e < _f.length; _e++) { - var member = _f[_e]; + for (var _f = 0, _g = node.members; _f < _g.length; _f++) { + var member = _g[_f]; if (!isComputedProperty(member)) { addLeafNode(member); } } endNode(); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: startNode(node); - for (var _g = 0, _h = node.members; _g < _h.length; _g++) { - var member = _h[_g]; + for (var _h = 0, _j = node.members; _h < _j.length; _h++) { + var member = _j[_h]; addChildrenRecursively(member); } endNode(); break; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 258 /* ExportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 163 /* IndexSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 243 /* TypeAliasDeclaration */: + case 259 /* ExportSpecifier */: + case 250 /* ImportEqualsDeclaration */: + case 164 /* IndexSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 244 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 205 /* BinaryExpression */: { + case 193 /* CallExpression */: + case 206 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: case 2 /* ModuleExports */: - case 3 /* PrototypeProperty */: - case 6 /* Prototype */: addNodeWithRecursiveChild(node, node.right); return; + case 6 /* Prototype */: + case 3 /* PrototypeProperty */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var prototypeAccess = special === 3 /* PrototypeProperty */ ? + assignmentTarget.expression : + assignmentTarget; + var depth = 0; + var className = void 0; + // If we see a prototype assignment, start tracking the target as a class + // This is only done for simple classes not nested assignments. + if (ts.isIdentifier(prototypeAccess.expression)) { + addTrackedEs5Class(prototypeAccess.expression.text); + className = prototypeAccess.expression; + } + else { + _a = startNestedNodes(binaryExpression, prototypeAccess.expression), depth = _a[0], className = _a[1]; + } + if (special === 6 /* Prototype */) { + if (ts.isObjectLiteralExpression(binaryExpression.right)) { + if (binaryExpression.right.properties.length > 0) { + startNode(binaryExpression, className); + ts.forEachChild(binaryExpression.right, addChildrenRecursively); + endNode(); + } + } + } + else if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, className); + } + else { + startNode(binaryExpression, className); + addNodeWithRecursiveChild(node, binaryExpression.right, assignmentTarget.name); + endNode(); + } + endNestedNodes(depth); + return; + } + case 7 /* ObjectDefinePropertyValue */: + case 9 /* ObjectDefinePrototypeProperty */: { + var defineCall = node; + var className = special === 7 /* ObjectDefinePropertyValue */ ? + defineCall.arguments[0] : + defineCall.arguments[0].expression; + var memberName = defineCall.arguments[1]; + var _k = startNestedNodes(node, className), depth = _k[0], classNameIdentifier = _k[1]; + startNode(node, classNameIdentifier); + startNode(node, ts.setTextRange(ts.createIdentifier(memberName.text), memberName)); + addChildrenRecursively(node.arguments[2]); + endNode(); + endNode(); + endNestedNodes(depth); + return; + } + case 5 /* Property */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var targetFunction = assignmentTarget.expression; + if (ts.isIdentifier(targetFunction) && assignmentTarget.name.escapedText !== "prototype" && + trackedEs5Classes && trackedEs5Classes.has(targetFunction.text)) { + if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, targetFunction); + } + else { + startNode(binaryExpression, targetFunction); + addNodeWithRecursiveChild(binaryExpression.left, binaryExpression.right, assignmentTarget.name); + endNode(); + } + return; + } + break; + } case 4 /* ThisProperty */: - case 5 /* Property */: case 0 /* None */: - case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: break; default: ts.Debug.assertNever(special); @@ -107774,8 +109303,8 @@ var ts; /** Merge declarations of the same kind. */ function mergeChildren(children, node) { var nameToItems = ts.createMap(); - ts.filterMutate(children, function (child) { - var declName = ts.getNameOfDeclaration(child.node); + ts.filterMutate(children, function (child, index) { + var declName = child.name || ts.getNameOfDeclaration(child.node); var name = declName && nodeText(declName); if (!name) { // Anonymous items are never merged. @@ -107789,7 +109318,7 @@ var ts; if (itemsWithSameName instanceof Array) { for (var _i = 0, itemsWithSameName_1 = itemsWithSameName; _i < itemsWithSameName_1.length; _i++) { var itemWithSameName = itemsWithSameName_1[_i]; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } } @@ -107798,7 +109327,7 @@ var ts; } else { var itemWithSameName = itemsWithSameName; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } nameToItems.set(name, [itemWithSameName, child]); @@ -107806,7 +109335,100 @@ var ts; } }); } - function tryMerge(a, b, parent) { + var isEs5ClassMember = (_a = {}, + _a[5 /* Property */] = true, + _a[3 /* PrototypeProperty */] = true, + _a[7 /* ObjectDefinePropertyValue */] = true, + _a[9 /* ObjectDefinePrototypeProperty */] = true, + _a[0 /* None */] = false, + _a[1 /* ExportsProperty */] = false, + _a[2 /* ModuleExports */] = false, + _a[8 /* ObjectDefinePropertyExports */] = false, + _a[6 /* Prototype */] = true, + _a[4 /* ThisProperty */] = false, + _a); + function tryMergeEs5Class(a, b, bIndex, parent) { + function isPossibleConstructor(node) { + return ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node) || ts.isVariableDeclaration(node); + } + var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? + ts.getAssignmentDeclarationKind(b.node) : + 0 /* None */; + var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? + ts.getAssignmentDeclarationKind(a.node) : + 0 /* None */; + // We treat this as an es5 class and merge the nodes in in one of several cases + if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements + || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member + || (isPossibleConstructor(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & ctor function + || (ts.isClassDeclaration(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // class (generated) & member + || (ts.isClassDeclaration(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & class (generated) + || (ts.isClassDeclaration(a.node) && isPossibleConstructor(b.node)) // class (generated) & ctor + || (ts.isClassDeclaration(b.node) && isPossibleConstructor(a.node)) // ctor & class (generated) + ) { + var lastANode = a.additionalNodes && ts.lastOrUndefined(a.additionalNodes) || a.node; + if ((!ts.isClassDeclaration(a.node) && !ts.isClassDeclaration(b.node)) // If neither outline node is a class + || isPossibleConstructor(a.node) || isPossibleConstructor(b.node) // If either function is a constructor function + ) { + var ctorFunction = isPossibleConstructor(a.node) ? a.node : + isPossibleConstructor(b.node) ? b.node : + undefined; + if (ctorFunction !== undefined) { + var ctorNode = ts.setTextRange(ts.createConstructor(/* decorators */ undefined, /* modifiers */ undefined, [], /* body */ undefined), ctorFunction); + var ctor = emptyNavigationBarNode(ctorNode); + ctor.indent = a.indent + 1; + ctor.children = a.node === ctorFunction ? a.children : b.children; + a.children = a.node === ctorFunction ? ts.concatenate([ctor], b.children || [b]) : ts.concatenate(a.children || [a], [ctor]); + } + else { + if (a.children || b.children) { + a.children = ts.concatenate(a.children || [a], b.children || [b]); + if (a.children) { + mergeChildren(a.children, a); + sortChildren(a.children); + } + } + } + lastANode = a.node = ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), a.node); + } + else { + a.children = ts.concatenate(a.children, b.children); + if (a.children) { + mergeChildren(a.children, a); + } + } + var bNode = b.node; + // We merge if the outline node previous to b (bIndex - 1) is already part of the current class + // We do this so that statements between class members that do not generate outline nodes do not split up the class outline: + // Ex This should produce one outline node C: + // function C() {}; a = 1; C.prototype.m = function () {} + // Ex This will produce 3 outline nodes: C, a, C + // function C() {}; let a = 1; C.prototype.m = function () {} + if (parent.children[bIndex - 1].node.end === lastANode.end) { + ts.setTextRange(lastANode, { pos: lastANode.pos, end: bNode.end }); + } + else { + if (!a.additionalNodes) + a.additionalNodes = []; + a.additionalNodes.push(ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), b.node)); + } + return true; + } + return bAssignmentDeclarationKind === 0 /* None */ ? false : true; + } + function tryMerge(a, b, bIndex, parent) { + // const v = false as boolean; + if (tryMergeEs5Class(a, b, bIndex, parent)) { + return true; + } if (shouldReallyMerge(a.node, b.node, parent)) { merge(a, b); return true; @@ -107819,12 +109441,12 @@ var ts; return false; } switch (a.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -107840,7 +109462,7 @@ var ts; // 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 !== 245 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 246 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -107870,7 +109492,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 245 /* ModuleDeclaration */) { + if (node.kind === 246 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -107878,35 +109500,35 @@ var ts; return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 } switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 211 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 245 /* ModuleDeclaration */) { - return getModuleName(node); + if (node.kind === 246 /* ModuleDeclaration */) { + return cleanText(getModuleName(node)); } if (name) { - var text = nodeText(name); + var text = ts.isIdentifier(name) ? name.text : nodeText(name); if (text.length > 0) { - return text; + return cleanText(text); } } switch (node.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 199 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -107914,24 +109536,27 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 158 /* Constructor */: + case 159 /* Constructor */: return "constructor"; - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: return "new()"; - case 161 /* CallSignature */: + case 162 /* CallSignature */: return "()"; - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: return "[]"; default: return ""; } } - /** Flattens the NavNode tree to a list, keeping only the top-level items. */ - function topLevelItems(root) { - var topLevel = []; + /** Flattens the NavNode tree to a list of items to appear in the primary navbar menu. */ + function primaryNavBarMenuItems(root) { + // The primary (middle) navbar menu displays the general code navigation hierarchy, similar to the navtree. + // The secondary (right) navbar menu displays the child items of whichever primary item is selected. + // Some less interesting items without their own child navigation items (e.g. a local variable declaration) only show up in the secondary menu. + var primaryNavBarMenuItems = []; function recur(item) { - if (isTopLevel(item)) { - topLevel.push(item); + if (shouldAppearInPrimaryNavBarMenu(item)) { + primaryNavBarMenuItems.push(item); if (item.children) { for (var _i = 0, _a = item.children; _i < _a.length; _i++) { var child = _a[_i]; @@ -107941,28 +109566,28 @@ var ts; } } recur(root); - return topLevel; - function isTopLevel(item) { + return primaryNavBarMenuItems; + /** Determines if a node should appear in the primary navbar menu. */ + function shouldAppearInPrimaryNavBarMenu(item) { + // Items with children should always appear in the primary navbar menu. + if (item.children) { + return true; + } + // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 285 /* SourceFile */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 245 /* EnumDeclaration */: + case 243 /* InterfaceDeclaration */: + case 246 /* ModuleDeclaration */: + case 286 /* SourceFile */: + case 244 /* TypeAliasDeclaration */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: return true; - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 238 /* VariableDeclaration */: - return hasSomeImportantChild(item); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -107972,21 +109597,15 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: + case 247 /* ModuleBlock */: + case 286 /* SourceFile */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: return true; default: - return hasSomeImportantChild(item); + return false; } } - function hasSomeImportantChild(item) { - return ts.some(item.children, function (child) { - var childKind = navigationBarNodeKind(child); - return childKind !== 238 /* VariableDeclaration */ && childKind !== 187 /* BindingElement */; - }); - } } } function convertToTree(n) { @@ -107999,18 +109618,18 @@ var ts; childItems: ts.map(n.children, convertToTree) }; } - function convertToTopLevelItem(n) { + function convertToPrimaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), kindModifiers: getModifiers(n.node), spans: getSpans(n), - childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, + childItems: ts.map(n.children, convertToSecondaryNavBarMenuItem) || emptyChildItemArray, indent: n.indent, bolded: false, grayed: false }; - function convertToChildItem(n) { + function convertToSecondaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), @@ -108041,7 +109660,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 246 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -108055,13 +109674,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 150 /* ComputedPropertyName */; + return !member.name || member.name.kind === 151 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 285 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 286 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 238 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 239 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -108069,11 +109688,11 @@ var ts; function getFunctionOrClassName(node) { var parent = node.parent; if (node.name && ts.getFullWidth(node.name) > 0) { - return ts.declarationNameToString(node.name); + return cleanText(ts.declarationNameToString(node.name)); } // See if it is a var initializer. If so, use the var name. else if (ts.isVariableDeclaration(parent)) { - return ts.declarationNameToString(parent.name); + return cleanText(ts.declarationNameToString(parent.name)); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 60 /* EqualsToken */) { @@ -108093,7 +109712,11 @@ var ts; else if (ts.isCallExpression(parent)) { var name = getCalledExpressionName(parent.expression); if (name !== undefined) { - var args = ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", "); + name = cleanText(name); + if (name.length > maxLength) { + return name + " callback"; + } + var args = cleanText(ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", ")); return name + "(" + args + ") callback"; } } @@ -108114,14 +109737,24 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: + case 199 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 211 /* ClassExpression */: return true; default: return false; } } + function cleanText(text) { + // Truncate to maximum amount of characters as we don't want to do a big replace operation. + text = text.length > maxLength ? text.substring(0, maxLength) + "..." : text; + // Replaces ECMAScript line terminators and removes the trailing `\` from each line: + // \n - Line Feed + // \r - Carriage Return + // \u2028 - Line separator + // \u2029 - Paragraph separator + return text.replace(/\\?(\r?\n|\r|\u2028|\u2029)/g, ""); + } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); /* @internal */ @@ -108581,7 +110214,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 219 /* Block */: + case 220 /* Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -108589,16 +110222,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 224 /* DoStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 275 /* CatchClause */: + case 225 /* DoStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 227 /* ForStatement */: + case 224 /* IfStatement */: + case 226 /* WhileStatement */: + case 233 /* WithStatement */: + case 276 /* CatchClause */: return spanForNode(n.parent); - case 236 /* TryStatement */: + case 237 /* TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { @@ -108613,24 +110246,24 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return spanForNode(n.parent); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 247 /* CaseBlock */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 248 /* CaseBlock */: return spanForNode(n); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 261 /* JsxElement */: + case 262 /* JsxElement */: return spanForJSXElement(n); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return spanForJSXFragment(n); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); } function spanForJSXElement(node) { @@ -108672,7 +110305,7 @@ var ts; ? ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) : ts.findChildOfKind(body, 18 /* OpenBraceToken */, sourceFile); var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 198 /* ArrowFunction */); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 199 /* ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } @@ -109516,7 +111149,7 @@ var ts; return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 150 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 151 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -109605,7 +111238,7 @@ var ts; if (node.getStart(sourceFile) > pos) { break outer; } - if (positionShouldSnapToNode(pos, node, nextNode)) { + 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 // of things that should be considered independently. @@ -109614,7 +111247,7 @@ var ts; // // Dive in without pushing a selection range. if (ts.isBlock(node) - || ts.isTemplateSpan(node) || ts.isTemplateHead(node) + || ts.isTemplateSpan(node) || ts.isTemplateHead(node) || ts.isTemplateTail(node) || prevNode && ts.isTemplateHead(prevNode) || ts.isVariableDeclarationList(node) && ts.isVariableStatement(parentNode) || ts.isSyntaxList(node) && ts.isVariableDeclarationList(parentNode) @@ -109677,12 +111310,11 @@ var ts; * count too, unless that position belongs to the next node. In effect, makes * selections able to snap to preceding tokens when the cursor is on the tail * end of them with only whitespace ahead. + * @param sourceFile The source file containing the nodes. * @param pos The position to check. * @param node The candidate node to snap to. - * @param nextNode The next sibling node in the tree. - * @param sourceFile The source file containing the nodes. */ - function positionShouldSnapToNode(pos, node, nextNode) { + function positionShouldSnapToNode(sourceFile, pos, node) { // Can’t use 'ts.positionBelongsToNode()' here because it cleverly accounts // for missing nodes, which can’t really be considered when deciding what // to select. @@ -109691,9 +111323,8 @@ var ts; return true; } var nodeEnd = node.getEnd(); - var nextNodeStart = nextNode && nextNode.getStart(); if (nodeEnd === pos) { - return pos !== nextNodeStart; + return ts.getTouchingPropertyName(sourceFile, pos).pos < node.end; } return false; } @@ -109735,7 +111366,7 @@ var ts; var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; return kind === 22 /* OpenBracketToken */ || - kind === 151 /* TypeParameter */ || + kind === 152 /* TypeParameter */ || kind === 23 /* CloseBracketToken */; }); return [ @@ -109842,7 +111473,7 @@ var ts; } function createSyntaxList(children) { ts.Debug.assertGreaterThanOrEqual(children.length, 1); - var syntaxList = ts.createNode(313 /* SyntaxList */, children[0].pos, ts.last(children).end); + var syntaxList = ts.createNode(315 /* SyntaxList */, children[0].pos, ts.last(children).end); syntaxList._children = children; return syntaxList; } @@ -109851,14 +111482,14 @@ var ts; return kind === 18 /* OpenBraceToken */ || kind === 22 /* OpenBracketToken */ || kind === 20 /* OpenParenToken */ - || kind === 263 /* JsxOpeningElement */; + || kind === 264 /* JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; return kind === 19 /* CloseBraceToken */ || kind === 23 /* CloseBracketToken */ || kind === 21 /* CloseParenToken */ - || kind === 264 /* JsxClosingElement */; + || kind === 265 /* JsxClosingElement */; } })(SmartSelectionRange = ts.SmartSelectionRange || (ts.SmartSelectionRange = {})); })(ts || (ts = {})); @@ -110063,10 +111694,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 194 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 195 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 207 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 208 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -110133,17 +111764,17 @@ var ts; return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 197 /* ParenthesizedExpression */: + case 158 /* MethodDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* 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 205 /* BinaryExpression */: { + case 206 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; @@ -110214,11 +111845,11 @@ var ts; // not enough to put us in the substitution expression; we should consider ourselves part of // the *next* span's expression by offsetting the index (argIndex = (spanIndex + 1) + 1). // - // tslint:disable no-double-space + /* eslint-disable no-double-space */ // Example: f `# abcd $#{# 1 + 1# }# efghi ${ #"#hello"# } # ` // ^ ^ ^ ^ ^ ^ ^ ^ ^ // Case: 1 1 3 2 1 3 2 2 1 - // tslint:enable no-double-space + /* eslint-enable no-double-space */ ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); if (ts.isTemplateLiteralToken(node)) { if (ts.isInsideTemplateLiteral(node, position, sourceFile)) { @@ -110267,7 +111898,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 === 207 /* TemplateExpression */) { + if (template.kind === 208 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -110332,14 +111963,14 @@ var ts; var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); var tags = symbol.getJsDocTags(); - var prefixDisplayParts = typeSymbolDisplay.concat([ts.punctuationPart(28 /* LessThanToken */)]); + var prefixDisplayParts = __spreadArrays(typeSymbolDisplay, [ts.punctuationPart(28 /* LessThanToken */)]); return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(30 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]; function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) { var _a = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile), isVariadic = _a.isVariadic, parameters = _a.parameters, prefix = _a.prefix, suffix = _a.suffix; - var prefixDisplayParts = callTargetDisplayParts.concat(prefix); - var suffixDisplayParts = suffix.concat(returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker)); + var prefixDisplayParts = __spreadArrays(callTargetDisplayParts, prefix); + var suffixDisplayParts = __spreadArrays(suffix, returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker)); var documentation = candidateSignature.getDocumentationComment(checker); var tags = candidateSignature.getJsDocTags(); return { isVariadic: isVariadic, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; @@ -110363,10 +111994,10 @@ var ts; var parameters = (typeParameters || ts.emptyArray).map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var parameterParts = ts.mapToDisplayParts(function (writer) { var thisParameter = candidateSignature.thisParameter ? [checker.symbolToParameterDeclaration(candidateSignature.thisParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags)] : []; - var params = ts.createNodeArray(thisParameter.concat(checker.getExpandedParameters(candidateSignature).map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); + var params = ts.createNodeArray(__spreadArrays(thisParameter, checker.getExpandedParameters(candidateSignature).map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(28 /* LessThanToken */)], suffix: [ts.punctuationPart(30 /* GreaterThanToken */)].concat(parameterParts) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(28 /* LessThanToken */)], suffix: __spreadArrays([ts.punctuationPart(30 /* GreaterThanToken */)], parameterParts) }; } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { var isVariadic = checker.hasEffectiveRestParameter(candidateSignature); @@ -110378,7 +112009,7 @@ var ts; } }); var parameters = checker.getExpandedParameters(candidateSignature).map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }); - return { isVariadic: isVariadic, parameters: parameters, prefix: typeParameterParts.concat([ts.punctuationPart(20 /* OpenParenToken */)]), suffix: [ts.punctuationPart(21 /* CloseParenToken */)] }; + return { isVariadic: isVariadic, parameters: parameters, prefix: __spreadArrays(typeParameterParts, [ts.punctuationPart(20 /* OpenParenToken */)]), suffix: [ts.punctuationPart(21 /* CloseParenToken */)] }; } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { @@ -110579,7 +112210,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: var decl = ts.getDeclarationOfExpando(node); if (decl) { var symbol_1 = decl.symbol; @@ -110589,7 +112220,7 @@ var ts; } } // falls through if no diagnostic was created - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: var symbol = node.symbol; if (symbol.members && (symbol.members.size > 0)) { diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); @@ -110622,11 +112253,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 222 /* ExpressionStatement */: { + case 223 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -110643,12 +112274,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 252 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 253 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -110706,11 +112337,11 @@ var ts; // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg) { switch (arg.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); - /* falls through */ + // falls through case 97 /* NullKeyword */: case 73 /* Identifier */: // identifier includes undefined return true; @@ -110735,7 +112366,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 211 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -110823,11 +112454,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 263 /* JsxOpeningElement */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: return location.kind === 73 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -110870,7 +112501,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 190 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 191 /* 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)) { @@ -110890,7 +112521,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 193 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 99 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 194 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 99 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -110945,7 +112576,7 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 125 /* ConstructorKeyword */ && location.parent.kind === 158 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 125 /* ConstructorKeyword */ && location.parent.kind === 159 /* 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 @@ -110953,21 +112584,21 @@ var ts; return declaration === (location.kind === 125 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 158 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 159 /* 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 === 158 /* Constructor */) { + if (functionDeclaration_1.kind === 159 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 161 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 162 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -110977,7 +112608,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 211 /* 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 @@ -111021,7 +112652,7 @@ var ts; } if (symbolFlags & 1536 /* Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 245 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 246 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 73 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 132 /* NamespaceKeyword */ : 131 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -111042,7 +112673,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 151 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 152 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -111050,16 +112681,16 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 162 /* ConstructSignature */) { + if (declaration.kind === 163 /* ConstructSignature */) { displayParts.push(ts.keywordPart(96 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 161 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 162 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 243 /* TypeAliasDeclaration */) { + else if (declaration.kind === 244 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path @@ -111076,7 +112707,7 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 279 /* EnumMember */) { + if (declaration.kind === 280 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -111106,17 +112737,17 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(132 /* NamespaceKeyword */)); break; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 60 /* EqualsToken */ : 81 /* DefaultKeyword */)); break; - case 258 /* ExportSpecifier */: + case 259 /* ExportSpecifier */: displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); break; default: @@ -111125,7 +112756,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 249 /* ImportEqualsDeclaration */) { + if (declaration.kind === 250 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -111203,10 +112834,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 === 285 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 286 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 205 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 206 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -111319,16 +112950,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 197 /* FunctionExpression */) { + if (declaration.kind === 198 /* FunctionExpression */) { return true; } - if (declaration.kind !== 238 /* VariableDeclaration */ && declaration.kind !== 240 /* FunctionDeclaration */) { + if (declaration.kind !== 239 /* VariableDeclaration */ && declaration.kind !== 241 /* 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 === 285 /* SourceFile */ || parent.kind === 246 /* ModuleBlock */) { + if (parent.kind === 286 /* SourceFile */ || parent.kind === 247 /* ModuleBlock */) { return false; } } @@ -111351,32 +112982,24 @@ var ts; */ function transpileModule(input, transpileOptions) { var diagnostics = []; - var options = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : ts.getDefaultCompilerOptions(); - options.isolatedModules = true; + var options = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : {}; + // mix in default options + var defaultOptions = ts.getDefaultCompilerOptions(); + for (var key in defaultOptions) { + if (ts.hasProperty(defaultOptions, key) && options[key] === undefined) { + options[key] = defaultOptions[key]; + } + } + for (var _i = 0, transpileOptionValueCompilerOptions_1 = ts.transpileOptionValueCompilerOptions; _i < transpileOptionValueCompilerOptions_1.length; _i++) { + var option = transpileOptionValueCompilerOptions_1[_i]; + options[option.name] = option.transpileOptionValue; + } // transpileModule does not write anything to disk so there is no need to verify that there are no conflicts between input and output paths. options.suppressOutputPathCheck = true; // Filename can be non-ts file. options.allowNonTsExtensions = true; - // We are not returning a sourceFile for lib file when asked by the program, - // so pass --noLib to avoid reporting a file not found error. - options.noLib = true; - // Clear out other settings that would not be used in transpiling this module - options.lib = undefined; - options.types = undefined; - options.noEmit = undefined; - options.noEmitOnError = undefined; - options.paths = undefined; - options.rootDirs = undefined; - options.declaration = undefined; - options.composite = undefined; - options.declarationDir = undefined; - options.out = undefined; - options.outFile = undefined; - // We are not doing a full typecheck, we are not resolving the whole context, - // so pass --noResolve to avoid reporting missing file errors. - options.noResolve = true; // if jsx is specified then treat file as .tsx - var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); + var inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts"); var sourceFile = ts.createSourceFile(inputFileName, input, options.target); // TODO: GH#18217 if (transpileOptions.moduleName) { sourceFile.moduleName = transpileOptions.moduleName; @@ -111633,10 +113256,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 268 /* JsxAttribute */: - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 269 /* JsxAttribute */: + case 264 /* JsxOpeningElement */: + case 265 /* JsxClosingElement */: + case 263 /* 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 === 73 /* Identifier */; } @@ -111660,17 +113283,12 @@ var ts; ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) - ? 1 /* RescanGreaterThanToken */ - : shouldRescanSlashToken(n) - ? 2 /* RescanSlashToken */ - : shouldRescanTemplateToken(n) - ? 3 /* RescanTemplateToken */ - : shouldRescanJsxIdentifier(n) - ? 4 /* RescanJsxIdentifier */ - : shouldRescanJsxText(n) - ? 5 /* RescanJsxText */ - : 0 /* Scan */; + var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : + shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : + shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : + shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : + shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : + 0 /* Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -111813,7 +113431,7 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 148 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 149 /* LastToken */; token++) { allTokens.push(token); } function anyTokenExcept() { @@ -111824,10 +113442,10 @@ var ts; return { tokens: allTokens.filter(function (t) { return !tokens.some(function (t2) { return t2 === t; }); }), isSpecific: false }; } var anyToken = { tokens: allTokens, isSpecific: false }; - var anyTokenIncludingMultilineComments = tokenRangeFrom(allTokens.concat([3 /* MultiLineCommentTrivia */])); - var keywords = tokenRangeFromRange(74 /* FirstKeyword */, 148 /* LastKeyword */); + var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArrays(allTokens, [3 /* MultiLineCommentTrivia */])); + var keywords = tokenRangeFromRange(74 /* FirstKeyword */, 149 /* LastKeyword */); var binaryOperators = tokenRangeFromRange(28 /* FirstBinaryOperator */, 72 /* LastBinaryOperator */); - var binaryKeywordOperators = [94 /* InKeyword */, 95 /* InstanceOfKeyword */, 148 /* OfKeyword */, 120 /* AsKeyword */, 129 /* IsKeyword */]; + var binaryKeywordOperators = [94 /* InKeyword */, 95 /* InstanceOfKeyword */, 149 /* OfKeyword */, 120 /* AsKeyword */, 129 /* IsKeyword */]; var unaryPrefixOperators = [44 /* PlusPlusToken */, 45 /* MinusMinusToken */, 53 /* TildeToken */, 52 /* ExclamationToken */]; var unaryPrefixExpressions = [ 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 73 /* Identifier */, 20 /* OpenParenToken */, @@ -111838,7 +113456,7 @@ var ts; var unaryPredecrementExpressions = [73 /* Identifier */, 20 /* OpenParenToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */]; var unaryPostdecrementExpressions = [73 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 96 /* NewKeyword */]; var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = [73 /* Identifier */].concat(ts.typeKeywords); + var typeNames = __spreadArrays([73 /* Identifier */], ts.typeKeywords); // Place a space before open brace in a function declaration // TypeScript: Function can have return types, which can be made of tons of different token kinds var functionOpenBraceLeftTokenRange = anyTokenIncludingMultilineComments; @@ -112076,7 +113694,7 @@ var ts; // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. rule("SpaceAfterTryFinally", [104 /* TryKeyword */, 89 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), ]; - return highPriorityCommonRules.concat(userConfigurableRules, lowPriorityCommonRules); + return __spreadArrays(highPriorityCommonRules, userConfigurableRules, lowPriorityCommonRules); } formatting.getAllRules = getAllRules; /** @@ -112130,45 +113748,50 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 226 /* ForStatement */; + return context.contextNode.kind === 227 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 176 /* ConditionalType */: - case 213 /* AsExpression */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 164 /* TypePredicate */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 206 /* BinaryExpression */: + case 207 /* ConditionalExpression */: + case 177 /* ConditionalType */: + case 214 /* AsExpression */: + case 259 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 165 /* TypePredicate */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 187 /* BindingElement */: + case 188 /* BindingElement */: // equals in type X = ... - case 243 /* TypeAliasDeclaration */: + // falls through + case 244 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 249 /* ImportEqualsDeclaration */: - // equal in let a = 0; - case 238 /* VariableDeclaration */: - // equal in p = 0; - case 152 /* Parameter */: - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + // falls through + case 250 /* ImportEqualsDeclaration */: + // equal in let a = 0 + // falls through + case 239 /* VariableDeclaration */: + // equal in p = 0 + // falls through + case 153 /* Parameter */: + case 280 /* EnumMember */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 151 /* TypeParameter */: + // falls through + case 152 /* TypeParameter */: return context.currentTokenSpan.kind === 94 /* InKeyword */ || context.nextTokenSpan.kind === 94 /* InKeyword */ || context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 228 /* ForOfStatement */: - return context.currentTokenSpan.kind === 148 /* OfKeyword */ || context.nextTokenSpan.kind === 148 /* OfKeyword */; + case 229 /* ForOfStatement */: + return context.currentTokenSpan.kind === 149 /* OfKeyword */ || context.nextTokenSpan.kind === 149 /* OfKeyword */; } return false; } @@ -112180,22 +113803,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 155 /* PropertyDeclaration */ || - contextKind === 154 /* PropertySignature */ || - contextKind === 152 /* Parameter */ || - contextKind === 238 /* VariableDeclaration */ || + return contextKind === 156 /* PropertyDeclaration */ || + contextKind === 155 /* PropertySignature */ || + contextKind === 153 /* Parameter */ || + contextKind === 239 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 206 /* ConditionalExpression */ || - context.contextNode.kind === 176 /* ConditionalType */; + return context.contextNode.kind === 207 /* ConditionalExpression */ || + context.contextNode.kind === 177 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 185 /* ObjectBindingPattern */ || - context.contextNode.kind === 182 /* MappedType */ || + return context.contextNode.kind === 186 /* ObjectBindingPattern */ || + context.contextNode.kind === 183 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -112221,31 +113844,34 @@ var ts; return true; } switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 189 /* ObjectLiteralExpression */: - case 246 /* ModuleBlock */: + case 220 /* Block */: + case 248 /* CaseBlock */: + case 190 /* ObjectLiteralExpression */: + case 247 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + // falls through + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 161 /* CallSignature */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 198 /* ArrowFunction */: + // falls through + case 162 /* CallSignature */: + case 198 /* FunctionExpression */: + case 159 /* Constructor */: + case 199 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 242 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + // falls through + case 243 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -112254,40 +113880,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 240 /* FunctionDeclaration */ || context.contextNode.kind === 197 /* FunctionExpression */; + return context.contextNode.kind === 241 /* FunctionDeclaration */ || context.contextNode.kind === 198 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 169 /* TypeLiteral */: - case 245 /* ModuleDeclaration */: - case 256 /* ExportDeclaration */: - case 257 /* NamedExports */: - case 250 /* ImportDeclaration */: - case 253 /* NamedImports */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 170 /* TypeLiteral */: + case 246 /* ModuleDeclaration */: + case 257 /* ExportDeclaration */: + case 258 /* NamedExports */: + case 251 /* ImportDeclaration */: + case 254 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 275 /* CatchClause */: - case 246 /* ModuleBlock */: - case 233 /* SwitchStatement */: + case 242 /* ClassDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 276 /* CatchClause */: + case 247 /* ModuleBlock */: + case 234 /* SwitchStatement */: return true; - case 219 /* Block */: { + case 220 /* 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 !== 198 /* ArrowFunction */ && blockParent.kind !== 197 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 199 /* ArrowFunction */ && blockParent.kind !== 198 /* FunctionExpression */) { return true; } } @@ -112296,31 +113922,32 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 232 /* WithStatement */: + case 224 /* IfStatement */: + case 234 /* SwitchStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 226 /* WhileStatement */: + case 237 /* TryStatement */: + case 225 /* DoStatement */: + case 233 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 275 /* CatchClause */: + // falls through + case 276 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 189 /* ObjectLiteralExpression */; + return context.contextNode.kind === 190 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 192 /* CallExpression */; + return context.contextNode.kind === 193 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 193 /* NewExpression */; + return context.contextNode.kind === 194 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -112332,28 +113959,28 @@ var ts; return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 198 /* ArrowFunction */; + return context.contextNode.kind === 199 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 184 /* ImportType */; + return context.contextNode.kind === 185 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 261 /* JsxElement */ && context.contextNode.kind !== 265 /* JsxFragment */; + return context.contextNode.kind !== 262 /* JsxElement */ && context.contextNode.kind !== 266 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 271 /* JsxExpression */ || context.contextNode.kind === 270 /* JsxSpreadAttribute */; + return context.contextNode.kind === 272 /* JsxExpression */ || context.contextNode.kind === 271 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 268 /* JsxAttribute */; + return context.nextTokenParent.kind === 269 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 268 /* JsxAttribute */; + return context.contextNode.kind === 269 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 262 /* JsxSelfClosingElement */; + return context.contextNode.kind === 263 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -112368,45 +113995,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 153 /* Decorator */; + return node.kind === 154 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 239 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 240 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 245 /* ModuleDeclaration */; + return context.contextNode.kind === 246 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 169 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 170 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 162 /* ConstructSignature */; + return context.contextNode.kind === 163 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { if (token.kind !== 28 /* LessThanToken */ && token.kind !== 30 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 165 /* TypeReference */: - case 195 /* TypeAssertionExpression */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: + case 166 /* TypeReference */: + case 196 /* TypeAssertionExpression */: + case 244 /* TypeAliasDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 213 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -112417,16 +114044,16 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 195 /* TypeAssertionExpression */; + return context.contextNode.kind === 196 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 107 /* VoidKeyword */ && context.currentTokenParent.kind === 201 /* VoidExpression */; + return context.currentTokenSpan.kind === 107 /* VoidKeyword */ && context.currentTokenParent.kind === 202 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 208 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 209 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 214 /* NonNullExpression */; + return context.contextNode.kind === 215 /* NonNullExpression */; } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -112477,12 +114104,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 148 /* LastKeyword */ && column <= 148 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 149 /* LastKeyword */ && column <= 149 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 148 /* LastToken */ + 1; + var mapRowLength = 149 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; @@ -112508,11 +114135,11 @@ var ts; // In order to insert a rule to the end of sub-bucket (3), we get the index by adding // the values in the bitmap segments 3rd, 2nd, and 1st. function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) { - var position = rule.action === 1 /* Ignore */ - ? specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny - : rule.context !== formatting.anyContext - ? specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny - : specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; + var position = rule.action === 1 /* Ignore */ ? + specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny : + rule.context !== formatting.anyContext ? + specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny : + specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; var state = constructionState[rulesBucketIndex] || 0; rules.splice(getInsertionIndex(state, position), 0, rule); constructionState[rulesBucketIndex] = increaseInsertionIndex(state, position); @@ -112660,17 +114287,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 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 246 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 285 /* SourceFile */: - case 219 /* Block */: - case 246 /* ModuleBlock */: + return !!body && body.kind === 247 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 286 /* SourceFile */: + case 220 /* Block */: + case 247 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -112895,19 +114522,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 241 /* ClassDeclaration */: return 77 /* ClassKeyword */; - case 242 /* InterfaceDeclaration */: return 111 /* InterfaceKeyword */; - case 240 /* FunctionDeclaration */: return 91 /* FunctionKeyword */; - case 244 /* EnumDeclaration */: return 244 /* EnumDeclaration */; - case 159 /* GetAccessor */: return 127 /* GetKeyword */; - case 160 /* SetAccessor */: return 138 /* SetKeyword */; - case 157 /* MethodDeclaration */: + case 242 /* ClassDeclaration */: return 77 /* ClassKeyword */; + case 243 /* InterfaceDeclaration */: return 111 /* InterfaceKeyword */; + case 241 /* FunctionDeclaration */: return 91 /* FunctionKeyword */; + case 245 /* EnumDeclaration */: return 245 /* EnumDeclaration */; + case 160 /* GetAccessor */: return 127 /* GetKeyword */; + case 161 /* SetAccessor */: return 138 /* SetKeyword */; + case 158 /* MethodDeclaration */: if (node.asteriskToken) { return 40 /* AsteriskToken */; } // falls through - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 153 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -112964,15 +114591,15 @@ var ts; case 42 /* SlashToken */: case 30 /* GreaterThanToken */: switch (container.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 265 /* JsxClosingElement */: + case 263 /* JsxSelfClosingElement */: return false; } break; case 22 /* OpenBracketToken */: case 23 /* CloseBracketToken */: - if (container.kind !== 182 /* MappedType */) { + if (container.kind !== 183 /* MappedType */) { return false; } break; @@ -113064,7 +114691,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 153 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 154 /* 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 */) { @@ -113072,7 +114699,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 188 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 189 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -113455,8 +115082,7 @@ var ts; /** * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. */ - function getRangeOfEnclosingComment(sourceFile, position, precedingToken, // tslint:disable-line:no-null-keyword - tokenAtPosition) { + function getRangeOfEnclosingComment(sourceFile, position, precedingToken, tokenAtPosition) { if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position); } var jsdoc = ts.findAncestor(tokenAtPosition, ts.isJSDoc); if (jsdoc) @@ -113465,6 +115091,7 @@ var ts; if (tokenStart <= position && position < tokenAtPosition.getEnd()) { return undefined; } + // eslint-disable-next-line no-null/no-null precedingToken = precedingToken === null ? undefined : precedingToken === undefined ? ts.findPrecedingToken(position, sourceFile) : precedingToken; // Between two consecutive tokens, all comments are either trailing on the former // or leading on the latter (and none are in both lists). @@ -113490,12 +115117,12 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 198 /* ArrowFunction */: + case 159 /* Constructor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 199 /* ArrowFunction */: if (node.typeParameters === list) { return 28 /* LessThanToken */; } @@ -113503,8 +115130,8 @@ var ts; return 20 /* OpenParenToken */; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: if (node.typeArguments === list) { return 28 /* LessThanToken */; } @@ -113512,12 +115139,12 @@ var ts; return 20 /* OpenParenToken */; } break; - case 165 /* TypeReference */: + case 166 /* TypeReference */: if (node.typeArguments === list) { return 28 /* LessThanToken */; } break; - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return 18 /* OpenBraceToken */; } return 0 /* Unknown */; @@ -113615,7 +115242,8 @@ var ts; return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); - var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); // tslint:disable-line:no-null-keyword + // eslint-disable-next-line no-null/no-null + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } @@ -113634,7 +115262,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 205 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 206 /* 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 */) { @@ -113788,7 +115416,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 === 285 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 286 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -113836,7 +115464,7 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 223 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 224 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 84 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -113871,40 +115499,40 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return getList(node.typeArguments); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return getList(node.properties); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return getList(node.elements); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return getList(node.members); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 159 /* Constructor */: + case 168 /* ConstructorType */: + case 163 /* ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 312 /* JSDocTemplateTag */: return getList(node.typeParameters); - case 193 /* NewExpression */: - case 192 /* CallExpression */: + case 194 /* NewExpression */: + case 193 /* CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return getList(node.declarations); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 254 /* NamedImports */: + case 258 /* NamedExports */: return getList(node.elements); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -113927,7 +115555,7 @@ var ts; return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 239 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 240 /* VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens return -1 /* Unknown */; } @@ -114000,83 +115628,87 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 222 /* ExpressionStatement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 188 /* ArrayLiteralExpression */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 182 /* MappedType */: - case 171 /* TupleType */: - case 247 /* CaseBlock */: - case 273 /* DefaultClause */: - case 272 /* CaseClause */: - case 196 /* ParenthesizedExpression */: - case 190 /* PropertyAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 220 /* VariableStatement */: - case 255 /* ExportAssignment */: - case 231 /* ReturnStatement */: - case 206 /* ConditionalExpression */: - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: - case 262 /* JsxSelfClosingElement */: - case 271 /* JsxExpression */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 152 /* Parameter */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 178 /* ParenthesizedType */: - case 194 /* TaggedTemplateExpression */: - case 202 /* AwaitExpression */: - case 257 /* NamedExports */: - case 253 /* NamedImports */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 155 /* PropertyDeclaration */: + case 223 /* ExpressionStatement */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 189 /* ArrayLiteralExpression */: + case 220 /* Block */: + case 247 /* ModuleBlock */: + case 190 /* ObjectLiteralExpression */: + case 170 /* TypeLiteral */: + case 183 /* MappedType */: + case 172 /* TupleType */: + case 248 /* CaseBlock */: + case 274 /* DefaultClause */: + case 273 /* CaseClause */: + case 197 /* ParenthesizedExpression */: + case 191 /* PropertyAccessExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 221 /* VariableStatement */: + case 256 /* ExportAssignment */: + case 232 /* ReturnStatement */: + case 207 /* ConditionalExpression */: + case 187 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 264 /* JsxOpeningElement */: + case 267 /* JsxOpeningFragment */: + case 263 /* JsxSelfClosingElement */: + case 272 /* JsxExpression */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 153 /* Parameter */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 179 /* ParenthesizedType */: + case 195 /* TaggedTemplateExpression */: + case 203 /* AwaitExpression */: + case 258 /* NamedExports */: + case 254 /* NamedImports */: + case 259 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 156 /* PropertyDeclaration */: return true; - case 238 /* VariableDeclaration */: - case 276 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 189 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 239 /* VariableDeclaration */: + case 277 /* PropertyAssignment */: + case 206 /* BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 190 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - return true; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return childKind !== 219 /* Block */; - case 256 /* ExportDeclaration */: - return childKind !== 257 /* NamedExports */; - case 250 /* ImportDeclaration */: - return childKind !== 251 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 253 /* NamedImports */); - case 261 /* JsxElement */: - return childKind !== 264 /* JsxClosingElement */; - case 265 /* JsxFragment */: - return childKind !== 267 /* JsxClosingFragment */; - case 175 /* IntersectionType */: - case 174 /* UnionType */: - if (childKind === 169 /* TypeLiteral */) { + if (parent.kind !== 206 /* BinaryExpression */) { + return true; + } + break; + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 227 /* ForStatement */: + case 224 /* IfStatement */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 199 /* ArrowFunction */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + return childKind !== 220 /* Block */; + case 257 /* ExportDeclaration */: + return childKind !== 258 /* NamedExports */; + case 251 /* ImportDeclaration */: + return childKind !== 252 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 254 /* NamedImports */); + case 262 /* JsxElement */: + return childKind !== 265 /* JsxClosingElement */; + case 266 /* JsxFragment */: + return childKind !== 268 /* JsxClosingFragment */; + case 176 /* IntersectionType */: + case 175 /* UnionType */: + if (childKind === 170 /* TypeLiteral */) { return false; } // falls through @@ -114087,11 +115719,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: - return parent.kind !== 219 /* Block */; + case 232 /* ReturnStatement */: + case 236 /* ThrowStatement */: + case 230 /* ContinueStatement */: + case 231 /* BreakStatement */: + return parent.kind !== 220 /* Block */; default: return false; } @@ -114233,7 +115865,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 === 189 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 190 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -114398,7 +116030,7 @@ var ts; } } else { - endNode = node.kind !== 238 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 239 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; @@ -114430,7 +116062,7 @@ var ts; ChangeTracker.prototype.insertNodeAtConstructorStart = function (sourceFile, ctr, newStatement) { var firstStatement = ts.firstOrUndefined(ctr.body.statements); if (!firstStatement || !ctr.body.multiLine) { - this.replaceConstructorBody(sourceFile, ctr, [newStatement].concat(ctr.body.statements)); + this.replaceConstructorBody(sourceFile, ctr, __spreadArrays([newStatement], ctr.body.statements)); } else { this.insertNodeBefore(sourceFile, firstStatement, newStatement); @@ -114439,7 +116071,7 @@ var ts; ChangeTracker.prototype.insertNodeAtConstructorEnd = function (sourceFile, ctr, newStatement) { var lastStatement = ts.lastOrUndefined(ctr.body.statements); if (!lastStatement || !ctr.body.multiLine) { - this.replaceConstructorBody(sourceFile, ctr, ctr.body.statements.concat([newStatement])); + this.replaceConstructorBody(sourceFile, ctr, __spreadArrays(ctr.body.statements, [newStatement])); } else { this.insertNodeAfter(sourceFile, lastStatement, newStatement); @@ -114472,7 +116104,7 @@ var ts; if (getMembersOrProperties(cls).length === 0) { if (ts.addToSeen(this.classesWithNodesInsertedAtStart, ts.getNodeId(cls), { node: cls, sourceFile: sourceFile })) { // For `class C {\n}`, don't add the trailing "\n" - var shouldSuffix = ts.positionsAreOnSameLine.apply(void 0, getClassOrObjectBraceEnds(cls, sourceFile).concat([sourceFile])); // TODO: GH#4130 remove 'as any' + var shouldSuffix = ts.positionsAreOnSameLine.apply(void 0, __spreadArrays(getClassOrObjectBraceEnds(cls, sourceFile), [sourceFile])); // TODO: GH#4130 remove 'as any' return { prefix: this.newLineCharacter, suffix: comma + (shouldSuffix ? this.newLineCharacter : "") }; } else { @@ -114511,22 +116143,22 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptions = function (sourceFile, after) { var options = this.getInsertNodeAfterOptionsWorker(after); - return __assign({}, options, { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); + return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 246 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: case 10 /* StringLiteral */: case 73 /* Identifier */: return { prefix: ", " }; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; case 86 /* ExportKeyword */: return { prefix: " " }; - case 152 /* Parameter */: + case 153 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -114535,7 +116167,7 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 198 /* ArrowFunction */) { + if (node.kind === 199 /* ArrowFunction */) { var arrow = ts.findChildOfKind(node, 37 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { @@ -114549,14 +116181,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 219 /* Block */) { + if (node.body.kind !== 220 /* Block */) { // `() => 0` => `function f() { return 0; }` this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(98 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(26 /* SemicolonToken */), ts.createToken(19 /* CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 197 /* FunctionExpression */ ? 91 /* FunctionKeyword */ : 77 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 198 /* FunctionExpression */ ? 91 /* FunctionKeyword */ : 77 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -114829,7 +116461,7 @@ var ts; var omitTrailingSemicolon = !!sourceFile && !ts.probablyUsesSemicolons(sourceFile); var writer = createWriter(newLineCharacter, omitTrailingSemicolon); var newLine = newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; - ts.createPrinter({ newLine: newLine, neverAsciiEscape: true, omitTrailingSemicolon: omitTrailingSemicolon }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + ts.createPrinter({ newLine: newLine, neverAsciiEscape: true }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -115081,14 +116713,14 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 150 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 151 /* 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 152 /* Parameter */: { + case 153 /* Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && @@ -115103,14 +116735,14 @@ var ts; } break; } - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: deleteNode(changes, sourceFile, node, // For first import, leave header comment in place node === sourceFile.imports[0].parent ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined); break; - case 187 /* BindingElement */: + case 188 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 186 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 187 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -115118,13 +116750,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -115133,7 +116765,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; default: @@ -115180,13 +116812,13 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 250 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 251 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 275 /* CatchClause */) { + if (parent.kind === 276 /* 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; @@ -115197,14 +116829,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 228 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); break; - case 226 /* ForStatement */: + case 227 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: deleteNode(changes, sourceFile, gp); break; default: @@ -115365,7 +116997,7 @@ var ts; }); function makeChange(changeTracker, sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); })); + var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); }), "Expected to find an assertion expression"); var replacement = ts.isAsExpression(assertion) ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(144 /* UnknownKeyword */)) : ts.createTypeAssertion(ts.createKeywordTypeNode(144 /* UnknownKeyword */), assertion.expression); @@ -115384,7 +117016,7 @@ var ts; ts.Diagnostics.This_expression_is_not_callable.code, ts.Diagnostics.This_expression_is_not_constructable.code, ]; - var errorCodes = [ + var errorCodes = __spreadArrays([ ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type.code, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type.code, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type.code, @@ -115400,13 +117032,13 @@ var ts; ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator.code, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code, propertyAccessCode - ].concat(callableConstructableErrorCodes); + ], callableConstructableErrorCodes); codefix.registerCodeFix({ fixIds: [fixId], errorCodes: errorCodes, getCodeActions: function (context) { var sourceFile = context.sourceFile, errorCode = context.errorCode, span = context.span, cancellationToken = context.cancellationToken, program = context.program; - var expression = getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program); if (!expression) { return; } @@ -115420,27 +117052,38 @@ var ts; getAllCodeActions: function (context) { var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; var checker = context.program.getTypeChecker(); + var fixedDeclarations = ts.createMap(); return codefix.codeFixAll(context, errorCodes, function (t, diagnostic) { - var expression = getAwaitableExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); if (!expression) { return; } var trackChanges = function (cb) { return (cb(t), []); }; - return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges) - || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges); + return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations) + || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations); }); }, }); - function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges) { - var sourceFile = context.sourceFile; - var awaitableInitializer = findAwaitableInitializer(expression, sourceFile, checker); - if (awaitableInitializer) { - var initializerChanges = trackChanges(function (t) { return makeChange(t, errorCode, sourceFile, checker, awaitableInitializer); }); - return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, [ts.Diagnostics.Add_await_to_initializer_for_0, expression.getText(sourceFile)]); + function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; + var awaitableInitializers = findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker); + if (awaitableInitializers) { + var initializerChanges = trackChanges(function (t) { + ts.forEach(awaitableInitializers.initializers, function (_a) { + var expression = _a.expression; + return makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + }); + if (fixedDeclarations && awaitableInitializers.needsSecondPassForFixAll) { + makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + } + }); + return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, awaitableInitializers.initializers.length === 1 + ? [ts.Diagnostics.Add_await_to_initializer_for_0, awaitableInitializers.initializers[0].declarationSymbol.name] + : ts.Diagnostics.Add_await_to_initializers); } } - function getUseSiteFix(context, expression, errorCode, checker, trackChanges) { - var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression); }); + function getUseSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression, fixedDeclarations); }); return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_await, fixId, ts.Diagnostics.Fix_all_expressions_possibly_missing_await); } function isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) { @@ -115454,7 +117097,7 @@ var ts; ts.some(relatedInformation, function (related) { return related.code === ts.Diagnostics.Did_you_forget_to_use_await.code; }); }); } - function getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program) { + function getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program) { var token = ts.getTokenAtPosition(sourceFile, span.start); // Checker has already done work to determine that await might be possible, and has attached // related info to the node, so start by finding the expression that exactly matches up @@ -115467,64 +117110,146 @@ var ts; }); return expression && isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) - && isInsideAwaitableBody(expression) - ? expression - : undefined; + && isInsideAwaitableBody(expression) ? expression : undefined; } - function findAwaitableInitializer(expression, sourceFile, checker) { - if (!ts.isIdentifier(expression)) { + function findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker) { + var identifiers = getIdentifiersFromErrorSpanExpression(expression, checker); + if (!identifiers) { return; } - var symbol = checker.getSymbolAtLocation(expression); - if (!symbol) { - return; + var isCompleteFix = identifiers.isCompleteFix; + var initializers; + var _loop_11 = 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, 221 /* VariableStatement */); + if (!declaration || !variableStatement || + declaration.type || + !declaration.initializer || + variableStatement.getSourceFile() !== sourceFile || + ts.hasModifier(variableStatement, 1 /* Export */) || + !variableName || + !isInsideAwaitableBody(declaration.initializer)) { + isCompleteFix = false; + return "continue"; + } + var diagnostics = program.getSemanticDiagnostics(sourceFile, cancellationToken); + var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (reference) { + return identifier !== reference && !symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker); + }); + if (isUsedElsewhere) { + isCompleteFix = false; + return "continue"; + } + (initializers || (initializers = [])).push({ + expression: declaration.initializer, + declarationSymbol: symbol, + }); + }; + for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { + var identifier = _a[_i]; + _loop_11(identifier); } - var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); - var variableName = ts.tryCast(declaration && declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 220 /* VariableStatement */); - if (!declaration || !variableStatement || - declaration.type || - !declaration.initializer || - variableStatement.getSourceFile() !== sourceFile || - ts.hasModifier(variableStatement, 1 /* Export */) || - !variableName || - !isInsideAwaitableBody(declaration.initializer)) { - return; + return initializers && { + initializers: initializers, + needsSecondPassForFixAll: !isCompleteFix, + }; + } + function getIdentifiersFromErrorSpanExpression(expression, checker) { + if (ts.isPropertyAccessExpression(expression.parent) && ts.isIdentifier(expression.parent.expression)) { + return { identifiers: [expression.parent.expression], isCompleteFix: true }; + } + if (ts.isIdentifier(expression)) { + return { identifiers: [expression], isCompleteFix: true }; + } + if (ts.isBinaryExpression(expression)) { + var sides = void 0; + var isCompleteFix = true; + for (var _i = 0, _a = [expression.left, expression.right]; _i < _a.length; _i++) { + var side = _a[_i]; + var type = checker.getTypeAtLocation(side); + if (checker.getPromisedTypeOfPromise(type)) { + if (!ts.isIdentifier(side)) { + isCompleteFix = false; + continue; + } + (sides || (sides = [])).push(side); + } + } + return sides && { identifiers: sides, isCompleteFix: isCompleteFix }; } - var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (identifier) { - return identifier !== expression; + } + function symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker) { + var errorNode = ts.isPropertyAccessExpression(reference.parent) ? reference.parent.name : + ts.isBinaryExpression(reference.parent) ? reference.parent : + reference; + var diagnostic = ts.find(diagnostics, function (diagnostic) { + return diagnostic.start === errorNode.getStart(sourceFile) && + diagnostic.start + diagnostic.length === errorNode.getEnd(); }); - if (isUsedElsewhere) { - return; - } - return declaration.initializer; + return diagnostic && ts.contains(errorCodes, diagnostic.code) || + // A Promise is usually not correct in a binary expression (it’s not valid + // in an arithmetic expression and an equality comparison seems unusual), + // but if the other side of the binary expression has an error, the side + // is typed `any` which will squash the error that would identify this + // Promise as an invalid operand. So if the whole binary expression is + // typed `any` as a result, there is a strong likelihood that this Promise + // is accidentally missing `await`. + checker.getTypeAtLocation(errorNode).flags & 1 /* Any */; } function isInsideAwaitableBody(node) { return node.kind & 16384 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 240 /* FunctionDeclaration */ || - ancestor.parent.kind === 197 /* FunctionExpression */ || - ancestor.parent.kind === 198 /* ArrowFunction */ || - ancestor.parent.kind === 157 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 241 /* FunctionDeclaration */ || + ancestor.parent.kind === 198 /* FunctionExpression */ || + ancestor.parent.kind === 199 /* ArrowFunction */ || + ancestor.parent.kind === 158 /* MethodDeclaration */); }); } - function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite) { + function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { if (ts.isBinaryExpression(insertionSite)) { - var left = insertionSite.left, right = insertionSite.right; - var leftType = checker.getTypeAtLocation(left); - var rightType = checker.getTypeAtLocation(right); - var newLeft = checker.getPromisedTypeOfPromise(leftType) ? ts.createAwait(left) : left; - var newRight = checker.getPromisedTypeOfPromise(rightType) ? ts.createAwait(right) : right; - changeTracker.replaceNode(sourceFile, left, newLeft); - changeTracker.replaceNode(sourceFile, right, newRight); + for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) { + var side = _a[_i]; + if (fixedDeclarations && ts.isIdentifier(side)) { + var symbol = checker.getSymbolAtLocation(side); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + continue; + } + } + var type = checker.getTypeAtLocation(side); + var newNode = checker.getPromisedTypeOfPromise(type) ? ts.createAwait(side) : side; + changeTracker.replaceNode(sourceFile, side, newNode); + } } else if (errorCode === propertyAccessCode && ts.isPropertyAccessExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite.parent.expression)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.expression); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite.parent.expression, ts.createParen(ts.createAwait(insertionSite.parent.expression))); } else if (ts.contains(callableConstructableErrorCodes, errorCode) && ts.isCallOrNewExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite)) { + var symbol = checker.getSymbolAtLocation(insertionSite); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createParen(ts.createAwait(insertionSite))); } else { + if (fixedDeclarations && ts.isVariableDeclaration(insertionSite.parent) && ts.isIdentifier(insertionSite.parent.name)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.name); + if (symbol && !ts.addToSeen(fixedDeclarations, ts.getSymbolId(symbol))) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createAwait(insertionSite)); } } @@ -115593,10 +117318,10 @@ var ts; function isPossiblyPartOfDestructuring(node) { switch (node.kind) { case 73 /* Identifier */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return true; default: return false; @@ -115611,7 +117336,7 @@ var ts; function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { case 73 /* Identifier */: - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: case 27 /* CommaToken */: return true; default: @@ -115752,33 +117477,33 @@ var ts; } } else { - var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl)); // If not defined, shouldn't have been an error to fix - ts.Debug.assert(!decl.type); // If defined, shouldn't have been an error to fix. + var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl), "A JSDocType for this declaration should exist"); // If not defined, shouldn't have been an error to fix + ts.Debug.assert(!decl.type, "The JSDocType decl should have a type"); // If defined, shouldn't have been an error to fix. changes.tryInsertTypeAnnotation(sourceFile, decl, transformJSDocType(jsdocType)); } } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 238 /* VariableDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 239 /* VariableDeclaration */ || + node.kind === 155 /* PropertySignature */ || + node.kind === 156 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 291 /* JSDocAllType */: + case 292 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 294 /* JSDocOptionalType */: + case 295 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 293 /* JSDocNonNullableType */: + case 294 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 292 /* JSDocNullableType */: + case 293 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 296 /* JSDocVariadicType */: + case 297 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); // TODO: GH#18217 @@ -115800,7 +117525,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 296 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 297 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); var dotdotdot = isRest ? ts.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -116032,13 +117757,8 @@ var ts; if (!ts.isIdentifier(parameterDeclaration.name)) { return; } - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - var parameterInferences = InferFromReference.inferTypeForParametersFromReferences(references, containingFunction, program, cancellationToken) || - containingFunction.parameters.map(function (p) { return ({ - declaration: p, - type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() - }); }); - ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length); + var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken); + ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length, "Parameter count and inference count should match"); if (ts.isInJSFile(containingFunction)) { annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } @@ -116057,14 +117777,11 @@ var ts; } } function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - if (!references) { - return; - } - var thisInference = InferFromReference.inferTypeForThisFromReferences(references, program, cancellationToken); - if (!thisInference) { + var references = getFunctionReferences(containingFunction, sourceFile, program, cancellationToken); + if (!references || !references.length) { return; } + var thisInference = inferTypeFromReferences(program, references, cancellationToken).thisParameter(); var typeNode = ts.getTypeNodeIfAccessible(thisInference, containingFunction, program, host); if (!typeNode) { return; @@ -116099,7 +117816,7 @@ var ts; function annotate(changes, sourceFile, declaration, type, program, host) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 154 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 155 /* PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -116139,14 +117856,14 @@ var ts; oldTags[i] = merged; return !!merged; }); }); - var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray((oldTags || ts.emptyArray).concat(unmergedNewTags))); - var jsDocNode = parent.kind === 198 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; + var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray(__spreadArrays((oldTags || ts.emptyArray), unmergedNewTags))); + var jsDocNode = parent.kind === 199 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; jsDocNode.jsDoc = parent.jsDoc; jsDocNode.jsDocCache = parent.jsDocCache; changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag); } function getJsDocNodeForArrowFunction(signature) { - if (signature.parent.kind === 155 /* PropertyDeclaration */) { + if (signature.parent.kind === 156 /* PropertyDeclaration */) { return signature.parent; } return signature.parent.parent; @@ -116156,14 +117873,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 306 /* JSDocParameterTag */: { + case 308 /* JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.createJSDocParamTag(newParam.name, newParam.isBracketed, newParam.typeExpression, oldParam.comment) : undefined; } - case 307 /* JSDocReturnTag */: + case 309 /* JSDocReturnTag */: return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); } } @@ -116175,25 +117892,31 @@ var ts; } function inferTypeForVariableFromUsage(token, program, cancellationToken) { var references = getReferences(token, program, cancellationToken); - var checker = program.getTypeChecker(); - var types = InferFromReference.inferTypesFromReferences(references, checker, cancellationToken); - return InferFromReference.unifyFromContext(types, checker); + return inferTypeFromReferences(program, references, cancellationToken).single(); } - function inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken) { + function inferTypeForParametersFromUsage(func, sourceFile, program, cancellationToken) { + var references = getFunctionReferences(func, sourceFile, program, cancellationToken); + return references && inferTypeFromReferences(program, references, cancellationToken).parameters(func) || + func.parameters.map(function (p) { return ({ + declaration: p, + type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() + }); }); + } + function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: searchToken = ts.findChildOfKind(containingFunction, 125 /* ConstructorKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 198 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: searchToken = containingFunction.name; break; } @@ -116202,54 +117925,51 @@ var ts; } return getReferences(searchToken, program, cancellationToken); } - var InferFromReference; - (function (InferFromReference) { - function inferTypesFromReferences(references, checker, cancellationToken) { - var usageContext = {}; - for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { - var reference = references_2[_i]; - cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); - } - return inferFromContext(usageContext, checker); + function inferTypeFromReferences(program, references, cancellationToken) { + var checker = program.getTypeChecker(); + return { + single: single, + parameters: parameters, + thisParameter: thisParameter, + }; + function single() { + return unifyFromUsage(inferTypesFromReferencesSingle(references)); } - InferFromReference.inferTypesFromReferences = inferTypesFromReferences; - function inferTypeForParametersFromReferences(references, declaration, program, cancellationToken) { - if (references === undefined || references.length === 0 || !declaration.parameters) { + function parameters(declaration) { + if (references.length === 0 || !declaration.parameters) { return undefined; } - var checker = program.getTypeChecker(); - var usageContext = {}; - for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { - var reference = references_3[_i]; + var usage = {}; + for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { + var reference = references_2[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - var callContexts = (usageContext.constructContexts || []).concat(usageContext.callContexts || []); + var calls = __spreadArrays(usage.constructs || [], usage.calls || []); return declaration.parameters.map(function (parameter, parameterIndex) { var types = []; var isRest = ts.isRestParameter(parameter); var isOptional = false; - for (var _i = 0, callContexts_1 = callContexts; _i < callContexts_1.length; _i++) { - var callContext = callContexts_1[_i]; - if (callContext.argumentTypes.length <= parameterIndex) { + for (var _i = 0, calls_1 = calls; _i < calls_1.length; _i++) { + var call = calls_1[_i]; + if (call.argumentTypes.length <= parameterIndex) { isOptional = ts.isInJSFile(declaration); types.push(checker.getUndefinedType()); } else if (isRest) { - for (var i = parameterIndex; i < callContext.argumentTypes.length; i++) { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + for (var i = parameterIndex; i < call.argumentTypes.length; i++) { + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[i])); } } else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex])); } } if (ts.isIdentifier(parameter.name)) { - var inferred = inferTypesFromReferences(getReferences(parameter.name, program, cancellationToken), checker, cancellationToken); + var inferred = inferTypesFromReferencesSingle(getReferences(parameter.name, program, cancellationToken)); types.push.apply(types, (isRest ? ts.mapDefined(inferred, checker.getElementTypeOfArrayType) : inferred)); } - var type = unifyFromContext(types, checker); + var type = unifyFromUsage(types); return { type: isRest ? checker.createArrayType(type) : type, isOptional: isOptional && !isRest, @@ -116257,112 +117977,119 @@ var ts; }; }); } - InferFromReference.inferTypeForParametersFromReferences = inferTypeForParametersFromReferences; - function inferTypeForThisFromReferences(references, program, cancellationToken) { - if (references.length === 0) { - return undefined; + function thisParameter() { + var usage = {}; + for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { + var reference = references_3[_i]; + cancellationToken.throwIfCancellationRequested(); + calculateUsageOfNode(reference, usage); } - var checker = program.getTypeChecker(); - var usageContext = {}; + return unifyFromUsage(usage.candidateThisTypes || ts.emptyArray); + } + function inferTypesFromReferencesSingle(references) { + var usage = {}; for (var _i = 0, references_4 = references; _i < references_4.length; _i++) { var reference = references_4[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - return unifyFromContext(usageContext.candidateThisTypes || ts.emptyArray, checker); + return inferFromUsage(usage); } - InferFromReference.inferTypeForThisFromReferences = inferTypeForThisFromReferences; - function inferTypeFromContext(node, checker, usageContext) { + function calculateUsageOfNode(node, usage) { while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } switch (node.parent.kind) { - case 204 /* PostfixUnaryExpression */: - usageContext.isNumber = true; + case 205 /* PostfixUnaryExpression */: + usage.isNumber = true; break; - case 203 /* PrefixUnaryExpression */: - inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); + case 204 /* PrefixUnaryExpression */: + inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 205 /* BinaryExpression */: - inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); + case 206 /* BinaryExpression */: + inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); + case 273 /* CaseClause */: + case 274 /* DefaultClause */: + inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: if (node.parent.expression === node) { - inferTypeFromCallExpressionContext(node.parent, checker, usageContext); + inferTypeFromCallExpression(node.parent, usage); } else { - inferTypeFromContextualType(node, checker, usageContext); + inferTypeFromContextualType(node, usage); } break; - case 190 /* PropertyAccessExpression */: - inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); + case 191 /* PropertyAccessExpression */: + inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 191 /* ElementAccessExpression */: - inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); + case 192 /* ElementAccessExpression */: + inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - inferTypeFromPropertyAssignment(node.parent, checker, usageContext); + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: + inferTypeFromPropertyAssignment(node.parent, usage); break; - case 155 /* PropertyDeclaration */: - inferTypeFromPropertyDeclaration(node.parent, checker, usageContext); + case 156 /* PropertyDeclaration */: + inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 238 /* VariableDeclaration */: { + case 239 /* 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. - addCandidateType(usageContext, checker.getTypeAtLocation(initializer)); + addCandidateType(usage, checker.getTypeAtLocation(initializer)); } break; } } // falls through default: - return inferTypeFromContextualType(node, checker, usageContext); + return inferTypeFromContextualType(node, usage); } } - function inferTypeFromContextualType(node, checker, usageContext) { + function inferTypeFromContextualType(node, usage) { if (ts.isExpressionNode(node)) { - addCandidateType(usageContext, checker.getContextualType(node)); + addCandidateType(usage, checker.getContextualType(node)); } } - function inferTypeFromPrefixUnaryExpressionContext(node, usageContext) { + function inferTypeFromPrefixUnaryExpression(node, usage) { switch (node.operator) { case 44 /* PlusPlusToken */: case 45 /* MinusMinusToken */: case 39 /* MinusToken */: case 53 /* TildeToken */: - usageContext.isNumber = true; + usage.isNumber = true; break; case 38 /* PlusToken */: - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; break; // case SyntaxKind.ExclamationToken: // no inferences here; } } - function inferTypeFromBinaryExpressionContext(node, parent, checker, usageContext) { + function inferTypeFromBinaryExpression(node, parent, usage) { switch (parent.operatorToken.kind) { // ExponentiationOperator case 41 /* AsteriskAsteriskToken */: // MultiplicativeOperator + // falls through case 40 /* AsteriskToken */: case 42 /* SlashToken */: case 43 /* PercentToken */: // ShiftOperator + // falls through case 46 /* LessThanLessThanToken */: case 47 /* GreaterThanGreaterThanToken */: case 48 /* GreaterThanGreaterThanGreaterThanToken */: // BitwiseOperator + // falls through case 49 /* AmpersandToken */: case 50 /* BarToken */: case 51 /* CaretToken */: // CompoundAssignmentOperator + // falls through case 62 /* MinusEqualsToken */: case 64 /* AsteriskAsteriskEqualsToken */: case 63 /* AsteriskEqualsToken */: @@ -116375,34 +118102,36 @@ var ts; case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: case 68 /* GreaterThanGreaterThanEqualsToken */: // AdditiveOperator + // falls through case 39 /* MinusToken */: // RelationalOperator + // falls through case 28 /* LessThanToken */: case 31 /* LessThanEqualsToken */: case 30 /* GreaterThanToken */: case 32 /* GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (operandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, operandType); + addCandidateType(usage, operandType); } else { - usageContext.isNumber = true; + usage.isNumber = true; } break; case 61 /* PlusEqualsToken */: case 38 /* PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (otherOperandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, otherOperandType); + addCandidateType(usage, otherOperandType); } else if (otherOperandType.flags & 296 /* NumberLike */) { - usageContext.isNumber = true; + usage.isNumber = true; } else if (otherOperandType.flags & 132 /* StringLike */) { - usageContext.isString = true; + usage.isString = true; } else { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; } break; // AssignmentOperators @@ -116411,20 +118140,20 @@ var ts; case 35 /* EqualsEqualsEqualsToken */: case 36 /* ExclamationEqualsEqualsToken */: case 34 /* ExclamationEqualsToken */: - addCandidateType(usageContext, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); + addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; case 94 /* InKeyword */: if (node === parent.left) { - usageContext.isString = true; + usage.isString = true; } break; // LogicalOperator case 55 /* BarBarToken */: if (node === parent.left && - (node.parent.parent.kind === 238 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 239 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType - addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); + addCandidateType(usage, checker.getTypeAtLocation(parent.right)); } break; case 54 /* AmpersandAmpersandToken */: @@ -116434,65 +118163,62 @@ var ts; break; } } - function inferTypeFromSwitchStatementLabelContext(parent, checker, usageContext) { - addCandidateType(usageContext, checker.getTypeAtLocation(parent.parent.parent.expression)); + function inferTypeFromSwitchStatementLabel(parent, usage) { + addCandidateType(usage, checker.getTypeAtLocation(parent.parent.parent.expression)); } - function inferTypeFromCallExpressionContext(parent, checker, usageContext) { - var callContext = { + function inferTypeFromCallExpression(parent, usage) { + var call = { argumentTypes: [], returnType: {} }; if (parent.arguments) { for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { var argument = _a[_i]; - callContext.argumentTypes.push(checker.getTypeAtLocation(argument)); + call.argumentTypes.push(checker.getTypeAtLocation(argument)); } } - inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 192 /* CallExpression */) { - (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); + calculateUsageOfNode(parent, call.returnType); + if (parent.kind === 193 /* CallExpression */) { + (usage.calls || (usage.calls = [])).push(call); } else { - (usageContext.constructContexts || (usageContext.constructContexts = [])).push(callContext); + (usage.constructs || (usage.constructs = [])).push(call); } } - function inferTypeFromPropertyAccessExpressionContext(parent, checker, usageContext) { + function inferTypeFromPropertyAccessExpression(parent, usage) { var name = ts.escapeLeadingUnderscores(parent.name.text); - if (!usageContext.properties) { - usageContext.properties = ts.createUnderscoreEscapedMap(); + if (!usage.properties) { + usage.properties = ts.createUnderscoreEscapedMap(); } - var propertyUsageContext = usageContext.properties.get(name) || {}; - inferTypeFromContext(parent, checker, propertyUsageContext); - usageContext.properties.set(name, propertyUsageContext); + var propertyUsage = usage.properties.get(name) || {}; + calculateUsageOfNode(parent, propertyUsage); + usage.properties.set(name, propertyUsage); } - function inferTypeFromPropertyElementExpressionContext(parent, node, checker, usageContext) { + function inferTypeFromPropertyElementExpression(parent, node, usage) { if (node === parent.argumentExpression) { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; return; } else { var indexType = checker.getTypeAtLocation(parent.argumentExpression); - var indexUsageContext = {}; - inferTypeFromContext(parent, checker, indexUsageContext); + var indexUsage = {}; + calculateUsageOfNode(parent, indexUsage); if (indexType.flags & 296 /* NumberLike */) { - usageContext.numberIndexContext = indexUsageContext; + usage.numberIndex = indexUsage; } else { - usageContext.stringIndexContext = indexUsageContext; + usage.stringIndex = indexUsage; } } } - function inferTypeFromPropertyAssignment(assignment, checker, usageContext) { - var objectLiteral = ts.isShorthandPropertyAssignment(assignment) ? - assignment.parent : - assignment.parent.parent; - var nodeWithRealType = ts.isVariableDeclaration(objectLiteral.parent) ? - objectLiteral.parent : - objectLiteral; - addCandidateThisType(usageContext, checker.getTypeAtLocation(nodeWithRealType)); + function inferTypeFromPropertyAssignment(assignment, usage) { + var nodeWithRealType = ts.isVariableDeclaration(assignment.parent.parent) ? + assignment.parent.parent : + assignment.parent; + addCandidateThisType(usage, checker.getTypeAtLocation(nodeWithRealType)); } - function inferTypeFromPropertyDeclaration(declaration, checker, usageContext) { - addCandidateThisType(usageContext, checker.getTypeAtLocation(declaration.parent)); + function inferTypeFromPropertyDeclaration(declaration, usage) { + addCandidateThisType(usage, checker.getTypeAtLocation(declaration.parent)); } function removeLowPriorityInferences(inferences, priorities) { var toRemove = []; @@ -116501,14 +118227,14 @@ var ts; for (var _a = 0, priorities_1 = priorities; _a < priorities_1.length; _a++) { var _b = priorities_1[_a], high = _b.high, low = _b.low; if (high(i)) { - ts.Debug.assert(!low(i)); + ts.Debug.assert(!low(i), "Priority can't have both low and high"); toRemove.push(low); } } } return inferences.filter(function (i) { return toRemove.every(function (f) { return !f(i); }); }); } - function unifyFromContext(inferences, checker, fallback) { + function unifyFromUsage(inferences, fallback) { if (fallback === void 0) { fallback = checker.getAnyType(); } if (!inferences.length) return fallback; @@ -116534,12 +118260,11 @@ var ts; var anons = good.filter(function (i) { return checker.getObjectFlags(i) & 16 /* Anonymous */; }); if (anons.length) { good = good.filter(function (i) { return !(checker.getObjectFlags(i) & 16 /* Anonymous */); }); - good.push(unifyAnonymousTypes(anons, checker)); + good.push(unifyAnonymousTypes(anons)); } return checker.getWidenedType(checker.getUnionType(good)); } - InferFromReference.unifyFromContext = unifyFromContext; - function unifyAnonymousTypes(anons, checker) { + function unifyAnonymousTypes(anons) { if (anons.length === 1) { return anons[0]; } @@ -116575,74 +118300,74 @@ var ts; }); return checker.createAnonymousType(anons[0].symbol, members, calls, constructs, stringIndices.length ? checker.createIndexInfo(checker.getUnionType(stringIndices), stringIndexReadonly) : undefined, numberIndices.length ? checker.createIndexInfo(checker.getUnionType(numberIndices), numberIndexReadonly) : undefined); } - function inferFromContext(usageContext, checker) { + function inferFromUsage(usage) { var types = []; - if (usageContext.isNumber) { + if (usage.isNumber) { types.push(checker.getNumberType()); } - if (usageContext.isString) { + if (usage.isString) { types.push(checker.getStringType()); } - if (usageContext.isNumberOrString) { + if (usage.isNumberOrString) { types.push(checker.getUnionType([checker.getStringType(), checker.getNumberType()])); } - types.push.apply(types, (usageContext.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); - if (usageContext.properties && hasCallContext(usageContext.properties.get("then"))) { - var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); // TODO: GH#18217 - var types_1 = paramType.getCallSignatures().map(function (c) { return c.getReturnType(); }); + types.push.apply(types, (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); + if (usage.properties && hasCalls(usage.properties.get("then"))) { + var paramType = getParameterTypeFromCalls(0, usage.properties.get("then").calls, /*isRestParameter*/ false); // TODO: GH#18217 + var types_1 = paramType.getCallSignatures().map(function (sig) { return sig.getReturnType(); }); types_1.push(checker.createPromiseType(types_1.length ? checker.getUnionType(types_1, 2 /* Subtype */) : checker.getAnyType())); } - else if (usageContext.properties && hasCallContext(usageContext.properties.get("push"))) { - types.push(checker.createArrayType(getParameterTypeFromCallContexts(0, usageContext.properties.get("push").callContexts, /*isRestParameter*/ false, checker))); + else if (usage.properties && hasCalls(usage.properties.get("push"))) { + types.push(checker.createArrayType(getParameterTypeFromCalls(0, usage.properties.get("push").calls, /*isRestParameter*/ false))); } - if (usageContext.numberIndexContext) { - types.push(checker.createArrayType(recur(usageContext.numberIndexContext))); + if (usage.numberIndex) { + types.push(checker.createArrayType(recur(usage.numberIndex))); } - else if (usageContext.properties || usageContext.callContexts || usageContext.constructContexts || usageContext.stringIndexContext) { + else if (usage.properties || usage.calls || usage.constructs || usage.stringIndex) { var members_1 = ts.createUnderscoreEscapedMap(); var callSignatures = []; var constructSignatures = []; var stringIndexInfo = void 0; - if (usageContext.properties) { - usageContext.properties.forEach(function (context, name) { + if (usage.properties) { + usage.properties.forEach(function (u, name) { var symbol = checker.createSymbol(4 /* Property */, name); - symbol.type = recur(context); + symbol.type = recur(u); members_1.set(name, symbol); }); } - if (usageContext.callContexts) { - for (var _i = 0, _a = usageContext.callContexts; _i < _a.length; _i++) { - var callContext = _a[_i]; - callSignatures.push(getSignatureFromCallContext(callContext, checker)); + if (usage.calls) { + for (var _i = 0, _a = usage.calls; _i < _a.length; _i++) { + var call = _a[_i]; + callSignatures.push(getSignatureFromCall(call)); } } - if (usageContext.constructContexts) { - for (var _b = 0, _c = usageContext.constructContexts; _b < _c.length; _b++) { - var constructContext = _c[_b]; - constructSignatures.push(getSignatureFromCallContext(constructContext, checker)); + if (usage.constructs) { + for (var _b = 0, _c = usage.constructs; _b < _c.length; _b++) { + var construct = _c[_b]; + constructSignatures.push(getSignatureFromCall(construct)); } } - if (usageContext.stringIndexContext) { - stringIndexInfo = checker.createIndexInfo(recur(usageContext.stringIndexContext), /*isReadonly*/ false); + if (usage.stringIndex) { + stringIndexInfo = checker.createIndexInfo(recur(usage.stringIndex), /*isReadonly*/ false); } types.push(checker.createAnonymousType(/*symbol*/ undefined, members_1, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined)); // TODO: GH#18217 } return types; - function recur(innerContext) { - return unifyFromContext(inferFromContext(innerContext, checker), checker); + function recur(innerUsage) { + return unifyFromUsage(inferFromUsage(innerUsage)); } } - function getParameterTypeFromCallContexts(parameterIndex, callContexts, isRestParameter, checker) { + function getParameterTypeFromCalls(parameterIndex, calls, isRestParameter) { var types = []; - if (callContexts) { - for (var _i = 0, callContexts_2 = callContexts; _i < callContexts_2.length; _i++) { - var callContext = callContexts_2[_i]; - if (callContext.argumentTypes.length > parameterIndex) { + if (calls) { + for (var _i = 0, calls_2 = calls; _i < calls_2.length; _i++) { + var call = calls_2[_i]; + if (call.argumentTypes.length > parameterIndex) { if (isRestParameter) { - types = ts.concatenate(types, ts.map(callContext.argumentTypes.slice(parameterIndex), function (a) { return checker.getBaseTypeOfLiteralType(a); })); + types = ts.concatenate(types, ts.map(call.argumentTypes.slice(parameterIndex), function (a) { return checker.getBaseTypeOfLiteralType(a); })); } else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex])); } } } @@ -116653,31 +118378,31 @@ var ts; } return undefined; } - function getSignatureFromCallContext(callContext, checker) { + function getSignatureFromCall(call) { var parameters = []; - for (var i = 0; i < callContext.argumentTypes.length; i++) { + for (var i = 0; i < call.argumentTypes.length; i++) { var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); - symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(call.argumentTypes[i])); parameters.push(symbol); } - var returnType = unifyFromContext(inferFromContext(callContext.returnType, checker), checker, checker.getVoidType()); + var returnType = unifyFromUsage(inferFromUsage(call.returnType), checker.getVoidType()); // TODO: GH#18217 - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, call.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); } - function addCandidateType(context, type) { + function addCandidateType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateTypes || (context.candidateTypes = [])).push(type); + (usage.candidateTypes || (usage.candidateTypes = [])).push(type); } } - function addCandidateThisType(context, type) { + function addCandidateThisType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateThisTypes || (context.candidateThisTypes = [])).push(type); + (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); } } - function hasCallContext(usageContext) { - return !!usageContext && !!usageContext.callContexts; + function hasCalls(usage) { + return !!usage && !!usage.calls; } - })(InferFromReference || (InferFromReference = {})); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -116706,12 +118431,12 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: precedingNode = ctorDeclaration; changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { @@ -116766,7 +118491,7 @@ var ts; return; } // 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 === 222 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 223 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { @@ -116774,7 +118499,7 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 197 /* FunctionExpression */: { + case 198 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 122 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, @@ -116782,12 +118507,12 @@ var ts; ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 198 /* ArrowFunction */: { + case 199 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 219 /* Block */) { + if (arrowFunctionBody.kind === 220 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] @@ -116815,7 +118540,7 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 197 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 198 /* FunctionExpression */) { return undefined; } if (node.name.kind !== 73 /* Identifier */) { @@ -116904,7 +118629,7 @@ var ts; var newNodes = transformExpression(node, transformer, node); changes.replaceNodeWithNodes(sourceFile, nodeToReplace, newNodes); } - var _loop_11 = function (statement) { + var _loop_12 = function (statement) { ts.forEachChild(statement, function visit(node) { if (ts.isCallExpression(node)) { startTransformation(node, statement); @@ -116916,7 +118641,7 @@ var ts; }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var statement = returnStatements_1[_i]; - _loop_11(statement); + _loop_12(statement); } } function getReturnStatementsWithPromiseHandlers(body) { @@ -117235,8 +118960,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: { var funcBody = func.body; // Arrow functions with block bodies { } will enter this control flow if (ts.isBlock(funcBody)) { @@ -117348,6 +119073,7 @@ var ts; name = getMapEntryOrDefault(funcNode); } // return undefined argName when arg is null or undefined + // eslint-disable-next-line no-in-operator if (!name || "identifier" in name && name.identifier.text === "undefined") { return undefined; } @@ -117439,10 +119165,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -117468,7 +119194,7 @@ var ts; forEachExportReference(sourceFile, function (node) { var _a = node.name, text = _a.text, originalKeywordKind = _a.originalKeywordKind; if (!res.has(text) && (originalKeywordKind !== undefined && ts.isNonContextualKeyword(originalKeywordKind) - || checker.resolveName(node.name.text, node, 67220415 /* Value */, /*excludeGlobals*/ true))) { + || checker.resolveName(node.name.text, node, 111551 /* Value */, /*excludeGlobals*/ true))) { // Unconditionally add an underscore in case `text` is a keyword. res.set(text, makeUniqueName("_" + text, identifiers)); } @@ -117495,20 +119221,20 @@ var ts; } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 222 /* ExpressionStatement */: { + case 223 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 192 /* CallExpression */: { + case 193 /* 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 205 /* BinaryExpression */: { + case 206 /* BinaryExpression */: { var operatorToken = expression.operatorToken; return operatorToken.kind === 60 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } @@ -117550,8 +119276,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: { + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -117563,7 +119289,7 @@ var ts; // `const a = require("b").c` --> `import { c as a } from "./b"; return [makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]; default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid syntax form " + name.kind); } } function convertAssignment(sourceFile, checker, assignment, changes, exports) { @@ -117602,18 +119328,19 @@ var ts; function tryChangeModuleExportsObject(object) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 277 /* ShorthandPropertyAssignment */: - case 278 /* SpreadAssignment */: + // falls through + case 278 /* ShorthandPropertyAssignment */: + case 279 /* SpreadAssignment */: return undefined; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(86 /* ExportKeyword */)], prop); default: - ts.Debug.assertNever(prop); + ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); } }); return statements && [statements, false]; @@ -117642,12 +119369,10 @@ var ts; var moduleSpecifier = reExported.text; var moduleSymbol = checker.getSymbolAtLocation(reExported); var exports = moduleSymbol ? moduleSymbol.exports : ts.emptyUnderscoreEscapedMap; - return exports.has("export=") - ? [[reExportDefault(moduleSpecifier)], true] - : !exports.has("default") - ? [[reExportStar(moduleSpecifier)], false] + return exports.has("export=") ? [[reExportDefault(moduleSpecifier)], true] : + !exports.has("default") ? [[reExportStar(moduleSpecifier)], false] : // If there's some non-default export, must include both `export *` and `export default`. - : exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; + exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; } function reExportStar(moduleSpecifier) { return makeExportDeclaration(/*exportClause*/ undefined, moduleSpecifier); @@ -117676,7 +119401,7 @@ var ts; function convertExportsDotXEquals_replaceNode(name, exported) { var modifiers = [ts.createToken(86 /* ExportKeyword */)]; switch (exported.kind) { - case 197 /* FunctionExpression */: { + case 198 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -117684,10 +119409,10 @@ var ts; } } // falls through - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -117705,18 +119430,20 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: { + case 186 /* 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 + // (TODO: GH#18217) + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion : makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text); - }); // tslint:disable-line no-unnecessary-type-assertion (TODO: GH#18217) + }); if (importSpecifiers) { return [ts.makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, quotePreference)]; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 186 /* ArrayBindingPattern */: { + case 187 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -117730,7 +119457,7 @@ var ts; case 73 /* Identifier */: return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, quotePreference); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid name kind " + name.kind); } } /** @@ -117752,7 +119479,7 @@ var ts; var parent = use.parent; if (ts.isPropertyAccessExpression(parent)) { var expression = parent.expression, propertyName = parent.name.text; - ts.Debug.assert(expression === use); // Else shouldn't have been in `collectIdentifiers` + 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); @@ -117799,11 +119526,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return parent.name !== node; - case 187 /* BindingElement */: + case 188 /* BindingElement */: return parent.propertyName !== node; - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -117878,8 +119605,10 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var errorCodes = [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, - ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code]; + var errorCodes = [ + ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, + ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code + ]; var fixId = "fixClassIncorrectlyImplementsInterface"; // TODO: share a group with fixClassDoesntImplementInheritedAbstractMember? codefix.registerCodeFix({ errorCodes: errorCodes, @@ -117906,7 +119635,7 @@ var ts; }, }); function getClass(sourceFile, pos) { - return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos))); + return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); @@ -118004,7 +119733,7 @@ var ts; ts.pushIfUnique(entry.namedImports, symbolName); } else { - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add to Existing) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; } break; @@ -118017,7 +119746,7 @@ var ts; } switch (importKind) { case 1 /* Default */: - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add new) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; break; case 0 /* Named */: @@ -118025,14 +119754,14 @@ var ts; break; case 3 /* Equals */: case 2 /* Namespace */: - ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName); + ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); entry.namespaceLikeImport = { importKind: importKind, name: symbolName }; break; } break; } default: - ts.Debug.assertNever(fix); + ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); } }); return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { @@ -118069,10 +119798,11 @@ var ts; ImportKind[ImportKind["Default"] = 1] = "Default"; ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; ImportKind[ImportKind["Equals"] = 3] = "Equals"; + ImportKind[ImportKind["ConstEquals"] = 4] = "ConstEquals"; })(ImportKind || (ImportKind = {})); function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) { - var exportInfos = getAllReExportingModules(exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles()); - ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; })); + var exportInfos = getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles()); + 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 for completions. var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, position, exportInfos, host, preferences)).moduleSpecifier; var fix = ts.first(getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences)); @@ -118083,14 +119813,14 @@ var ts; var description = _a.description, changes = _a.changes, commands = _a.commands; return { description: description, changes: changes, commands: commands }; } - function getAllReExportingModules(exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, compilerOptions, checker, allSourceFiles) { + function getAllReExportingModules(importingFile, exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, compilerOptions, checker, allSourceFiles) { var result = []; forEachExternalModule(checker, allSourceFiles, function (moduleSymbol, moduleFile) { // Don't import from a re-export when looking "up" like to `./index` or `../index`. if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(sourceFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) { return; } - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + var defaultInfo = getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions); if (defaultInfo && defaultInfo.name === symbolName && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol) { result.push({ moduleSymbol: moduleSymbol, importKind: defaultInfo.kind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker) }); } @@ -118104,7 +119834,7 @@ var ts; return result; } function isTypeOnlySymbol(s, checker) { - return !(ts.skipAlias(s, checker).flags & 67220415 /* Value */); + return !(ts.skipAlias(s, checker).flags & 111551 /* Value */); } function getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences) { var checker = program.getTypeChecker(); @@ -118113,7 +119843,7 @@ var ts; var addToExisting = tryAddToExistingImport(existingImports); // Don't bother providing an action to add a new import if we can add to an existing one. var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences); - return (useNamespace ? [useNamespace] : ts.emptyArray).concat(addImport); + return __spreadArrays((useNamespace ? [useNamespace] : ts.emptyArray), addImport); } function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) { // It is possible that multiple import statements with the same specifier exist in the file. @@ -118142,21 +119872,21 @@ var ts; function tryAddToExistingImport(existingImports) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind !== 250 /* ImportDeclaration */) + if (declaration.kind !== 251 /* ImportDeclaration */) return undefined; var importClause = declaration.importClause; if (!importClause) return undefined; var name = importClause.name, namedBindings = importClause.namedBindings; - return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 253 /* NamedImports */) + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 254 /* NamedImports */) ? { kind: 2 /* AddToExisting */, importClause: importClause, importKind: importKind } : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 250 /* ImportDeclaration */) { + if (declaration.kind === 251 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 252 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 253 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -118167,7 +119897,7 @@ var ts; // Can't use an es6 import for a type in JS. return exportedSymbolIsTypeOnly && ts.isSourceFileJS(sourceFile) ? ts.emptyArray : ts.mapDefined(sourceFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 250 /* ImportDeclaration */ || i.kind === 249 /* ImportEqualsDeclaration */) + return (i.kind === 251 /* ImportDeclaration */ || i.kind === 250 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } @@ -118178,7 +119908,7 @@ var ts; return ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences, program.redirectTargetsMap) .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.assertDefined(position) } : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; + return exportedSymbolIsTypeOnly && isJs ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position, "position should be defined") } : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; }); }); // Sort to keep the shortest paths first @@ -118190,9 +119920,9 @@ var ts; } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 250 /* ImportDeclaration */ + var expression = declaration.kind === 251 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 260 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 261 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; return expression && ts.isStringLiteral(expression) ? { kind: 3 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; @@ -118202,7 +119932,7 @@ 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) : undefined; - return info && __assign({}, info, { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); + return info && __assign(__assign({}, info), { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); } function getFixesInfoForUMDImport(_a, token) { var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences; @@ -118212,7 +119942,7 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; + var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(sourceFile, program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; var fixes = getFixForImport(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, program, sourceFile, host, preferences); return { fixes: fixes, symbolName: symbolName }; } @@ -118224,10 +119954,10 @@ var ts; // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. var parent = token.parent; return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) - ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 67220415 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } - function getUmdImportKind(compilerOptions) { + function getUmdImportKind(importingFile, compilerOptions) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { return 1 /* Default */; @@ -118238,6 +119968,9 @@ var ts; case ts.ModuleKind.AMD: case ts.ModuleKind.CommonJS: case ts.ModuleKind.UMD: + if (ts.isInJSFile(importingFile)) { + return ts.isExternalModule(importingFile) ? 2 /* Namespace */ : 4 /* ConstEquals */; + } return 3 /* Equals */; case ts.ModuleKind.System: case ts.ModuleKind.ES2015: @@ -118246,7 +119979,7 @@ var ts; // Fall back to the `import * as ns` style import. return 2 /* Namespace */; default: - return ts.Debug.assertNever(moduleKind); + return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind); } } function getFixesInfoForNonUMDImport(_a, symbolToken) { @@ -118259,7 +119992,7 @@ var ts; ? checker.getJsxNamespace(sourceFile) : symbolToken.text; // "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 */); + ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here"); var fixes = ts.arrayFrom(ts.flatMapIterator(getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), program, sourceFile, host, preferences); @@ -118276,7 +120009,7 @@ var ts; } forEachExternalModuleToImportFrom(checker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { cancellationToken.throwIfCancellationRequested(); - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, program.getCompilerOptions()); + var defaultInfo = getDefaultLikeExportInfo(sourceFile, moduleSymbol, checker, program.getCompilerOptions()); if (defaultInfo && defaultInfo.name === symbolName && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { addSymbol(moduleSymbol, defaultInfo.symbol, defaultInfo.kind); } @@ -118288,20 +120021,41 @@ var ts; }); return originalSymbolToExportInfos; } - function getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions) { - var exported = getDefaultLikeExportWorker(moduleSymbol, checker); + function getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions) { + var exported = getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions); if (!exported) return undefined; var symbol = exported.symbol, kind = exported.kind; var info = getDefaultExportInfoWorker(symbol, moduleSymbol, checker, compilerOptions); return info && __assign({ symbol: symbol, kind: kind }, info); } - function getDefaultLikeExportWorker(moduleSymbol, checker) { + function getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions) { 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: 3 /* Equals */ }; + return exportEquals === moduleSymbol ? undefined : { symbol: exportEquals, kind: getExportEqualsImportKind(importingFile, compilerOptions, checker) }; + } + function getExportEqualsImportKind(importingFile, compilerOptions, checker) { + if (ts.getAllowSyntheticDefaultImports(compilerOptions) && ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { + return 1 /* Default */; + } + if (ts.isInJSFile(importingFile)) { + return ts.isExternalModule(importingFile) ? 1 /* Default */ : 4 /* ConstEquals */; + } + for (var _i = 0, _a = importingFile.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (ts.isImportEqualsDeclaration(statement)) { + return 3 /* Equals */; + } + if (ts.isImportDeclaration(statement) && statement.importClause && statement.importClause.name) { + var moduleSymbol = checker.getImmediateAliasedSymbol(statement.importClause.symbol); + if (moduleSymbol && moduleSymbol.name !== "default" /* Default */) { + return 1 /* Default */; + } + } + } + return 3 /* Equals */; } function getDefaultExportInfoWorker(defaultExport, moduleSymbol, checker, compilerOptions) { var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); @@ -118312,7 +120066,7 @@ var ts; return { symbolForMeaning: defaultExport, name: name }; if (defaultExport.flags & 2097152 /* Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); - return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent), checker, compilerOptions); + return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent, "Alias targets of default exports must have a parent"), checker, compilerOptions); } if (defaultExport.escapedName !== "default" /* Default */ && defaultExport.escapedName !== "export=" /* ExportEquals */) { @@ -118328,7 +120082,7 @@ var ts; } } else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.text === "default" /* Default */); + ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); return declaration.propertyName && declaration.propertyName.text; } }); @@ -118362,12 +120116,12 @@ var ts; return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; } default: - return ts.Debug.assertNever(fix); + return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind); } } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports) { if (defaultImport) { - ts.Debug.assert(!clause.name); + ts.Debug.assert(!clause.name, "Default imports can't have names"); changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), ts.createIdentifier(defaultImport), { suffix: ", " }); } if (namedImports.length) { @@ -118385,7 +120139,7 @@ var ts; changes.replaceNode(sourceFile, clause.namedBindings, namedImports_1); } else { - changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name), namedImports_1); + changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name, "Named import specifiers must have names"), namedImports_1); } } } @@ -118410,11 +120164,17 @@ var ts; ts.insertImport(changes, sourceFile, ts.makeImport(defaultImport === undefined ? undefined : ts.createIdentifier(defaultImport), namedImports.map(function (n) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(n)); }), moduleSpecifier, quotePreference)); } if (namespaceLikeImport) { - ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ - ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) - : ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); + ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) : + namespaceLikeImport.importKind === 4 /* ConstEquals */ ? createConstEqualsRequireDeclaration(namespaceLikeImport.name, quotedModuleSpecifier) : + ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); } } + function createConstEqualsRequireDeclaration(name, quotedModuleSpecifier) { + return ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.createIdentifier(name), + /*type*/ undefined, ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, [quotedModuleSpecifier])) + ], 2 /* Const */)); + } function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); @@ -118522,12 +120282,12 @@ var ts; var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 73 /* Identifier */); + ts.Debug.assert(node.kind === 73 /* Identifier */, "Expected an identifier for spelling (property access)"); var containingType = checker.getTypeAtLocation(node.parent.expression); suggestion = checker.getSuggestionForNonexistentProperty(node, containingType); } else if (ts.isImportSpecifier(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 73 /* Identifier */); + ts.Debug.assert(node.kind === 73 /* Identifier */, "Expected an identifier for spelling (import)"); var importDeclaration = ts.findAncestor(node, ts.isImportDeclaration); var resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration); if (resolvedSourceFile && resolvedSourceFile.symbol) { @@ -118556,10 +120316,10 @@ var ts; flags |= 1920 /* Namespace */; } if (meaning & 2 /* Type */) { - flags |= 67897832 /* Type */; + flags |= 788968 /* Type */; } if (meaning & 1 /* Value */) { - flags |= 67220415 /* Value */; + flags |= 111551 /* Value */; } return flags; } @@ -118630,7 +120390,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, classDeclaration) { var supers = getAllSupers(classDeclaration, checker); - var _loop_12 = function (info) { + var _loop_13 = function (info) { // If some superclass added this property, don't add it again. if (supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -118657,7 +120417,7 @@ var ts; }; for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { var info = infos_1[_i]; - _loop_12(info); + _loop_13(info); } }); })); @@ -118718,7 +120478,7 @@ var ts; } function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 210 /* ClassExpression */) { + if (classDeclaration.kind === 211 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -118744,7 +120504,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 205 /* BinaryExpression */) { + if (token.parent.parent.kind === 206 /* 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))); @@ -118807,7 +120567,7 @@ var ts; } function addMethodDeclaration(context, changeTracker, declSourceFile, typeDecl, token, callExpression, makeStatic, inJs, preferences) { var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences, typeDecl); - var containingMethodDeclaration = ts.getAncestor(callExpression, 157 /* MethodDeclaration */); + var containingMethodDeclaration = ts.getAncestor(callExpression, 158 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === typeDecl) { changeTracker.insertNodeAfter(declSourceFile, containingMethodDeclaration, methodDeclaration); } @@ -119054,7 +120814,7 @@ var ts; }); function getNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 125 /* ConstructorKeyword */); + ts.Debug.assert(token.kind === 125 /* ConstructorKeyword */, "token should be at the constructor keyword"); return token.parent; } function doChange(changes, sourceFile, ctr) { @@ -119098,6 +120858,43 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixID = "fixEnableJsxFlag"; + var errorCodes = [ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) { + return doChange(changeTracker, configFile); + }); + return [ + codefix.createCodeFixActionNoFixId(fixID, changes, ts.Diagnostics.Enable_the_jsx_flag_in_your_configuration_file) + ]; + }, + fixIds: [fixID], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + doChange(changes, configFile); + }); + } + }); + function doChange(changeTracker, configFile) { + codefix.setJsonCompilerOptionValue(changeTracker, configFile, "jsx", ts.createStringLiteral("react")); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -119307,7 +121104,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); } function deleteTypeParameters(changes, sourceFile, token) { - changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters)); + changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. function tryGetFullImport(token) { @@ -119317,7 +121114,7 @@ var ts; if (token.kind !== 18 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; var decl = token.parent.parent; - if (decl.kind === 152 /* Parameter */) { + if (decl.kind === 153 /* Parameter */) { tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); } else { @@ -119328,7 +121125,7 @@ var ts; function tryDeleteFullVariableStatement(sourceFile, token, changes) { var declarationList = ts.tryCast(token.parent, ts.isVariableDeclarationList); if (declarationList && declarationList.getChildren(sourceFile)[0] === token) { - changes.delete(sourceFile, declarationList.parent.kind === 220 /* VariableStatement */ ? declarationList.parent : declarationList); + changes.delete(sourceFile, declarationList.parent.kind === 221 /* VariableStatement */ ? declarationList.parent : declarationList); return true; } return false; @@ -119346,14 +121143,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 152 /* Parameter */: - case 151 /* TypeParameter */: + case 153 /* Parameter */: + case 152 /* TypeParameter */: return true; - case 238 /* VariableDeclaration */: { + case 239 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 228 /* ForInStatement */: return true; } } @@ -119400,26 +121197,26 @@ var ts; function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: // Don't remove a parameter if this overrides something. var symbol = checker.getSymbolAtLocation(parent.name); if (ts.isMemberSymbolInBaseType(symbol, checker)) return false; // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: + case 159 /* Constructor */: + case 241 /* FunctionDeclaration */: return true; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 198 /* FunctionExpression */: + case 199 /* 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. var parameters = parent.parameters; var index = parameters.indexOf(p); - ts.Debug.assert(index !== -1); + ts.Debug.assert(index !== -1, "The parameter should already be in the list"); return isFixAll ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 73 /* Identifier */ && !p.symbol.isReferenced; }) : index === parameters.length - 1; } - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -119455,11 +121252,11 @@ var ts; function doChange(changes, sourceFile, start, length) { var token = ts.getTokenAtPosition(sourceFile, start); var statement = ts.findAncestor(token, ts.isStatement); - ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); + ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile), "token and statement should start at the same point"); 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 223 /* IfStatement */: + case 224 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -119470,15 +121267,15 @@ var ts; return; } // falls through - case 225 /* WhileStatement */: - case 226 /* ForStatement */: + case 226 /* WhileStatement */: + case 227 /* ForStatement */: changes.delete(sourceFile, container); return; } } if (ts.isBlock(statement.parent)) { var end_3 = start + length; - var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; })); + var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; }), "Some statement should be last"); changes.deleteNodeRange(sourceFile, statement, lastStatement); } else { @@ -119544,7 +121341,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 === 292 /* JSDocNullableType */) { + if (typeNode.kind === 293 /* 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)); @@ -119564,7 +121361,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 292 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 293 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -119581,22 +121378,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 213 /* AsExpression */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 240 /* FunctionDeclaration */: - case 159 /* GetAccessor */: - case 163 /* IndexSignature */: - case 182 /* MappedType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 195 /* TypeAssertionExpression */: - case 238 /* VariableDeclaration */: + case 214 /* AsExpression */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 241 /* FunctionDeclaration */: + case 160 /* GetAccessor */: + case 164 /* IndexSignature */: + case 183 /* MappedType */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 153 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 161 /* SetAccessor */: + case 244 /* TypeAliasDeclaration */: + case 196 /* TypeAssertionExpression */: + case 239 /* VariableDeclaration */: return true; default: return false; @@ -119625,12 +121422,15 @@ var ts; return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_async_modifier_to_containing_function, fixId, ts.Diagnostics.Add_all_missing_async_modifiers)]; }, fixIds: [fixId], - getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var nodes = getNodes(diag.file, diag.start); - if (!nodes) - return; - doChange(changes, context.sourceFile, nodes); - }); }, + getAllCodeActions: function (context) { + var seen = ts.createMap(); + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var nodes = getNodes(diag.file, diag.start); + if (!nodes || !ts.addToSeen(seen, ts.getNodeId(nodes.insertBefore))) + return; + doChange(changes, context.sourceFile, nodes); + }); + }, }); function getReturnType(expr) { if (expr.type) { @@ -119650,14 +121450,14 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: insertBefore = ts.findChildOfKind(containingFunction, 91 /* FunctionKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -119784,18 +121584,40 @@ var ts; var modifiers = visibilityModifier ? ts.createNodeArray([visibilityModifier]) : undefined; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var optional = !!(symbol.flags & 16777216 /* Optional */); + var ambient = !!(enclosingDeclaration.flags & 4194304 /* Ambient */); switch (declaration.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 154 /* PropertySignature */: - case 155 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 156 /* PropertyDeclaration */: var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); out(ts.createProperty( /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 156 /* MethodSignature */: - case 157 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: { + var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); + var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); + var orderedAccessors = allAccessors.secondAccessor + ? [allAccessors.firstAccessor, allAccessors.secondAccessor] + : [allAccessors.firstAccessor]; + for (var _i = 0, orderedAccessors_1 = orderedAccessors; _i < orderedAccessors_1.length; _i++) { + var accessor = orderedAccessors_1[_i]; + if (ts.isGetAccessorDeclaration(accessor)) { + out(ts.createGetAccessor( + /*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : createStubbedMethodBody(preferences))); + } + else { + ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter"); + var parameter = ts.getSetAccessorValueParameter(accessor); + var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined; + out(ts.createSetAccessor( + /*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : createStubbedMethodBody(preferences))); + } + } + break; + } + case 157 /* MethodSignature */: + case 158 /* 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 @@ -119808,23 +121630,25 @@ var ts; break; } if (declarations.length === 1) { - ts.Debug.assert(signatures.length === 1); + ts.Debug.assert(signatures.length === 1, "One declaration implies one signature"); var signature = signatures[0]; - outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); + outputMethod(signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(preferences)); break; } - for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { - var signature = signatures_1[_i]; + for (var _a = 0, signatures_1 = signatures; _a < signatures_1.length; _a++) { + var signature = signatures_1[_a]; // Need to ensure nodes are fresh each time so they can have different positions. outputMethod(signature, ts.getSynthesizedDeepClones(modifiers, /*includeTrivia*/ false), ts.getSynthesizedDeepClone(name, /*includeTrivia*/ false)); } - if (declarations.length > signatures.length) { - var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); - outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); - } - else { - ts.Debug.assert(declarations.length === signatures.length); - out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); + if (!ambient) { + if (declarations.length > signatures.length) { + var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); + outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); + } + else { + ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); + out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); + } } break; } @@ -119836,7 +121660,7 @@ var ts; } function signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body) { var program = context.program; - var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 157 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); + var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 158 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } @@ -119857,8 +121681,7 @@ var ts; return checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, /*flags*/ undefined, tracker); }); var names = ts.map(args, function (arg) { - return ts.isIdentifier(arg) ? arg.text : - ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; + return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; }); var contextualType = checker.getContextualType(call); var returnType = (inJs || !contextualType) ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); @@ -120012,7 +121835,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 192 /* CallExpression */ : 193 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 193 /* CallExpression */ : 194 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -120252,6 +122075,39 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "useBigintLiteral"; + var errorCodes = [ + ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span); }); + if (changes.length > 0) { + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_to_a_bigint_numeric_literal, fixId, ts.Diagnostics.Convert_all_to_bigint_numeric_literals)]; + } + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag); }); + }, + }); + function makeChange(changeTracker, sourceFile, span) { + var numericLiteral = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), ts.isNumericLiteral); + if (!numericLiteral) { + return; + } + // We use .getText to overcome parser inaccuracies: https://github.com/microsoft/TypeScript/issues/33298 + var newText = numericLiteral.getText(sourceFile) + "n"; + changeTracker.replaceNode(sourceFile, numericLiteral, ts.createBigIntLiteral(newText)); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -120273,8 +122129,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 93 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 184 /* ImportType */); + ts.Debug.assert(token.kind === 93 /* ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 185 /* ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -120327,7 +122183,7 @@ var ts; var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(134 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); - var intersectionType = ts.createIntersectionTypeNode(ts.getAllSuperTypeNodes(container).concat([ + var intersectionType = ts.createIntersectionTypeNode(__spreadArrays(ts.getAllSuperTypeNodes(container), [ mappedIntersectionType ], (otherMembers.length ? [ts.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); changes.replaceNode(sourceFile, container, createTypeAliasFromInterface(container, intersectionType)); @@ -120379,6 +122235,40 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "fixConvertConstToLet"; + var errorCodes = [ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, span = context.span, program = context.program; + var variableStatement = getVariableStatement(sourceFile, span.start, program); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, variableStatement); }); + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_const_to_let, fixId, ts.Diagnostics.Convert_const_to_let)]; + }, + fixIds: [fixId] + }); + function getVariableStatement(sourceFile, pos, program) { + var token = ts.getTokenAtPosition(sourceFile, pos); + var checker = program.getTypeChecker(); + var symbol = checker.getSymbolAtLocation(token); + if (symbol) { + return symbol.valueDeclaration.parent.parent; + } + } + function doChange(changes, sourceFile, variableStatement) { + if (!variableStatement) { + return; + } + var start = variableStatement.getStart(); + changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 5 }, "let"); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var refactor; (function (refactor) { @@ -120395,8 +122285,8 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context)), t, context.cancellationToken); }); + ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context), "context must have info"), t, context.cancellationToken); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; }, }); @@ -120416,16 +122306,16 @@ var ts; return undefined; } switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: { + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 246 /* ModuleDeclaration */: { var node = exportNode; return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } - case 220 /* VariableStatement */: { + case 221 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -120434,7 +122324,7 @@ var ts; var decl = ts.first(vs.declarationList.declarations); if (!decl.initializer) return undefined; - ts.Debug.assert(!wasDefault); + 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; } default: @@ -120448,40 +122338,40 @@ 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.assertDefined(ts.findModifier(exportNode, 81 /* DefaultKeyword */))); + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 81 /* DefaultKeyword */), "Should find a default keyword in modifier list")); } else { - var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 86 /* ExportKeyword */)); + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 86 /* ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(81 /* DefaultKeyword */)); break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: // If 'x' isn't used in this file, `export const x = 0;` --> `export default 0;` if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile)) { // We checked in `getInfo` that an initializer exists. - changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer))); + changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer, "Initializer was previously known to be present"))); break; } // falls through - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 246 /* ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.createExportDefault(ts.createIdentifier(exportName.text))); break; default: - ts.Debug.assertNever(exportNode); + ts.Debug.assertNever(exportNode, "Unexpected exportNode kind " + exportNode.kind); } } } function changeImports(program, _a, changes, cancellationToken) { var wasDefault = _a.wasDefault, exportName = _a.exportName, exportingModuleSymbol = _a.exportingModuleSymbol; var checker = program.getTypeChecker(); - var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName)); + var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName), "Export name should resolve to a symbol"); ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) { var importingSourceFile = ref.getSourceFile(); if (wasDefault) { @@ -120495,27 +122385,27 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: { + case 255 /* ImportSpecifier */: + case 259 /* 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 251 /* ImportClause */: { + case 252 /* ImportClause */: { var clause = parent; - ts.Debug.assert(clause.name === ref); + ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); var namedBindings = clause.namedBindings; if (!namedBindings) { // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); } - else if (namedBindings.kind === 252 /* NamespaceImport */) { + else if (namedBindings.kind === 253 /* 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 */; @@ -120536,11 +122426,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); break; - case 254 /* ImportSpecifier */: { + case 255 /* ImportSpecifier */: { // `import { foo } from "./a";` --> `import foo from "./a";` // `import { foo as bar } from "./a";` --> `import bar from "./a";` var defaultImport = ts.createIdentifier(parent.name.text); @@ -120553,7 +122443,7 @@ var ts; } break; } - case 258 /* ExportSpecifier */: { + case 259 /* 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";` @@ -120562,7 +122452,7 @@ var ts; break; } default: - ts.Debug.assertNever(parent); + ts.Debug.assertNever(parent, "Unexpected parent kind " + parent.kind); } } function makeImportSpecifier(propertyName, name) { @@ -120586,13 +122476,13 @@ var ts; var i = getImportToConvert(context); if (!i) return ts.emptyArray; - var description = i.kind === 252 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; - var actionName = i.kind === 252 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + var description = i.kind === 253 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 253 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); + ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context), "Context must provide an import to convert")); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; } }); @@ -120609,7 +122499,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 252 /* NamespaceImport */) { + if (toConvert.kind === 253 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -120630,7 +122520,7 @@ var ts; if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { conflictingNames.set(exportName, true); } - ts.Debug.assert(parent.expression === id); + ts.Debug.assert(parent.expression === id, "Parent expression should match id"); nodesToReplace.push(parent); } }); @@ -120669,7 +122559,7 @@ var ts; }); var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; var neededNamedImports = []; - var _loop_13 = function (element) { + var _loop_14 = function (element) { var propertyName = (element.propertyName || element.name).text; ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); @@ -120688,7 +122578,7 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_13(element); + _loop_14(element); } changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); if (neededNamedImports.length) { @@ -120809,6 +122699,7 @@ var ts; Messages.cannotExtractRange = createMessage("Cannot extract range."); Messages.cannotExtractImport = createMessage("Cannot extract import statement."); Messages.cannotExtractSuper = createMessage("Cannot extract super call."); + Messages.cannotExtractJSDoc = createMessage("Cannot extract JSDoc."); Messages.cannotExtractEmpty = createMessage("Cannot extract empty range."); Messages.expressionExpected = createMessage("expression expected."); Messages.uselessConstantType = createMessage("No reason to extract constant of type."); @@ -120900,6 +122791,9 @@ 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)] }; @@ -120952,20 +122846,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 155 /* PropertyDeclaration */) { + if (current.kind === 156 /* PropertyDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 152 /* Parameter */) { + else if (current.kind === 153 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 158 /* Constructor */) { + if (ctorOrMethod.kind === 159 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 157 /* MethodDeclaration */) { + else if (current.kind === 158 /* MethodDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -120983,9 +122877,9 @@ var ts; PermittedJumps[PermittedJumps["Return"] = 4] = "Return"; })(PermittedJumps || (PermittedJumps = {})); // We believe it's true because the node is from the (unmodified) tree. - ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (1)"); // For understanding how skipTrivia functioned: - ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (2)"); if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck))) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)]; } @@ -121008,7 +122902,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 238 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 239 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasModifier(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`! @@ -121020,13 +122914,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; case 99 /* 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 === 192 /* CallExpression */) { + if (node.parent.kind === 193 /* 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)) { @@ -121041,8 +122935,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -121054,20 +122948,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 223 /* IfStatement */: + case 224 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 236 /* TryStatement */: + case 237 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 219 /* Block */: - if (node.parent && node.parent.kind === 236 /* TryStatement */ && node.parent.finallyBlock === node) { + case 220 /* Block */: + if (node.parent && node.parent.kind === 237 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 272 /* CaseClause */: + case 273 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -121079,19 +122973,19 @@ var ts; break; } switch (node.kind) { - case 179 /* ThisType */: + case 180 /* ThisType */: case 101 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 234 /* LabeledStatement */: { + case 235 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: { + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -121100,20 +122994,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 230 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 231 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -121167,7 +123061,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 === 152 /* Parameter */) { + if (current.kind === 153 /* 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; } @@ -121178,7 +123072,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 285 /* SourceFile */) { + if (current.kind === 286 /* SourceFile */) { return scopes; } } @@ -121268,32 +123162,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: return "constructor"; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return "arrow function"; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return "method '" + scope.name.getText() + "'"; - case 159 /* GetAccessor */: + case 160 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: - throw ts.Debug.assertNever(scope); + throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 241 /* ClassDeclaration */ + return scope.kind === 242 /* 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 === 246 /* ModuleBlock */ + return scope.kind === 247 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -121397,8 +123291,8 @@ var ts; if (exposedVariableDeclarations.length && !writes) { // No need to mix declarations and writes. // How could any variables be exposed if there's a return statement? - ts.Debug.assert(!returnValueProperty); - ts.Debug.assert(!(range.facts & RangeFacts.HasReturn)); + ts.Debug.assert(!returnValueProperty, "Expected no returnValueProperty"); + ts.Debug.assert(!(range.facts & RangeFacts.HasReturn), "Expected RangeFacts.HasReturn flag to be unset"); if (exposedVariableDeclarations.length === 1) { // Declaring exactly one variable: let x = newFunction(); var variableDeclaration = exposedVariableDeclarations[0]; @@ -121466,7 +123360,7 @@ var ts; if (assignments.length === 1) { // We would only have introduced a return value property if there had been // other assignments to make. - ts.Debug.assert(!returnValueProperty); + ts.Debug.assert(!returnValueProperty, "Shouldn't have returnValueProperty here"); newNodes.push(ts.createStatement(ts.createAssignment(assignments[0].name, call))); if (range.facts & RangeFacts.HasReturn) { newNodes.push(ts.createReturn()); @@ -121523,6 +123417,7 @@ var ts; * Stores either a list of changes that should be applied to extract a range or a list of errors */ function extractConstantInScope(node, scope, _a, rangeFacts, context) { + var _b; var substitutions = _a.substitutions; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable @@ -121533,10 +123428,11 @@ var ts; ? undefined : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(node, substitutions); + (_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer); ts.suppressLeadingAndTrailingTrivia(initializer); var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); if (ts.isClassLike(scope)) { - ts.Debug.assert(!isJS); // See CannotExtractToJSClass + ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass var modifiers = []; modifiers.push(ts.createToken(114 /* PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { @@ -121571,7 +123467,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 222 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 223 /* 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.createVariableStatement( @@ -121590,7 +123486,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 222 /* ExpressionStatement */) { + if (node.parent.kind === 223 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -121604,6 +123500,63 @@ var ts; var renameFilename = node.getSourceFile().fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, localNameText, /*isDeclaredBeforeUse*/ true); return { renameFilename: renameFilename, renameLocation: renameLocation, edits: edits }; + function transformFunctionInitializerAndType(variableType, initializer) { + // If no contextual type exists there is nothing to transfer to the function signature + if (variableType === undefined) + return { variableType: variableType, initializer: initializer }; + // Only do this for function expressions and arrow functions that are not generic + if (!ts.isFunctionExpression(initializer) && !ts.isArrowFunction(initializer) || !!initializer.typeParameters) + return { variableType: variableType, initializer: initializer }; + var functionType = checker.getTypeAtLocation(node); + var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* Call */)); + // If no function signature, maybe there was an error, do nothing + if (!functionSignature) + return { variableType: variableType, initializer: initializer }; + // If the function signature has generic type parameters we don't attempt to move the parameters + if (!!functionSignature.getTypeParameters()) + return { variableType: variableType, initializer: initializer }; + // We add parameter types if needed + var parameters = []; + var hasAny = false; + for (var _i = 0, _a = initializer.parameters; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.type) { + parameters.push(p); + } + else { + var paramType = checker.getTypeAtLocation(p); + if (paramType === checker.getAnyType()) + hasAny = true; + parameters.push(ts.updateParameter(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NoTruncation */), p.initializer)); + } + } + // If a parameter was inferred as any we skip adding function parameters at all. + // Turning an implicit any (which under common settings is a error) to an explicit + // is probably actually a worse refactor outcome. + if (hasAny) + return { variableType: variableType, initializer: initializer }; + variableType = undefined; + if (ts.isArrowFunction(initializer)) { + initializer = ts.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); + } + else { + if (functionSignature && !!functionSignature.thisParameter) { + var firstParameter = ts.firstOrUndefined(parameters); + // If the function signature has a this parameter and if the first defined parameter is not the this parameter, we must add it + // Note: If this parameter was already there, it would have been previously updated with the type if not type was present + if ((!firstParameter || (ts.isIdentifier(firstParameter.name) && firstParameter.name.escapedText !== "this"))) { + var thisType = checker.getTypeOfSymbolAtLocation(functionSignature.thisParameter, node); + parameters.splice(0, 0, ts.createParameter( + /* decorators */ undefined, + /* modifiers */ undefined, + /* dotDotDotToken */ undefined, "this", + /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NoTruncation */))); + } + } + initializer = ts.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.body); + } + return { variableType: variableType, initializer: initializer }; + } } function getContainingVariableDeclarationIfInList(node, scope) { var prevNode; @@ -121677,7 +123630,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 231 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 232 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -121740,7 +123693,7 @@ var ts; } function getNodeToInsertPropertyBefore(maxPos, scope) { var members = scope.members; - ts.Debug.assert(members.length > 0); // There must be at least one child, since we extracted from one. + ts.Debug.assert(members.length > 0, "Found no members"); // There must be at least one child, since we extracted from one. var prevMember; var allProperties = true; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { @@ -121782,11 +123735,11 @@ var ts; } if (!prevStatement && ts.isCaseClause(curr)) { // We must have been in the expression of the case clause. - ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent)); + ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent), "Grandparent isn't a switch statement"); return curr.parent.parent; } // There must be at least one statement since we started in one. - return ts.Debug.assertDefined(prevStatement); + return ts.Debug.assertDefined(prevStatement, "prevStatement failed to get set"); } ts.Debug.assert(curr !== scope, "Didn't encounter a block-like before encountering scope"); } @@ -121855,7 +123808,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 240 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 241 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -121908,7 +123861,7 @@ var ts; // If we didn't get through all the scopes, then there were some that weren't in our // parent chain (impossible at time of writing). A conservative solution would be to // copy allTypeParameterUsages into all remaining scopes. - ts.Debug.assert(i_1 === scopes.length); + ts.Debug.assert(i_1 === scopes.length, "Should have iterated all scopes"); } // If there are any declarations in the extracted block that are used in the same enclosing // lexical scope, we can't move the extraction "up" as those declarations will become unreachable @@ -121918,7 +123871,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_14 = function (i) { + var _loop_15 = 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 @@ -121940,7 +123893,7 @@ var ts; } }); // If an expression was extracted, then there shouldn't have been any variable declarations. - ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0); + ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0, "No variable declarations expected if something was extracted"); if (hasWrite && !isReadonlyArray(targetRange.range)) { var diag = ts.createDiagnosticForNode(targetRange.range, Messages.cannotWriteInExpression); functionErrorsPerScope[i].push(diag); @@ -121958,7 +123911,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_14(i); + _loop_15(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -122171,30 +124124,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 279 /* EnumMember */: + case 280 /* EnumMember */: return false; } switch (node.kind) { case 10 /* StringLiteral */: - return parent.kind !== 250 /* ImportDeclaration */ && - parent.kind !== 254 /* ImportSpecifier */; - case 209 /* SpreadElement */: - case 185 /* ObjectBindingPattern */: - case 187 /* BindingElement */: + return parent.kind !== 251 /* ImportDeclaration */ && + parent.kind !== 255 /* ImportSpecifier */; + case 210 /* SpreadElement */: + case 186 /* ObjectBindingPattern */: + case 188 /* BindingElement */: return false; case 73 /* Identifier */: - return parent.kind !== 187 /* BindingElement */ && - parent.kind !== 254 /* ImportSpecifier */ && - parent.kind !== 258 /* ExportSpecifier */; + return parent.kind !== 188 /* BindingElement */ && + parent.kind !== 255 /* ImportSpecifier */ && + parent.kind !== 259 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 219 /* Block */: - case 285 /* SourceFile */: - case 246 /* ModuleBlock */: - case 272 /* CaseClause */: + case 220 /* Block */: + case 286 /* SourceFile */: + case 247 /* ModuleBlock */: + case 273 /* CaseClause */: return true; default: return false; @@ -122210,6 +124163,7 @@ var ts; (function (refactor) { var refactorName = "Extract type"; var extractToTypeAlias = "Extract to type alias"; + var extractToInterface = "Extract to interface"; var extractToTypeDef = "Extract to typedef"; refactor.registerRefactor(refactorName, { getAvailableActions: function (context) { @@ -122219,22 +124173,34 @@ var ts; return [{ name: refactorName, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_type), - actions: [info.isJS ? { + actions: info.isJS ? [{ name: extractToTypeDef, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_typedef) - } : { + }] : ts.append([{ name: extractToTypeAlias, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_type_alias) - }] + }], info.typeElements && { + name: extractToInterface, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_interface) + }) }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === extractToTypeAlias || actionName === extractToTypeDef); var file = context.file; - var info = ts.Debug.assertDefined(getRangeToExtract(context)); - ts.Debug.assert(actionName === extractToTypeAlias && !info.isJS || actionName === extractToTypeDef && info.isJS); + var info = ts.Debug.assertDefined(getRangeToExtract(context), "Expected to find a range to extract"); var name = ts.getUniqueName("NewType", file); - var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { return info.isJS ? - doTypedefChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters) : - doTypeAliasChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters); }); + var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { + switch (actionName) { + case extractToTypeAlias: + ts.Debug.assert(!info.isJS, "Invalid actionName/JS combo"); + return doTypeAliasChange(changes, file, name, info); + case extractToTypeDef: + ts.Debug.assert(info.isJS, "Invalid actionName/JS combo"); + return doTypedefChange(changes, file, name, info); + case extractToInterface: + ts.Debug.assert(!info.isJS && !!info.typeElements, "Invalid actionName/JS combo"); + return doInterfaceChange(changes, file, name, info); + default: + ts.Debug.fail("Unexpected action name"); + } + }); var renameFilename = file.fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, name, /*preferLastLocation*/ false); return { edits: edits, renameFilename: renameFilename, renameLocation: renameLocation }; @@ -122249,11 +124215,36 @@ var ts; if (!selection || !ts.isTypeNode(selection)) return undefined; var checker = context.program.getTypeChecker(); - var firstStatement = ts.Debug.assertDefined(isJS ? ts.findAncestor(selection, isStatementAndHasJSDoc) : ts.findAncestor(selection, ts.isStatement)); + var firstStatement = ts.Debug.assertDefined(isJS ? ts.findAncestor(selection, isStatementAndHasJSDoc) : ts.findAncestor(selection, ts.isStatement), "Should find a statement"); var typeParameters = collectTypeParameters(checker, selection, firstStatement, file); if (!typeParameters) return undefined; - return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters }; + var typeElements = flattenTypeLiteralNodeReference(checker, selection); + return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters, typeElements: typeElements }; + } + function flattenTypeLiteralNodeReference(checker, node) { + if (!node) + return undefined; + if (ts.isIntersectionTypeNode(node)) { + var result = []; + var seen_1 = ts.createMap(); + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var type = _a[_i]; + var flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type); + if (!flattenedTypeMembers || !flattenedTypeMembers.every(function (type) { return type.name && ts.addToSeen(seen_1, ts.getNameFromPropertyName(type.name)); })) { + return undefined; + } + ts.addRange(result, flattenedTypeMembers); + } + return result; + } + else if (ts.isParenthesizedTypeNode(node)) { + return flattenTypeLiteralNodeReference(checker, node.type); + } + else if (ts.isTypeLiteralNode(node)) { + return node.members; + } + return undefined; } function isStatementAndHasJSDoc(n) { return ts.isStatement(n) && ts.hasJSDocNodes(n); @@ -122290,7 +124281,7 @@ var ts; } else if (ts.isTypeQueryNode(node)) { if (ts.isIdentifier(node.exprName)) { - var symbol = checker.resolveName(node.exprName.text, node.exprName, 67220415 /* Value */, /* excludeGlobals */ false); + 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)) { return true; } @@ -122304,15 +124295,26 @@ var ts; return ts.forEachChild(node, visitor); } } - function doTypeAliasChange(changes, file, name, firstStatement, selection, typeParameters) { + function doTypeAliasChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; var newTypeNode = ts.createTypeAliasDeclaration( /* decorators */ undefined, /* modifiers */ undefined, name, typeParameters.map(function (id) { return ts.updateTypeParameterDeclaration(id, id.name, id.constraint, /* defaultType */ undefined); }), selection); changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); } - function doTypedefChange(changes, file, name, firstStatement, selection, typeParameters) { - var node = ts.createNode(311 /* JSDocTypedefTag */); + function doInterfaceChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters, typeElements = info.typeElements; + var newTypeNode = ts.createInterfaceDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, name, typeParameters, + /* heritageClauses */ undefined, typeElements); + changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); + changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); + } + function doTypedefChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; + var node = ts.createNode(313 /* JSDocTypedefTag */); node.tagName = ts.createIdentifier("typedef"); // TODO: jsdoc factory https://github.com/Microsoft/TypeScript/pull/29539 node.fullName = ts.createIdentifier(name); node.name = node.fullName; @@ -122320,10 +124322,10 @@ var ts; var templates = []; ts.forEach(typeParameters, function (typeParameter) { var constraint = ts.getEffectiveConstraintOfTypeParameter(typeParameter); - var template = ts.createNode(310 /* JSDocTemplateTag */); + var template = ts.createNode(312 /* JSDocTemplateTag */); template.tagName = ts.createIdentifier("template"); template.constraint = constraint && ts.cast(constraint, ts.isJSDocTypeExpression); - var parameter = ts.createNode(151 /* TypeParameter */); + var parameter = ts.createNode(152 /* TypeParameter */); parameter.name = typeParameter.name; template.typeParameters = ts.createNodeArray([parameter]); templates.push(template); @@ -122404,7 +124406,7 @@ var ts; return ts.isIdentifier(name) || ts.isStringLiteral(name); } function isAcceptedDeclaration(node) { - return ts.isParameterPropertyDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); + return ts.isParameterPropertyDeclaration(node, node.parent) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); } function createPropertyName(name, originalName) { return ts.isIdentifier(originalName) ? ts.createIdentifier(name) : ts.createLiteral(name); @@ -122437,7 +124439,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasReadonlyModifier(declaration), type: ts.getTypeAnnotationNode(declaration), - container: declaration.kind === 152 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 153 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -122483,11 +124485,9 @@ var ts; } } function insertAccessor(changeTracker, file, accessor, declaration, container) { - ts.isParameterPropertyDeclaration(declaration) - ? changeTracker.insertNodeAtClassStart(file, container, accessor) - : ts.isPropertyAssignment(declaration) - ? changeTracker.insertNodeAfterComma(file, declaration, accessor) - : changeTracker.insertNodeAfter(file, declaration, accessor); + ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.insertNodeAtClassStart(file, container, accessor) : + ts.isPropertyAssignment(declaration) ? changeTracker.insertNodeAfterComma(file, declaration, accessor) : + changeTracker.insertNodeAfter(file, declaration, accessor); } function updateReadonlyPropertyInitializerStatementConstructor(changeTracker, file, constructor, fieldName, originalName) { if (!constructor.body) @@ -122525,7 +124525,7 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Wrong refactor invoked"); var statements = ts.Debug.assertDefined(getStatementsToMove(context)); var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; @@ -122582,11 +124582,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return true; - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -122621,7 +124621,7 @@ var ts; deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker); deleteMovedStatements(oldFile, toMove.ranges, changes); updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName); - return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference).concat(addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); + return __spreadArrays(getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference), addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); } function deleteMovedStatements(sourceFile, moved, changes) { for (var _i = 0, moved_1 = moved; _i < moved_1.length; _i++) { @@ -122639,10 +124639,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_15 = function (sourceFile) { + var _loop_16 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_16 = function (statement) { + var _loop_17 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -122664,25 +124664,25 @@ var ts; }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_16(statement); + _loop_17(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_15(sourceFile); + _loop_16(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 252 /* NamespaceImport */ ? + case 251 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 253 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return node.name; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { @@ -122710,20 +124710,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function moduleSpecifierFromImport(i) { - return (i.kind === 250 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 249 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 251 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 250 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -122765,7 +124765,7 @@ var ts; return ts.makeImportIfNecessary(defaultImport, specifiers, path, quotePreference); } else { - ts.Debug.assert(!defaultImport); // If there's a default export, it should have been an es6 module. + ts.Debug.assert(!defaultImport, "No default import should exist"); // If there's a default export, it should have been an es6 module. var bindingElements = imports.map(function (i) { return ts.createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, i); }); return bindingElements.length ? makeVariableStatement(ts.createObjectBindingPattern(bindingElements), /*type*/ undefined, createRequireCall(ts.createLiteral(path))) @@ -122793,19 +124793,19 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: - ts.Debug.assertNever(importDecl); + ts.Debug.assertNever(importDecl, "Unexpected import decl kind " + importDecl.kind); } } function deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused) { @@ -122814,7 +124814,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 252 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 253 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -122824,9 +124824,9 @@ var ts; } if (namedBindings) { if (namedBindingsUnused) { - changes.delete(sourceFile, namedBindings); + changes.replaceNode(sourceFile, importDecl.importClause, ts.updateImportClause(importDecl.importClause, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 253 /* NamedImports */) { + else if (namedBindings.kind === 254 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -122844,9 +124844,9 @@ var ts; changes.delete(sourceFile, name); } break; - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: break; - case 185 /* ObjectBindingPattern */: + case 186 /* 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); } @@ -122920,7 +124920,7 @@ var ts; for (var _i = 0, toMove_1 = toMove; _i < toMove_1.length; _i++) { var statement = toMove_1[_i]; forEachTopLevelDeclaration(statement, function (decl) { - movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol)); + movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol, "Need a symbol here")); }); } for (var _a = 0, toMove_2 = toMove; _a < toMove_2.length; _a++) { @@ -122973,13 +124973,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: + case 250 /* ImportEqualsDeclaration */: + case 255 /* ImportSpecifier */: + case 252 /* ImportClause */: return true; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -122991,7 +124991,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 250 /* ImportDeclaration */: { + case 251 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -123001,18 +125001,18 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 238 /* VariableDeclaration */: { + case 239 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } default: - return ts.Debug.assertNever(i); + return ts.Debug.assertNever(i, "Unexpected import kind " + i.kind); } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 253 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -123024,9 +125024,9 @@ var ts; switch (name.kind) { case 73 /* Identifier */: return keep(name) ? name : undefined; - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: return name; - case 185 /* ObjectBindingPattern */: { + case 186 /* 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.createObjectBindingPattern(newElements) : undefined; @@ -123078,18 +125078,18 @@ var ts; return ts.isVariableDeclaration(node) ? node.parent.parent.parent : node.parent; } function isTopLevelDeclarationStatement(node) { - ts.Debug.assert(ts.isSourceFile(node.parent)); + ts.Debug.assert(ts.isSourceFile(node.parent), "Node parent should be a SourceFile"); return isNonVariableTopLevelDeclaration(node) || ts.isVariableStatement(node); } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 250 /* ImportEqualsDeclaration */: return true; default: return false; @@ -123097,17 +125097,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 250 /* ImportEqualsDeclaration */: return cb(statement); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 222 /* ExpressionStatement */: { + case 223 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -123119,11 +125119,11 @@ var ts; switch (name.kind) { case 73 /* Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); } } function nameOfTopLevelDeclaration(d) { @@ -123131,9 +125131,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return d.parent.parent; - case 187 /* BindingElement */: + case 188 /* BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -123166,48 +125166,48 @@ var ts; function addEs6Export(d) { var modifiers = ts.concatenate([ts.createModifier(86 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(d); + return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); } } function addCommonjsExport(decl) { - return [decl].concat(getNamesToExportInCommonJS(decl).map(createExportAssignment)); + return __spreadArrays([decl], getNamesToExportInCommonJS(decl).map(createExportAssignment)); } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 250 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 222 /* ExpressionStatement */: - return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` + case 223 /* 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); + return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); } } /** Creates `exports.x = x;` */ @@ -123335,7 +125335,7 @@ var ts; }]; } function getEditsForAction(context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Unexpected action name"); var file = context.file, startPosition = context.startPosition, program = context.program, cancellationToken = context.cancellationToken, host = context.host; var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker()); if (!functionDeclaration || !cancellationToken) @@ -123367,7 +125367,7 @@ var ts; function getGroupedReferences(functionDeclaration, program, cancellationToken) { var functionNames = getFunctionNames(functionDeclaration); var classNames = ts.isConstructorDeclaration(functionDeclaration) ? getClassNames(functionDeclaration) : []; - var names = ts.deduplicate(functionNames.concat(classNames), ts.equateValues); + var names = ts.deduplicate(__spreadArrays(functionNames, classNames), ts.equateValues); var checker = program.getTypeChecker(); var references = ts.flatMap(names, /*mapfn*/ function (/*mapfn*/ name) { return ts.FindAllReferences.getReferenceEntriesForNode(-1, name, program, program.getSourceFiles(), cancellationToken); }); var groupedReferences = groupReferences(references); @@ -123474,15 +125474,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -123492,7 +125492,7 @@ var ts; } break; // x["foo"](...) - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -123511,14 +125511,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -123560,11 +125560,11 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return isSingleImplementation(functionDeclaration, checker); - case 158 /* Constructor */: + case 159 /* Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -123572,8 +125572,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -123744,7 +125744,7 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; @@ -123752,7 +125752,7 @@ var ts; // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 81 /* DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -123763,30 +125763,30 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* 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.assertDefined(ts.findModifier(functionDeclaration, 81 /* DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return [functionDeclaration.name]; - case 158 /* Constructor */: + case 159 /* Constructor */: var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 125 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 210 /* ClassExpression */) { + if (functionDeclaration.parent.kind === 211 /* ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return [functionDeclaration.parent.name]; - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; default: - return ts.Debug.assertNever(functionDeclaration); + return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind " + functionDeclaration.kind); } } })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); @@ -123815,7 +125815,7 @@ var ts; this.kind = kind; } NodeObject.prototype.assertHasRealPosition = function (message) { - // tslint:disable-next-line:debug-assert + // eslint-disable-next-line debug-assert ts.Debug.assert(!ts.positionIsSynthesized(this.pos) && !ts.positionIsSynthesized(this.end), message || "Node must have a real position for this operation"); }; NodeObject.prototype.getSourceFile = function () { @@ -123872,8 +125872,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 289 /* FirstJSDocNode */ || kid.kind > 312 /* LastJSDocNode */; }); - return child.kind < 149 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 290 /* FirstJSDocNode */ || kid.kind > 314 /* LastJSDocNode */; }); + return child.kind < 150 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -123884,7 +125884,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 149 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 150 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -123942,7 +125942,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(313 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(315 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { @@ -124277,10 +126277,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -124300,31 +126300,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 169 /* TypeLiteral */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 245 /* EnumDeclaration */: + case 246 /* ModuleDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 259 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 252 /* ImportClause */: + case 253 /* NamespaceImport */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 170 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 152 /* Parameter */: + case 153 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // falls through - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: { + case 239 /* VariableDeclaration */: + case 188 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -124335,19 +126335,19 @@ var ts; } } // falls through - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 280 /* EnumMember */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: addDeclaration(node); break; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -124359,7 +126359,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 253 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -124368,7 +126368,7 @@ var ts; } } break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -124565,7 +126565,7 @@ var ts; return sourceFile; } ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; - ts.disableIncrementalParsing = false; + ts.disableIncrementalParsing = false; // eslint-disable-line prefer-const function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { // If we were given a text change range, and our version or open-ness changed, then // incrementally parse this file. @@ -124694,7 +126694,11 @@ var ts; function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { - throw new Error("Could not find sourceFile: '" + fileName + "' in " + (program && JSON.stringify(program.getSourceFiles().map(function (f) { return f.fileName; }))) + "."); + var error = new Error("Could not find source file: '" + fileName + "'."); + // We've been having trouble debugging this, so attach sidecar data for the tsserver log. + // See https://github.com/microsoft/TypeScript/issues/30180. + error.ProgramFiles = program.getSourceFiles().map(function (f) { return f.fileName; }); + throw error; } return sourceFile; } @@ -124763,11 +126767,21 @@ var ts; compilerHost.trace = function (message) { return host.trace(message); }; } if (host.resolveModuleNames) { - compilerHost.resolveModuleNames = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }; + compilerHost.resolveModuleNames = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveModuleNames.apply(host, args); + }; } if (host.resolveTypeReferenceDirectives) { - compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { - return host.resolveTypeReferenceDirectives(typeReferenceDirectiveNames, containingFile, redirectedReference); + compilerHost.resolveTypeReferenceDirectives = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveTypeReferenceDirectives.apply(host, args); }; } var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); @@ -124905,7 +126919,7 @@ var ts; } // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); - return semanticDiagnostics.concat(declarationDiagnostics); + return __spreadArrays(semanticDiagnostics, declarationDiagnostics); } function getSuggestionDiagnostics(fileName) { synchronizeHostData(); @@ -124913,12 +126927,12 @@ var ts; } function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); + return __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken)); } function getCompletionsAtPosition(fileName, position, options) { if (options === void 0) { options = ts.emptyOptions; } // Convert from deprecated options names to new names - var fullPreferences = __assign({}, ts.identity(options), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); + var fullPreferences = __assign(__assign({}, ts.identity(options)), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); synchronizeHostData(); return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter); } @@ -124976,12 +126990,12 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node); - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 191 /* PropertyAccessExpression */: + case 150 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); case 101 /* ThisKeyword */: - case 179 /* ThisType */: + case 180 /* ThisType */: case 99 /* SuperKeyword */: return true; default: @@ -125008,13 +127022,13 @@ var ts; } /// References and Occurrences function getOccurrencesAtPosition(fileName, position) { - return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */, isDefinition: false }, highlightSpan.isInString && { isInString: true }, highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); + return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */, isDefinition: false }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); } function getDocumentHighlights(fileName, position, filesToSearch) { var normalizedFileName = ts.normalizePath(fileName); ts.Debug.assert(filesToSearch.some(function (f) { return ts.normalizePath(f) === normalizedFileName; })); synchronizeHostData(); - var sourceFilesToSearch = filesToSearch.map(getValidSourceFile); + var sourceFilesToSearch = ts.mapDefined(filesToSearch, function (fileName) { return program.getSourceFile(fileName); }); var sourceFile = getValidSourceFile(fileName); return ts.DocumentHighlights.getDocumentHighlights(program, cancellationToken, sourceFile, position, sourceFilesToSearch); } @@ -125084,15 +127098,15 @@ var ts; return undefined; } switch (node.kind) { - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 191 /* PropertyAccessExpression */: + case 150 /* QualifiedName */: case 10 /* StringLiteral */: case 88 /* FalseKeyword */: case 103 /* TrueKeyword */: case 97 /* NullKeyword */: case 99 /* SuperKeyword */: case 101 /* ThisKeyword */: - case 179 /* ThisType */: + case 180 /* ThisType */: case 73 /* Identifier */: break; // Cant create the text span @@ -125109,7 +127123,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 === 245 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 246 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -125561,7 +127575,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 260 /* ExternalModuleReference */ || + node.parent.kind === 261 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -125578,13 +127592,13 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 150 /* ComputedPropertyName */) { + if (node.parent.kind === 151 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through case 73 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 189 /* ObjectLiteralExpression */ || node.parent.parent.kind === 269 /* JsxAttributes */) && + (node.parent.parent.kind === 190 /* ObjectLiteralExpression */ || node.parent.parent.kind === 270 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -125626,7 +127640,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 191 /* ElementAccessExpression */ && + node.parent.kind === 192 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -125706,114 +127720,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 239 /* VariableDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return spanInVariableDeclaration(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return spanInParameterDeclaration(node); - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 159 /* Constructor */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 219 /* Block */: + case 220 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return spanInBlock(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return spanInBlock(node.block); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 224 /* DoStatement */: + case 225 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 237 /* DebuggerStatement */: + case 238 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 223 /* IfStatement */: + case 224 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return spanInForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 236 /* TryStatement */: + case 237 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 187 /* BindingElement */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 188 /* BindingElement */: // span on complete node return textSpan(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 153 /* Decorator */: + case 154 /* Decorator */: return spanInNodeArray(parent.decorators); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: return undefined; // Tokens: case 26 /* SemicolonToken */: @@ -125843,7 +127857,7 @@ var ts; case 76 /* CatchKeyword */: case 89 /* FinallyKeyword */: return spanInNextNode(node); - case 148 /* OfKeyword */: + case 149 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -125856,13 +127870,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 === 73 /* Identifier */ || - node.kind === 209 /* SpreadElement */ || - node.kind === 276 /* PropertyAssignment */ || - node.kind === 277 /* ShorthandPropertyAssignment */) && + node.kind === 210 /* SpreadElement */ || + node.kind === 277 /* PropertyAssignment */ || + node.kind === 278 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 205 /* BinaryExpression */) { + if (node.kind === 206 /* 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 @@ -125884,22 +127898,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 224 /* DoStatement */: + case 225 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 153 /* Decorator */: + case 154 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 227 /* ForStatement */: + case 229 /* ForOfStatement */: return textSpan(node); - case 205 /* BinaryExpression */: + case 206 /* 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 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -125908,21 +127922,21 @@ var ts; } } switch (node.parent.kind) { - case 276 /* PropertyAssignment */: + case 277 /* 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 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: { + case 239 /* VariableDeclaration */: + case 153 /* 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)) { @@ -125930,7 +127944,7 @@ var ts; } break; } - case 205 /* BinaryExpression */: { + case 206 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -125960,7 +127974,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 227 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 228 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -125972,7 +127986,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 228 /* ForOfStatement */) { + parent.parent.kind === 229 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -126013,7 +128027,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 241 /* ClassDeclaration */ && functionDeclaration.kind !== 158 /* Constructor */); + (functionDeclaration.parent.kind === 242 /* ClassDeclaration */ && functionDeclaration.kind !== 159 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -126036,26 +128050,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } - // falls through // Set on parent if on same line otherwise on first statement - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 227 /* ForInStatement */: + // falls through + case 226 /* WhileStatement */: + case 224 /* IfStatement */: + case 228 /* 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 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 227 /* ForStatement */: + case 229 /* 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 === 239 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 240 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -126080,21 +128094,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 212 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 187 /* BindingElement */) { + if (bindingPattern.parent.kind === 188 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 186 /* ArrayBindingPattern */ && node.kind !== 185 /* ObjectBindingPattern */); - var elements = node.kind === 188 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 187 /* ArrayBindingPattern */ && node.kind !== 186 /* ObjectBindingPattern */); + var elements = node.kind === 189 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 212 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -126102,18 +128116,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 === 205 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 206 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -126121,25 +128135,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 246 /* ModuleBlock */: + case 247 /* 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 244 /* EnumDeclaration */: - case 241 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 242 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 219 /* Block */: + case 220 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 275 /* CatchClause */: + case 276 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -126147,7 +128161,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 185 /* ObjectBindingPattern */: + case 186 /* 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); @@ -126163,7 +128177,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 186 /* ArrayBindingPattern */: + case 187 /* 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); @@ -126178,12 +128192,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 224 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 192 /* CallExpression */ || - node.parent.kind === 193 /* NewExpression */) { + if (node.parent.kind === 225 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 193 /* CallExpression */ || + node.parent.kind === 194 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 196 /* ParenthesizedExpression */) { + if (node.parent.kind === 197 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -126192,21 +128206,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 196 /* ParenthesizedExpression */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 159 /* Constructor */: + case 226 /* WhileStatement */: + case 225 /* DoStatement */: + case 227 /* ForStatement */: + case 229 /* ForOfStatement */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 197 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -126216,20 +128230,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ || - node.parent.kind === 152 /* Parameter */) { + node.parent.kind === 277 /* PropertyAssignment */ || + node.parent.kind === 153 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 195 /* TypeAssertionExpression */) { + if (node.parent.kind === 196 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 224 /* DoStatement */) { + if (node.parent.kind === 225 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -126237,7 +128251,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.kind === 229 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -126282,10 +128296,9 @@ var ts; // limitations under the License. // /* @internal */ -var debugObjectHost = (function () { return this; })(); +var debugObjectHost = (function () { return this; })(); // eslint-disable-line prefer-const // We need to use 'null' to interface with the managed side. -/* tslint:disable:no-null-keyword */ -/* tslint:disable:no-in-operator */ +/* eslint-disable no-in-operator */ /* @internal */ var ts; (function (ts) { @@ -126307,9 +128320,11 @@ var ts; ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + /* eslint-disable no-null/no-null */ if (encoded === null) { return null; // TODO: GH#18217 } + /* eslint-enable no-null/no-null */ var decoded = JSON.parse(encoded); // TODO: GH#18217 return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); }; @@ -126380,6 +128395,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); + // eslint-disable-next-line no-null/no-null if (settingsJson === null || settingsJson === "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } @@ -126408,6 +128424,7 @@ var ts; return this.shimHost.getScriptVersion(fileName); }; LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { + /* eslint-disable no-null/no-null */ var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); if (diagnosticMessagesJson === null || diagnosticMessagesJson === "") { return null; @@ -126419,6 +128436,7 @@ var ts; this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); return null; } + /* eslint-enable no-null/no-null */ }; LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { var hostCancellationToken = this.shimHost.getCancellationToken(); @@ -126562,13 +128580,13 @@ var ts; LanguageServiceShimObject.prototype.dispose = function (dummy) { this.logger.log("dispose()"); this.languageService.dispose(); - this.languageService = null; + this.languageService = null; // eslint-disable-line no-null/no-null // force a GC if (debugObjectHost && debugObjectHost.CollectGarbage) { debugObjectHost.CollectGarbage(); this.logger.log("CollectGarbage()"); } - this.logger = null; + this.logger = null; // eslint-disable-line no-null/no-null _super.prototype.dispose.call(this, dummy); }; /// REFRESH @@ -126576,13 +128594,14 @@ var ts; * Update the list of scripts known to the compiler */ LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); + this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; } // eslint-disable-line no-null/no-null + ); }; LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { var _this = this; this.forwardJSONCall("cleanupSemanticCache()", function () { _this.languageService.cleanupSemanticCache(); - return null; + return null; // eslint-disable-line no-null/no-null }); }; LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { @@ -126953,7 +128972,7 @@ var ts; typeAcquisition: configFile.typeAcquisition, files: configFile.fileNames, raw: configFile.raw, - errors: realizeDiagnostics(result.parseDiagnostics.concat(configFile.errors), "\r\n") + errors: realizeDiagnostics(__spreadArrays(result.parseDiagnostics, configFile.errors), "\r\n") }; }); }; @@ -127040,8 +129059,7 @@ var ts; module.exports = ts; } })(ts || (ts = {})); -/* tslint:enable:no-in-operator */ -/* tslint:enable:no-null */ +/* eslint-enable no-in-operator */ /// TODO: this is used by VS, clean this up on both sides of the interface /* @internal */ var TypeScript; diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index e47b92d5fec71..fad382f8b5c1f 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "3.6"; + const versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ const version: string; } @@ -65,17 +65,17 @@ declare namespace ts { } } declare namespace ts { - type Path = string & { + export type Path = string & { __pathBrand: any; }; - interface TextRange { + export interface TextRange { pos: number; end: number; } - type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; - type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | 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.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | 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 | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; - type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; - enum SyntaxKind { + export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; + export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | 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.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | 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 | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.TagKeyword | SyntaxKind.OfKeyword; + export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; + export enum SyntaxKind { Unknown = 0, EndOfFileToken = 1, SingleLineCommentTrivia = 2, @@ -225,178 +225,180 @@ declare namespace ts { FromKeyword = 145, GlobalKeyword = 146, BigIntKeyword = 147, - OfKeyword = 148, - QualifiedName = 149, - ComputedPropertyName = 150, - TypeParameter = 151, - Parameter = 152, - Decorator = 153, - PropertySignature = 154, - PropertyDeclaration = 155, - MethodSignature = 156, - MethodDeclaration = 157, - Constructor = 158, - GetAccessor = 159, - SetAccessor = 160, - CallSignature = 161, - ConstructSignature = 162, - IndexSignature = 163, - TypePredicate = 164, - TypeReference = 165, - FunctionType = 166, - ConstructorType = 167, - TypeQuery = 168, - TypeLiteral = 169, - ArrayType = 170, - TupleType = 171, - OptionalType = 172, - RestType = 173, - UnionType = 174, - IntersectionType = 175, - ConditionalType = 176, - InferType = 177, - ParenthesizedType = 178, - ThisType = 179, - TypeOperator = 180, - IndexedAccessType = 181, - MappedType = 182, - LiteralType = 183, - ImportType = 184, - ObjectBindingPattern = 185, - ArrayBindingPattern = 186, - BindingElement = 187, - ArrayLiteralExpression = 188, - ObjectLiteralExpression = 189, - PropertyAccessExpression = 190, - ElementAccessExpression = 191, - CallExpression = 192, - NewExpression = 193, - TaggedTemplateExpression = 194, - TypeAssertionExpression = 195, - ParenthesizedExpression = 196, - FunctionExpression = 197, - ArrowFunction = 198, - DeleteExpression = 199, - TypeOfExpression = 200, - VoidExpression = 201, - AwaitExpression = 202, - PrefixUnaryExpression = 203, - PostfixUnaryExpression = 204, - BinaryExpression = 205, - ConditionalExpression = 206, - TemplateExpression = 207, - YieldExpression = 208, - SpreadElement = 209, - ClassExpression = 210, - OmittedExpression = 211, - ExpressionWithTypeArguments = 212, - AsExpression = 213, - NonNullExpression = 214, - MetaProperty = 215, - SyntheticExpression = 216, - TemplateSpan = 217, - SemicolonClassElement = 218, - Block = 219, - VariableStatement = 220, - EmptyStatement = 221, - ExpressionStatement = 222, - IfStatement = 223, - DoStatement = 224, - WhileStatement = 225, - ForStatement = 226, - ForInStatement = 227, - ForOfStatement = 228, - ContinueStatement = 229, - BreakStatement = 230, - ReturnStatement = 231, - WithStatement = 232, - SwitchStatement = 233, - LabeledStatement = 234, - ThrowStatement = 235, - TryStatement = 236, - DebuggerStatement = 237, - VariableDeclaration = 238, - VariableDeclarationList = 239, - FunctionDeclaration = 240, - ClassDeclaration = 241, - InterfaceDeclaration = 242, - TypeAliasDeclaration = 243, - EnumDeclaration = 244, - ModuleDeclaration = 245, - ModuleBlock = 246, - CaseBlock = 247, - NamespaceExportDeclaration = 248, - ImportEqualsDeclaration = 249, - ImportDeclaration = 250, - ImportClause = 251, - NamespaceImport = 252, - NamedImports = 253, - ImportSpecifier = 254, - ExportAssignment = 255, - ExportDeclaration = 256, - NamedExports = 257, - ExportSpecifier = 258, - MissingDeclaration = 259, - ExternalModuleReference = 260, - JsxElement = 261, - JsxSelfClosingElement = 262, - JsxOpeningElement = 263, - JsxClosingElement = 264, - JsxFragment = 265, - JsxOpeningFragment = 266, - JsxClosingFragment = 267, - JsxAttribute = 268, - JsxAttributes = 269, - JsxSpreadAttribute = 270, - JsxExpression = 271, - CaseClause = 272, - DefaultClause = 273, - HeritageClause = 274, - CatchClause = 275, - PropertyAssignment = 276, - ShorthandPropertyAssignment = 277, - SpreadAssignment = 278, - EnumMember = 279, - UnparsedPrologue = 280, - UnparsedPrepend = 281, - UnparsedText = 282, - UnparsedInternalText = 283, - UnparsedSyntheticReference = 284, - SourceFile = 285, - Bundle = 286, - UnparsedSource = 287, - InputFiles = 288, - JSDocTypeExpression = 289, - JSDocAllType = 290, - JSDocUnknownType = 291, - JSDocNullableType = 292, - JSDocNonNullableType = 293, - JSDocOptionalType = 294, - JSDocFunctionType = 295, - JSDocVariadicType = 296, - JSDocComment = 297, - JSDocTypeLiteral = 298, - JSDocSignature = 299, - JSDocTag = 300, - JSDocAugmentsTag = 301, - JSDocAuthorTag = 302, - JSDocClassTag = 303, - JSDocCallbackTag = 304, - JSDocEnumTag = 305, - JSDocParameterTag = 306, - JSDocReturnTag = 307, - JSDocThisTag = 308, - JSDocTypeTag = 309, - JSDocTemplateTag = 310, - JSDocTypedefTag = 311, - JSDocPropertyTag = 312, - SyntaxList = 313, - NotEmittedStatement = 314, - PartiallyEmittedExpression = 315, - CommaListExpression = 316, - MergeDeclarationMarker = 317, - EndOfDeclarationMarker = 318, - Count = 319, + TagKeyword = 148, + OfKeyword = 149, + QualifiedName = 150, + ComputedPropertyName = 151, + TypeParameter = 152, + Parameter = 153, + Decorator = 154, + PropertySignature = 155, + PropertyDeclaration = 156, + MethodSignature = 157, + MethodDeclaration = 158, + Constructor = 159, + GetAccessor = 160, + SetAccessor = 161, + CallSignature = 162, + ConstructSignature = 163, + IndexSignature = 164, + TypePredicate = 165, + TypeReference = 166, + FunctionType = 167, + ConstructorType = 168, + TypeQuery = 169, + TypeLiteral = 170, + ArrayType = 171, + TupleType = 172, + OptionalType = 173, + RestType = 174, + UnionType = 175, + IntersectionType = 176, + ConditionalType = 177, + InferType = 178, + ParenthesizedType = 179, + ThisType = 180, + TypeOperator = 181, + IndexedAccessType = 182, + MappedType = 183, + LiteralType = 184, + ImportType = 185, + ObjectBindingPattern = 186, + ArrayBindingPattern = 187, + BindingElement = 188, + ArrayLiteralExpression = 189, + ObjectLiteralExpression = 190, + PropertyAccessExpression = 191, + ElementAccessExpression = 192, + CallExpression = 193, + NewExpression = 194, + TaggedTemplateExpression = 195, + TypeAssertionExpression = 196, + ParenthesizedExpression = 197, + FunctionExpression = 198, + ArrowFunction = 199, + DeleteExpression = 200, + TypeOfExpression = 201, + VoidExpression = 202, + AwaitExpression = 203, + PrefixUnaryExpression = 204, + PostfixUnaryExpression = 205, + BinaryExpression = 206, + ConditionalExpression = 207, + TemplateExpression = 208, + YieldExpression = 209, + SpreadElement = 210, + ClassExpression = 211, + OmittedExpression = 212, + ExpressionWithTypeArguments = 213, + AsExpression = 214, + NonNullExpression = 215, + MetaProperty = 216, + SyntheticExpression = 217, + TemplateSpan = 218, + SemicolonClassElement = 219, + Block = 220, + VariableStatement = 221, + EmptyStatement = 222, + ExpressionStatement = 223, + IfStatement = 224, + DoStatement = 225, + WhileStatement = 226, + ForStatement = 227, + ForInStatement = 228, + ForOfStatement = 229, + ContinueStatement = 230, + BreakStatement = 231, + ReturnStatement = 232, + WithStatement = 233, + SwitchStatement = 234, + LabeledStatement = 235, + ThrowStatement = 236, + TryStatement = 237, + DebuggerStatement = 238, + VariableDeclaration = 239, + VariableDeclarationList = 240, + FunctionDeclaration = 241, + ClassDeclaration = 242, + InterfaceDeclaration = 243, + TypeAliasDeclaration = 244, + EnumDeclaration = 245, + ModuleDeclaration = 246, + ModuleBlock = 247, + CaseBlock = 248, + NamespaceExportDeclaration = 249, + ImportEqualsDeclaration = 250, + ImportDeclaration = 251, + ImportClause = 252, + NamespaceImport = 253, + NamedImports = 254, + ImportSpecifier = 255, + ExportAssignment = 256, + ExportDeclaration = 257, + NamedExports = 258, + ExportSpecifier = 259, + MissingDeclaration = 260, + ExternalModuleReference = 261, + JsxElement = 262, + JsxSelfClosingElement = 263, + JsxOpeningElement = 264, + JsxClosingElement = 265, + JsxFragment = 266, + JsxOpeningFragment = 267, + JsxClosingFragment = 268, + JsxAttribute = 269, + JsxAttributes = 270, + JsxSpreadAttribute = 271, + JsxExpression = 272, + CaseClause = 273, + DefaultClause = 274, + HeritageClause = 275, + CatchClause = 276, + PropertyAssignment = 277, + ShorthandPropertyAssignment = 278, + SpreadAssignment = 279, + EnumMember = 280, + UnparsedPrologue = 281, + UnparsedPrepend = 282, + UnparsedText = 283, + UnparsedInternalText = 284, + UnparsedSyntheticReference = 285, + SourceFile = 286, + Bundle = 287, + UnparsedSource = 288, + InputFiles = 289, + JSDocTypeExpression = 290, + JSDocAllType = 291, + JSDocUnknownType = 292, + JSDocNullableType = 293, + JSDocNonNullableType = 294, + JSDocOptionalType = 295, + JSDocFunctionType = 296, + JSDocVariadicType = 297, + JSDocNamepathType = 298, + JSDocComment = 299, + JSDocTypeLiteral = 300, + JSDocSignature = 301, + JSDocTag = 302, + JSDocAugmentsTag = 303, + JSDocAuthorTag = 304, + JSDocClassTag = 305, + JSDocCallbackTag = 306, + JSDocEnumTag = 307, + JSDocParameterTag = 308, + JSDocReturnTag = 309, + JSDocThisTag = 310, + JSDocTypeTag = 311, + JSDocTemplateTag = 312, + JSDocTypedefTag = 313, + JSDocPropertyTag = 314, + SyntaxList = 315, + NotEmittedStatement = 316, + PartiallyEmittedExpression = 317, + CommaListExpression = 318, + MergeDeclarationMarker = 319, + EndOfDeclarationMarker = 320, + Count = 321, FirstAssignment = 60, LastAssignment = 72, FirstCompoundAssignment = 61, @@ -404,15 +406,15 @@ declare namespace ts { FirstReservedWord = 74, LastReservedWord = 109, FirstKeyword = 74, - LastKeyword = 148, + LastKeyword = 149, FirstFutureReservedWord = 110, LastFutureReservedWord = 118, - FirstTypeNode = 164, - LastTypeNode = 184, + FirstTypeNode = 165, + LastTypeNode = 185, FirstPunctuation = 18, LastPunctuation = 72, FirstToken = 0, - LastToken = 148, + LastToken = 149, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -421,13 +423,13 @@ declare namespace ts { LastTemplateToken = 17, FirstBinaryOperator = 28, LastBinaryOperator = 72, - FirstNode = 149, - FirstJSDocNode = 289, - LastJSDocNode = 312, - FirstJSDocTagNode = 300, - LastJSDocTagNode = 312, + FirstNode = 150, + FirstJSDocNode = 290, + LastJSDocNode = 314, + FirstJSDocTagNode = 302, + LastJSDocTagNode = 314, } - enum NodeFlags { + export enum NodeFlags { None = 0, Let = 1, Const = 2, @@ -456,7 +458,7 @@ declare namespace ts { ContextFlags = 12679168, TypeExcludesFlags = 20480, } - enum ModifierFlags { + export enum ModifierFlags { None = 0, Export = 1, Ambient = 2, @@ -477,7 +479,7 @@ declare namespace ts { ExportDefault = 513, All = 3071 } - enum JsxFlags { + export enum JsxFlags { None = 0, /** An element from a named property of the JSX.IntrinsicElements interface */ IntrinsicNamedElement = 1, @@ -485,40 +487,40 @@ declare namespace ts { IntrinsicIndexedElement = 2, IntrinsicElement = 3 } - interface Node extends TextRange { + export interface Node extends TextRange { kind: SyntaxKind; flags: NodeFlags; decorators?: NodeArray; modifiers?: ModifiersArray; parent: Node; } - interface JSDocContainer { + export interface JSDocContainer { } - 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 | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | EndOfFileToken; - type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; - type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; - type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertySignature | PropertyDeclaration | PropertyAssignment | EnumMember; - interface NodeArray extends ReadonlyArray, TextRange { + 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 | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | EndOfFileToken; + export type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; + export type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; + export type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertySignature | PropertyDeclaration | PropertyAssignment | EnumMember; + export interface NodeArray extends ReadonlyArray, TextRange { hasTrailingComma?: boolean; } - interface Token extends Node { + export interface Token extends Node { kind: TKind; } - type DotDotDotToken = Token; - type QuestionToken = Token; - type ExclamationToken = Token; - type ColonToken = Token; - type EqualsToken = Token; - type AsteriskToken = Token; - type EqualsGreaterThanToken = Token; - type EndOfFileToken = Token & JSDocContainer; - type ReadonlyToken = Token; - type AwaitKeywordToken = Token; - type PlusToken = Token; - type MinusToken = Token; - type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; - type ModifiersArray = NodeArray; - interface Identifier extends PrimaryExpression, Declaration { + export type DotDotDotToken = Token; + export type QuestionToken = Token; + export type ExclamationToken = Token; + export type ColonToken = Token; + export type EqualsToken = Token; + export type AsteriskToken = Token; + export type EqualsGreaterThanToken = Token; + export type EndOfFileToken = Token & JSDocContainer; + export type ReadonlyToken = Token; + export type AwaitKeywordToken = Token; + export type PlusToken = Token; + export type MinusToken = Token; + export type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; + export type ModifiersArray = NodeArray; + export interface Identifier extends PrimaryExpression, Declaration { kind: SyntaxKind.Identifier; /** * Prefer to use `id.unescapedText`. (Note: This is available only in services, not internally to the TypeScript compiler.) @@ -528,37 +530,37 @@ declare namespace ts { originalKeywordKind?: SyntaxKind; isInJSDocNamespace?: boolean; } - interface TransientIdentifier extends Identifier { + export interface TransientIdentifier extends Identifier { resolvedSymbol: Symbol; } - interface QualifiedName extends Node { + export interface QualifiedName extends Node { kind: SyntaxKind.QualifiedName; left: EntityName; right: Identifier; } - type EntityName = Identifier | QualifiedName; - type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName; - type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | BindingPattern; - interface Declaration extends Node { + export type EntityName = Identifier | QualifiedName; + export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName; + export type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | BindingPattern; + export interface Declaration extends Node { _declarationBrand: any; } - interface NamedDeclaration extends Declaration { + export interface NamedDeclaration extends Declaration { name?: DeclarationName; } - interface DeclarationStatement extends NamedDeclaration, Statement { + export interface DeclarationStatement extends NamedDeclaration, Statement { name?: Identifier | StringLiteral | NumericLiteral; } - interface ComputedPropertyName extends Node { + export interface ComputedPropertyName extends Node { parent: Declaration; kind: SyntaxKind.ComputedPropertyName; expression: Expression; } - interface Decorator extends Node { + export interface Decorator extends Node { kind: SyntaxKind.Decorator; parent: NamedDeclaration; expression: LeftHandSideExpression; } - interface TypeParameterDeclaration extends NamedDeclaration { + export interface TypeParameterDeclaration extends NamedDeclaration { kind: SyntaxKind.TypeParameter; parent: DeclarationWithTypeParameterChildren | InferTypeNode; name: Identifier; @@ -567,22 +569,22 @@ declare namespace ts { default?: TypeNode; expression?: Expression; } - interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { + export interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SignatureDeclaration["kind"]; name?: PropertyName; typeParameters?: NodeArray; parameters: NodeArray; type?: TypeNode; } - type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; - interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { + export type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; + export interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.CallSignature; } - interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement { + export interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.ConstructSignature; } - type BindingName = Identifier | BindingPattern; - interface VariableDeclaration extends NamedDeclaration { + export type BindingName = Identifier | BindingPattern; + export interface VariableDeclaration extends NamedDeclaration { kind: SyntaxKind.VariableDeclaration; parent: VariableDeclarationList | CatchClause; name: BindingName; @@ -590,12 +592,12 @@ declare namespace ts { type?: TypeNode; initializer?: Expression; } - interface VariableDeclarationList extends Node { + export interface VariableDeclarationList extends Node { kind: SyntaxKind.VariableDeclarationList; parent: VariableStatement | ForStatement | ForOfStatement | ForInStatement; declarations: NodeArray; } - interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { + export interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.Parameter; parent: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; @@ -604,7 +606,7 @@ declare namespace ts { type?: TypeNode; initializer?: Expression; } - interface BindingElement extends NamedDeclaration { + export interface BindingElement extends NamedDeclaration { kind: SyntaxKind.BindingElement; parent: BindingPattern; propertyName?: PropertyName; @@ -612,14 +614,14 @@ declare namespace ts { name: BindingName; initializer?: Expression; } - interface PropertySignature extends TypeElement, JSDocContainer { + export interface PropertySignature extends TypeElement, JSDocContainer { kind: SyntaxKind.PropertySignature; name: PropertyName; questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } - interface PropertyDeclaration extends ClassElement, JSDocContainer { + export interface PropertyDeclaration extends ClassElement, JSDocContainer { kind: SyntaxKind.PropertyDeclaration; parent: ClassLikeDeclaration; name: PropertyName; @@ -628,20 +630,20 @@ declare namespace ts { type?: TypeNode; initializer?: Expression; } - interface ObjectLiteralElement extends NamedDeclaration { + export interface ObjectLiteralElement extends NamedDeclaration { _objectLiteralBrand: any; name?: PropertyName; } /** Unlike ObjectLiteralElement, excludes JSXAttribute and JSXSpreadAttribute. */ - type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration; - interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer { + export type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration; + export interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.PropertyAssignment; name: PropertyName; questionToken?: QuestionToken; initializer: Expression; } - interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { + export interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.ShorthandPropertyAssignment; name: Identifier; @@ -650,27 +652,27 @@ declare namespace ts { equalsToken?: Token; objectAssignmentInitializer?: Expression; } - interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer { + export interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.SpreadAssignment; expression: Expression; } - type VariableLikeDeclaration = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertyAssignment | PropertySignature | JsxAttribute | ShorthandPropertyAssignment | EnumMember | JSDocPropertyTag | JSDocParameterTag; - interface PropertyLikeDeclaration extends NamedDeclaration { + export type VariableLikeDeclaration = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertyAssignment | PropertySignature | JsxAttribute | ShorthandPropertyAssignment | EnumMember | JSDocPropertyTag | JSDocParameterTag; + export interface PropertyLikeDeclaration extends NamedDeclaration { name: PropertyName; } - interface ObjectBindingPattern extends Node { + export interface ObjectBindingPattern extends Node { kind: SyntaxKind.ObjectBindingPattern; parent: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } - interface ArrayBindingPattern extends Node { + export interface ArrayBindingPattern extends Node { kind: SyntaxKind.ArrayBindingPattern; parent: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } - type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; - type ArrayBindingElement = BindingElement | OmittedExpression; + export type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; + export type ArrayBindingElement = BindingElement | OmittedExpression; /** * Several node kinds share function-like features such as a signature, * a name, and a body. These nodes should extend FunctionLikeDeclarationBase. @@ -679,298 +681,298 @@ declare namespace ts { * - MethodDeclaration * - AccessorDeclaration */ - interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { + export interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { _functionLikeDeclarationBrand: any; asteriskToken?: AsteriskToken; questionToken?: QuestionToken; exclamationToken?: ExclamationToken; body?: Block | Expression; } - type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction; + export type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction; /** @deprecated Use SignatureDeclaration */ - type FunctionLike = SignatureDeclaration; - interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement { + export type FunctionLike = SignatureDeclaration; + export interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.FunctionDeclaration; name?: Identifier; body?: FunctionBody; } - interface MethodSignature extends SignatureDeclarationBase, TypeElement { + export interface MethodSignature extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.MethodSignature; parent: ObjectTypeDeclaration; name: PropertyName; } - interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.MethodDeclaration; parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } - interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { + export interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { kind: SyntaxKind.Constructor; parent: ClassLikeDeclaration; body?: FunctionBody; } /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */ - interface SemicolonClassElement extends ClassElement { + export interface SemicolonClassElement extends ClassElement { kind: SyntaxKind.SemicolonClassElement; parent: ClassLikeDeclaration; } - interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.GetAccessor; parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } - interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.SetAccessor; parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } - type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; - interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { + export type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; + export interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; parent: ObjectTypeDeclaration; } - interface TypeNode extends Node { + export interface TypeNode extends Node { _typeNodeBrand: any; } - interface KeywordTypeNode extends TypeNode { + export interface KeywordTypeNode extends TypeNode { kind: SyntaxKind.AnyKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.NumberKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; } - interface ImportTypeNode extends NodeWithTypeArguments { + export interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportType; isTypeOf?: boolean; argument: TypeNode; qualifier?: EntityName; } - interface ThisTypeNode extends TypeNode { + export interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; } - type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; - interface FunctionOrConstructorTypeNodeBase extends TypeNode, SignatureDeclarationBase { + export type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; + export interface FunctionOrConstructorTypeNodeBase extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType; type: TypeNode; } - interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase { + export interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase { kind: SyntaxKind.FunctionType; } - interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase { + export interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase { kind: SyntaxKind.ConstructorType; } - interface NodeWithTypeArguments extends TypeNode { + export interface NodeWithTypeArguments extends TypeNode { typeArguments?: NodeArray; } - type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments; - interface TypeReferenceNode extends NodeWithTypeArguments { + export type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments; + export interface TypeReferenceNode extends NodeWithTypeArguments { kind: SyntaxKind.TypeReference; typeName: EntityName; } - interface TypePredicateNode extends TypeNode { + export interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; parent: SignatureDeclaration | JSDocTypeExpression; parameterName: Identifier | ThisTypeNode; type: TypeNode; } - interface TypeQueryNode extends TypeNode { + export interface TypeQueryNode extends TypeNode { kind: SyntaxKind.TypeQuery; exprName: EntityName; } - interface TypeLiteralNode extends TypeNode, Declaration { + export interface TypeLiteralNode extends TypeNode, Declaration { kind: SyntaxKind.TypeLiteral; members: NodeArray; } - interface ArrayTypeNode extends TypeNode { + export interface ArrayTypeNode extends TypeNode { kind: SyntaxKind.ArrayType; elementType: TypeNode; } - interface TupleTypeNode extends TypeNode { + export interface TupleTypeNode extends TypeNode { kind: SyntaxKind.TupleType; elementTypes: NodeArray; } - interface OptionalTypeNode extends TypeNode { + export interface OptionalTypeNode extends TypeNode { kind: SyntaxKind.OptionalType; type: TypeNode; } - interface RestTypeNode extends TypeNode { + export interface RestTypeNode extends TypeNode { kind: SyntaxKind.RestType; type: TypeNode; } - type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; - interface UnionTypeNode extends TypeNode { + export type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; + export interface UnionTypeNode extends TypeNode { kind: SyntaxKind.UnionType; types: NodeArray; } - interface IntersectionTypeNode extends TypeNode { + export interface IntersectionTypeNode extends TypeNode { kind: SyntaxKind.IntersectionType; types: NodeArray; } - interface ConditionalTypeNode extends TypeNode { + export interface ConditionalTypeNode extends TypeNode { kind: SyntaxKind.ConditionalType; checkType: TypeNode; extendsType: TypeNode; trueType: TypeNode; falseType: TypeNode; } - interface InferTypeNode extends TypeNode { + export interface InferTypeNode extends TypeNode { kind: SyntaxKind.InferType; typeParameter: TypeParameterDeclaration; } - interface ParenthesizedTypeNode extends TypeNode { + export interface ParenthesizedTypeNode extends TypeNode { kind: SyntaxKind.ParenthesizedType; type: TypeNode; } - interface TypeOperatorNode extends TypeNode { + export interface TypeOperatorNode extends TypeNode { kind: SyntaxKind.TypeOperator; - operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword; + operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.TagKeyword; type: TypeNode; } - interface IndexedAccessTypeNode extends TypeNode { + export interface IndexedAccessTypeNode extends TypeNode { kind: SyntaxKind.IndexedAccessType; objectType: TypeNode; indexType: TypeNode; } - interface MappedTypeNode extends TypeNode, Declaration { + export interface MappedTypeNode extends TypeNode, Declaration { kind: SyntaxKind.MappedType; readonlyToken?: ReadonlyToken | PlusToken | MinusToken; typeParameter: TypeParameterDeclaration; questionToken?: QuestionToken | PlusToken | MinusToken; type?: TypeNode; } - interface LiteralTypeNode extends TypeNode { + export interface LiteralTypeNode extends TypeNode { kind: SyntaxKind.LiteralType; literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } - interface StringLiteral extends LiteralExpression { + export interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; } - type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; - interface Expression extends Node { + export type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; + export interface Expression extends Node { _expressionBrand: any; } - interface OmittedExpression extends Expression { + export interface OmittedExpression extends Expression { kind: SyntaxKind.OmittedExpression; } - interface PartiallyEmittedExpression extends LeftHandSideExpression { + export interface PartiallyEmittedExpression extends LeftHandSideExpression { kind: SyntaxKind.PartiallyEmittedExpression; expression: Expression; } - interface UnaryExpression extends Expression { + export interface UnaryExpression extends Expression { _unaryExpressionBrand: any; } /** Deprecated, please use UpdateExpression */ - type IncrementExpression = UpdateExpression; - interface UpdateExpression extends UnaryExpression { + export type IncrementExpression = UpdateExpression; + export interface UpdateExpression extends UnaryExpression { _updateExpressionBrand: any; } - type PrefixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.TildeToken | SyntaxKind.ExclamationToken; - interface PrefixUnaryExpression extends UpdateExpression { + export type PrefixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.TildeToken | SyntaxKind.ExclamationToken; + export interface PrefixUnaryExpression extends UpdateExpression { kind: SyntaxKind.PrefixUnaryExpression; operator: PrefixUnaryOperator; operand: UnaryExpression; } - type PostfixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken; - interface PostfixUnaryExpression extends UpdateExpression { + export type PostfixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken; + export interface PostfixUnaryExpression extends UpdateExpression { kind: SyntaxKind.PostfixUnaryExpression; operand: LeftHandSideExpression; operator: PostfixUnaryOperator; } - interface LeftHandSideExpression extends UpdateExpression { + export interface LeftHandSideExpression extends UpdateExpression { _leftHandSideExpressionBrand: any; } - interface MemberExpression extends LeftHandSideExpression { + export interface MemberExpression extends LeftHandSideExpression { _memberExpressionBrand: any; } - interface PrimaryExpression extends MemberExpression { + export interface PrimaryExpression extends MemberExpression { _primaryExpressionBrand: any; } - interface NullLiteral extends PrimaryExpression, TypeNode { + export interface NullLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.NullKeyword; } - interface BooleanLiteral extends PrimaryExpression, TypeNode { + export interface BooleanLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword; } - interface ThisExpression extends PrimaryExpression, KeywordTypeNode { + export interface ThisExpression extends PrimaryExpression, KeywordTypeNode { kind: SyntaxKind.ThisKeyword; } - interface SuperExpression extends PrimaryExpression { + export interface SuperExpression extends PrimaryExpression { kind: SyntaxKind.SuperKeyword; } - interface ImportExpression extends PrimaryExpression { + export interface ImportExpression extends PrimaryExpression { kind: SyntaxKind.ImportKeyword; } - interface DeleteExpression extends UnaryExpression { + export interface DeleteExpression extends UnaryExpression { kind: SyntaxKind.DeleteExpression; expression: UnaryExpression; } - interface TypeOfExpression extends UnaryExpression { + export interface TypeOfExpression extends UnaryExpression { kind: SyntaxKind.TypeOfExpression; expression: UnaryExpression; } - interface VoidExpression extends UnaryExpression { + export interface VoidExpression extends UnaryExpression { kind: SyntaxKind.VoidExpression; expression: UnaryExpression; } - interface AwaitExpression extends UnaryExpression { + export interface AwaitExpression extends UnaryExpression { kind: SyntaxKind.AwaitExpression; expression: UnaryExpression; } - interface YieldExpression extends Expression { + export interface YieldExpression extends Expression { kind: SyntaxKind.YieldExpression; asteriskToken?: AsteriskToken; expression?: Expression; } - interface SyntheticExpression extends Expression { + export interface SyntheticExpression extends Expression { kind: SyntaxKind.SyntheticExpression; isSpread: boolean; type: Type; } - type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; - type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; - type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; - type AdditiveOperator = SyntaxKind.PlusToken | SyntaxKind.MinusToken; - type AdditiveOperatorOrHigher = MultiplicativeOperatorOrHigher | AdditiveOperator; - type ShiftOperator = SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken; - type ShiftOperatorOrHigher = AdditiveOperatorOrHigher | ShiftOperator; - type RelationalOperator = SyntaxKind.LessThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.InstanceOfKeyword | SyntaxKind.InKeyword; - type RelationalOperatorOrHigher = ShiftOperatorOrHigher | RelationalOperator; - type EqualityOperator = SyntaxKind.EqualsEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.ExclamationEqualsToken; - type EqualityOperatorOrHigher = RelationalOperatorOrHigher | EqualityOperator; - type BitwiseOperator = SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken; - type BitwiseOperatorOrHigher = EqualityOperatorOrHigher | BitwiseOperator; - type LogicalOperator = SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken; - type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; - type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken; - type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; - type AssignmentOperatorOrHigher = LogicalOperatorOrHigher | AssignmentOperator; - type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; - type BinaryOperatorToken = Token; - interface BinaryExpression extends Expression, Declaration { + export type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; + export type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; + export type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; + export type AdditiveOperator = SyntaxKind.PlusToken | SyntaxKind.MinusToken; + export type AdditiveOperatorOrHigher = MultiplicativeOperatorOrHigher | AdditiveOperator; + export type ShiftOperator = SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken; + export type ShiftOperatorOrHigher = AdditiveOperatorOrHigher | ShiftOperator; + export type RelationalOperator = SyntaxKind.LessThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.InstanceOfKeyword | SyntaxKind.InKeyword; + export type RelationalOperatorOrHigher = ShiftOperatorOrHigher | RelationalOperator; + export type EqualityOperator = SyntaxKind.EqualsEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.ExclamationEqualsToken; + export type EqualityOperatorOrHigher = RelationalOperatorOrHigher | EqualityOperator; + export type BitwiseOperator = SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken; + export type BitwiseOperatorOrHigher = EqualityOperatorOrHigher | BitwiseOperator; + export type LogicalOperator = SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken; + export type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; + export type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken; + export type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; + export type AssignmentOperatorOrHigher = LogicalOperatorOrHigher | AssignmentOperator; + export type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; + export type BinaryOperatorToken = Token; + export interface BinaryExpression extends Expression, Declaration { kind: SyntaxKind.BinaryExpression; left: Expression; operatorToken: BinaryOperatorToken; right: Expression; } - type AssignmentOperatorToken = Token; - interface AssignmentExpression extends BinaryExpression { + export type AssignmentOperatorToken = Token; + export interface AssignmentExpression extends BinaryExpression { left: LeftHandSideExpression; operatorToken: TOperator; } - interface ObjectDestructuringAssignment extends AssignmentExpression { + export interface ObjectDestructuringAssignment extends AssignmentExpression { left: ObjectLiteralExpression; } - interface ArrayDestructuringAssignment extends AssignmentExpression { + export interface ArrayDestructuringAssignment extends AssignmentExpression { left: ArrayLiteralExpression; } - type DestructuringAssignment = ObjectDestructuringAssignment | ArrayDestructuringAssignment; - type BindingOrAssignmentElement = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | OmittedExpression | SpreadElement | ArrayLiteralExpression | ObjectLiteralExpression | AssignmentExpression | Identifier | PropertyAccessExpression | ElementAccessExpression; - type BindingOrAssignmentElementRestIndicator = DotDotDotToken | SpreadElement | SpreadAssignment; - type BindingOrAssignmentElementTarget = BindingOrAssignmentPattern | Identifier | PropertyAccessExpression | ElementAccessExpression | OmittedExpression; - type ObjectBindingOrAssignmentPattern = ObjectBindingPattern | ObjectLiteralExpression; - type ArrayBindingOrAssignmentPattern = ArrayBindingPattern | ArrayLiteralExpression; - type AssignmentPattern = ObjectLiteralExpression | ArrayLiteralExpression; - type BindingOrAssignmentPattern = ObjectBindingOrAssignmentPattern | ArrayBindingOrAssignmentPattern; - interface ConditionalExpression extends Expression { + export type DestructuringAssignment = ObjectDestructuringAssignment | ArrayDestructuringAssignment; + export type BindingOrAssignmentElement = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | OmittedExpression | SpreadElement | ArrayLiteralExpression | ObjectLiteralExpression | AssignmentExpression | Identifier | PropertyAccessExpression | ElementAccessExpression; + export type BindingOrAssignmentElementRestIndicator = DotDotDotToken | SpreadElement | SpreadAssignment; + export type BindingOrAssignmentElementTarget = BindingOrAssignmentPattern | Identifier | PropertyAccessExpression | ElementAccessExpression | OmittedExpression; + export type ObjectBindingOrAssignmentPattern = ObjectBindingPattern | ObjectLiteralExpression; + export type ArrayBindingOrAssignmentPattern = ArrayBindingPattern | ArrayLiteralExpression; + export type AssignmentPattern = ObjectLiteralExpression | ArrayLiteralExpression; + export type BindingOrAssignmentPattern = ObjectBindingOrAssignmentPattern | ArrayBindingOrAssignmentPattern; + export interface ConditionalExpression extends Expression { kind: SyntaxKind.ConditionalExpression; condition: Expression; questionToken: QuestionToken; @@ -978,34 +980,37 @@ declare namespace ts { colonToken: ColonToken; whenFalse: Expression; } - type FunctionBody = Block; - type ConciseBody = FunctionBody | Expression; - interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { + export type FunctionBody = Block; + export type ConciseBody = FunctionBody | Expression; + export interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.FunctionExpression; name?: Identifier; body: FunctionBody; } - interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { + export interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.ArrowFunction; equalsGreaterThanToken: EqualsGreaterThanToken; body: ConciseBody; name: never; } - interface LiteralLikeNode extends Node { + export interface LiteralLikeNode extends Node { text: string; isUnterminated?: boolean; hasExtendedUnicodeEscape?: boolean; } - interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { + export interface TemplateLiteralLikeNode extends LiteralLikeNode { + rawText?: string; + } + export interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { _literalExpressionBrand: any; } - interface RegularExpressionLiteral extends LiteralExpression { + export interface RegularExpressionLiteral extends LiteralExpression { kind: SyntaxKind.RegularExpressionLiteral; } - interface NoSubstitutionTemplateLiteral extends LiteralExpression { + export interface NoSubstitutionTemplateLiteral extends LiteralExpression, TemplateLiteralLikeNode { kind: SyntaxKind.NoSubstitutionTemplateLiteral; } - enum TokenFlags { + export enum TokenFlags { None = 0, Scientific = 16, Octal = 32, @@ -1013,45 +1018,45 @@ declare namespace ts { BinarySpecifier = 128, OctalSpecifier = 256, } - interface NumericLiteral extends LiteralExpression { + export interface NumericLiteral extends LiteralExpression { kind: SyntaxKind.NumericLiteral; } - interface BigIntLiteral extends LiteralExpression { + export interface BigIntLiteral extends LiteralExpression { kind: SyntaxKind.BigIntLiteral; } - interface TemplateHead extends LiteralLikeNode { + export interface TemplateHead extends TemplateLiteralLikeNode { kind: SyntaxKind.TemplateHead; parent: TemplateExpression; } - interface TemplateMiddle extends LiteralLikeNode { + export interface TemplateMiddle extends TemplateLiteralLikeNode { kind: SyntaxKind.TemplateMiddle; parent: TemplateSpan; } - interface TemplateTail extends LiteralLikeNode { + export interface TemplateTail extends TemplateLiteralLikeNode { kind: SyntaxKind.TemplateTail; parent: TemplateSpan; } - type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; - interface TemplateExpression extends PrimaryExpression { + export type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; + export interface TemplateExpression extends PrimaryExpression { kind: SyntaxKind.TemplateExpression; head: TemplateHead; templateSpans: NodeArray; } - interface TemplateSpan extends Node { + export interface TemplateSpan extends Node { kind: SyntaxKind.TemplateSpan; parent: TemplateExpression; expression: Expression; literal: TemplateMiddle | TemplateTail; } - interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer { + export interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer { kind: SyntaxKind.ParenthesizedExpression; expression: Expression; } - interface ArrayLiteralExpression extends PrimaryExpression { + export interface ArrayLiteralExpression extends PrimaryExpression { kind: SyntaxKind.ArrayLiteralExpression; elements: NodeArray; } - interface SpreadElement extends Expression { + export interface SpreadElement extends Expression { kind: SyntaxKind.SpreadElement; parent: ArrayLiteralExpression | CallExpression | NewExpression; expression: Expression; @@ -1062,413 +1067,413 @@ declare namespace ts { * JSXAttribute or JSXSpreadAttribute. ObjectLiteralExpression, on the other hand, can only have properties of type * ObjectLiteralElement (e.g. PropertyAssignment, ShorthandPropertyAssignment etc.) */ - interface ObjectLiteralExpressionBase extends PrimaryExpression, Declaration { + export interface ObjectLiteralExpressionBase extends PrimaryExpression, Declaration { properties: NodeArray; } - interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { + export interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { kind: SyntaxKind.ObjectLiteralExpression; } - type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; - type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; - interface PropertyAccessExpression extends MemberExpression, NamedDeclaration { + export type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; + export type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; + export interface PropertyAccessExpression extends MemberExpression, NamedDeclaration { kind: SyntaxKind.PropertyAccessExpression; expression: LeftHandSideExpression; name: Identifier; } - interface SuperPropertyAccessExpression extends PropertyAccessExpression { + export interface SuperPropertyAccessExpression extends PropertyAccessExpression { expression: SuperExpression; } /** Brand for a PropertyAccessExpression which, like a QualifiedName, consists of a sequence of identifiers separated by dots. */ - interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { + export interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { _propertyAccessExpressionLikeQualifiedNameBrand?: any; expression: EntityNameExpression; } - interface ElementAccessExpression extends MemberExpression { + export interface ElementAccessExpression extends MemberExpression { kind: SyntaxKind.ElementAccessExpression; expression: LeftHandSideExpression; argumentExpression: Expression; } - interface SuperElementAccessExpression extends ElementAccessExpression { + export interface SuperElementAccessExpression extends ElementAccessExpression { expression: SuperExpression; } - type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; - interface CallExpression extends LeftHandSideExpression, Declaration { + export type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; + export interface CallExpression extends LeftHandSideExpression, Declaration { kind: SyntaxKind.CallExpression; expression: LeftHandSideExpression; typeArguments?: NodeArray; arguments: NodeArray; } - interface SuperCall extends CallExpression { + export interface SuperCall extends CallExpression { expression: SuperExpression; } - interface ImportCall extends CallExpression { + export interface ImportCall extends CallExpression { expression: ImportExpression; } - interface ExpressionWithTypeArguments extends NodeWithTypeArguments { + export interface ExpressionWithTypeArguments extends NodeWithTypeArguments { kind: SyntaxKind.ExpressionWithTypeArguments; parent: HeritageClause | JSDocAugmentsTag; expression: LeftHandSideExpression; } - interface NewExpression extends PrimaryExpression, Declaration { + export interface NewExpression extends PrimaryExpression, Declaration { kind: SyntaxKind.NewExpression; expression: LeftHandSideExpression; typeArguments?: NodeArray; arguments?: NodeArray; } - interface TaggedTemplateExpression extends MemberExpression { + export interface TaggedTemplateExpression extends MemberExpression { kind: SyntaxKind.TaggedTemplateExpression; tag: LeftHandSideExpression; typeArguments?: NodeArray; template: TemplateLiteral; } - type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; - interface AsExpression extends Expression { + export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; + export interface AsExpression extends Expression { kind: SyntaxKind.AsExpression; expression: Expression; type: TypeNode; } - interface TypeAssertion extends UnaryExpression { + export interface TypeAssertion extends UnaryExpression { kind: SyntaxKind.TypeAssertionExpression; type: TypeNode; expression: UnaryExpression; } - type AssertionExpression = TypeAssertion | AsExpression; - interface NonNullExpression extends LeftHandSideExpression { + export type AssertionExpression = TypeAssertion | AsExpression; + export interface NonNullExpression extends LeftHandSideExpression { kind: SyntaxKind.NonNullExpression; expression: Expression; } - interface MetaProperty extends PrimaryExpression { + export interface MetaProperty extends PrimaryExpression { kind: SyntaxKind.MetaProperty; keywordToken: SyntaxKind.NewKeyword | SyntaxKind.ImportKeyword; name: Identifier; } - interface JsxElement extends PrimaryExpression { + export interface JsxElement extends PrimaryExpression { kind: SyntaxKind.JsxElement; openingElement: JsxOpeningElement; children: NodeArray; closingElement: JsxClosingElement; } - type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; - type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; - interface JsxTagNamePropertyAccess extends PropertyAccessExpression { + export type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; + export type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; + export type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; + export interface JsxTagNamePropertyAccess extends PropertyAccessExpression { expression: JsxTagNameExpression; } - interface JsxAttributes extends ObjectLiteralExpressionBase { + export interface JsxAttributes extends ObjectLiteralExpressionBase { kind: SyntaxKind.JsxAttributes; parent: JsxOpeningLikeElement; } - interface JsxOpeningElement extends Expression { + export interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; parent: JsxElement; tagName: JsxTagNameExpression; typeArguments?: NodeArray; attributes: JsxAttributes; } - interface JsxSelfClosingElement extends PrimaryExpression { + export interface JsxSelfClosingElement extends PrimaryExpression { kind: SyntaxKind.JsxSelfClosingElement; tagName: JsxTagNameExpression; typeArguments?: NodeArray; attributes: JsxAttributes; } - interface JsxFragment extends PrimaryExpression { + export interface JsxFragment extends PrimaryExpression { kind: SyntaxKind.JsxFragment; openingFragment: JsxOpeningFragment; children: NodeArray; closingFragment: JsxClosingFragment; } - interface JsxOpeningFragment extends Expression { + export interface JsxOpeningFragment extends Expression { kind: SyntaxKind.JsxOpeningFragment; parent: JsxFragment; } - interface JsxClosingFragment extends Expression { + export interface JsxClosingFragment extends Expression { kind: SyntaxKind.JsxClosingFragment; parent: JsxFragment; } - interface JsxAttribute extends ObjectLiteralElement { + export interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; parent: JsxAttributes; name: Identifier; initializer?: StringLiteral | JsxExpression; } - interface JsxSpreadAttribute extends ObjectLiteralElement { + export interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; parent: JsxAttributes; expression: Expression; } - interface JsxClosingElement extends Node { + export interface JsxClosingElement extends Node { kind: SyntaxKind.JsxClosingElement; parent: JsxElement; tagName: JsxTagNameExpression; } - interface JsxExpression extends Expression { + export interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; parent: JsxElement | JsxAttributeLike; dotDotDotToken?: Token; expression?: Expression; } - interface JsxText extends LiteralLikeNode { + export interface JsxText extends LiteralLikeNode { kind: SyntaxKind.JsxText; containsOnlyTriviaWhiteSpaces: boolean; parent: JsxElement; } - type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; - interface Statement extends Node { + export type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; + export interface Statement extends Node { _statementBrand: any; } - interface NotEmittedStatement extends Statement { + export interface NotEmittedStatement extends Statement { kind: SyntaxKind.NotEmittedStatement; } /** * A list of comma-separated expressions. This node is only created by transformations. */ - interface CommaListExpression extends Expression { + export interface CommaListExpression extends Expression { kind: SyntaxKind.CommaListExpression; elements: NodeArray; } - interface EmptyStatement extends Statement { + export interface EmptyStatement extends Statement { kind: SyntaxKind.EmptyStatement; } - interface DebuggerStatement extends Statement { + export interface DebuggerStatement extends Statement { kind: SyntaxKind.DebuggerStatement; } - interface MissingDeclaration extends DeclarationStatement { + export interface MissingDeclaration extends DeclarationStatement { kind: SyntaxKind.MissingDeclaration; name?: Identifier; } - type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; - interface Block extends Statement { + export type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; + export interface Block extends Statement { kind: SyntaxKind.Block; statements: NodeArray; } - interface VariableStatement extends Statement, JSDocContainer { + export interface VariableStatement extends Statement, JSDocContainer { kind: SyntaxKind.VariableStatement; declarationList: VariableDeclarationList; } - interface ExpressionStatement extends Statement, JSDocContainer { + export interface ExpressionStatement extends Statement, JSDocContainer { kind: SyntaxKind.ExpressionStatement; expression: Expression; } - interface IfStatement extends Statement { + export interface IfStatement extends Statement { kind: SyntaxKind.IfStatement; expression: Expression; thenStatement: Statement; elseStatement?: Statement; } - interface IterationStatement extends Statement { + export interface IterationStatement extends Statement { statement: Statement; } - interface DoStatement extends IterationStatement { + export interface DoStatement extends IterationStatement { kind: SyntaxKind.DoStatement; expression: Expression; } - interface WhileStatement extends IterationStatement { + export interface WhileStatement extends IterationStatement { kind: SyntaxKind.WhileStatement; expression: Expression; } - type ForInitializer = VariableDeclarationList | Expression; - interface ForStatement extends IterationStatement { + export type ForInitializer = VariableDeclarationList | Expression; + export interface ForStatement extends IterationStatement { kind: SyntaxKind.ForStatement; initializer?: ForInitializer; condition?: Expression; incrementor?: Expression; } - type ForInOrOfStatement = ForInStatement | ForOfStatement; - interface ForInStatement extends IterationStatement { + export type ForInOrOfStatement = ForInStatement | ForOfStatement; + export interface ForInStatement extends IterationStatement { kind: SyntaxKind.ForInStatement; initializer: ForInitializer; expression: Expression; } - interface ForOfStatement extends IterationStatement { + export interface ForOfStatement extends IterationStatement { kind: SyntaxKind.ForOfStatement; awaitModifier?: AwaitKeywordToken; initializer: ForInitializer; expression: Expression; } - interface BreakStatement extends Statement { + export interface BreakStatement extends Statement { kind: SyntaxKind.BreakStatement; label?: Identifier; } - interface ContinueStatement extends Statement { + export interface ContinueStatement extends Statement { kind: SyntaxKind.ContinueStatement; label?: Identifier; } - type BreakOrContinueStatement = BreakStatement | ContinueStatement; - interface ReturnStatement extends Statement { + export type BreakOrContinueStatement = BreakStatement | ContinueStatement; + export interface ReturnStatement extends Statement { kind: SyntaxKind.ReturnStatement; expression?: Expression; } - interface WithStatement extends Statement { + export interface WithStatement extends Statement { kind: SyntaxKind.WithStatement; expression: Expression; statement: Statement; } - interface SwitchStatement extends Statement { + export interface SwitchStatement extends Statement { kind: SyntaxKind.SwitchStatement; expression: Expression; caseBlock: CaseBlock; possiblyExhaustive?: boolean; } - interface CaseBlock extends Node { + export interface CaseBlock extends Node { kind: SyntaxKind.CaseBlock; parent: SwitchStatement; clauses: NodeArray; } - interface CaseClause extends Node { + export interface CaseClause extends Node { kind: SyntaxKind.CaseClause; parent: CaseBlock; expression: Expression; statements: NodeArray; } - interface DefaultClause extends Node { + export interface DefaultClause extends Node { kind: SyntaxKind.DefaultClause; parent: CaseBlock; statements: NodeArray; } - type CaseOrDefaultClause = CaseClause | DefaultClause; - interface LabeledStatement extends Statement, JSDocContainer { + export type CaseOrDefaultClause = CaseClause | DefaultClause; + export interface LabeledStatement extends Statement, JSDocContainer { kind: SyntaxKind.LabeledStatement; label: Identifier; statement: Statement; } - interface ThrowStatement extends Statement { + export interface ThrowStatement extends Statement { kind: SyntaxKind.ThrowStatement; expression?: Expression; } - interface TryStatement extends Statement { + export interface TryStatement extends Statement { kind: SyntaxKind.TryStatement; tryBlock: Block; catchClause?: CatchClause; finallyBlock?: Block; } - interface CatchClause extends Node { + export interface CatchClause extends Node { kind: SyntaxKind.CatchClause; parent: TryStatement; variableDeclaration?: VariableDeclaration; block: Block; } - type ObjectTypeDeclaration = ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode; - type DeclarationWithTypeParameters = DeclarationWithTypeParameterChildren | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature; - type DeclarationWithTypeParameterChildren = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; - interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { + export type ObjectTypeDeclaration = ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode; + export type DeclarationWithTypeParameters = DeclarationWithTypeParameterChildren | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature; + export type DeclarationWithTypeParameterChildren = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; + export interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression; name?: Identifier; typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; } - interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { + export interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.ClassDeclaration; /** May be undefined in `export default class { ... }`. */ name?: Identifier; } - interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { + export interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { kind: SyntaxKind.ClassExpression; } - type ClassLikeDeclaration = ClassDeclaration | ClassExpression; - interface ClassElement extends NamedDeclaration { + export type ClassLikeDeclaration = ClassDeclaration | ClassExpression; + export interface ClassElement extends NamedDeclaration { _classElementBrand: any; name?: PropertyName; } - interface TypeElement extends NamedDeclaration { + export interface TypeElement extends NamedDeclaration { _typeElementBrand: any; name?: PropertyName; questionToken?: QuestionToken; } - interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { + export interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.InterfaceDeclaration; name: Identifier; typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; } - interface HeritageClause extends Node { + export interface HeritageClause extends Node { kind: SyntaxKind.HeritageClause; parent: InterfaceDeclaration | ClassLikeDeclaration; token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword; types: NodeArray; } - interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { + export interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.TypeAliasDeclaration; name: Identifier; typeParameters?: NodeArray; type: TypeNode; } - interface EnumMember extends NamedDeclaration, JSDocContainer { + export interface EnumMember extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.EnumMember; parent: EnumDeclaration; name: PropertyName; initializer?: Expression; } - interface EnumDeclaration extends DeclarationStatement, JSDocContainer { + export interface EnumDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.EnumDeclaration; name: Identifier; members: NodeArray; } - type ModuleName = Identifier | StringLiteral; - type ModuleBody = NamespaceBody | JSDocNamespaceBody; - interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { + export type ModuleName = Identifier | StringLiteral; + export type ModuleBody = NamespaceBody | JSDocNamespaceBody; + export interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ModuleDeclaration; parent: ModuleBody | SourceFile; name: ModuleName; body?: ModuleBody | JSDocNamespaceDeclaration; } - type NamespaceBody = ModuleBlock | NamespaceDeclaration; - interface NamespaceDeclaration extends ModuleDeclaration { + export type NamespaceBody = ModuleBlock | NamespaceDeclaration; + export interface NamespaceDeclaration extends ModuleDeclaration { name: Identifier; body: NamespaceBody; } - type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; - interface JSDocNamespaceDeclaration extends ModuleDeclaration { + export type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; + export interface JSDocNamespaceDeclaration extends ModuleDeclaration { name: Identifier; body?: JSDocNamespaceBody; } - interface ModuleBlock extends Node, Statement { + export interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; parent: ModuleDeclaration; statements: NodeArray; } - type ModuleReference = EntityName | ExternalModuleReference; + export type ModuleReference = EntityName | ExternalModuleReference; /** * One of: * - import x = require("mod"); * - import x = M.x; */ - interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { + export interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ImportEqualsDeclaration; parent: SourceFile | ModuleBlock; name: Identifier; moduleReference: ModuleReference; } - interface ExternalModuleReference extends Node { + export interface ExternalModuleReference extends Node { kind: SyntaxKind.ExternalModuleReference; parent: ImportEqualsDeclaration; expression: Expression; } - interface ImportDeclaration extends Statement { + export interface ImportDeclaration extends Statement { kind: SyntaxKind.ImportDeclaration; parent: SourceFile | ModuleBlock; importClause?: ImportClause; /** If this is not a StringLiteral it will be a grammar error. */ moduleSpecifier: Expression; } - type NamedImportBindings = NamespaceImport | NamedImports; - interface ImportClause extends NamedDeclaration { + export type NamedImportBindings = NamespaceImport | NamedImports; + export interface ImportClause extends NamedDeclaration { kind: SyntaxKind.ImportClause; parent: ImportDeclaration; name?: Identifier; namedBindings?: NamedImportBindings; } - interface NamespaceImport extends NamedDeclaration { + export interface NamespaceImport extends NamedDeclaration { kind: SyntaxKind.NamespaceImport; parent: ImportClause; name: Identifier; } - interface NamespaceExportDeclaration extends DeclarationStatement { + export interface NamespaceExportDeclaration extends DeclarationStatement { kind: SyntaxKind.NamespaceExportDeclaration; name: Identifier; } - interface ExportDeclaration extends DeclarationStatement, JSDocContainer { + export interface ExportDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ExportDeclaration; parent: SourceFile | ModuleBlock; /** Will not be assigned in the case of `export * from "foo";` */ @@ -1476,161 +1481,166 @@ declare namespace ts { /** If this is not a StringLiteral it will be a grammar error. */ moduleSpecifier?: Expression; } - interface NamedImports extends Node { + export interface NamedImports extends Node { kind: SyntaxKind.NamedImports; parent: ImportClause; elements: NodeArray; } - interface NamedExports extends Node { + export interface NamedExports extends Node { kind: SyntaxKind.NamedExports; parent: ExportDeclaration; elements: NodeArray; } - type NamedImportsOrExports = NamedImports | NamedExports; - interface ImportSpecifier extends NamedDeclaration { + export type NamedImportsOrExports = NamedImports | NamedExports; + export interface ImportSpecifier extends NamedDeclaration { kind: SyntaxKind.ImportSpecifier; parent: NamedImports; propertyName?: Identifier; name: Identifier; } - interface ExportSpecifier extends NamedDeclaration { + export interface ExportSpecifier extends NamedDeclaration { kind: SyntaxKind.ExportSpecifier; parent: NamedExports; propertyName?: Identifier; name: Identifier; } - type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; + export type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; /** * This is either an `export =` or an `export default` declaration. * Unless `isExportEquals` is set, this node was parsed as an `export default`. */ - interface ExportAssignment extends DeclarationStatement { + export interface ExportAssignment extends DeclarationStatement { kind: SyntaxKind.ExportAssignment; parent: SourceFile; isExportEquals?: boolean; expression: Expression; } - interface FileReference extends TextRange { + export interface FileReference extends TextRange { fileName: string; } - interface CheckJsDirective extends TextRange { + export interface CheckJsDirective extends TextRange { enabled: boolean; } - type CommentKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia; - interface CommentRange extends TextRange { + export type CommentKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia; + export interface CommentRange extends TextRange { hasTrailingNewLine?: boolean; kind: CommentKind; } - interface SynthesizedComment extends CommentRange { + export interface SynthesizedComment extends CommentRange { text: string; pos: -1; end: -1; } - interface JSDocTypeExpression extends TypeNode { + export interface JSDocTypeExpression extends TypeNode { kind: SyntaxKind.JSDocTypeExpression; type: TypeNode; } - interface JSDocType extends TypeNode { + export interface JSDocType extends TypeNode { _jsDocTypeBrand: any; } - interface JSDocAllType extends JSDocType { + export interface JSDocAllType extends JSDocType { kind: SyntaxKind.JSDocAllType; } - interface JSDocUnknownType extends JSDocType { + export interface JSDocUnknownType extends JSDocType { kind: SyntaxKind.JSDocUnknownType; } - interface JSDocNonNullableType extends JSDocType { + export interface JSDocNonNullableType extends JSDocType { kind: SyntaxKind.JSDocNonNullableType; type: TypeNode; } - interface JSDocNullableType extends JSDocType { + export interface JSDocNullableType extends JSDocType { kind: SyntaxKind.JSDocNullableType; type: TypeNode; } - interface JSDocOptionalType extends JSDocType { + export interface JSDocOptionalType extends JSDocType { kind: SyntaxKind.JSDocOptionalType; type: TypeNode; } - interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase { + export interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase { kind: SyntaxKind.JSDocFunctionType; } - interface JSDocVariadicType extends JSDocType { + export interface JSDocVariadicType extends JSDocType { kind: SyntaxKind.JSDocVariadicType; type: TypeNode; } - type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; - interface JSDoc extends Node { + export interface JSDocNamepathType extends JSDocType { + kind: SyntaxKind.JSDocNamepathType; + type: TypeNode; + } + export type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; + export interface JSDoc extends Node { kind: SyntaxKind.JSDocComment; parent: HasJSDoc; tags?: NodeArray; comment?: string; } - interface JSDocTag extends Node { + export interface JSDocTag extends Node { parent: JSDoc | JSDocTypeLiteral; tagName: Identifier; comment?: string; } - interface JSDocUnknownTag extends JSDocTag { + export interface JSDocUnknownTag extends JSDocTag { kind: SyntaxKind.JSDocTag; } /** * Note that `@extends` is a synonym of `@augments`. * Both tags are represented by this interface. */ - interface JSDocAugmentsTag extends JSDocTag { + export interface JSDocAugmentsTag extends JSDocTag { kind: SyntaxKind.JSDocAugmentsTag; class: ExpressionWithTypeArguments & { expression: Identifier | PropertyAccessEntityNameExpression; }; } - interface JSDocAuthorTag extends JSDocTag { + export interface JSDocAuthorTag extends JSDocTag { kind: SyntaxKind.JSDocAuthorTag; } - interface JSDocClassTag extends JSDocTag { + export interface JSDocClassTag extends JSDocTag { kind: SyntaxKind.JSDocClassTag; } - interface JSDocEnumTag extends JSDocTag { + export interface JSDocEnumTag extends JSDocTag, Declaration { + parent: JSDoc; kind: SyntaxKind.JSDocEnumTag; typeExpression?: JSDocTypeExpression; } - interface JSDocThisTag extends JSDocTag { + export interface JSDocThisTag extends JSDocTag { kind: SyntaxKind.JSDocThisTag; typeExpression?: JSDocTypeExpression; } - interface JSDocTemplateTag extends JSDocTag { + export interface JSDocTemplateTag extends JSDocTag { kind: SyntaxKind.JSDocTemplateTag; constraint: JSDocTypeExpression | undefined; typeParameters: NodeArray; } - interface JSDocReturnTag extends JSDocTag { + export interface JSDocReturnTag extends JSDocTag { kind: SyntaxKind.JSDocReturnTag; typeExpression?: JSDocTypeExpression; } - interface JSDocTypeTag extends JSDocTag { + export interface JSDocTypeTag extends JSDocTag { kind: SyntaxKind.JSDocTypeTag; typeExpression: JSDocTypeExpression; } - interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { + export interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { parent: JSDoc; kind: SyntaxKind.JSDocTypedefTag; fullName?: JSDocNamespaceDeclaration | Identifier; name?: Identifier; typeExpression?: JSDocTypeExpression | JSDocTypeLiteral; } - interface JSDocCallbackTag extends JSDocTag, NamedDeclaration { + export interface JSDocCallbackTag extends JSDocTag, NamedDeclaration { parent: JSDoc; kind: SyntaxKind.JSDocCallbackTag; fullName?: JSDocNamespaceDeclaration | Identifier; name?: Identifier; typeExpression: JSDocSignature; } - interface JSDocSignature extends JSDocType, Declaration { + export interface JSDocSignature extends JSDocType, Declaration { kind: SyntaxKind.JSDocSignature; - typeParameters?: ReadonlyArray; - parameters: ReadonlyArray; + typeParameters?: readonly JSDocTemplateTag[]; + parameters: readonly JSDocParameterTag[]; type: JSDocReturnTag | undefined; } - interface JSDocPropertyLikeTag extends JSDocTag, Declaration { + export interface JSDocPropertyLikeTag extends JSDocTag, Declaration { parent: JSDoc; name: EntityName; typeExpression?: JSDocTypeExpression; @@ -1638,19 +1648,19 @@ declare namespace ts { isNameFirst: boolean; isBracketed: boolean; } - interface JSDocPropertyTag extends JSDocPropertyLikeTag { + export interface JSDocPropertyTag extends JSDocPropertyLikeTag { kind: SyntaxKind.JSDocPropertyTag; } - interface JSDocParameterTag extends JSDocPropertyLikeTag { + export interface JSDocParameterTag extends JSDocPropertyLikeTag { kind: SyntaxKind.JSDocParameterTag; } - interface JSDocTypeLiteral extends JSDocType { + export interface JSDocTypeLiteral extends JSDocType { kind: SyntaxKind.JSDocTypeLiteral; - jsDocPropertyTags?: ReadonlyArray; + jsDocPropertyTags?: readonly JSDocPropertyLikeTag[]; /** If true, then this type literal represents an *array* of its type. */ isArrayType?: boolean; } - enum FlowFlags { + export enum FlowFlags { Unreachable = 1, Start = 2, BranchLabel = 4, @@ -1667,65 +1677,65 @@ declare namespace ts { Label = 12, Condition = 96 } - interface FlowLock { + export interface FlowLock { locked?: boolean; } - interface AfterFinallyFlow extends FlowNodeBase, FlowLock { + export interface AfterFinallyFlow extends FlowNodeBase, FlowLock { antecedent: FlowNode; } - interface PreFinallyFlow extends FlowNodeBase { + export interface PreFinallyFlow extends FlowNodeBase { antecedent: FlowNode; lock: FlowLock; } - type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation; - interface FlowNodeBase { + export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation; + export interface FlowNodeBase { flags: FlowFlags; id?: number; } - interface FlowStart extends FlowNodeBase { + export interface FlowStart extends FlowNodeBase { container?: FunctionExpression | ArrowFunction | MethodDeclaration; } - interface FlowLabel extends FlowNodeBase { + export interface FlowLabel extends FlowNodeBase { antecedents: FlowNode[] | undefined; } - interface FlowAssignment extends FlowNodeBase { + export interface FlowAssignment extends FlowNodeBase { node: Expression | VariableDeclaration | BindingElement; antecedent: FlowNode; } - interface FlowCondition extends FlowNodeBase { + export interface FlowCondition extends FlowNodeBase { expression: Expression; antecedent: FlowNode; } - interface FlowSwitchClause extends FlowNodeBase { + export interface FlowSwitchClause extends FlowNodeBase { switchStatement: SwitchStatement; clauseStart: number; clauseEnd: number; antecedent: FlowNode; } - interface FlowArrayMutation extends FlowNodeBase { + export interface FlowArrayMutation extends FlowNodeBase { node: CallExpression | BinaryExpression; antecedent: FlowNode; } - type FlowType = Type | IncompleteType; - interface IncompleteType { + export type FlowType = Type | IncompleteType; + export interface IncompleteType { flags: TypeFlags; type: Type; } - interface AmdDependency { + export interface AmdDependency { path: string; name?: string; } - interface SourceFile extends Declaration { + export interface SourceFile extends Declaration { kind: SyntaxKind.SourceFile; statements: NodeArray; endOfFileToken: Token; fileName: string; text: string; - amdDependencies: ReadonlyArray; + amdDependencies: readonly AmdDependency[]; moduleName?: string; - referencedFiles: ReadonlyArray; - typeReferenceDirectives: ReadonlyArray; - libReferenceDirectives: ReadonlyArray; + referencedFiles: readonly FileReference[]; + typeReferenceDirectives: readonly FileReference[]; + libReferenceDirectives: readonly FileReference[]; languageVariant: LanguageVariant; isDeclarationFile: boolean; /** @@ -1739,12 +1749,12 @@ declare namespace ts { hasNoDefaultLib: boolean; languageVersion: ScriptTarget; } - interface Bundle extends Node { + export interface Bundle extends Node { kind: SyntaxKind.Bundle; - prepends: ReadonlyArray; - sourceFiles: ReadonlyArray; + prepends: readonly (InputFiles | UnparsedSource)[]; + sourceFiles: readonly SourceFile[]; } - interface InputFiles extends Node { + export interface InputFiles extends Node { kind: SyntaxKind.InputFiles; javascriptPath?: string; javascriptText: string; @@ -1755,70 +1765,70 @@ declare namespace ts { declarationMapPath?: string; declarationMapText?: string; } - interface UnparsedSource extends Node { + export interface UnparsedSource extends Node { kind: SyntaxKind.UnparsedSource; fileName: string; text: string; - prologues: ReadonlyArray; - helpers: ReadonlyArray | undefined; - referencedFiles: ReadonlyArray; - typeReferenceDirectives: ReadonlyArray | undefined; - libReferenceDirectives: ReadonlyArray; + prologues: readonly UnparsedPrologue[]; + helpers: readonly UnscopedEmitHelper[] | undefined; + referencedFiles: readonly FileReference[]; + typeReferenceDirectives: readonly string[] | undefined; + libReferenceDirectives: readonly FileReference[]; hasNoDefaultLib?: boolean; sourceMapPath?: string; sourceMapText?: string; - syntheticReferences?: ReadonlyArray; - texts: ReadonlyArray; + syntheticReferences?: readonly UnparsedSyntheticReference[]; + texts: readonly UnparsedSourceText[]; } - type UnparsedSourceText = UnparsedPrepend | UnparsedTextLike; - type UnparsedNode = UnparsedPrologue | UnparsedSourceText | UnparsedSyntheticReference; - interface UnparsedSection extends Node { + export type UnparsedSourceText = UnparsedPrepend | UnparsedTextLike; + export type UnparsedNode = UnparsedPrologue | UnparsedSourceText | UnparsedSyntheticReference; + export interface UnparsedSection extends Node { kind: SyntaxKind; data?: string; parent: UnparsedSource; } - interface UnparsedPrologue extends UnparsedSection { + export interface UnparsedPrologue extends UnparsedSection { kind: SyntaxKind.UnparsedPrologue; data: string; parent: UnparsedSource; } - interface UnparsedPrepend extends UnparsedSection { + export interface UnparsedPrepend extends UnparsedSection { kind: SyntaxKind.UnparsedPrepend; data: string; parent: UnparsedSource; - texts: ReadonlyArray; + texts: readonly UnparsedTextLike[]; } - interface UnparsedTextLike extends UnparsedSection { + export interface UnparsedTextLike extends UnparsedSection { kind: SyntaxKind.UnparsedText | SyntaxKind.UnparsedInternalText; parent: UnparsedSource; } - interface UnparsedSyntheticReference extends UnparsedSection { + export interface UnparsedSyntheticReference extends UnparsedSection { kind: SyntaxKind.UnparsedSyntheticReference; parent: UnparsedSource; } - interface JsonSourceFile extends SourceFile { + export interface JsonSourceFile extends SourceFile { statements: NodeArray; } - interface TsConfigSourceFile extends JsonSourceFile { + export interface TsConfigSourceFile extends JsonSourceFile { extendedSourceFiles?: string[]; } - interface JsonMinusNumericLiteral extends PrefixUnaryExpression { + export interface JsonMinusNumericLiteral extends PrefixUnaryExpression { kind: SyntaxKind.PrefixUnaryExpression; operator: SyntaxKind.MinusToken; operand: NumericLiteral; } - interface JsonObjectExpressionStatement extends ExpressionStatement { + export interface JsonObjectExpressionStatement extends ExpressionStatement { expression: ObjectLiteralExpression | ArrayLiteralExpression | JsonMinusNumericLiteral | NumericLiteral | StringLiteral | BooleanLiteral | NullLiteral; } - interface ScriptReferenceHost { + export interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; getSourceFile(fileName: string): SourceFile | undefined; getSourceFileByPath(path: Path): SourceFile | undefined; getCurrentDirectory(): string; } - interface ParseConfigHost { + export interface ParseConfigHost { useCaseSensitiveFileNames: boolean; - readDirectory(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): ReadonlyArray; + readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): readonly string[]; /** * Gets a value indicating whether the specified path exists and is a file. * @param path The path to test. @@ -1832,26 +1842,26 @@ declare namespace ts { * specified like "./blah" to an absolute path to an actual * tsconfig file, e.g. "/root/blah/tsconfig.json" */ - type ResolvedConfigFileName = string & { + export type ResolvedConfigFileName = string & { _isResolvedConfigFileName: never; }; - type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: ReadonlyArray) => void; - class OperationCanceledException { + export type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[]) => void; + export class OperationCanceledException { } - interface CancellationToken { + export interface CancellationToken { isCancellationRequested(): boolean; /** @throws OperationCanceledException if isCancellationRequested is true */ throwIfCancellationRequested(): void; } - interface Program extends ScriptReferenceHost { + export interface Program extends ScriptReferenceHost { /** * Get a list of root file names that were passed to a 'createProgram' */ - getRootFileNames(): ReadonlyArray; + getRootFileNames(): readonly string[]; /** * Get a list of files in the program */ - getSourceFiles(): ReadonlyArray; + getSourceFiles(): readonly SourceFile[]; /** * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then * the JavaScript and declaration files will be produced for all the files in this program. @@ -1863,33 +1873,42 @@ declare namespace ts { * will be invoked when writing the JavaScript and declaration files. */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; /** The first time this is called, it will return global diagnostics (no location). */ - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getConfigFileParsingDiagnostics(): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; /** * Gets a type checker that can be used to semantically analyze source files in the program. */ getTypeChecker(): TypeChecker; + getNodeCount(): number; + getIdentifierCount(): number; + getSymbolCount(): number; + getTypeCount(): number; + getRelationCacheSizes(): { + assignable: number; + identity: number; + subtype: number; + }; isSourceFileFromExternalLibrary(file: SourceFile): boolean; isSourceFileDefaultLibrary(file: SourceFile): boolean; - getProjectReferences(): ReadonlyArray | undefined; - getResolvedProjectReferences(): ReadonlyArray | undefined; + getProjectReferences(): readonly ProjectReference[] | undefined; + getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined; } - interface ResolvedProjectReference { + export interface ResolvedProjectReference { commandLine: ParsedCommandLine; sourceFile: SourceFile; - references?: ReadonlyArray; + references?: readonly (ResolvedProjectReference | undefined)[]; } - type CustomTransformerFactory = (context: TransformationContext) => CustomTransformer; - interface CustomTransformer { + export type CustomTransformerFactory = (context: TransformationContext) => CustomTransformer; + export interface CustomTransformer { transformSourceFile(node: SourceFile): SourceFile; transformBundle(node: Bundle): Bundle; } - interface CustomTransformers { + export interface CustomTransformers { /** Custom transformers to evaluate before built-in .js transformations. */ before?: (TransformerFactory | CustomTransformerFactory)[]; /** Custom transformers to evaluate after built-in .js transformations. */ @@ -1897,7 +1916,7 @@ declare namespace ts { /** Custom transformers to evaluate after built-in .d.ts transformations. */ afterDeclarations?: (TransformerFactory | CustomTransformerFactory)[]; } - interface SourceMapSpan { + export interface SourceMapSpan { /** Line number in the .js file. */ emittedLine: number; /** Column number in the .js file. */ @@ -1912,25 +1931,26 @@ declare namespace ts { sourceIndex: number; } /** Return code used by getEmitOutput function to indicate status of the function */ - enum ExitStatus { + export enum ExitStatus { Success = 0, DiagnosticsPresent_OutputsSkipped = 1, DiagnosticsPresent_OutputsGenerated = 2, - InvalidProject_OutputsSkipped = 3 + InvalidProject_OutputsSkipped = 3, + ProjectReferenceCycle_OutputsSkupped = 4 } - interface EmitResult { + export interface EmitResult { emitSkipped: boolean; /** Contains declaration emit diagnostics */ - diagnostics: ReadonlyArray; + diagnostics: readonly Diagnostic[]; emittedFiles?: string[]; } - interface TypeChecker { + export interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; getDeclaredTypeOfSymbol(symbol: Symbol): Type; getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol | undefined; getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined; - getSignaturesOfType(type: Type, kind: SignatureKind): ReadonlyArray; + getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined; getBaseTypes(type: InterfaceType): BaseType[]; getBaseTypeOfLiteralType(type: Type): Type; @@ -1984,7 +2004,7 @@ declare namespace ts { typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; - getRootSymbols(symbol: Symbol): ReadonlyArray; + getRootSymbols(symbol: Symbol): readonly Symbol[]; getContextualType(node: Expression): Type | undefined; /** * returns unknownSignature in the case of an error. @@ -2016,7 +2036,7 @@ declare namespace ts { */ runWithCancellationToken(token: CancellationToken, cb: (checker: TypeChecker) => T): T; } - enum NodeBuilderFlags { + export enum NodeBuilderFlags { None = 0, NoTruncation = 1, WriteArrayAsGenericType = 2, @@ -2047,7 +2067,7 @@ declare namespace ts { InInitialEntityName = 16777216, InReverseMappedType = 33554432 } - enum TypeFormatFlags { + export enum TypeFormatFlags { None = 0, NoTruncation = 1, WriteArrayAsGenericType = 2, @@ -2070,31 +2090,31 @@ declare namespace ts { /** @deprecated */ WriteOwnNameForAnyLike = 0, NodeBuilderFlagsMask = 9469291 } - enum SymbolFormatFlags { + export enum SymbolFormatFlags { None = 0, WriteTypeParametersOrArguments = 1, UseOnlyExternalAliasing = 2, AllowAnyNodeKind = 4, UseAliasDefinedOutsideCurrentScope = 8, } - enum TypePredicateKind { + export enum TypePredicateKind { This = 0, Identifier = 1 } - interface TypePredicateBase { + export interface TypePredicateBase { kind: TypePredicateKind; type: Type; } - interface ThisTypePredicate extends TypePredicateBase { + export interface ThisTypePredicate extends TypePredicateBase { kind: TypePredicateKind.This; } - interface IdentifierTypePredicate extends TypePredicateBase { + export interface IdentifierTypePredicate extends TypePredicateBase { kind: TypePredicateKind.Identifier; parameterName: string; parameterIndex: number; } - type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; - enum SymbolFlags { + export type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; + export enum SymbolFlags { None = 0, FunctionScopedVariable = 1, BlockScopedVariable = 2, @@ -2126,28 +2146,28 @@ declare namespace ts { ModuleExports = 134217728, Enum = 384, Variable = 3, - Value = 67220415, - Type = 67897832, + Value = 111551, + Type = 788968, Namespace = 1920, Module = 1536, Accessor = 98304, - FunctionScopedVariableExcludes = 67220414, - BlockScopedVariableExcludes = 67220415, - ParameterExcludes = 67220415, + FunctionScopedVariableExcludes = 111550, + BlockScopedVariableExcludes = 111551, + ParameterExcludes = 111551, PropertyExcludes = 0, - EnumMemberExcludes = 68008959, - FunctionExcludes = 67219887, - ClassExcludes = 68008383, - InterfaceExcludes = 67897736, - RegularEnumExcludes = 68008191, - ConstEnumExcludes = 68008831, + EnumMemberExcludes = 900095, + FunctionExcludes = 110991, + ClassExcludes = 899503, + InterfaceExcludes = 788872, + RegularEnumExcludes = 899327, + ConstEnumExcludes = 899967, ValueModuleExcludes = 110735, NamespaceModuleExcludes = 0, - MethodExcludes = 67212223, - GetAccessorExcludes = 67154879, - SetAccessorExcludes = 67187647, - TypeParameterExcludes = 67635688, - TypeAliasExcludes = 67897832, + MethodExcludes = 103359, + GetAccessorExcludes = 46015, + SetAccessorExcludes = 78783, + TypeParameterExcludes = 526824, + TypeAliasExcludes = 788968, AliasExcludes = 2097152, ModuleMember = 2623475, ExportHasLocal = 944, @@ -2155,7 +2175,7 @@ declare namespace ts { PropertyOrAccessor = 98308, ClassMember = 106500, } - interface Symbol { + export interface Symbol { flags: SymbolFlags; escapedName: __String; declarations: Declaration[]; @@ -2164,7 +2184,7 @@ declare namespace ts { exports?: SymbolTable; globalExports?: SymbolTable; } - enum InternalSymbolName { + export enum InternalSymbolName { Call = "__call", Constructor = "__constructor", New = "__new", @@ -2191,13 +2211,13 @@ declare namespace ts { * with a normal string (which is good, it cannot be misused on assignment or on usage), * while still being comparable with a normal string via === (also good) and castable from a string. */ - type __String = (string & { + export type __String = (string & { __escapedIdentifier: void; }) | (void & { __escapedIdentifier: void; }) | InternalSymbolName; /** ReadonlyMap where keys are `__String`s. */ - interface ReadonlyUnderscoreEscapedMap { + export interface ReadonlyUnderscoreEscapedMap { get(key: __String): T | undefined; has(key: __String): boolean; forEach(action: (value: T, key: __String) => void): void; @@ -2207,14 +2227,14 @@ declare namespace ts { entries(): Iterator<[__String, T]>; } /** Map where keys are `__String`s. */ - interface UnderscoreEscapedMap extends ReadonlyUnderscoreEscapedMap { + export interface UnderscoreEscapedMap extends ReadonlyUnderscoreEscapedMap { set(key: __String, value: T): this; delete(key: __String): boolean; clear(): void; } /** SymbolTable based on ES6 Map interface. */ - type SymbolTable = UnderscoreEscapedMap; - enum TypeFlags { + export type SymbolTable = UnderscoreEscapedMap; + export enum TypeFlags { Any = 1, Unknown = 2, String = 4, @@ -2242,6 +2262,7 @@ declare namespace ts { Conditional = 16777216, Substitution = 33554432, NonPrimitive = 67108864, + StructuralTag = 134217728, Literal = 2944, Unit = 109440, StringOrNumberLiteral = 384, @@ -2254,44 +2275,44 @@ declare namespace ts { ESSymbolLike = 12288, VoidLike = 49152, UnionOrIntersection = 3145728, - StructuredType = 3670016, + StructuredType = 137887744, TypeVariable = 8650752, InstantiableNonPrimitive = 58982400, InstantiablePrimitive = 4194304, Instantiable = 63176704, - StructuredOrInstantiable = 66846720, - Narrowable = 133970943, + StructuredOrInstantiable = 201064448, + Narrowable = 268188671, NotUnionOrUnit = 67637251, } - type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; - interface Type { + export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; + export interface Type { flags: TypeFlags; symbol: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; - aliasTypeArguments?: ReadonlyArray; + aliasTypeArguments?: readonly Type[]; } - interface LiteralType extends Type { + export interface LiteralType extends Type { value: string | number | PseudoBigInt; freshType: LiteralType; regularType: LiteralType; } - interface UniqueESSymbolType extends Type { + export interface UniqueESSymbolType extends Type { symbol: Symbol; escapedName: __String; } - interface StringLiteralType extends LiteralType { + export interface StringLiteralType extends LiteralType { value: string; } - interface NumberLiteralType extends LiteralType { + export interface NumberLiteralType extends LiteralType { value: number; } - interface BigIntLiteralType extends LiteralType { + export interface BigIntLiteralType extends LiteralType { value: PseudoBigInt; } - interface EnumType extends Type { + export interface EnumType extends Type { } - enum ObjectFlags { + export enum ObjectFlags { Class = 1, Interface = 2, Reference = 4, @@ -2311,18 +2332,18 @@ declare namespace ts { ArrayLiteral = 65536, ClassOrInterface = 3, } - interface ObjectType extends Type { + export interface ObjectType extends Type { objectFlags: ObjectFlags; } /** Class and interface types (ObjectFlags.Class and ObjectFlags.Interface). */ - interface InterfaceType extends ObjectType { + export interface InterfaceType extends ObjectType { typeParameters: TypeParameter[] | undefined; outerTypeParameters: TypeParameter[] | undefined; localTypeParameters: TypeParameter[] | undefined; thisType: TypeParameter | undefined; } - type BaseType = ObjectType | IntersectionType; - interface InterfaceTypeWithDeclaredMembers extends InterfaceType { + export type BaseType = ObjectType | IntersectionType; + export interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; declaredConstructSignatures: Signature[]; @@ -2339,49 +2360,49 @@ declare namespace ts { * if the class or interface has no type parameters and the reference isn't specifying an * explicit "this" argument. */ - interface TypeReference extends ObjectType { + export interface TypeReference extends ObjectType { target: GenericType; - typeArguments?: ReadonlyArray; + typeArguments?: readonly Type[]; } - interface GenericType extends InterfaceType, TypeReference { + export interface GenericType extends InterfaceType, TypeReference { } - interface TupleType extends GenericType { + export interface TupleType extends GenericType { minLength: number; hasRestElement: boolean; readonly: boolean; associatedNames?: __String[]; } - interface TupleTypeReference extends TypeReference { + export interface TupleTypeReference extends TypeReference { target: TupleType; } - interface UnionOrIntersectionType extends Type { + export interface UnionOrIntersectionType extends Type { types: Type[]; } - interface UnionType extends UnionOrIntersectionType { + export interface UnionType extends UnionOrIntersectionType { } - interface IntersectionType extends UnionOrIntersectionType { + export interface IntersectionType extends UnionOrIntersectionType { } - type StructuredType = ObjectType | UnionType | IntersectionType; - interface EvolvingArrayType extends ObjectType { + export type StructuredType = ObjectType | UnionType | IntersectionType | StructuralTagType; + export interface EvolvingArrayType extends ObjectType { elementType: Type; finalArrayType?: Type; } - interface InstantiableType extends Type { + export interface InstantiableType extends Type { } - interface TypeParameter extends InstantiableType { + export interface TypeParameter extends InstantiableType { } - interface IndexedAccessType extends InstantiableType { + export interface IndexedAccessType extends InstantiableType { objectType: Type; indexType: Type; constraint?: Type; simplifiedForReading?: Type; simplifiedForWriting?: Type; } - type TypeVariable = TypeParameter | IndexedAccessType; - interface IndexType extends InstantiableType { + export type TypeVariable = TypeParameter | IndexedAccessType; + export interface IndexType extends InstantiableType { type: InstantiableType | UnionOrIntersectionType; } - interface ConditionalRoot { + export interface ConditionalRoot { node: ConditionalTypeNode; checkType: Type; extendsType: Type; @@ -2394,36 +2415,39 @@ declare namespace ts { aliasSymbol?: Symbol; aliasTypeArguments?: Type[]; } - interface ConditionalType extends InstantiableType { + export interface ConditionalType extends InstantiableType { root: ConditionalRoot; checkType: Type; extendsType: Type; resolvedTrueType: Type; resolvedFalseType: Type; } - interface SubstitutionType extends InstantiableType { + export interface SubstitutionType extends InstantiableType { typeVariable: TypeVariable; substitute: Type; } - enum SignatureKind { + export interface StructuralTagType extends Type { + type: Type; + } + export enum SignatureKind { Call = 0, Construct = 1 } - interface Signature { + export interface Signature { declaration?: SignatureDeclaration | JSDocSignature; - typeParameters?: ReadonlyArray; - parameters: ReadonlyArray; + typeParameters?: readonly TypeParameter[]; + parameters: readonly Symbol[]; } - enum IndexKind { + export enum IndexKind { String = 0, Number = 1 } - interface IndexInfo { + export interface IndexInfo { type: Type; isReadonly: boolean; declaration?: IndexSignatureDeclaration; } - enum InferencePriority { + export enum InferencePriority { NakedTypeVariable = 1, HomomorphicMappedType = 2, PartialHomomorphicMappedType = 4, @@ -2432,16 +2456,18 @@ declare namespace ts { LiteralKeyof = 32, NoConstraints = 64, AlwaysStrict = 128, - PriorityImpliesCombination = 56 + MaxValue = 256, + PriorityImpliesCombination = 56, + Circularity = -1 } /** @deprecated Use FileExtensionInfo instead. */ - type JsFileExtensionInfo = FileExtensionInfo; - interface FileExtensionInfo { + export type JsFileExtensionInfo = FileExtensionInfo; + export interface FileExtensionInfo { extension: string; isMixedContent: boolean; scriptKind?: ScriptKind; } - interface DiagnosticMessage { + export interface DiagnosticMessage { key: string; category: DiagnosticCategory; code: number; @@ -2454,19 +2480,19 @@ declare namespace ts { * While it seems that DiagnosticMessageChain is structurally similar to DiagnosticMessage, * the difference is that messages are all preformatted in DMC. */ - interface DiagnosticMessageChain { + export interface DiagnosticMessageChain { messageText: string; category: DiagnosticCategory; code: number; next?: DiagnosticMessageChain[]; } - interface Diagnostic extends DiagnosticRelatedInformation { + export interface Diagnostic extends DiagnosticRelatedInformation { /** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */ reportsUnnecessary?: {}; source?: string; relatedInformation?: DiagnosticRelatedInformation[]; } - interface DiagnosticRelatedInformation { + export interface DiagnosticRelatedInformation { category: DiagnosticCategory; code: number; file: SourceFile | undefined; @@ -2474,25 +2500,25 @@ declare namespace ts { length: number | undefined; messageText: string | DiagnosticMessageChain; } - interface DiagnosticWithLocation extends Diagnostic { + export interface DiagnosticWithLocation extends Diagnostic { file: SourceFile; start: number; length: number; } - enum DiagnosticCategory { + export enum DiagnosticCategory { Warning = 0, Error = 1, Suggestion = 2, Message = 3 } - enum ModuleResolutionKind { + export enum ModuleResolutionKind { Classic = 1, NodeJs = 2 } - interface PluginImport { + export interface PluginImport { name: string; } - interface ProjectReference { + export interface ProjectReference { /** A normalized path on disk */ path: string; /** The path as the user originally wrote it */ @@ -2502,8 +2528,8 @@ declare namespace ts { /** True if it is intended that this reference form a circularity */ circular?: boolean; } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; - interface CompilerOptions { + export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; + export interface CompilerOptions { allowJs?: boolean; allowSyntheticDefaultImports?: boolean; allowUmdGlobalAccess?: boolean; @@ -2586,14 +2612,14 @@ declare namespace ts { esModuleInterop?: boolean; [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } - interface TypeAcquisition { + export interface TypeAcquisition { enableAutoDiscovery?: boolean; enable?: boolean; include?: string[]; exclude?: string[]; [option: string]: string[] | boolean | undefined; } - enum ModuleKind { + export enum ModuleKind { None = 0, CommonJS = 1, AMD = 2, @@ -2602,22 +2628,22 @@ declare namespace ts { ES2015 = 5, ESNext = 99 } - enum JsxEmit { + export enum JsxEmit { None = 0, Preserve = 1, React = 2, ReactNative = 3 } - enum NewLineKind { + export enum NewLineKind { CarriageReturnLineFeed = 0, LineFeed = 1 } - interface LineAndCharacter { + export interface LineAndCharacter { /** 0-based. */ line: number; character: number; } - enum ScriptKind { + export enum ScriptKind { Unknown = 0, JS = 1, JSX = 2, @@ -2631,7 +2657,7 @@ declare namespace ts { */ Deferred = 7 } - enum ScriptTarget { + export enum ScriptTarget { ES3 = 0, ES5 = 1, ES2015 = 2, @@ -2644,38 +2670,38 @@ declare namespace ts { JSON = 100, Latest = 99 } - enum LanguageVariant { + export enum LanguageVariant { Standard = 0, JSX = 1 } /** Either a parsed command line or a parsed tsconfig.json */ - interface ParsedCommandLine { + export interface ParsedCommandLine { options: CompilerOptions; typeAcquisition?: TypeAcquisition; fileNames: string[]; - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; raw?: any; errors: Diagnostic[]; wildcardDirectories?: MapLike; compileOnSave?: boolean; } - enum WatchDirectoryFlags { + export enum WatchDirectoryFlags { None = 0, Recursive = 1 } - interface ExpandResult { + export interface ExpandResult { fileNames: string[]; wildcardDirectories: MapLike; } - interface CreateProgramOptions { - rootNames: ReadonlyArray; + export interface CreateProgramOptions { + rootNames: readonly string[]; options: CompilerOptions; - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; host?: CompilerHost; oldProgram?: Program; - configFileParsingDiagnostics?: ReadonlyArray; + configFileParsingDiagnostics?: readonly Diagnostic[]; } - interface ModuleResolutionHost { + export interface ModuleResolutionHost { fileExists(fileName: string): boolean; readFile(fileName: string): string | undefined; trace?(s: string): void; @@ -2695,7 +2721,7 @@ declare namespace ts { * * Prefer to return a `ResolvedModuleFull` so that the file type does not have to be inferred. */ - interface ResolvedModule { + export interface ResolvedModule { /** Path of the file the module was resolved to. */ resolvedFileName: string; /** True if `resolvedFileName` comes from `node_modules`. */ @@ -2706,7 +2732,7 @@ declare namespace ts { * Prefer this over `ResolvedModule`. * If changing this, remember to change `moduleResolutionIsEqualTo`. */ - interface ResolvedModuleFull extends ResolvedModule { + export interface ResolvedModuleFull extends ResolvedModule { /** * Extension of resolvedFileName. This must match what's at the end of resolvedFileName. * This is optional for backwards-compatibility, but will be added if not provided. @@ -2718,7 +2744,7 @@ declare namespace ts { * Unique identifier with a package name and version. * If changing this, remember to change `packageIdIsEqual`. */ - interface PackageId { + export interface PackageId { /** * Name of the package. * Should not include `@types`. @@ -2733,7 +2759,7 @@ declare namespace ts { /** Version of the package, e.g. "1.2.3" */ version: string; } - enum Extension { + export enum Extension { Ts = ".ts", Tsx = ".tsx", Dts = ".d.ts", @@ -2742,21 +2768,21 @@ declare namespace ts { Json = ".json", TsBuildInfo = ".tsbuildinfo" } - interface ResolvedModuleWithFailedLookupLocations { + export interface ResolvedModuleWithFailedLookupLocations { readonly resolvedModule: ResolvedModuleFull | undefined; } - interface ResolvedTypeReferenceDirective { + export interface ResolvedTypeReferenceDirective { primary: boolean; resolvedFileName: string | undefined; packageId?: PackageId; /** True if `resolvedFileName` comes from `node_modules`. */ isExternalLibraryImport?: boolean; } - interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { + export interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; - readonly failedLookupLocations: ReadonlyArray; + readonly failedLookupLocations: readonly string[]; } - interface CompilerHost extends ModuleResolutionHost { + export interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; getCancellationToken?(): CancellationToken; @@ -2767,25 +2793,25 @@ declare namespace ts { getCanonicalFileName(fileName: string): string; useCaseSensitiveFileNames(): boolean; getNewLine(): string; - readDirectory?(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): string[]; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; + readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; /** * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[]; getEnvironmentVariable?(name: string): string | undefined; createHash?(data: string): string; getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; } - interface SourceMapRange extends TextRange { + export interface SourceMapRange extends TextRange { source?: SourceMapSource; } - interface SourceMapSource { + export interface SourceMapSource { fileName: string; text: string; skipTrivia?: (pos: number) => number; } - enum EmitFlags { + export enum EmitFlags { None = 0, SingleLine = 1, AdviseOnEmitNode = 2, @@ -2816,18 +2842,18 @@ declare namespace ts { Iterator = 8388608, NoAsciiEscaping = 16777216, } - interface EmitHelper { + export interface EmitHelper { readonly name: string; readonly scoped: boolean; readonly text: string | ((node: EmitHelperUniqueNameCallback) => string); readonly priority?: number; } - interface UnscopedEmitHelper extends EmitHelper { + export interface UnscopedEmitHelper extends EmitHelper { readonly scoped: false; readonly text: string; } - type EmitHelperUniqueNameCallback = (name: string) => string; - enum EmitHint { + export type EmitHelperUniqueNameCallback = (name: string) => string; + export enum EmitHint { SourceFile = 0, Expression = 1, IdentifierName = 2, @@ -2835,7 +2861,7 @@ declare namespace ts { Unspecified = 4, EmbeddedStatement = 5 } - interface TransformationContext { + export interface TransformationContext { /** Gets the compiler options supplied to the transformer. */ getCompilerOptions(): CompilerOptions; /** Starts a new lexical environment. */ @@ -2885,7 +2911,7 @@ declare namespace ts { */ onEmitNode: (hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) => void; } - interface TransformationResult { + export interface TransformationResult { /** Gets the transformed source files. */ transformed: T[]; /** Gets diagnostics for the transformation. */ @@ -2914,17 +2940,17 @@ declare namespace ts { * A function that is used to initialize and return a `Transformer` callback, which in turn * will be used to transform one or more nodes. */ - type TransformerFactory = (context: TransformationContext) => Transformer; + export type TransformerFactory = (context: TransformationContext) => Transformer; /** * A function that transforms a node. */ - type Transformer = (node: T) => T; + export type Transformer = (node: T) => T; /** * A function that accepts and possibly transforms a node. */ - type Visitor = (node: Node) => VisitResult; - type VisitResult = T | T[] | undefined; - interface Printer { + export type Visitor = (node: Node) => VisitResult; + export type VisitResult = T | T[] | undefined; + export interface Printer { /** * Print a node and its subtree as-is, without any emit transformations. * @param hint A value indicating the purpose of a node. This is primarily used to @@ -2952,7 +2978,7 @@ declare namespace ts { */ printBundle(bundle: Bundle): string; } - interface PrintHandlers { + export interface PrintHandlers { /** * A hook used by the Printer when generating unique names to avoid collisions with * globally defined names that exist outside of the current source file. @@ -2995,28 +3021,28 @@ declare namespace ts { */ substituteNode?(hint: EmitHint, node: Node): Node; } - interface PrinterOptions { + export interface PrinterOptions { removeComments?: boolean; newLine?: NewLineKind; omitTrailingSemicolon?: boolean; noEmitHelpers?: boolean; } - interface GetEffectiveTypeRootsHost { + export interface GetEffectiveTypeRootsHost { directoryExists?(directoryName: string): boolean; getCurrentDirectory?(): string; } - interface TextSpan { + export interface TextSpan { start: number; length: number; } - interface TextChangeRange { + export interface TextChangeRange { span: TextSpan; newLength: number; } - interface SyntaxList extends Node { + export interface SyntaxList extends Node { _children: Node[]; } - enum ListFormat { + export enum ListFormat { None = 0, SingleLine = 0, MultiLine = 1, @@ -3083,7 +3109,7 @@ declare namespace ts { IndexSignatureParameters = 8848, JSDocComment = 33 } - interface UserPreferences { + export interface UserPreferences { readonly disableSuggestions?: boolean; readonly quotePreference?: "auto" | "double" | "single"; readonly includeCompletionsForModuleExports?: boolean; @@ -3095,22 +3121,23 @@ declare namespace ts { readonly providePrefixAndSuffixTextForRename?: boolean; } /** Represents a bigint literal value without requiring bigint support */ - interface PseudoBigInt { + export interface PseudoBigInt { negative: boolean; base10Value: string; } + export {}; } declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; declare namespace ts { - enum FileWatcherEventKind { + export enum FileWatcherEventKind { Created = 0, Changed = 1, Deleted = 2 } - type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind) => void; - type DirectoryWatcherCallback = (fileName: string) => void; - interface System { + export type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind) => void; + export type DirectoryWatcherCallback = (fileName: string) => void; + export interface System { args: string[]; newLine: string; useCaseSensitiveFileNames: boolean; @@ -3132,7 +3159,7 @@ declare namespace ts { getExecutingFilePath(): string; getCurrentDirectory(): string; getDirectories(path: string): string[]; - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; getModifiedTime?(path: string): Date | undefined; setModifiedTime?(path: string, time: Date): void; deleteFile?(path: string): void; @@ -3151,11 +3178,12 @@ declare namespace ts { base64decode?(input: string): string; base64encode?(input: string): string; } - interface FileWatcher { + export interface FileWatcher { close(): void; } - function getNodeMajorVersion(): number | undefined; - let sys: System; + export function getNodeMajorVersion(): number | undefined; + export let sys: System; + export {}; } declare namespace ts { type ErrorCallback = (message: DiagnosticMessage, length: number) => void; @@ -3166,6 +3194,7 @@ declare namespace ts { getTokenPos(): number; getTokenText(): string; getTokenValue(): string; + hasUnicodeEscape(): boolean; hasExtendedUnicodeEscape(): boolean; hasPrecedingLineBreak(): boolean; isIdentifier(): boolean; @@ -3215,7 +3244,7 @@ declare namespace ts { } declare namespace ts { function isExternalModuleNameRelative(moduleName: string): boolean; - function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): SortedReadonlyArray; + function sortAndDeduplicateDiagnostics(diagnostics: readonly T[]): SortedReadonlyArray; } declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -3244,13 +3273,13 @@ declare namespace ts { * This function will then merge those changes into a single change range valid between V1 and * Vn. */ - function collapseTextChangeRangesAcrossMultipleVersions(changes: ReadonlyArray): TextChangeRange; + function collapseTextChangeRangesAcrossMultipleVersions(changes: readonly TextChangeRange[]): TextChangeRange; function getTypeParameterOwner(d: Declaration): Declaration | undefined; type ParameterPropertyDeclaration = ParameterDeclaration & { parent: ConstructorDeclaration; name: Identifier; }; - function isParameterPropertyDeclaration(node: Node): node is ParameterPropertyDeclaration; + function isParameterPropertyDeclaration(node: Node, parent: Node): node is ParameterPropertyDeclaration; function isEmptyBindingPattern(node: BindingName): node is BindingPattern; function isEmptyBindingElement(node: BindingElement): boolean; function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; @@ -3316,7 +3345,7 @@ declare namespace ts { * * For binding patterns, parameter tags are matched by position. */ - function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray; + function getJSDocParameterTags(param: ParameterDeclaration): readonly JSDocParameterTag[]; /** * Gets the JSDoc type parameter tags for the node if present. * @@ -3327,7 +3356,7 @@ declare namespace ts { * node are returned first, so in the previous example, the template * tag on the containing function expression would be first. */ - function getJSDocTypeParameterTags(param: TypeParameterDeclaration): ReadonlyArray; + function getJSDocTypeParameterTags(param: TypeParameterDeclaration): readonly JSDocTemplateTag[]; /** * Return true if the node has JSDoc parameter tags. * @@ -3369,14 +3398,14 @@ declare namespace ts { */ function getJSDocReturnType(node: Node): TypeNode | undefined; /** Get all JSDoc tags related to a node, including those on parent nodes. */ - function getJSDocTags(node: Node): ReadonlyArray; + function getJSDocTags(node: Node): readonly JSDocTag[]; /** Gets all JSDoc tags of a specified kind, or undefined if not present. */ - function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): ReadonlyArray; + function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): readonly JSDocTag[]; /** * 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): ReadonlyArray; + function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[]; function getEffectiveConstraintOfTypeParameter(node: TypeParameterDeclaration): TypeNode | undefined; } declare namespace ts { @@ -3601,7 +3630,7 @@ declare namespace ts { function isStringLiteralLike(node: Node): node is StringLiteralLike; } declare namespace ts { - function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; + export function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; /** * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes * stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise, @@ -3615,25 +3644,26 @@ declare namespace ts { * @remarks `forEachChild` must visit the children of a node in the order * that they appear in the source code. The language service depends on this property to locate nodes by position. */ - function forEachChild(node: Node, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray) => T | undefined): T | undefined; - function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; - function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName | undefined; + export function forEachChild(node: Node, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray) => T | undefined): T | undefined; + export function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; + export function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName | undefined; /** * Parse json text into SyntaxTree and return node and parse errors if any * @param fileName * @param sourceText */ - function parseJsonText(fileName: string, sourceText: string): JsonSourceFile; - function isExternalModule(file: SourceFile): boolean; - function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + export function parseJsonText(fileName: string, sourceText: string): JsonSourceFile; + export function isExternalModule(file: SourceFile): boolean; + export function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + export {}; } declare namespace ts { - function parseCommandLine(commandLine: ReadonlyArray, readFile?: (path: string) => string | undefined): ParsedCommandLine; - type DiagnosticReporter = (diagnostic: Diagnostic) => void; + export function parseCommandLine(commandLine: readonly string[], readFile?: (path: string) => string | undefined): ParsedCommandLine; + export type DiagnosticReporter = (diagnostic: Diagnostic) => void; /** * Reports config file diagnostics */ - interface ConfigFileDiagnosticsReporter { + export interface ConfigFileDiagnosticsReporter { /** * Reports unrecoverable error when parsing config file */ @@ -3642,18 +3672,18 @@ declare namespace ts { /** * Interface extending ParseConfigHost to support ParseConfigFile that reads config file and reports errors */ - interface ParseConfigFileHost extends ParseConfigHost, ConfigFileDiagnosticsReporter { + export interface ParseConfigFileHost extends ParseConfigHost, ConfigFileDiagnosticsReporter { getCurrentDirectory(): string; } /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ - function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map): ParsedCommandLine | undefined; + export function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map): ParsedCommandLine | undefined; /** * Read tsconfig.json file * @param fileName The path to the config file */ - function readConfigFile(fileName: string, readFile: (path: string) => string | undefined): { + export function readConfigFile(fileName: string, readFile: (path: string) => string | undefined): { config?: any; error?: Diagnostic; }; @@ -3662,7 +3692,7 @@ declare namespace ts { * @param fileName The path to the config file * @param jsonText The text of the config file */ - function parseConfigFileTextToJson(fileName: string, jsonText: string): { + export function parseConfigFileTextToJson(fileName: string, jsonText: string): { config?: any; error?: Diagnostic; }; @@ -3670,11 +3700,11 @@ declare namespace ts { * Read tsconfig.json file * @param fileName The path to the config file */ - function readJsonConfigFile(fileName: string, readFile: (path: string) => string | undefined): TsConfigSourceFile; + export function readJsonConfigFile(fileName: string, readFile: (path: string) => string | undefined): TsConfigSourceFile; /** * Convert the json syntax tree into the json value */ - function convertToObject(sourceFile: JsonSourceFile, errors: Push): any; + export function convertToObject(sourceFile: JsonSourceFile, errors: Push): any; /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse @@ -3682,7 +3712,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; + export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map): ParsedCommandLine; /** * Parse the contents of a config file (tsconfig.json). * @param jsonNode The contents of the config file to parse @@ -3690,8 +3720,8 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; - interface ParsedTsconfig { + export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map): ParsedCommandLine; + export interface ParsedTsconfig { raw: any; options?: CompilerOptions; typeAcquisition?: TypeAcquisition; @@ -3700,18 +3730,19 @@ declare namespace ts { */ extendedConfigPath?: string; } - interface ExtendedConfigCacheEntry { + export interface ExtendedConfigCacheEntry { extendedResult: TsConfigSourceFile; extendedConfig: ParsedTsconfig | undefined; } - function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { + export function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; }; - function convertTypeAcquisitionFromJson(jsonOptions: any, basePath: string, configFileName?: string): { + export function convertTypeAcquisitionFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: TypeAcquisition; errors: Diagnostic[]; }; + export {}; } declare namespace ts { function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined; @@ -3755,7 +3786,7 @@ declare namespace ts { function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; } declare namespace ts { - function createNodeArray(elements?: ReadonlyArray, hasTrailingComma?: boolean): NodeArray; + function createNodeArray(elements?: readonly T[], hasTrailingComma?: boolean): NodeArray; /** If a node is passed, creates a string literal whose source text is read from a source node during emit. */ function createLiteral(value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier): StringLiteral; function createLiteral(value: number | PseudoBigInt): NumericLiteral; @@ -3793,67 +3824,67 @@ declare namespace ts { function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; function createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration; function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; - function createParameter(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; - function updateParameter(node: ParameterDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; + function createParameter(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + function updateParameter(node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; function createDecorator(expression: Expression): Decorator; function updateDecorator(node: Decorator, expression: Expression): Decorator; - function createPropertySignature(modifiers: ReadonlyArray | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; - function updatePropertySignature(node: PropertySignature, modifiers: ReadonlyArray | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; - function createProperty(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; - function updateProperty(node: PropertyDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; - function createMethodSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature; + function createPropertySignature(modifiers: readonly Modifier[] | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function updatePropertySignature(node: PropertySignature, modifiers: readonly Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function createProperty(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + function updateProperty(node: PropertyDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + function createMethodSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature; function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined): MethodSignature; - function createMethod(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - function updateMethod(node: MethodDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - function createConstructor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, body: Block | undefined): ConstructorDeclaration; - function updateConstructor(node: ConstructorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, body: Block | undefined): ConstructorDeclaration; - function createGetAccessor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - function updateGetAccessor(node: GetAccessorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: PropertyName, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - function createSetAccessor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, parameters: ReadonlyArray, body: Block | undefined): SetAccessorDeclaration; - function updateSetAccessor(node: SetAccessorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: PropertyName, parameters: ReadonlyArray, body: Block | undefined): SetAccessorDeclaration; - function createCallSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): CallSignatureDeclaration; + function createMethod(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function updateMethod(node: MethodDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function createConstructor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function updateConstructor(node: ConstructorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function createGetAccessor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function updateGetAccessor(node: GetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function createSetAccessor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + function updateSetAccessor(node: SetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + function createCallSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration; function updateCallSignature(node: CallSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): CallSignatureDeclaration; - function createConstructSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): ConstructSignatureDeclaration; + function createConstructSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration; function updateConstructSignature(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructSignatureDeclaration; - function createIndexSignature(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode): IndexSignatureDeclaration; - function updateIndexSignature(node: IndexSignatureDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode): IndexSignatureDeclaration; + function createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + function updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode; function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode; function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode; - function createTypeReferenceNode(typeName: string | EntityName, typeArguments: ReadonlyArray | undefined): TypeReferenceNode; + function createTypeReferenceNode(typeName: string | EntityName, typeArguments: readonly TypeNode[] | undefined): TypeReferenceNode; function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray | undefined): TypeReferenceNode; - function createFunctionTypeNode(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): FunctionTypeNode; + function createFunctionTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode; function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): FunctionTypeNode; - function createConstructorTypeNode(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): ConstructorTypeNode; + function createConstructorTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructorTypeNode; function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructorTypeNode; function createTypeQueryNode(exprName: EntityName): TypeQueryNode; function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode; - function createTypeLiteralNode(members: ReadonlyArray | undefined): TypeLiteralNode; + function createTypeLiteralNode(members: readonly TypeElement[] | undefined): TypeLiteralNode; function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray): TypeLiteralNode; function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; - function createTupleTypeNode(elementTypes: ReadonlyArray): TupleTypeNode; - function updateTupleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray): TupleTypeNode; + function createTupleTypeNode(elementTypes: readonly TypeNode[]): TupleTypeNode; + function updateTupleTypeNode(node: TupleTypeNode, elementTypes: readonly TypeNode[]): TupleTypeNode; function createOptionalTypeNode(type: TypeNode): OptionalTypeNode; function updateOptionalTypeNode(node: OptionalTypeNode, type: TypeNode): OptionalTypeNode; function createRestTypeNode(type: TypeNode): RestTypeNode; function updateRestTypeNode(node: RestTypeNode, type: TypeNode): RestTypeNode; - function createUnionTypeNode(types: ReadonlyArray): UnionTypeNode; + function createUnionTypeNode(types: readonly TypeNode[]): UnionTypeNode; function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray): UnionTypeNode; - function createIntersectionTypeNode(types: ReadonlyArray): IntersectionTypeNode; + function createIntersectionTypeNode(types: readonly TypeNode[]): IntersectionTypeNode; function updateIntersectionTypeNode(node: IntersectionTypeNode, types: NodeArray): IntersectionTypeNode; - function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: ReadonlyArray): UnionOrIntersectionTypeNode; + function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: readonly TypeNode[]): UnionOrIntersectionTypeNode; function createConditionalTypeNode(checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function updateConditionalTypeNode(node: ConditionalTypeNode, checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function createInferTypeNode(typeParameter: TypeParameterDeclaration): InferTypeNode; function updateInferTypeNode(node: InferTypeNode, typeParameter: TypeParameterDeclaration): InferTypeNode; - function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; - function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; + function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; + function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode; function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; function createThisTypeNode(): ThisTypeNode; function createTypeOperatorNode(type: TypeNode): TypeOperatorNode; - function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword, type: TypeNode): TypeOperatorNode; + function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.TagKeyword, type: TypeNode): TypeOperatorNode; function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode; function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; @@ -3861,36 +3892,36 @@ declare namespace ts { function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode; function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; - function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; - function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray): ObjectBindingPattern; - function createArrayBindingPattern(elements: ReadonlyArray): ArrayBindingPattern; - function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ReadonlyArray): ArrayBindingPattern; + function createObjectBindingPattern(elements: readonly BindingElement[]): ObjectBindingPattern; + function updateObjectBindingPattern(node: ObjectBindingPattern, elements: readonly BindingElement[]): ObjectBindingPattern; + function createArrayBindingPattern(elements: readonly ArrayBindingElement[]): ArrayBindingPattern; + function updateArrayBindingPattern(node: ArrayBindingPattern, elements: readonly ArrayBindingElement[]): ArrayBindingPattern; function createBindingElement(dotDotDotToken: DotDotDotToken | undefined, propertyName: string | PropertyName | undefined, name: string | BindingName, initializer?: Expression): BindingElement; function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken | undefined, propertyName: PropertyName | undefined, name: BindingName, initializer: Expression | undefined): BindingElement; - function createArrayLiteral(elements?: ReadonlyArray, multiLine?: boolean): ArrayLiteralExpression; - function updateArrayLiteral(node: ArrayLiteralExpression, elements: ReadonlyArray): ArrayLiteralExpression; - function createObjectLiteral(properties?: ReadonlyArray, multiLine?: boolean): ObjectLiteralExpression; - function updateObjectLiteral(node: ObjectLiteralExpression, properties: ReadonlyArray): ObjectLiteralExpression; + function createArrayLiteral(elements?: readonly Expression[], multiLine?: boolean): ArrayLiteralExpression; + function updateArrayLiteral(node: ArrayLiteralExpression, elements: readonly Expression[]): ArrayLiteralExpression; + function createObjectLiteral(properties?: readonly ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; + function updateObjectLiteral(node: ObjectLiteralExpression, properties: readonly ObjectLiteralElementLike[]): ObjectLiteralExpression; function createPropertyAccess(expression: Expression, name: string | Identifier): PropertyAccessExpression; function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression; function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; - function createCall(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): CallExpression; - function updateCall(node: CallExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray): CallExpression; - function createNew(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; - function updateNew(node: NewExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; + function createCall(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): CallExpression; + function updateCall(node: CallExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[]): CallExpression; + function createNew(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression; + function updateNew(node: NewExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression; /** @deprecated */ function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function createTaggedTemplate(tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; + function createTaggedTemplate(tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; /** @deprecated */ function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; + function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; function createParen(expression: Expression): ParenthesizedExpression; function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; - function createFunctionExpression(modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; - function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; - function createArrowFunction(modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; - function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; + function createFunctionExpression(modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[] | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; + function updateFunctionExpression(node: FunctionExpression, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block): FunctionExpression; + function createArrowFunction(modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; + function updateArrowFunction(node: ArrowFunction, modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; function createTypeOf(expression: Expression): TypeOfExpression; @@ -3908,22 +3939,22 @@ declare namespace ts { /** @deprecated */ function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token, whenTrue: Expression, colonToken: Token, whenFalse: Expression): ConditionalExpression; - function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; - function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; - function createTemplateHead(text: string): TemplateHead; - function createTemplateMiddle(text: string): TemplateMiddle; - function createTemplateTail(text: string): TemplateTail; - function createNoSubstitutionTemplateLiteral(text: string): NoSubstitutionTemplateLiteral; + function createTemplateExpression(head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression; + function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression; + function createTemplateHead(text: string, rawText?: string): TemplateHead; + function createTemplateMiddle(text: string, rawText?: string): TemplateMiddle; + function createTemplateTail(text: string, rawText?: string): TemplateTail; + function createNoSubstitutionTemplateLiteral(text: string, rawText?: string): NoSubstitutionTemplateLiteral; function createYield(expression?: Expression): YieldExpression; function createYield(asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function createSpread(expression: Expression): SpreadElement; function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; - function createClassExpression(modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; - function updateClassExpression(node: ClassExpression, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; + function createClassExpression(modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; + function updateClassExpression(node: ClassExpression, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; function createOmittedExpression(): OmittedExpression; - function createExpressionWithTypeArguments(typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; - function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; + function createExpressionWithTypeArguments(typeArguments: readonly TypeNode[] | undefined, expression: Expression): ExpressionWithTypeArguments; + function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: readonly TypeNode[] | undefined, expression: Expression): ExpressionWithTypeArguments; function createAsExpression(expression: Expression, type: TypeNode): AsExpression; function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression; function createNonNullExpression(expression: Expression): NonNullExpression; @@ -3933,10 +3964,10 @@ declare namespace ts { function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function createSemicolonClassElement(): SemicolonClassElement; - function createBlock(statements: ReadonlyArray, multiLine?: boolean): Block; - function updateBlock(node: Block, statements: ReadonlyArray): Block; - function createVariableStatement(modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList | ReadonlyArray): VariableStatement; - function updateVariableStatement(node: VariableStatement, modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList): VariableStatement; + function createBlock(statements: readonly Statement[], multiLine?: boolean): Block; + function updateBlock(node: Block, statements: readonly Statement[]): Block; + function createVariableStatement(modifiers: readonly Modifier[] | undefined, declarationList: VariableDeclarationList | readonly VariableDeclaration[]): VariableStatement; + function updateVariableStatement(node: VariableStatement, modifiers: readonly Modifier[] | undefined, declarationList: VariableDeclarationList): VariableStatement; function createEmptyStatement(): EmptyStatement; function createExpressionStatement(expression: Expression): ExpressionStatement; function updateExpressionStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; @@ -3975,76 +4006,76 @@ declare namespace ts { function createDebuggerStatement(): DebuggerStatement; function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration; function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; - function createVariableDeclarationList(declarations: ReadonlyArray, flags?: NodeFlags): VariableDeclarationList; - function updateVariableDeclarationList(node: VariableDeclarationList, declarations: ReadonlyArray): VariableDeclarationList; - function createFunctionDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - function updateFunctionDeclaration(node: FunctionDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - function createClassDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; - function updateClassDeclaration(node: ClassDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; - function createInterfaceDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; - function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; - function createTypeAliasDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, type: TypeNode): TypeAliasDeclaration; - function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, typeParameters: ReadonlyArray | undefined, type: TypeNode): TypeAliasDeclaration; - function createEnumDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, members: ReadonlyArray): EnumDeclaration; - function updateEnumDeclaration(node: EnumDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, members: ReadonlyArray): EnumDeclaration; - function createModuleDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; - function updateModuleDeclaration(node: ModuleDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; - function createModuleBlock(statements: ReadonlyArray): ModuleBlock; - function updateModuleBlock(node: ModuleBlock, statements: ReadonlyArray): ModuleBlock; - function createCaseBlock(clauses: ReadonlyArray): CaseBlock; - function updateCaseBlock(node: CaseBlock, clauses: ReadonlyArray): CaseBlock; + function createVariableDeclarationList(declarations: readonly VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; + function updateVariableDeclarationList(node: VariableDeclarationList, declarations: readonly VariableDeclaration[]): VariableDeclarationList; + function createFunctionDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function updateFunctionDeclaration(node: FunctionDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function createClassDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + function updateClassDeclaration(node: ClassDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + function createInterfaceDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + function createTypeAliasDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + function createEnumDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; + function updateEnumDeclaration(node: EnumDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; + function createModuleDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; + function updateModuleDeclaration(node: ModuleDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; + function createModuleBlock(statements: readonly Statement[]): ModuleBlock; + function updateModuleBlock(node: ModuleBlock, statements: readonly Statement[]): ModuleBlock; + function createCaseBlock(clauses: readonly CaseOrDefaultClause[]): CaseBlock; + function updateCaseBlock(node: CaseBlock, clauses: readonly CaseOrDefaultClause[]): CaseBlock; function createNamespaceExportDeclaration(name: string | Identifier): NamespaceExportDeclaration; function updateNamespaceExportDeclaration(node: NamespaceExportDeclaration, name: Identifier): NamespaceExportDeclaration; - function createImportEqualsDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function createImportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; - function updateImportDeclaration(node: ImportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; + function createImportEqualsDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function createImportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; + function updateImportDeclaration(node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; function createImportClause(name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function updateImportClause(node: ImportClause, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function createNamespaceImport(name: Identifier): NamespaceImport; function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; - function createNamedImports(elements: ReadonlyArray): NamedImports; - function updateNamedImports(node: NamedImports, elements: ReadonlyArray): NamedImports; + function createNamedImports(elements: readonly ImportSpecifier[]): NamedImports; + function updateNamedImports(node: NamedImports, elements: readonly ImportSpecifier[]): NamedImports; function createImportSpecifier(propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; - function createExportAssignment(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; - function updateExportAssignment(node: ExportAssignment, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, expression: Expression): ExportAssignment; - function createExportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; - function updateExportDeclaration(node: ExportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; - function createNamedExports(elements: ReadonlyArray): NamedExports; - function updateNamedExports(node: NamedExports, elements: ReadonlyArray): NamedExports; + function createExportAssignment(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; + function updateExportAssignment(node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; + function createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; + function updateExportDeclaration(node: ExportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; + function createNamedExports(elements: readonly ExportSpecifier[]): NamedExports; + function updateNamedExports(node: NamedExports, elements: readonly ExportSpecifier[]): NamedExports; function createExportSpecifier(propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier; function updateExportSpecifier(node: ExportSpecifier, propertyName: Identifier | undefined, name: Identifier): ExportSpecifier; function createExternalModuleReference(expression: Expression): ExternalModuleReference; function updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference; - function createJsxElement(openingElement: JsxOpeningElement, children: ReadonlyArray, closingElement: JsxClosingElement): JsxElement; - function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: ReadonlyArray, closingElement: JsxClosingElement): JsxElement; - function createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxSelfClosingElement; - function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxSelfClosingElement; - function createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxOpeningElement; - function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxOpeningElement; + function createJsxElement(openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; + function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; + function createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; + function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; + function createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement; + function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement; function createJsxClosingElement(tagName: JsxTagNameExpression): JsxClosingElement; function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement; - function createJsxFragment(openingFragment: JsxOpeningFragment, children: ReadonlyArray, closingFragment: JsxClosingFragment): JsxFragment; + function createJsxFragment(openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; function createJsxText(text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText; function updateJsxText(node: JsxText, text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText; function createJsxOpeningFragment(): JsxOpeningFragment; function createJsxJsxClosingFragment(): JsxClosingFragment; - function updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: ReadonlyArray, closingFragment: JsxClosingFragment): JsxFragment; + function updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; - function createJsxAttributes(properties: ReadonlyArray): JsxAttributes; - function updateJsxAttributes(node: JsxAttributes, properties: ReadonlyArray): JsxAttributes; + function createJsxAttributes(properties: readonly JsxAttributeLike[]): JsxAttributes; + function updateJsxAttributes(node: JsxAttributes, properties: readonly JsxAttributeLike[]): JsxAttributes; function createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; function createJsxExpression(dotDotDotToken: DotDotDotToken | undefined, expression: Expression | undefined): JsxExpression; function updateJsxExpression(node: JsxExpression, expression: Expression | undefined): JsxExpression; - function createCaseClause(expression: Expression, statements: ReadonlyArray): CaseClause; - function updateCaseClause(node: CaseClause, expression: Expression, statements: ReadonlyArray): CaseClause; - function createDefaultClause(statements: ReadonlyArray): DefaultClause; - function updateDefaultClause(node: DefaultClause, statements: ReadonlyArray): DefaultClause; - function createHeritageClause(token: HeritageClause["token"], types: ReadonlyArray): HeritageClause; - function updateHeritageClause(node: HeritageClause, types: ReadonlyArray): HeritageClause; + function createCaseClause(expression: Expression, statements: readonly Statement[]): CaseClause; + function updateCaseClause(node: CaseClause, expression: Expression, statements: readonly Statement[]): CaseClause; + function createDefaultClause(statements: readonly Statement[]): DefaultClause; + function updateDefaultClause(node: DefaultClause, statements: readonly Statement[]): DefaultClause; + function createHeritageClause(token: HeritageClause["token"], types: readonly ExpressionWithTypeArguments[]): HeritageClause; + function updateHeritageClause(node: HeritageClause, types: readonly ExpressionWithTypeArguments[]): HeritageClause; function createCatchClause(variableDeclaration: string | VariableDeclaration | undefined, block: Block): CatchClause; function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration | undefined, block: Block): CatchClause; function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; @@ -4055,7 +4086,7 @@ declare namespace ts { function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember; function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember; - function updateSourceFileNode(node: SourceFile, statements: ReadonlyArray, isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean, libReferences?: SourceFile["libReferenceDirectives"]): SourceFile; + function updateSourceFileNode(node: SourceFile, statements: readonly Statement[], isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean, libReferences?: SourceFile["libReferenceDirectives"]): SourceFile; /** * Creates a shallow, memberwise clone of a node for mutation. */ @@ -4077,20 +4108,20 @@ declare namespace ts { */ function createPartiallyEmittedExpression(expression: Expression, original?: Node): PartiallyEmittedExpression; function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; - function createCommaList(elements: ReadonlyArray): CommaListExpression; - function updateCommaList(node: CommaListExpression, elements: ReadonlyArray): CommaListExpression; - function createBundle(sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; + function createCommaList(elements: readonly Expression[]): CommaListExpression; + function updateCommaList(node: CommaListExpression, elements: readonly Expression[]): CommaListExpression; + function createBundle(sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle; function createUnparsedSourceFile(text: string): UnparsedSource; function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts", stripInternal?: boolean): UnparsedSource; function createUnparsedSourceFile(text: string, mapPath: string | undefined, map: string | undefined): UnparsedSource; function createInputFiles(javascriptText: string, declarationText: string): InputFiles; function createInputFiles(readFileText: (path: string) => string | undefined, javascriptPath: string, javascriptMapPath: string | undefined, declarationPath: string, declarationMapPath: string | undefined, buildInfoPath: string | undefined): InputFiles; function createInputFiles(javascriptText: string, declarationText: string, javascriptMapPath: string | undefined, javascriptMapText: string | undefined, declarationMapPath: string | undefined, declarationMapText: string | undefined): InputFiles; - function updateBundle(node: Bundle, sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; - function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray): CallExpression; - function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; - function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray): CallExpression; - function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; + function updateBundle(node: Bundle, sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle; + function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[]): CallExpression; + function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; function createComma(left: Expression, right: Expression): Expression; function createLessThan(left: Expression, right: Expression): Expression; function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment; @@ -4266,20 +4297,20 @@ declare namespace ts { function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; } declare namespace ts { - function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string | undefined; - function resolveTripleslashReference(moduleName: string, containingFile: string): string; - function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; - function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - interface FormatDiagnosticsHost { + export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string | undefined; + export function resolveTripleslashReference(moduleName: string, containingFile: string): string; + export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; + export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + export interface FormatDiagnosticsHost { getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; getNewLine(): string; } - function formatDiagnostics(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; - function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string; - function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; - function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string; - function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): ReadonlyArray; + export function formatDiagnostics(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string; + export function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string; + export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string; + export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string; + export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[]; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' * that represent a compilation unit. @@ -4290,7 +4321,7 @@ declare namespace ts { * @param createProgramOptions - The options for creating a program. * @returns A 'Program' object. */ - function createProgram(createProgramOptions: CreateProgramOptions): Program; + export function createProgram(createProgramOptions: CreateProgramOptions): Program; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' * that represent a compilation unit. @@ -4305,16 +4336,17 @@ declare namespace ts { * @param configFileParsingDiagnostics - error during config file parsing * @returns A 'Program' object. */ - function createProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: ReadonlyArray): Program; - /** @deprecated */ interface ResolveProjectReferencePathHost { + export function createProgram(rootNames: readonly string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: readonly Diagnostic[]): Program; + /** @deprecated */ export interface ResolveProjectReferencePathHost { fileExists(fileName: string): boolean; } /** * Returns the target config filename of a project reference. * Note: The file might not exist. */ - function resolveProjectReferencePath(ref: ProjectReference): ResolvedConfigFileName; - /** @deprecated */ function resolveProjectReferencePath(host: ResolveProjectReferencePathHost, ref: ProjectReference): ResolvedConfigFileName; + export function resolveProjectReferencePath(ref: ProjectReference): ResolvedConfigFileName; + /** @deprecated */ export function resolveProjectReferencePath(host: ResolveProjectReferencePathHost, ref: ProjectReference): ResolvedConfigFileName; + export {}; } declare namespace ts { interface EmitOutput { @@ -4366,31 +4398,31 @@ declare namespace ts { /** * Get a list of files in the program */ - getSourceFiles(): ReadonlyArray; + getSourceFiles(): readonly SourceFile[]; /** * Get the diagnostics for compiler options */ - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the diagnostics that dont belong to any file */ - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the diagnostics from config file parsing */ - getConfigFileParsingDiagnostics(): ReadonlyArray; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; /** * Get the syntax diagnostics, for all source files if source file is not supplied */ - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the declaration diagnostics, for all source files if source file is not supplied */ - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; /** * Get all the dependencies of the file */ - getAllDependencies(sourceFile: SourceFile): ReadonlyArray; + getAllDependencies(sourceFile: SourceFile): readonly string[]; /** * Gets the semantic diagnostics from the program corresponding to this state of file (if provided) or whole program * The semantic diagnostics are cached and managed here @@ -4399,7 +4431,7 @@ declare namespace ts { * In case of SemanticDiagnosticsBuilderProgram if the source file is not provided, * it will iterate through all the affected files, to ensure that cache stays valid and yet provide a way to get all semantic diagnostics */ - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Emits the JavaScript and declaration files. * When targetSource file is specified, emits the files corresponding to that source file, @@ -4425,7 +4457,7 @@ declare namespace ts { * Gets the semantic diagnostics from the program for the next affected file and caches it * Returns undefined if the iteration is complete */ - getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult>; + getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult; } /** * The builder that can handle the changes in program and iterate through changed file to emit the files @@ -4442,19 +4474,19 @@ declare namespace ts { /** * Create the builder to manage semantic diagnostics and cache them */ - function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; - function createSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; + function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): SemanticDiagnosticsBuilderProgram; + function createSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): SemanticDiagnosticsBuilderProgram; /** * Create the builder that can handle the changes in program and iterate through changed files * to emit the those files and manage semantic diagnostics cache as well */ - function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; - function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; + function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): EmitAndSemanticDiagnosticsBuilderProgram; + function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): EmitAndSemanticDiagnosticsBuilderProgram; /** * Creates a builder thats just abstraction over program and can be used with watch */ - function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderProgram; - function createAbstractBuilder(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): BuilderProgram; + function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): BuilderProgram; + function createAbstractBuilder(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): BuilderProgram; } declare namespace ts { interface ReadBuildProgramHost { @@ -4465,21 +4497,21 @@ declare namespace ts { function readBuilderProgram(compilerOptions: CompilerOptions, host: ReadBuildProgramHost): EmitAndSemanticDiagnosticsBuilderProgram | undefined; function createIncrementalCompilerHost(options: CompilerOptions, system?: System): CompilerHost; interface IncrementalProgramOptions { - rootNames: ReadonlyArray; + rootNames: readonly string[]; options: CompilerOptions; - configFileParsingDiagnostics?: ReadonlyArray; - projectReferences?: ReadonlyArray; + configFileParsingDiagnostics?: readonly Diagnostic[]; + projectReferences?: readonly ProjectReference[]; host?: CompilerHost; createProgram?: CreateProgram; } function createIncrementalProgram({ rootNames, options, configFileParsingDiagnostics, projectReferences, host, createProgram }: IncrementalProgramOptions): T; - type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions) => void; + type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions, errorCount?: number) => void; /** Create the program with rootNames and options, if they are undefined, oldProgram and new configFile diagnostics create new program */ - type CreateProgram = (rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: T, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray | undefined) => T; + type CreateProgram = (rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: T, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[] | undefined) => T; /** Host that has watch functionality used in --watch mode */ interface WatchHost { /** If provided, called with Diagnostic message that informs about change in watch status */ - onWatchStatusChange?(diagnostic: Diagnostic, newLine: string, options: CompilerOptions): void; + onWatchStatusChange?(diagnostic: Diagnostic, newLine: string, options: CompilerOptions, errorCount?: number): void; /** Used to watch changes in source files, missing files needed to update the program or config file */ watchFile(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher; /** Used to watch resolved module's failed lookup locations, config file specs, type roots where auto type reference directives are added */ @@ -4515,7 +4547,7 @@ declare namespace ts { /** If provided, used in resolutions as well as handling directory structure */ getDirectories?(path: string): string[]; /** If provided, used to cache and handle directory structure modifications */ - readDirectory?(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; /** Symbol links resolution */ realpath?(path: string): string; /** If provided would be used to write log about compilation */ @@ -4523,9 +4555,9 @@ declare namespace ts { /** If provided is used to get the environment variable */ getEnvironmentVariable?(name: string): string | undefined; /** If provided, used to resolve the module names, otherwise typescript's default module resolution */ - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[]; } interface WatchCompilerHost extends ProgramHost, WatchHost { /** If provided, callback to invoke after every new program creation */ @@ -4540,7 +4572,7 @@ declare namespace ts { /** Compiler options */ options: CompilerOptions; /** Project References */ - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; } /** * Host to create watch with config file @@ -4554,7 +4586,7 @@ declare namespace ts { * Used to generate source file names from the config file and its include, exclude, files rules * and also to cache the directory stucture */ - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; } interface Watch { /** Synchronize with host and get updated program */ @@ -4578,7 +4610,7 @@ declare namespace ts { * Create the watch compiler host for either configFile or fileNames and its options */ function createWatchCompilerHost(configFileName: string, optionsToExtend: CompilerOptions | undefined, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): WatchCompilerHostOfConfigFile; - function createWatchCompilerHost(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: ReadonlyArray): WatchCompilerHostOfFilesAndCompilerOptions; + function createWatchCompilerHost(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: readonly ProjectReference[]): WatchCompilerHostOfFilesAndCompilerOptions; /** * Creates the watch from the host for root files and compiler options */ @@ -4631,8 +4663,8 @@ declare namespace ts { function createBuilderStatusReporter(system: System, pretty?: boolean): DiagnosticReporter; function createSolutionBuilderHost(system?: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportErrorSummary?: ReportEmitErrorSummary): SolutionBuilderHost; function createSolutionBuilderWithWatchHost(system?: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): SolutionBuilderWithWatchHost; - function createSolutionBuilder(host: SolutionBuilderHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilder; - function createSolutionBuilderWithWatch(host: SolutionBuilderWithWatchHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilder; + function createSolutionBuilder(host: SolutionBuilderHost, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder; + function createSolutionBuilderWithWatch(host: SolutionBuilderWithWatchHost, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder; enum InvalidatedProjectKind { Build = 0, UpdateBundle = 1, @@ -4657,14 +4689,14 @@ declare namespace ts { getBuilderProgram(): T | undefined; getProgram(): Program | undefined; getSourceFile(fileName: string): SourceFile | undefined; - getSourceFiles(): ReadonlyArray; - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getConfigFileParsingDiagnostics(): ReadonlyArray; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getAllDependencies(sourceFile: SourceFile): ReadonlyArray; - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult>; + getSourceFiles(): readonly SourceFile[]; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getAllDependencies(sourceFile: SourceFile): readonly string[]; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult; emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult | undefined; } interface UpdateBundleProject extends InvalidatedProjectBase { @@ -4727,7 +4759,7 @@ declare namespace ts.server { readonly kind: EventBeginInstallTypes | EventEndInstallTypes; readonly eventId: number; readonly typingsInstallerVersion: string; - readonly packagesToInstall: ReadonlyArray; + readonly packagesToInstall: readonly string[]; } interface BeginInstallTypes extends InstallTypes { readonly kind: EventBeginInstallTypes; @@ -4780,8 +4812,8 @@ declare namespace ts { getProperties(): Symbol[]; getProperty(propertyName: string): Symbol | undefined; getApparentProperties(): Symbol[]; - getCallSignatures(): ReadonlyArray; - getConstructSignatures(): ReadonlyArray; + getCallSignatures(): readonly Signature[]; + getConstructSignatures(): readonly Signature[]; getStringIndexType(): Type | undefined; getNumberIndexType(): Type | undefined; getBaseTypes(): BaseType[] | undefined; @@ -4809,7 +4841,7 @@ declare namespace ts { interface SourceFile { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineEndOfPosition(pos: number): number; - getLineStarts(): ReadonlyArray; + getLineStarts(): readonly number[]; getPositionOfLineAndCharacter(line: number, character: number): number; update(newText: string, textChangeRange: TextChangeRange): SourceFile; } @@ -4866,7 +4898,7 @@ declare namespace ts { getScriptKind?(fileName: string): ScriptKind; getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): IScriptSnapshot | undefined; - getProjectReferences?(): ReadonlyArray | undefined; + getProjectReferences?(): readonly ProjectReference[] | undefined; getLocalizedDiagnosticMessages?(): any; getCancellationToken?(): HostCancellationToken; getCurrentDirectory(): string; @@ -4875,14 +4907,14 @@ declare namespace ts { trace?(s: string): void; error?(s: string): void; useCaseSensitiveFileNames?(): boolean; - readDirectory?(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; readFile?(path: string, encoding?: string): string | undefined; realpath?(path: string): string; fileExists?(path: string): boolean; getTypeRootsVersion?(): number; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined; - resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[]; getDirectories?(directoryName: string): string[]; /** * Gets a set of custom transformers to use during emit. @@ -4920,17 +4952,17 @@ declare namespace ts { getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): ReadonlyArray | undefined; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): readonly RenameLocation[] | undefined; getSmartSelectionRange(fileName: string, position: number): SelectionRange; - getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; - getTypeDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; - getImplementationAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getTypeDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; + getImplementationAtPosition(fileName: string, position: number): readonly ImplementationLocation[] | undefined; getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] | undefined; findReferences(fileName: string, position: number): ReferencedSymbol[] | undefined; getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] | undefined; /** @deprecated */ - getOccurrencesAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getOccurrencesAtPosition(fileName: string, position: number): readonly ReferenceEntry[] | undefined; getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; getNavigationTree(fileName: string): NavigationTree; @@ -4950,7 +4982,7 @@ declare namespace ts { getJsxClosingTagAtPosition(fileName: string, position: number): JsxClosingTagInfo | undefined; getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan | undefined; toLineColumnOffset?(fileName: string, position: number): LineAndCharacter; - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray, formatOptions: FormatCodeSettings, preferences: UserPreferences): ReadonlyArray; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: readonly number[], formatOptions: FormatCodeSettings, preferences: UserPreferences): readonly CodeFixAction[]; getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings, preferences: UserPreferences): CombinedCodeActions; applyCodeActionCommand(action: CodeActionCommand, formatSettings?: FormatCodeSettings): Promise; applyCodeActionCommand(action: CodeActionCommand[], formatSettings?: FormatCodeSettings): Promise; @@ -4963,8 +4995,8 @@ declare namespace ts { applyCodeActionCommand(fileName: string, action: CodeActionCommand | CodeActionCommand[]): Promise; getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined): 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): ReadonlyArray; - getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): ReadonlyArray; + organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; + getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; getProgram(): Program | undefined; dispose(): void; @@ -5113,8 +5145,8 @@ declare namespace ts { fixAllDescription?: string; } interface CombinedCodeActions { - changes: ReadonlyArray; - commands?: ReadonlyArray; + changes: readonly FileTextChanges[]; + commands?: readonly CodeActionCommand[]; } type CodeActionCommand = InstallPackageAction; interface InstallPackageAction { @@ -5296,7 +5328,7 @@ declare namespace ts { containerName: string; } interface DefinitionInfoAndBoundSpan { - definitions?: ReadonlyArray; + definitions?: readonly DefinitionInfo[]; textSpan: TextSpan; } interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { @@ -5665,6 +5697,7 @@ declare namespace ts { } } declare namespace ts { + /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier(): Classifier; } declare namespace ts { diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index cc593ef2db30f..75be6bc31344d 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -14,6 +14,13 @@ and limitations under the License. ***************************************************************************** */ "use strict"; +var __spreadArrays = (this && this.__spreadArrays) || function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +}; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { @@ -73,7 +80,7 @@ var ts; (function (ts) { // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configureNightly` too. - ts.versionMajorMinor = "3.6"; + ts.versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ ts.version = ts.versionMajorMinor + ".0-dev"; })(ts || (ts = {})); @@ -91,7 +98,7 @@ var ts; ts.emptyArray = []; /** Create a MapLike with good performance. */ function createDictionaryObject() { - var map = Object.create(/*prototype*/ null); // tslint:disable-line:no-null-keyword + var map = Object.create(/*prototype*/ null); // eslint-disable-line no-null/no-null // Using 'delete' on an object causes V8 to put the object in dictionary mode. // This disables creation of hidden classes, which are expensive when an object is // constantly changing shape. @@ -126,7 +133,7 @@ var ts; } ts.createMapFromTemplate = createMapFromTemplate; // Internet Explorer's Map doesn't support iteration, so don't use it. - // tslint:disable-next-line no-in-operator variable-name + // eslint-disable-next-line no-in-operator ts.MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); // Keep the class inside a function so it doesn't get compiled if it's not used. function shimMap() { @@ -190,7 +197,7 @@ var ts; return this; }; class_1.prototype.has = function (key) { - // tslint:disable-next-line:no-in-operator + // eslint-disable-next-line no-in-operator return key in this.data; }; class_1.prototype.delete = function (key) { @@ -783,7 +790,7 @@ var ts; return array1; if (!some(array1)) return array2; - return array1.concat(array2); + return __spreadArrays(array1, array2); } ts.concatenate = concatenate; function deduplicateRelational(array, equalityComparer, comparer) { @@ -840,6 +847,7 @@ var ts; // equality comparison case true: // relational comparison + // falls through case 0 /* EqualTo */: continue; case -1 /* LessThan */: @@ -1230,6 +1238,18 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; + function getAllKeys(obj) { + var result = []; + do { + var names = Object.getOwnPropertyNames(obj); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name = names_1[_i]; + pushIfUnique(result, name); + } + } while (obj = Object.getPrototypeOf(obj)); + return result; + } + ts.getAllKeys = getAllKeys; function getOwnValues(sparseArray) { var values = []; for (var key in sparseArray) { @@ -1427,7 +1447,7 @@ var ts; } ts.cast = cast; /** Does nothing. */ - function noop(_) { } // tslint:disable-line no-empty + function noop(_) { } ts.noop = noop; /** Do nothing and return false */ function returnFalse() { return false; } @@ -1939,7 +1959,7 @@ var ts; return function (arg) { return f(arg) || g(arg); }; } ts.or = or; - function assertType(_) { } // tslint:disable-line no-empty + function assertType(_) { } ts.assertType = assertType; function singleElementArray(t) { return t === undefined ? undefined : [t]; @@ -2016,8 +2036,10 @@ var ts; (function (ts) { var Debug; (function (Debug) { + /* eslint-disable prefer-const */ Debug.currentAssertionLevel = 0 /* None */; Debug.isDebugging = false; + /* eslint-enable prefer-const */ function shouldAssert(level) { return Debug.currentAssertionLevel >= level; } @@ -2066,6 +2088,7 @@ var ts; } Debug.fail = fail; function assertDefined(value, message) { + // eslint-disable-next-line no-null/no-null if (value === undefined || value === null) return fail(message); return value; @@ -2081,7 +2104,7 @@ var ts; Debug.assertEachDefined = assertEachDefined; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } - var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); + var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); return fail(message + " " + detail, stackCrawlMark || assertNever); } Debug.assertNever = assertNever; @@ -2369,6 +2392,47 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var nullLogger = { + logEvent: ts.noop, + logErrEvent: ts.noop, + logPerfEvent: ts.noop, + logInfoEvent: ts.noop, + logStartCommand: ts.noop, + logStopCommand: ts.noop, + logStartUpdateProgram: ts.noop, + logStopUpdateProgram: ts.noop, + logStartUpdateGraph: ts.noop, + logStopUpdateGraph: ts.noop, + logStartResolveModule: ts.noop, + logStopResolveModule: ts.noop, + logStartParseSourceFile: ts.noop, + logStopParseSourceFile: ts.noop, + logStartReadFile: ts.noop, + logStopReadFile: ts.noop, + logStartBindFile: ts.noop, + logStopBindFile: ts.noop, + logStartScheduledOperation: ts.noop, + logStopScheduledOperation: ts.noop, + }; + // Load optional module to enable Event Tracing for Windows + // See https://github.com/microsoft/typescript-etw for more information + var etwModule; + try { + // require() will throw an exception if the module is not installed + // It may also return undefined if not installed properly + etwModule = require("@microsoft/typescript-etw"); + } + catch (e) { + etwModule = undefined; + } + /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ + ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; + var args = typeof process === "undefined" ? [] : process.argv; + ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify(args)); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { // https://semver.org/#spec-item-2 // > A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative @@ -2893,200 +2957,203 @@ var ts; SyntaxKind[SyntaxKind["FromKeyword"] = 145] = "FromKeyword"; SyntaxKind[SyntaxKind["GlobalKeyword"] = 146] = "GlobalKeyword"; SyntaxKind[SyntaxKind["BigIntKeyword"] = 147] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 148] = "OfKeyword"; + SyntaxKind[SyntaxKind["TagKeyword"] = 148] = "TagKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 149] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 149] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 150] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 150] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 151] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 151] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 152] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 153] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 152] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 153] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 154] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 154] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 155] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 156] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 157] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 158] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 159] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 160] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 161] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 162] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 163] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 155] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 156] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 157] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 158] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 159] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 160] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 161] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 162] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 163] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 164] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 164] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 165] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 166] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 167] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 168] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 169] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 170] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 171] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 172] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 173] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 174] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 175] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 176] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 177] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 178] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 179] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 180] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 181] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 182] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 183] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 184] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 165] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 166] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 167] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 168] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 169] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 170] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 171] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 172] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 173] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 174] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 175] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 176] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 177] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 178] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 179] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 180] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 181] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 182] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 183] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 184] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 185] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 185] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 186] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 187] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 186] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 187] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 188] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 188] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 189] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 190] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 191] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 192] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 193] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 194] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 195] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 196] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 197] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 198] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 199] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 200] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 201] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 202] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 203] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 204] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 205] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 206] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 207] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 208] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 209] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 210] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 211] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 212] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 213] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 214] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 215] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 216] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 189] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 190] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 191] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 192] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 193] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 194] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 195] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 196] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 197] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 198] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 199] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 200] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 201] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 202] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 203] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 204] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 205] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 206] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 207] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 208] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 209] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 210] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 211] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 212] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 213] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 214] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 215] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 216] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 217] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 217] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 218] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 218] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 219] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 219] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 220] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 221] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 222] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 223] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 224] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 225] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 226] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 227] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 228] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 229] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 230] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 231] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 232] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 233] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 234] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 235] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 236] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 237] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 238] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 239] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 240] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 241] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 242] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 243] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 244] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 245] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 246] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 247] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 248] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 249] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 250] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 251] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 252] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 253] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 254] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 255] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 256] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 257] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 258] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 259] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 220] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 221] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 222] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 223] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 224] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 225] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 226] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 227] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 228] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 229] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 230] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 231] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 232] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 233] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 234] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 235] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 236] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 237] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 238] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 239] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 240] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 241] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 242] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 243] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 244] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 245] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 246] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 247] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 248] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 249] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 250] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 251] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 252] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 253] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 254] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 255] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 256] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 257] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 258] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 259] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 260] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 260] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 261] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 261] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 262] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 263] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 264] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 265] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 266] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 267] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 268] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 269] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 270] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 271] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 262] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 263] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 264] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 265] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 266] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 267] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 268] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 269] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 270] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 271] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 272] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 272] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 273] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 274] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 275] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 273] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 274] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 275] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 276] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 276] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 277] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 278] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 277] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 278] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 279] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 279] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 280] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 280] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 281] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 282] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 283] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 284] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 281] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 282] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 283] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 284] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 285] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 285] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 286] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 287] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 288] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 286] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 287] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 288] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 289] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 289] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 290] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 290] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 291] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 291] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 292] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 293] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 294] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 295] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 296] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 297] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 298] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 299] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 300] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 301] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 302] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 303] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 304] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 305] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 306] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 307] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 308] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 309] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 310] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 311] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 312] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 292] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 293] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 294] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 295] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 296] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 297] = "JSDocVariadicType"; + // https://jsdoc.app/about-namepaths.html + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 298] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 299] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 300] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 301] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 302] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 303] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 304] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 305] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 306] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 307] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 308] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 309] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 310] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 311] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 312] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 313] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 314] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 313] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 315] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 314] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 315] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 316] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 317] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 318] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 316] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 317] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 318] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 319] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 320] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 319] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 321] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 60] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 72] = "LastAssignment"; @@ -3095,15 +3162,15 @@ var ts; SyntaxKind[SyntaxKind["FirstReservedWord"] = 74] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 109] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 74] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 148] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 149] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 110] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 118] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 164] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 184] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 165] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 185] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 72] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 148] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 149] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -3112,13 +3179,13 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 72] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 149] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 289] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 312] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 300] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 312] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 150] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 290] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 314] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 302] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 314] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 119] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 148] = "LastContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 149] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -3242,6 +3309,8 @@ var ts; /* @internal */ TokenFlags[TokenFlags["ContainsSeparator"] = 512] = "ContainsSeparator"; /* @internal */ + TokenFlags[TokenFlags["UnicodeEscape"] = 1024] = "UnicodeEscape"; + /* @internal */ TokenFlags[TokenFlags["BinaryOrOctalSpecifier"] = 384] = "BinaryOrOctalSpecifier"; /* @internal */ TokenFlags[TokenFlags["NumericLiteralFlags"] = 1008] = "NumericLiteralFlags"; @@ -3272,6 +3341,13 @@ var ts; return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + /*@internal*/ + var RefFileKind; + (function (RefFileKind) { + RefFileKind[RefFileKind["Import"] = 0] = "Import"; + RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile"; + RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective"; + })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {})); /* @internal */ var StructureIsReused; (function (StructureIsReused) { @@ -3292,6 +3368,8 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; // When build skipped because passed in project is invalid ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped"; + // When build is skipped because project references form cycle + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); /* @internal */ var UnionReduction; @@ -3357,7 +3435,6 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 4096] = "UseTypeOfFunction"; TypeFormatFlags[TypeFormatFlags["OmitParameterModifiers"] = 8192] = "OmitParameterModifiers"; TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; - // even though `T` can't be accessed in the current scope. // Error Handling TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; // TypeFormatFlags exclusive @@ -3412,22 +3489,33 @@ var ts; /* @internal */ var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { + // The TypeReferenceNode could not be resolved. + // The type name should be emitted using a safe fallback. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; - // should be emitted using a safe fallback. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a type with a constructor // function that can be reached at runtime (e.g. a `class` // declaration or a `var` declaration for the static side // of a type, such as the global `Promise` type in lib.d.ts). + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a Void-like, Nullable, or Never type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType"; + // The TypeReferenceNode resolves to a Number-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + // The TypeReferenceNode resolves to a BigInt-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType"; + // The TypeReferenceNode resolves to a String-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType"; + // The TypeReferenceNode resolves to a Boolean-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType"; + // The TypeReferenceNode resolves to an Array-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType"; + // The TypeReferenceNode resolves to the ESSymbol type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType"; + // The TypeReferenceNode resolved to the global Promise constructor symbol. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise"; + // The TypeReferenceNode resolves to a Function type or a type with call signatures. TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature"; - // with call signatures. + // The TypeReferenceNode resolves to any other type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var SymbolFlags; @@ -3465,32 +3553,32 @@ var ts; SymbolFlags[SymbolFlags["All"] = 67108863] = "All"; SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; - SymbolFlags[SymbolFlags["Value"] = 67220415] = "Value"; - SymbolFlags[SymbolFlags["Type"] = 67897832] = "Type"; + SymbolFlags[SymbolFlags["Value"] = 111551] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 788968] = "Type"; SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; // Variables can be redeclared, but can not redeclare a block-scoped declaration with the // same name, or any other value that is not a variable, e.g. ValueModule or Class - SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 67220414] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 111550] = "FunctionScopedVariableExcludes"; // Block-scoped declarations are not allowed to be re-declared // they can not merge with anything in the value space - SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 67220415] = "BlockScopedVariableExcludes"; - SymbolFlags[SymbolFlags["ParameterExcludes"] = 67220415] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 111551] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 111551] = "ParameterExcludes"; SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; - SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 68008959] = "EnumMemberExcludes"; - SymbolFlags[SymbolFlags["FunctionExcludes"] = 67219887] = "FunctionExcludes"; - SymbolFlags[SymbolFlags["ClassExcludes"] = 68008383] = "ClassExcludes"; - SymbolFlags[SymbolFlags["InterfaceExcludes"] = 67897736] = "InterfaceExcludes"; - SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 68008191] = "RegularEnumExcludes"; - SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 68008831] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 110991] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899503] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 788872] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 110735] = "ValueModuleExcludes"; SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; - SymbolFlags[SymbolFlags["MethodExcludes"] = 67212223] = "MethodExcludes"; - SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 67154879] = "GetAccessorExcludes"; - SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 67187647] = "SetAccessorExcludes"; - SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 67635688] = "TypeParameterExcludes"; - SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 67897832] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 103359] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 46015] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 78783] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 526824] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 788968] = "TypeAliasExcludes"; SymbolFlags[SymbolFlags["AliasExcludes"] = 2097152] = "AliasExcludes"; SymbolFlags[SymbolFlags["ModuleMember"] = 2623475] = "ModuleMember"; SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; @@ -3609,6 +3697,7 @@ var ts; TypeFlags[TypeFlags["Conditional"] = 16777216] = "Conditional"; TypeFlags[TypeFlags["Substitution"] = 33554432] = "Substitution"; TypeFlags[TypeFlags["NonPrimitive"] = 67108864] = "NonPrimitive"; + TypeFlags[TypeFlags["StructuralTag"] = 134217728] = "StructuralTag"; /* @internal */ TypeFlags[TypeFlags["AnyOrUnknown"] = 3] = "AnyOrUnknown"; /* @internal */ @@ -3635,22 +3724,22 @@ var ts; /* @internal */ TypeFlags[TypeFlags["DisjointDomains"] = 67238908] = "DisjointDomains"; TypeFlags[TypeFlags["UnionOrIntersection"] = 3145728] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 3670016] = "StructuredType"; + TypeFlags[TypeFlags["StructuredType"] = 137887744] = "StructuredType"; TypeFlags[TypeFlags["TypeVariable"] = 8650752] = "TypeVariable"; TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 58982400] = "InstantiableNonPrimitive"; TypeFlags[TypeFlags["InstantiablePrimitive"] = 4194304] = "InstantiablePrimitive"; TypeFlags[TypeFlags["Instantiable"] = 63176704] = "Instantiable"; - TypeFlags[TypeFlags["StructuredOrInstantiable"] = 66846720] = "StructuredOrInstantiable"; + TypeFlags[TypeFlags["StructuredOrInstantiable"] = 201064448] = "StructuredOrInstantiable"; /* @internal */ TypeFlags[TypeFlags["ObjectFlagsType"] = 3899392] = "ObjectFlagsType"; /* @internal */ TypeFlags[TypeFlags["Simplifiable"] = 25165824] = "Simplifiable"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - TypeFlags[TypeFlags["Narrowable"] = 133970943] = "Narrowable"; + TypeFlags[TypeFlags["Narrowable"] = 268188671] = "Narrowable"; TypeFlags[TypeFlags["NotUnionOrUnit"] = 67637251] = "NotUnionOrUnit"; /* @internal */ - TypeFlags[TypeFlags["NotPrimitiveUnion"] = 66994211] = "NotPrimitiveUnion"; + TypeFlags[TypeFlags["NotPrimitiveUnion"] = 201211939] = "NotPrimitiveUnion"; // The following flags are aggregated during union and intersection type construction /* @internal */ TypeFlags[TypeFlags["IncludesMask"] = 68943871] = "IncludesMask"; @@ -3740,7 +3829,9 @@ var ts; InferencePriority[InferencePriority["LiteralKeyof"] = 32] = "LiteralKeyof"; InferencePriority[InferencePriority["NoConstraints"] = 64] = "NoConstraints"; InferencePriority[InferencePriority["AlwaysStrict"] = 128] = "AlwaysStrict"; + InferencePriority[InferencePriority["MaxValue"] = 256] = "MaxValue"; InferencePriority[InferencePriority["PriorityImpliesCombination"] = 56] = "PriorityImpliesCombination"; + InferencePriority[InferencePriority["Circularity"] = -1] = "Circularity"; })(InferencePriority = ts.InferencePriority || (ts.InferencePriority = {})); /* @internal */ var InferenceFlags; @@ -3818,6 +3909,9 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; + // NOTE: ES module kinds should be contiguous to more easily check whether a module kind is *any* ES module kind. + // Non-ES module kinds should not come between ES2015 (the earliest ES module kind) and ESNext (the last ES + // module kind). ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); @@ -4402,7 +4496,7 @@ var ts; function getCustomPollingBasedLevels(baseVariable, defaultLevels) { var customLevels = getCustomLevels(baseVariable); return (pollingIntervalChanged || customLevels) && - createPollingIntervalBasedLevels(customLevels ? __assign({}, defaultLevels, customLevels) : defaultLevels); + createPollingIntervalBasedLevels(customLevels ? __assign(__assign({}, defaultLevels), customLevels) : defaultLevels); } } ts.setCustomPollingValues = setCustomPollingValues; @@ -4556,6 +4650,38 @@ var ts; } } ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile; + /* @internal */ + function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) { + var cache = ts.createMap(); + var callbacksCache = ts.createMultiMap(); + var toCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); + return function (fileName, callback, pollingInterval) { + var path = toCanonicalFileName(fileName); + var existing = cache.get(path); + if (existing) { + existing.refCount++; + } + else { + cache.set(path, { + watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval), + refCount: 1 + }); + } + callbacksCache.add(path, callback); + return { + close: function () { + var watcher = ts.Debug.assertDefined(cache.get(path)); + callbacksCache.remove(path, callback); + watcher.refCount--; + if (watcher.refCount) + return; + cache.delete(path); + ts.closeFileWatcherOf(watcher); + } + }; + }; + } + ts.createSingleFileWatcherPerName = createSingleFileWatcherPerName; /** * Returns true if file status changed */ @@ -4582,6 +4708,8 @@ var ts; ts.getFileWatcherEventKind = getFileWatcherEventKind; /*@internal*/ ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"]; + /*@internal*/ + ts.sysLog = ts.noop; // eslint-disable-line prefer-const /** * Watch the directory recursively using host provided method to watch child directories * that means if this is recursive watcher, watch the children directories as well @@ -4702,6 +4830,7 @@ var ts; } ts.getNodeMajorVersion = getNodeMajorVersion; // TODO: GH#18217 this is used as if it's certainly defined in many places. + // eslint-disable-next-line prefer-const ts.sys = (function () { // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual // byte order mark from the specified encoding. Using any other byte order mark does @@ -4722,6 +4851,7 @@ var ts; 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 FileSystemEntryKind; @@ -4732,6 +4862,7 @@ var ts; var useNonPollingWatchers = process.env.TSC_NONPOLLING_WATCHER; var tscWatchFile = process.env.TSC_WATCHFILE; var tscWatchDirectory = process.env.TSC_WATCHDIRECTORY; + var fsWatchFile = createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames); var dynamicPollingWatchFile; var nodeSystem = { args: process.argv.slice(2), @@ -4868,7 +4999,7 @@ var ts; return useNonPollingWatchers ? createNonPollingWatchFile() : // Default to do not use polling interval as it is before this experiment branch - function (fileName, callback) { return fsWatchFile(fileName, callback); }; + function (fileName, callback) { return fsWatchFile(fileName, callback, /*pollingInterval*/ undefined); }; } function getWatchDirectory() { // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows @@ -4942,7 +5073,7 @@ var ts; return watcher; } } - function fsWatchFile(fileName, callback, pollingInterval) { + function fsWatchFileWorker(fileName, callback, pollingInterval) { _fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged); var eventKind; return { @@ -5000,6 +5131,12 @@ var ts; } function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingWatchFile, pollingInterval) { var options; + var lastDirectoryPartWithDirectorySeparator; + var lastDirectoryPart; + if (isLinuxOrMacOs) { + lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator)); + lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length); + } /** Watcher for the file system entry depending on whether it is missing or present */ var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry() : @@ -5016,6 +5153,7 @@ var ts; * @param createWatcher */ function invokeCallbackAndUpdateWatcher(createWatcher) { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); // Call the callback for current directory callback("rename", ""); // If watcher is not closed, update it @@ -5040,7 +5178,9 @@ var ts; } } try { - var presentWatcher = _fs.watch(fileOrDirectory, options, callback); + var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ? + callbackChangingToMissingFileSystemEntry : + callback); // Watch the missing file or directory or error presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); }); return presentWatcher; @@ -5052,11 +5192,23 @@ var ts; return watchPresentFileSystemEntryWithFsWatchFile(); } } + function callbackChangingToMissingFileSystemEntry(event, relativeName) { + // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations + // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path + return event === "rename" && + (!relativeName || + relativeName === lastDirectoryPart || + relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) && + !fileSystemEntryExists(fileOrDirectory, entryKind) ? + invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) : + callback(event, relativeName); + } /** * Watch the file or directory using fs.watchFile since fs.watch threw exception * Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point */ function watchPresentFileSystemEntryWithFsWatchFile() { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile"); return fallbackPollingWatchFile(fileOrDirectory, createFileWatcherCallback(callback), pollingInterval); } /** @@ -5089,7 +5241,7 @@ var ts; function createWatchDirectoryUsing(fsWatchFile) { return function (directoryName, callback) { return fsWatchFile(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium); }; } - function readFile(fileName, _encoding) { + function readFileWorker(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -5117,7 +5269,14 @@ var ts; // Default is UTF-8 with no byte order mark return buffer.toString("utf8"); } + function readFile(fileName, _encoding) { + ts.perfLogger.logStartReadFile(fileName); + var file = readFileWorker(fileName, _encoding); + ts.perfLogger.logStopReadFile(); + return file; + } function writeFile(fileName, data, writeByteOrderMark) { + ts.perfLogger.logEvent("WriteFile: " + fileName); // If a BOM is required, emit one if (writeByteOrderMark) { data = byteOrderMarkIndicator + data; @@ -5134,6 +5293,7 @@ var ts; } } function getAccessibleFileSystemEntries(path) { + ts.perfLogger.logEvent("ReadDir: " + (path || ".")); try { var entries = _fs.readdirSync(path || ".").sort(); var files = []; @@ -5189,6 +5349,7 @@ var ts; return fileSystemEntryExists(path, 1 /* Directory */); } function getDirectories(path) { + ts.perfLogger.logEvent("ReadDir: " + path); return ts.filter(_fs.readdirSync(path), function (dir) { return fileSystemEntryExists(ts.combinePaths(path, dir), 1 /* Directory */); }); } function realpath(path) { @@ -5316,7 +5477,6 @@ var ts; function diag(code, category, key, message, reportsUnnecessary) { return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary }; } - // tslint:disable-next-line variable-name ts.Diagnostics = { Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), @@ -5379,7 +5539,6 @@ var ts; A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), - An_accessor_cannot_be_declared_in_an_ambient_context: diag(1086, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_declared_in_an_ambient_context_1086", "An accessor cannot be declared in an ambient context."), _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), @@ -5434,7 +5593,6 @@ var ts; Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: diag(1150, ts.DiagnosticCategory.Error, "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", "'new T[]' cannot be used to create an array. Use 'new Array()' instead."), const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), @@ -5532,6 +5690,7 @@ var ts; 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."), Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), 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."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -5564,7 +5723,7 @@ var ts; Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), - The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), @@ -5578,6 +5737,7 @@ var ts; readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), + An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), @@ -6358,6 +6518,8 @@ var ts; Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2: diag(6381, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381", "Project '{0}' is out of date because output for it was generated with version '{1}' that differs with current version '{2}'"), + Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), + Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), 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."), @@ -6473,6 +6635,7 @@ var ts; require_call_may_be_converted_to_an_import: diag(80005, ts.DiagnosticCategory.Suggestion, "require_call_may_be_converted_to_an_import_80005", "'require' call may be converted to an import."), This_may_be_converted_to_an_async_function: diag(80006, ts.DiagnosticCategory.Suggestion, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."), await_has_no_effect_on_the_type_of_this_expression: diag(80007, ts.DiagnosticCategory.Suggestion, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."), + Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, ts.DiagnosticCategory.Suggestion, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."), Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"), Make_super_call_the_first_statement_in_the_constructor: diag(90002, ts.DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"), Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"), @@ -6590,6 +6753,12 @@ var ts; Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"), Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"), Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"), + Enable_the_jsx_flag_in_your_configuration_file: diag(95088, ts.DiagnosticCategory.Message, "Enable_the_jsx_flag_in_your_configuration_file_95088", "Enable the '--jsx' flag in your configuration file"), + Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"), + Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"), + Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"), + Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"), + Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"), 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?"), @@ -6684,10 +6853,11 @@ var ts; _a.yield = 118 /* YieldKeyword */, _a.async = 122 /* AsyncKeyword */, _a.await = 123 /* AwaitKeyword */, - _a.of = 148 /* OfKeyword */, + _a.of = 149 /* OfKeyword */, + _a.tag = 148 /* TagKeyword */, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 28 /* LessThanToken */, ">": 30 /* GreaterThanToken */, "<=": 31 /* LessThanEqualsToken */, ">=": 32 /* GreaterThanEqualsToken */, "==": 33 /* EqualsEqualsToken */, "!=": 34 /* ExclamationEqualsToken */, "===": 35 /* EqualsEqualsEqualsToken */, "!==": 36 /* ExclamationEqualsEqualsToken */, "=>": 37 /* EqualsGreaterThanToken */, "+": 38 /* PlusToken */, "-": 39 /* MinusToken */, "**": 41 /* AsteriskAsteriskToken */, "*": 40 /* AsteriskToken */, "/": 42 /* SlashToken */, "%": 43 /* PercentToken */, "++": 44 /* PlusPlusToken */, "--": 45 /* MinusMinusToken */, "<<": 46 /* LessThanLessThanToken */, ">": 47 /* GreaterThanGreaterThanToken */, ">>>": 48 /* GreaterThanGreaterThanGreaterThanToken */, "&": 49 /* AmpersandToken */, "|": 50 /* BarToken */, "^": 51 /* CaretToken */, "!": 52 /* ExclamationToken */, "~": 53 /* TildeToken */, "&&": 54 /* AmpersandAmpersandToken */, "||": 55 /* BarBarToken */, "?": 56 /* QuestionToken */, ":": 57 /* ColonToken */, "=": 60 /* EqualsToken */, "+=": 61 /* PlusEqualsToken */, "-=": 62 /* MinusEqualsToken */, "*=": 63 /* AsteriskEqualsToken */, "**=": 64 /* AsteriskAsteriskEqualsToken */, "/=": 65 /* SlashEqualsToken */, "%=": 66 /* PercentEqualsToken */, "<<=": 67 /* LessThanLessThanEqualsToken */, ">>=": 68 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 70 /* AmpersandEqualsToken */, "|=": 71 /* BarEqualsToken */, "^=": 72 /* CaretEqualsToken */, "@": 58 /* AtToken */, "`": 59 /* BacktickToken */ })); + var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 28 /* LessThanToken */, ">": 30 /* GreaterThanToken */, "<=": 31 /* LessThanEqualsToken */, ">=": 32 /* GreaterThanEqualsToken */, "==": 33 /* EqualsEqualsToken */, "!=": 34 /* ExclamationEqualsToken */, "===": 35 /* EqualsEqualsEqualsToken */, "!==": 36 /* ExclamationEqualsEqualsToken */, "=>": 37 /* EqualsGreaterThanToken */, "+": 38 /* PlusToken */, "-": 39 /* MinusToken */, "**": 41 /* AsteriskAsteriskToken */, "*": 40 /* AsteriskToken */, "/": 42 /* SlashToken */, "%": 43 /* PercentToken */, "++": 44 /* PlusPlusToken */, "--": 45 /* MinusMinusToken */, "<<": 46 /* LessThanLessThanToken */, ">": 47 /* GreaterThanGreaterThanToken */, ">>>": 48 /* GreaterThanGreaterThanGreaterThanToken */, "&": 49 /* AmpersandToken */, "|": 50 /* BarToken */, "^": 51 /* CaretToken */, "!": 52 /* ExclamationToken */, "~": 53 /* TildeToken */, "&&": 54 /* AmpersandAmpersandToken */, "||": 55 /* BarBarToken */, "?": 56 /* QuestionToken */, ":": 57 /* ColonToken */, "=": 60 /* EqualsToken */, "+=": 61 /* PlusEqualsToken */, "-=": 62 /* MinusEqualsToken */, "*=": 63 /* AsteriskEqualsToken */, "**=": 64 /* AsteriskAsteriskEqualsToken */, "/=": 65 /* SlashEqualsToken */, "%=": 66 /* PercentEqualsToken */, "<<=": 67 /* LessThanLessThanEqualsToken */, ">>=": 68 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 70 /* AmpersandEqualsToken */, "|=": 71 /* BarEqualsToken */, "^=": 72 /* CaretEqualsToken */, "@": 58 /* AtToken */, "`": 59 /* BacktickToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -6734,6 +6904,14 @@ var ts; */ var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + /** + * Generated by scripts/regenerate-unicode-identifier-parts.js on node v12.4.0 with unicode 12.1 + * based on http://www.unicode.org/reports/tr31/ and https://www.ecma-international.org/ecma-262/6.0/#sec-names-and-keywords + * unicodeESNextIdentifierStart corresponds to the ID_Start and Other_ID_Start property, and + * unicodeESNextIdentifierPart corresponds to ID_Continue, Other_ID_Continue, plus ID_Start and Other_ID_Start + */ + var unicodeESNextIdentifierStart = [65, 90, 97, 122, 170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2809, 2809, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101]; + var unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2208, 2228, 2230, 2237, 2259, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3328, 3331, 3333, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7673, 7675, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43047, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69376, 69404, 69415, 69415, 69424, 69456, 69600, 69622, 69632, 69702, 69734, 69743, 69759, 69818, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69958, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70096, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70206, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70751, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71680, 71738, 71840, 71913, 71935, 71935, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123584, 123641, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101, 917760, 917999]; function lookupInUnicodeMap(code, map) { // Bail out quickly if it couldn't possibly be in the map. if (code < map[0]) { @@ -6760,15 +6938,17 @@ var ts; return false; } /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierStart) : - lookupInUnicodeMap(code, unicodeES3IdentifierStart); + return languageVersion >= 2 /* ES2015 */ ? + lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : + languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierPart) : - lookupInUnicodeMap(code, unicodeES3IdentifierPart); + return languageVersion >= 2 /* ES2015 */ ? + lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : + languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { var result = []; @@ -6941,6 +7121,7 @@ var ts; case 32 /* space */: case 47 /* slash */: // starts of normal trivia + // falls through case 60 /* lessThan */: case 124 /* bar */: case 61 /* equals */: @@ -7264,11 +7445,12 @@ var ts; ts.isIdentifierPart = isIdentifierPart; /* @internal */ function isIdentifierText(name, languageVersion) { - if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { + var ch = codePointAt(name, 0); + if (!isIdentifierStart(ch, languageVersion)) { return false; } - for (var i = 1; i < name.length; i++) { - if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { + for (var i = charSize(ch); i < name.length; i += charSize(ch)) { + if (!isIdentifierPart(ch = codePointAt(name, i), languageVersion)) { return false; } } @@ -7292,13 +7474,14 @@ var ts; var tokenFlags; var inJSDocType = 0; setText(text, start, length); - return { + var scanner = { getStartPos: function () { return startPos; }, getTextPos: function () { return pos; }, getToken: function () { return token; }, getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, isIdentifier: function () { return token === 73 /* Identifier */ || token > 109 /* LastReservedWord */; }, @@ -7326,6 +7509,15 @@ var ts; lookAhead: lookAhead, scanRange: scanRange, }; + if (ts.Debug.isDebugging) { + Object.defineProperty(scanner, "__debugShowCurrentPositionInText", { + get: function () { + var text = scanner.getText(); + return text.slice(0, scanner.getStartPos()) + "║" + text.slice(scanner.getStartPos()); + }, + }); + } + return scanner; function error(message, errPos, length) { if (errPos === void 0) { errPos = pos; } if (onError) { @@ -7425,7 +7617,7 @@ var ts; } } function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) { - if (!isIdentifierStart(text.charCodeAt(pos), languageVersion)) { + if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) { return; } var identifierStart = pos; @@ -7633,6 +7825,7 @@ var ts; pos++; return scanExtendedUnicodeEscape(); } + tokenFlags |= 1024 /* UnicodeEscape */; // '\uDDDD' return scanHexadecimalEscape(/*numDigits*/ 4); case 120 /* x */: @@ -7715,21 +7908,41 @@ var ts; } return -1; } + function peekExtendedUnicodeEscape() { + if (languageVersion >= 2 /* ES2015 */ && codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) { + var start_2 = pos; + pos += 3; + var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); + var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; + pos = start_2; + return escapedValue; + } + return -1; + } function scanIdentifierParts() { var result = ""; var start = pos; while (pos < end) { - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); if (isIdentifierPart(ch, languageVersion)) { - pos++; + pos += charSize(ch); } else if (ch === 92 /* backslash */) { + ch = peekExtendedUnicodeEscape(); + if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + result += scanExtendedUnicodeEscape(); + start = pos; + continue; + } ch = peekUnicodeEscape(); if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } + tokenFlags |= 1024 /* UnicodeEscape */; result += text.substring(start, pos); - result += String.fromCharCode(ch); + result += utf16EncodeAsString(ch); // Valid Unicode escape is always six characters pos += 6; start = pos; @@ -7817,14 +8030,14 @@ var ts; function scan() { var _a; startPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; var asteriskSeen = false; while (true) { tokenPos = pos; if (pos >= end) { return token = 1 /* EndOfFileToken */; } - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); // Special handling for shebang if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); @@ -8189,9 +8402,17 @@ var ts; pos++; return token = 58 /* AtToken */; case 92 /* backslash */: + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; + tokenFlags |= 1024 /* UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } @@ -8200,9 +8421,9 @@ var ts; return token = 0 /* Unknown */; default: if (isIdentifierStart(ch, languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; + pos += charSize(ch); + while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) + pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); if (ch === 92 /* backslash */) { tokenValue += scanIdentifierParts(); @@ -8210,16 +8431,16 @@ var ts; return token = getIdentifierToken(); } else if (isWhiteSpaceSingleLine(ch)) { - pos++; + pos += charSize(ch); continue; } else if (isLineBreak(ch)) { tokenFlags |= 1 /* PrecedingLineBreak */; - pos++; + pos += charSize(ch); continue; } error(ts.Diagnostics.Invalid_character); - pos++; + pos += charSize(ch); return token = 0 /* Unknown */; } } @@ -8336,7 +8557,7 @@ var ts; // First non-whitespace character on this line. var firstNonWhitespace = 0; // These initial values are special because the first line is: - // firstNonWhitespace = 0 to indicate that we want leading whitspace, + // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { char = text.charCodeAt(pos); if (char === 123 /* openBrace */) { @@ -8370,17 +8591,22 @@ var ts; // they allow dashes function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { - var firstCharPosition = pos; + // An identifier or keyword has already been parsed - check for a `-` and then append it and everything after it to the token + // Do note that this means that `scanJsxIdentifier` effectively _mutates_ the visible token without advancing to a new token + // Any caller should be expecting this behavior and should only read the pos or token value after calling it. while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { + if (ch === 45 /* minus */) { + tokenValue += "-"; pos++; + continue; } - else { + var oldPos = pos; + tokenValue += scanIdentifierParts(); // reuse `scanIdentifierParts` so unicode escapes are handled + if (pos === oldPos) { break; } } - tokenValue += text.substring(firstCharPosition, pos); } return token; } @@ -8398,12 +8624,12 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; if (pos >= end) { return token = 1 /* EndOfFileToken */; } - var ch = text.charCodeAt(pos); - pos++; + var ch = codePointAt(text, pos); + pos += charSize(ch); switch (ch) { case 9 /* tab */: case 11 /* verticalTab */: @@ -8441,12 +8667,33 @@ var ts; return token = 24 /* DotToken */; case 96 /* backtick */: return token = 59 /* BacktickToken */; - } - if (isIdentifierStart(ch, 99 /* Latest */)) { - while (isIdentifierPart(text.charCodeAt(pos), 99 /* Latest */) && pos < end) { + case 92 /* backslash */: + pos--; + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } + var cookedChar = peekUnicodeEscape(); + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + pos += 6; + tokenFlags |= 1024 /* UnicodeEscape */; + tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); + return token = getIdentifierToken(); + } pos++; - } + return token = 0 /* Unknown */; + } + if (isIdentifierStart(ch, languageVersion)) { + var char = ch; + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) + pos += charSize(char); tokenValue = text.substring(tokenPos, pos); + if (char === 92 /* backslash */) { + tokenValue += scanIdentifierParts(); + } return token = getIdentifierToken(); } else { @@ -8522,13 +8769,40 @@ var ts; tokenPos = textPos; token = 0 /* Unknown */; tokenValue = undefined; - tokenFlags = 0; + tokenFlags = 0 /* None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; } } ts.createScanner = createScanner; + /* @internal */ + var codePointAt = String.prototype.codePointAt ? function (s, i) { return s.codePointAt(i); } : function codePointAt(str, i) { + // from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt + var size = str.length; + // Account for out-of-bounds indices: + if (i < 0 || i >= size) { + return undefined; // String.codePointAt returns `undefined` for OOB indexes + } + // Get the first code unit + var first = str.charCodeAt(i); + // check if it’s the start of a surrogate pair + if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) { // high surrogate and there is a next code unit + var second = str.charCodeAt(i + 1); + if (second >= 0xDC00 && second <= 0xDFFF) { // low surrogate + // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + } + } + return first; + }; + /* @internal */ + function charSize(ch) { + if (ch >= 0x10000) { + return 2; + } + return 1; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -8695,7 +8969,7 @@ var ts; } ts.copyEntries = copyEntries; function arrayToSet(array, makeKey) { - return ts.arrayToMap(array, makeKey || (function (s) { return s; }), function () { return true; }); + return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue); } ts.arrayToSet = arrayToSet; function cloneMap(map) { @@ -8804,7 +9078,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 285 /* SourceFile */) { + while (node && node.kind !== 286 /* SourceFile */) { node = node.parent; } return node; @@ -8812,11 +9086,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 220 /* Block */: + case 248 /* CaseBlock */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: return true; } return false; @@ -8901,7 +9175,7 @@ var ts; break; } } - to.splice.apply(to, [statementIndex, 0].concat(from)); + to.splice.apply(to, __spreadArrays([statementIndex, 0], from)); return to; } function insertStatementAfterPrologue(to, statement, isPrologueDirective) { @@ -8984,7 +9258,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 313 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 315 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -9003,7 +9277,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 289 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 290 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -9049,6 +9323,8 @@ var ts; ts.isBigIntLiteral(node))) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } + // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text + // had to include a backslash: `not \${a} substitution`. var escapeText = neverAsciiEscape || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; // If we can't reach the original source text, use the canonical form if it's a number, // or a (possibly escaped) quoted form of the original text if it's string-like. @@ -9061,15 +9337,21 @@ var ts; return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; } case 14 /* NoSubstitutionTemplateLiteral */: - return "`" + escapeText(node.text, 96 /* backtick */) + "`"; case 15 /* TemplateHead */: - // tslint:disable-next-line no-invalid-template-strings - return "`" + escapeText(node.text, 96 /* backtick */) + "${"; case 16 /* TemplateMiddle */: - // tslint:disable-next-line no-invalid-template-strings - return "}" + escapeText(node.text, 96 /* backtick */) + "${"; case 17 /* TemplateTail */: - return "}" + escapeText(node.text, 96 /* backtick */) + "`"; + var rawText = node.rawText || escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); + switch (node.kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + return "`" + rawText + "`"; + case 15 /* TemplateHead */: + return "`" + rawText + "${"; + case 16 /* TemplateMiddle */: + return "}" + rawText + "${"; + case 17 /* TemplateTail */: + return "}" + rawText + "`"; + } + break; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 13 /* RegularExpressionLiteral */: @@ -9095,7 +9377,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 238 /* VariableDeclaration */ && node.parent.kind === 275 /* CatchClause */; + return node.kind === 239 /* VariableDeclaration */ && node.parent.kind === 276 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -9127,11 +9409,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 === 245 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 246 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 285 /* SourceFile */ || - node.kind === 245 /* ModuleDeclaration */ || + return node.kind === 286 /* SourceFile */ || + node.kind === 246 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -9148,9 +9430,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: return ts.isExternalModule(node.parent); - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -9164,24 +9446,61 @@ var ts; return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS) && !!node.commonJsModuleIndicator); } ts.isEffectiveExternalModule = isEffectiveExternalModule; + /** + * Returns whether the source file will be treated as if it were in strict mode at runtime. + */ + function isEffectiveStrictModeSourceFile(node, compilerOptions) { + // We can only verify strict mode for JS/TS files + switch (node.scriptKind) { + case 1 /* JS */: + case 3 /* TS */: + case 2 /* JSX */: + case 4 /* TSX */: + break; + default: + return false; + } + // Strict mode does not matter for declaration files. + if (node.isDeclarationFile) { + return false; + } + // If `alwaysStrict` is set, then treat the file as strict. + if (ts.getStrictOptionValue(compilerOptions, "alwaysStrict")) { + return true; + } + // Starting with a "use strict" directive indicates the file is strict. + if (ts.startsWithUseStrict(node.statements)) { + return true; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + // ECMAScript Modules are always strict. + if (ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { + return true; + } + // Other modules are strict unless otherwise specified. + return !compilerOptions.noImplicitUseStrict; + } + return false; + } + ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 275 /* CatchClause */: - case 245 /* ModuleDeclaration */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 286 /* SourceFile */: + case 248 /* CaseBlock */: + case 276 /* CatchClause */: + case 246 /* ModuleDeclaration */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return true; - case 219 /* Block */: + case 220 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -9191,9 +9510,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: - case 299 /* JSDocSignature */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 301 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -9203,25 +9522,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 157 /* MethodSignature */: + case 164 /* IndexSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 296 /* JSDocFunctionType */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 312 /* JSDocTemplateTag */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -9231,8 +9550,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: return true; default: return false; @@ -9241,15 +9560,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 220 /* VariableStatement */: - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 221 /* VariableStatement */: + case 242 /* ClassDeclaration */: + case 241 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: return true; default: return false; @@ -9285,7 +9604,7 @@ var ts; case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 151 /* 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"); @@ -9298,9 +9617,9 @@ var ts; switch (name.kind) { case 73 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -9345,7 +9664,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 219 /* Block */) { + if (node.body && node.body.kind === 220 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -9359,7 +9678,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 285 /* SourceFile */: + case 286 /* 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 @@ -9368,25 +9687,25 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 239 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 244 /* TypeAliasDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: errorNode = node.name; break; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -9394,6 +9713,7 @@ var ts; // construct. return getSpanOfTokenAtPosition(sourceFile, node.pos); } + ts.Debug.assert(!ts.isJSDoc(errorNode)); var isMissing = nodeIsMissing(errorNode); var pos = isMissing || ts.isJsxText(node) ? errorNode.pos @@ -9423,7 +9743,7 @@ var ts; } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { @@ -9435,19 +9755,25 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 99 /* SuperKeyword */; + return n.kind === 193 /* CallExpression */ && n.expression.kind === 99 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 93 /* ImportKeyword */; + return n.kind === 193 /* CallExpression */ && n.expression.kind === 93 /* ImportKeyword */; } ts.isImportCall = isImportCall; + function isImportMeta(n) { + return ts.isMetaProperty(n) + && n.keywordToken === 93 /* ImportKeyword */ + && n.name.escapedText === "meta"; + } + ts.isImportMeta = isImportMeta; function isLiteralImportTypeNode(n) { return ts.isImportTypeNode(n) && ts.isLiteralTypeNode(n.argument) && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 222 /* ExpressionStatement */ + return node.kind === 223 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -9456,11 +9782,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 152 /* Parameter */ || - node.kind === 151 /* TypeParameter */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 198 /* ArrowFunction */ || - node.kind === 196 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 153 /* Parameter */ || + node.kind === 152 /* TypeParameter */ || + node.kind === 198 /* FunctionExpression */ || + node.kind === 199 /* ArrowFunction */ || + node.kind === 197 /* ParenthesizedExpression */) ? 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 '/**/' @@ -9476,7 +9802,7 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (164 /* FirstTypeNode */ <= node.kind && node.kind <= 184 /* LastTypeNode */) { + if (165 /* FirstTypeNode */ <= node.kind && node.kind <= 185 /* LastTypeNode */) { return true; } switch (node.kind) { @@ -9492,32 +9818,32 @@ var ts; case 133 /* NeverKeyword */: return true; case 107 /* VoidKeyword */: - return node.parent.kind !== 201 /* VoidExpression */; - case 212 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 202 /* VoidExpression */; + case 213 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 151 /* TypeParameter */: - return node.parent.kind === 182 /* MappedType */ || node.parent.kind === 177 /* InferType */; + case 152 /* TypeParameter */: + return node.parent.kind === 183 /* MappedType */ || node.parent.kind === 178 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 73 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 150 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 191 /* 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 === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */ || node.kind === 190 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 73 /* Identifier */ || node.kind === 150 /* QualifiedName */ || node.kind === 191 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 149 /* QualifiedName */: - case 190 /* PropertyAccessExpression */: + case 150 /* QualifiedName */: + case 191 /* PropertyAccessExpression */: case 101 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 168 /* TypeQuery */) { + if (parent.kind === 169 /* TypeQuery */) { return false; } - if (parent.kind === 184 /* ImportType */) { + if (parent.kind === 185 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -9526,40 +9852,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 (164 /* FirstTypeNode */ <= parent.kind && parent.kind <= 184 /* LastTypeNode */) { + if (165 /* FirstTypeNode */ <= parent.kind && parent.kind <= 185 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return node === parent.constraint; - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return node === parent.constraint; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 153 /* Parameter */: + case 239 /* VariableDeclaration */: return node === parent.type; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return node === parent.type; - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: return node === parent.type; - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: return node === parent.type; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -9584,23 +9910,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitor(node); - case 247 /* CaseBlock */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 248 /* CaseBlock */: + case 220 /* Block */: + case 224 /* IfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 233 /* WithStatement */: + case 234 /* SwitchStatement */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: + case 235 /* LabeledStatement */: + case 237 /* TryStatement */: + case 276 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -9610,26 +9936,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 245 /* EnumDeclaration */: + case 243 /* InterfaceDeclaration */: + case 246 /* ModuleDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 151 /* 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); @@ -9652,10 +9978,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 170 /* ArrayType */) { + if (node && node.kind === 171 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 165 /* TypeReference */) { + else if (node && node.kind === 166 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9665,12 +9991,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 169 /* TypeLiteral */: + case 243 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 170 /* TypeLiteral */: return node.members; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return node.properties; } } @@ -9678,14 +10004,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 187 /* BindingElement */: - case 279 /* EnumMember */: - case 152 /* Parameter */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 277 /* ShorthandPropertyAssignment */: - case 238 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 280 /* EnumMember */: + case 153 /* Parameter */: + case 277 /* PropertyAssignment */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 278 /* ShorthandPropertyAssignment */: + case 239 /* VariableDeclaration */: return true; } } @@ -9697,8 +10023,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 239 /* VariableDeclarationList */ - && node.parent.parent.kind === 220 /* VariableStatement */; + return node.parent.kind === 240 /* VariableDeclarationList */ + && node.parent.parent.kind === 221 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -9709,13 +10035,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: return true; } return false; @@ -9726,7 +10052,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 234 /* LabeledStatement */) { + if (node.statement.kind !== 235 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -9734,17 +10060,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 219 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 220 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 157 /* MethodDeclaration */ && node.parent.kind === 189 /* ObjectLiteralExpression */; + return node && node.kind === 158 /* MethodDeclaration */ && node.parent.kind === 190 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 157 /* MethodDeclaration */ && - (node.parent.kind === 189 /* ObjectLiteralExpression */ || - node.parent.kind === 210 /* ClassExpression */); + return node.kind === 158 /* MethodDeclaration */ && + (node.parent.kind === 190 /* ObjectLiteralExpression */ || + node.parent.kind === 211 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -9757,7 +10083,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 276 /* PropertyAssignment */) { + if (property.kind === 277 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -9798,14 +10124,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 285 /* SourceFile */); + ts.Debug.assert(node.kind !== 286 /* 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 150 /* ComputedPropertyName */: + case 151 /* 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 @@ -9820,9 +10146,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 153 /* Decorator */: + case 154 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 153 /* 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; @@ -9833,26 +10159,26 @@ var ts; node = node.parent; } break; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 245 /* ModuleDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 244 /* EnumDeclaration */: - case 285 /* SourceFile */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 246 /* ModuleDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 245 /* EnumDeclaration */: + case 286 /* SourceFile */: return node; } } @@ -9862,9 +10188,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 159 /* Constructor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: return container; } } @@ -9886,27 +10212,27 @@ var ts; return node; } switch (node.kind) { - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: node = node.parent; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return node; - case 153 /* Decorator */: + case 154 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 153 /* 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; @@ -9922,14 +10248,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 197 /* FunctionExpression */ || func.kind === 198 /* ArrowFunction */) { + if (func.kind === 198 /* FunctionExpression */ || func.kind === 199 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 196 /* ParenthesizedExpression */) { + while (parent.kind === 197 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 192 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 193 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -9945,7 +10271,7 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) + return (kind === 191 /* PropertyAccessExpression */ || kind === 192 /* ElementAccessExpression */) && node.expression.kind === 99 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; @@ -9954,20 +10280,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) + return (kind === 191 /* PropertyAccessExpression */ || kind === 192 /* ElementAccessExpression */) && node.expression.kind === 101 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return node; } return undefined; @@ -9975,10 +10301,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return node.tag; - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -9987,25 +10313,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: // classes are valid targets return true; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 241 /* ClassDeclaration */; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + return parent.kind === 242 /* ClassDeclaration */; + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 158 /* 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 === 241 /* ClassDeclaration */; - case 152 /* Parameter */: + && parent.kind === 242 /* ClassDeclaration */; + case 153 /* 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 === 158 /* Constructor */ - || parent.kind === 157 /* MethodDeclaration */ - || parent.kind === 160 /* SetAccessor */) - && grandparent.kind === 241 /* ClassDeclaration */; + && (parent.kind === 159 /* Constructor */ + || parent.kind === 158 /* MethodDeclaration */ + || parent.kind === 161 /* SetAccessor */) + && grandparent.kind === 242 /* ClassDeclaration */; } return false; } @@ -10021,10 +10347,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 161 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -10033,9 +10359,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 263 /* JsxOpeningElement */ || - parent.kind === 262 /* JsxSelfClosingElement */ || - parent.kind === 264 /* JsxClosingElement */) { + if (parent.kind === 264 /* JsxOpeningElement */ || + parent.kind === 263 /* JsxSelfClosingElement */ || + parent.kind === 265 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -10048,45 +10374,45 @@ var ts; case 103 /* TrueKeyword */: case 88 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 213 /* AsExpression */: - case 195 /* TypeAssertionExpression */: - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 209 /* SpreadElement */: - case 207 /* TemplateExpression */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 195 /* TaggedTemplateExpression */: + case 214 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 215 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: + case 198 /* FunctionExpression */: + case 211 /* ClassExpression */: + case 199 /* ArrowFunction */: + case 202 /* VoidExpression */: + case 200 /* DeleteExpression */: + case 201 /* TypeOfExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: + case 206 /* BinaryExpression */: + case 207 /* ConditionalExpression */: + case 210 /* SpreadElement */: + case 208 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: - case 211 /* OmittedExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 208 /* YieldExpression */: - case 202 /* AwaitExpression */: - case 215 /* MetaProperty */: + case 212 /* OmittedExpression */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 266 /* JsxFragment */: + case 209 /* YieldExpression */: + case 203 /* AwaitExpression */: + case 216 /* MetaProperty */: return true; - case 149 /* QualifiedName */: - while (node.parent.kind === 149 /* QualifiedName */) { + case 150 /* QualifiedName */: + while (node.parent.kind === 150 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node); + return node.parent.kind === 169 /* TypeQuery */ || isJSXTagName(node); case 73 /* Identifier */: - if (node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node)) { + if (node.parent.kind === 169 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through @@ -10103,49 +10429,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 187 /* BindingElement */: + case 239 /* VariableDeclaration */: + case 153 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 280 /* EnumMember */: + case 277 /* PropertyAssignment */: + case 188 /* BindingElement */: return parent.initializer === node; - case 222 /* ExpressionStatement */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 231 /* ReturnStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 235 /* ThrowStatement */: + case 223 /* ExpressionStatement */: + case 224 /* IfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 232 /* ReturnStatement */: + case 233 /* WithStatement */: + case 234 /* SwitchStatement */: + case 273 /* CaseClause */: + case 236 /* ThrowStatement */: return parent.expression === node; - case 226 /* ForStatement */: + case 227 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 240 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 240 /* VariableDeclarationList */) || forInStatement.expression === node; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: return node === parent.expression; - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return node === parent.expression; - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return node === parent.expression; - case 153 /* Decorator */: - case 271 /* JsxExpression */: - case 270 /* JsxSpreadAttribute */: - case 278 /* SpreadAssignment */: + case 154 /* Decorator */: + case 272 /* JsxExpression */: + case 271 /* JsxSpreadAttribute */: + case 279 /* SpreadAssignment */: return true; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -10153,7 +10479,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */; + return node.kind === 250 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 261 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -10162,7 +10488,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 260 /* ExternalModuleReference */; + return node.kind === 250 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 261 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -10194,7 +10520,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 192 /* CallExpression */) { + if (callExpression.kind !== 193 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -10306,11 +10632,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 197 /* FunctionExpression */ || e.kind === 198 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 198 /* FunctionExpression */ || e.kind === 199 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 197 /* FunctionExpression */ || - initializer.kind === 210 /* ClassExpression */ || - initializer.kind === 198 /* ArrowFunction */) { + if (initializer.kind === 198 /* FunctionExpression */ || + initializer.kind === 211 /* ClassExpression */ || + initializer.kind === 199 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -10478,7 +10804,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 222 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 223 /* ExpressionStatement */ && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -10487,7 +10813,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 240 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 241 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -10496,14 +10822,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: return node.parent; - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: return node.parent.parent; - case 192 /* CallExpression */: + case 193 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 183 /* LiteralType */: + case 184 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -10513,12 +10839,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: return node.moduleSpecifier; - case 249 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 260 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 184 /* ImportType */: + case 250 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 261 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 185 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -10527,11 +10853,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return node; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -10539,19 +10865,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 250 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 251 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 152 /* Parameter */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 277 /* ShorthandPropertyAssignment */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 153 /* Parameter */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 278 /* ShorthandPropertyAssignment */: + case 277 /* PropertyAssignment */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -10565,7 +10891,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 311 /* JSDocTypedefTag */ || node.kind === 304 /* JSDocCallbackTag */; + return node.kind === 313 /* JSDocTypedefTag */ || node.kind === 306 /* JSDocCallbackTag */ || node.kind === 307 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10590,12 +10916,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return node.initializer; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return node.initializer; } } @@ -10606,7 +10932,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 245 /* ModuleDeclaration */ + node.body.kind === 246 /* ModuleDeclaration */ ? node.body : undefined; } @@ -10621,11 +10947,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 152 /* Parameter */) { + if (node.kind === 153 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 151 /* TypeParameter */) { + if (node.kind === 152 /* TypeParameter */) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -10636,10 +10962,10 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 276 /* PropertyAssignment */ || - parent.kind === 255 /* ExportAssignment */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 222 /* ExpressionStatement */ && node.kind === 190 /* PropertyAccessExpression */ || + if (parent.kind === 277 /* PropertyAssignment */ || + parent.kind === 256 /* ExportAssignment */ || + parent.kind === 156 /* PropertyDeclaration */ || + parent.kind === 223 /* ExpressionStatement */ && node.kind === 191 /* PropertyAccessExpression */ || getNestedModuleDeclaration(parent) || ts.isBinaryExpression(node) && node.operatorToken.kind === 60 /* EqualsToken */) { return parent; @@ -10700,7 +11026,7 @@ var ts; function getTypeParameterFromJsDoc(node) { var name = node.name.escapedText; var typeParameters = node.parent.parent.parent.typeParameters; - return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); + return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { @@ -10710,7 +11036,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 === 296 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 297 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10723,31 +11049,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 60 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 44 /* PlusPlusToken */ || unaryOperator === 45 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 196 /* ParenthesizedExpression */: - case 188 /* ArrayLiteralExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: + case 189 /* ArrayLiteralExpression */: + case 210 /* SpreadElement */: + case 215 /* NonNullExpression */: node = parent; break; - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -10774,22 +11100,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 219 /* Block */: - case 220 /* VariableStatement */: - case 232 /* WithStatement */: - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 220 /* Block */: + case 221 /* VariableStatement */: + case 233 /* WithStatement */: + case 224 /* IfStatement */: + case 234 /* SwitchStatement */: + case 248 /* CaseBlock */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: + case 235 /* LabeledStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 237 /* TryStatement */: + case 276 /* CatchClause */: return true; } return false; @@ -10806,33 +11132,33 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 178 /* ParenthesizedType */); + return walkUp(node, 179 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 196 /* ParenthesizedExpression */); + return walkUp(node, 197 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 197 /* ParenthesizedExpression */) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 197 /* 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 !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 191 /* PropertyAccessExpression */ && node.kind !== 192 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 199 /* DeleteExpression */; + return node && node.kind === 200 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -10882,7 +11208,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 10 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 150 /* ComputedPropertyName */ && + node.parent.kind === 151 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -10890,32 +11216,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 190 /* PropertyAccessExpression */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 280 /* EnumMember */: + case 277 /* PropertyAssignment */: + case 191 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 149 /* QualifiedName */) { + while (parent.kind === 150 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 168 /* TypeQuery */ || parent.kind === 165 /* TypeReference */; + return parent.kind === 169 /* TypeQuery */ || parent.kind === 166 /* TypeReference */; } return false; - case 187 /* BindingElement */: - case 254 /* ImportSpecifier */: + case 188 /* BindingElement */: + case 255 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 258 /* ExportSpecifier */: - case 268 /* JsxAttribute */: + case 259 /* ExportSpecifier */: + case 269 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -10932,13 +11258,13 @@ var ts; // export default // module.exports = function isAliasSymbolDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 248 /* NamespaceExportDeclaration */ || - node.kind === 251 /* ImportClause */ && !!node.name || - node.kind === 252 /* NamespaceImport */ || - node.kind === 254 /* ImportSpecifier */ || - node.kind === 258 /* ExportSpecifier */ || - node.kind === 255 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + return node.kind === 250 /* ImportEqualsDeclaration */ || + node.kind === 249 /* NamespaceExportDeclaration */ || + node.kind === 252 /* ImportClause */ && !!node.name || + node.kind === 253 /* NamespaceImport */ || + node.kind === 255 /* ImportSpecifier */ || + node.kind === 259 /* ExportSpecifier */ || + node.kind === 256 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -10971,9 +11297,9 @@ var ts; ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { - return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray - : ts.emptyArray; + return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray : + ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : + ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { @@ -11004,17 +11330,21 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 74 /* FirstKeyword */ <= token && token <= 148 /* LastKeyword */; + return 74 /* FirstKeyword */ <= token && token <= 149 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 119 /* FirstContextualKeyword */ <= token && token <= 148 /* LastContextualKeyword */; + return 119 /* FirstContextualKeyword */ <= token && token <= 149 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { return isKeyword(token) && !isContextualKeyword(token); } ts.isNonContextualKeyword = isNonContextualKeyword; + function isFutureReservedKeyword(token) { + return 110 /* FirstFutureReservedWord */ <= token && token <= 118 /* LastFutureReservedWord */; + } + ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { var token = ts.stringToToken(name); return token !== undefined && isNonContextualKeyword(token); @@ -11043,14 +11373,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -11064,10 +11394,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -11100,7 +11430,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 150 /* ComputedPropertyName */ && + return name.kind === 151 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression) && !isSignedNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); @@ -11122,7 +11452,7 @@ var ts; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -11177,11 +11507,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 152 /* Parameter */; + return root.kind === 153 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 187 /* BindingElement */) { + while (node.kind === 188 /* BindingElement */) { node = node.parent.parent; } return node; @@ -11189,15 +11519,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 197 /* FunctionExpression */ - || kind === 240 /* FunctionDeclaration */ - || kind === 198 /* ArrowFunction */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 245 /* ModuleDeclaration */ - || kind === 285 /* SourceFile */; + return kind === 159 /* Constructor */ + || kind === 198 /* FunctionExpression */ + || kind === 241 /* FunctionDeclaration */ + || kind === 199 /* ArrowFunction */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */ + || kind === 246 /* ModuleDeclaration */ + || kind === 286 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -11216,23 +11546,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 194 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 193 /* NewExpression */: + case 194 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: + case 204 /* PrefixUnaryExpression */: + case 201 /* TypeOfExpression */: + case 202 /* VoidExpression */: + case 200 /* DeleteExpression */: + case 203 /* AwaitExpression */: + case 207 /* ConditionalExpression */: + case 209 /* YieldExpression */: return 1 /* Right */; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (operator) { case 41 /* AsteriskAsteriskToken */: case 60 /* EqualsToken */: @@ -11256,15 +11586,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 194 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 205 /* BinaryExpression */) { + if (expression.kind === 206 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 203 /* PrefixUnaryExpression */ || expression.kind === 204 /* PostfixUnaryExpression */) { + else if (expression.kind === 204 /* PrefixUnaryExpression */ || expression.kind === 205 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -11274,15 +11604,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: return 0; - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return 1; - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return 2; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return 4; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0; @@ -11303,21 +11633,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: + case 204 /* PrefixUnaryExpression */: + case 201 /* TypeOfExpression */: + case 202 /* VoidExpression */: + case 200 /* DeleteExpression */: + case 203 /* AwaitExpression */: return 16; - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return 17; - case 192 /* CallExpression */: + case 193 /* CallExpression */: return 18; - case 193 /* NewExpression */: + case 194 /* NewExpression */: return hasArguments ? 19 : 18; - case 194 /* TaggedTemplateExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 195 /* TaggedTemplateExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return 19; case 101 /* ThisKeyword */: case 99 /* SuperKeyword */: @@ -11328,19 +11658,19 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 211 /* ClassExpression */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 266 /* JsxFragment */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 196 /* ParenthesizedExpression */: - case 211 /* OmittedExpression */: + case 208 /* TemplateExpression */: + case 197 /* ParenthesizedExpression */: + case 212 /* OmittedExpression */: return 20; default: return -1; @@ -11460,6 +11790,10 @@ var ts; } } ts.createDiagnosticCollection = createDiagnosticCollection; + var templateSubstitutionRegExp = /\$\{/g; + function escapeTemplateSubstitution(str) { + return str.replace(templateSubstitutionRegExp, "\\${"); + } // This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, // paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in // the language service. These characters should be escaped when printing, and if any characters are added, @@ -11467,7 +11801,8 @@ var ts; // There is no reason for this other than that JSON.stringify does not handle it either. var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var backtickQuoteEscapedCharsRegExp = /[\\\`\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + // Template strings should be preserved as much as possible + var backtickQuoteEscapedCharsRegExp = /[\\\`]/g; var escapedCharsMap = ts.createMapFromTemplate({ "\t": "\\t", "\v": "\\v", @@ -11645,7 +11980,7 @@ var ts; }; } ts.createTextWriter = createTextWriter; - function getTrailingSemicolonOmittingWriter(writer) { + function getTrailingSemicolonDeferringWriter(writer) { var pendingTrailingSemicolon = false; function commitPendingTrailingSemicolon() { if (pendingTrailingSemicolon) { @@ -11653,7 +11988,7 @@ var ts; pendingTrailingSemicolon = false; } } - return __assign({}, writer, { writeTrailingSemicolon: function () { + return __assign(__assign({}, writer), { writeTrailingSemicolon: function () { pendingTrailingSemicolon = true; }, writeLiteral: function (s) { @@ -11707,6 +12042,17 @@ var ts; decreaseIndent: function () { commitPendingTrailingSemicolon(); writer.decreaseIndent(); + }, + resetPendingTrailingSemicolon: function () { + pendingTrailingSemicolon = false; + } }); + } + ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter; + function getTrailingSemicolonOmittingWriter(writer) { + var deferringWriter = getTrailingSemicolonDeferringWriter(writer); + return __assign(__assign({}, deferringWriter), { writeLine: function () { + deferringWriter.resetPendingTrailingSemicolon(); + writer.writeLine(); } }); } ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; @@ -11828,6 +12174,7 @@ var ts; return accessor.parameters[hasThis ? 1 : 0]; } } + ts.getSetAccessorValueParameter = getSetAccessorValueParameter; /** Get the type annotation for the value parameter. */ function getSetAccessorTypeAnnotationNode(accessor) { var parameter = getSetAccessorValueParameter(accessor); @@ -11864,10 +12211,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 160 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 160 /* SetAccessor */) { + else if (accessor.kind === 161 /* SetAccessor */) { setAccessor = accessor; } else { @@ -11887,10 +12234,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 159 /* GetAccessor */ && !getAccessor) { + if (member.kind === 160 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 160 /* SetAccessor */ && !setAccessor) { + if (member.kind === 161 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -11936,7 +12283,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 === 297 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 299 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -12234,8 +12581,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 189 /* ObjectLiteralExpression */ - || kind === 188 /* ArrayLiteralExpression */; + return kind === 190 /* ObjectLiteralExpression */ + || kind === 189 /* ArrayLiteralExpression */; } return false; } @@ -12267,17 +12614,17 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 150 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 191 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 189 /* ObjectLiteralExpression */ && + return expression.kind === 190 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 188 /* ArrayLiteralExpression */ && + return expression.kind === 189 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -12575,8 +12922,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 246 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -12653,35 +13000,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return accessKind(parent); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 44 /* PlusPlusToken */ || operator === 45 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? operatorToken.kind === 60 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 276 /* PropertyAssignment */: { + case 277 /* 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 277 /* ShorthandPropertyAssignment */: + case 278 /* 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 188 /* ArrayLiteralExpression */: + case 189 /* 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 === 222 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 223 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -12727,8 +13074,8 @@ var ts; /** * Mutates the map with newMap such that keys in map will be same as newMap. */ - function mutateMap(map, newMap, options) { - var createNewValue = options.createNewValue, onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; + function mutateMapSkippingNewValues(map, newMap, options) { + var onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; // Needs update map.forEach(function (existingValue, key) { var valueInNewMap = newMap.get(key); @@ -12742,6 +13089,15 @@ var ts; onExistingValue(existingValue, valueInNewMap, key); } }); + } + ts.mutateMapSkippingNewValues = mutateMapSkippingNewValues; + /** + * Mutates the map with newMap such that keys in map will be same as newMap. + */ + function mutateMap(map, newMap, options) { + // Needs update + mutateMapSkippingNewValues(map, newMap, options); + var createNewValue = options.createNewValue; // Add new values that are not already present newMap.forEach(function (valueInNewMap, key) { if (!map.has(key)) { @@ -12836,7 +13192,7 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) + return (kind >= 165 /* FirstTypeNode */ && kind <= 185 /* LastTypeNode */) || kind === 121 /* AnyKeyword */ || kind === 144 /* UnknownKeyword */ || kind === 136 /* NumberKeyword */ @@ -12850,18 +13206,18 @@ var ts; || kind === 142 /* UndefinedKeyword */ || kind === 97 /* NullKeyword */ || kind === 133 /* NeverKeyword */ - || kind === 212 /* ExpressionWithTypeArguments */ - || kind === 290 /* JSDocAllType */ - || kind === 291 /* JSDocUnknownType */ - || kind === 292 /* JSDocNullableType */ - || kind === 293 /* JSDocNonNullableType */ - || kind === 294 /* JSDocOptionalType */ - || kind === 295 /* JSDocFunctionType */ - || kind === 296 /* JSDocVariadicType */; + || kind === 213 /* ExpressionWithTypeArguments */ + || kind === 291 /* JSDocAllType */ + || kind === 292 /* JSDocUnknownType */ + || kind === 293 /* JSDocNullableType */ + || kind === 294 /* JSDocNonNullableType */ + || kind === 295 /* JSDocOptionalType */ + || kind === 296 /* JSDocFunctionType */ + || kind === 297 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */ || node.kind === 191 /* ElementAccessExpression */; + return node.kind === 191 /* PropertyAccessExpression */ || node.kind === 192 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function isBundleFileTextLike(section) { @@ -12981,7 +13337,7 @@ var ts; return { span: span, newLength: newLength }; } ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); // eslint-disable-line prefer-const /** * Called to merge all the changes that occurred across several versions of a script snapshot * into a single change. i.e. if a user keeps making successive edits to a script we will @@ -13098,17 +13454,17 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 151 /* TypeParameter */) { + if (d && d.kind === 152 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 243 /* InterfaceDeclaration */) { return current; } } } } ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 158 /* Constructor */; + function isParameterPropertyDeclaration(node, parent) { + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 159 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -13138,14 +13494,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 238 /* VariableDeclaration */) { + if (node.kind === 239 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 239 /* VariableDeclarationList */) { + if (node && node.kind === 240 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 220 /* VariableStatement */) { + if (node && node.kind === 221 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -13209,7 +13565,8 @@ var ts; return false; } try { - // tslint:disable-next-line no-unnecessary-qualifier (making clear this is a global mutation!) + // making clear this is a global mutation! + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier ts.localizedDiagnosticMessages = JSON.parse(fileContents); } catch (_a) { @@ -13291,27 +13648,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: var expr = hostNode.expression; + if (expr.kind === 206 /* BinaryExpression */ && expr.operatorToken.kind === 60 /* EqualsToken */) { + expr = expr.left; + } switch (expr.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return expr.name; - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 196 /* ParenthesizedExpression */: { + case 197 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 234 /* LabeledStatement */: { + case 235 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -13337,16 +13697,16 @@ var ts; switch (declaration.kind) { case 73 /* Identifier */: return declaration; - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: { + case 314 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 149 /* QualifiedName */) { + if (name.kind === 150 /* QualifiedName */) { return name.right; } break; } - case 192 /* CallExpression */: - case 205 /* BinaryExpression */: { + case 193 /* CallExpression */: + case 206 /* BinaryExpression */: { var expr = declaration; switch (ts.getAssignmentDeclarationKind(expr)) { case 1 /* ExportsProperty */: @@ -13362,9 +13722,11 @@ var ts; return undefined; } } - case 311 /* JSDocTypedefTag */: + case 313 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 255 /* ExportAssignment */: { + case 307 /* JSDocEnumTag */: + return nameForNamelessJSDocTypedef(declaration); + case 256 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } @@ -13569,7 +13931,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 297 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 299 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13589,10 +13951,9 @@ var ts; } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getEffectiveConstraintOfTypeParameter(node) { - return node.constraint ? node.constraint - : ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] - ? node.parent.constraint - : undefined; + return node.constraint ? node.constraint : + ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint : + undefined; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; })(ts || (ts = {})); @@ -13642,193 +14003,193 @@ var ts; ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 149 /* QualifiedName */; + return node.kind === 150 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 150 /* ComputedPropertyName */; + return node.kind === 151 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 151 /* TypeParameter */; + return node.kind === 152 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 152 /* Parameter */; + return node.kind === 153 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 153 /* Decorator */; + return node.kind === 154 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 154 /* PropertySignature */; + return node.kind === 155 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 155 /* PropertyDeclaration */; + return node.kind === 156 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 156 /* MethodSignature */; + return node.kind === 157 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 158 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 158 /* Constructor */; + return node.kind === 159 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 160 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 161 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 161 /* CallSignature */; + return node.kind === 162 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 162 /* ConstructSignature */; + return node.kind === 163 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 163 /* IndexSignature */; + return node.kind === 164 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */ || node.kind === 159 /* GetAccessor */; + return node.kind === 161 /* SetAccessor */ || node.kind === 160 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 164 /* TypePredicate */; + return node.kind === 165 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 165 /* TypeReference */; + return node.kind === 166 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 166 /* FunctionType */; + return node.kind === 167 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 167 /* ConstructorType */; + return node.kind === 168 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 168 /* TypeQuery */; + return node.kind === 169 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 169 /* TypeLiteral */; + return node.kind === 170 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 170 /* ArrayType */; + return node.kind === 171 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 171 /* TupleType */; + return node.kind === 172 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 174 /* UnionType */; + return node.kind === 175 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 175 /* IntersectionType */; + return node.kind === 176 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 176 /* ConditionalType */; + return node.kind === 177 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 177 /* InferType */; + return node.kind === 178 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 178 /* ParenthesizedType */; + return node.kind === 179 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 179 /* ThisType */; + return node.kind === 180 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 180 /* TypeOperator */; + return node.kind === 181 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 181 /* IndexedAccessType */; + return node.kind === 182 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 182 /* MappedType */; + return node.kind === 183 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 183 /* LiteralType */; + return node.kind === 184 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 184 /* ImportType */; + return node.kind === 185 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 185 /* ObjectBindingPattern */; + return node.kind === 186 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 186 /* ArrayBindingPattern */; + return node.kind === 187 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 187 /* BindingElement */; + return node.kind === 188 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 188 /* ArrayLiteralExpression */; + return node.kind === 189 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 189 /* ObjectLiteralExpression */; + return node.kind === 190 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */; + return node.kind === 191 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 191 /* ElementAccessExpression */; + return node.kind === 192 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 192 /* CallExpression */; + return node.kind === 193 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 193 /* NewExpression */; + return node.kind === 194 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 194 /* TaggedTemplateExpression */; + return node.kind === 195 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 195 /* TypeAssertionExpression */; + return node.kind === 196 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isConstTypeReference(node) { @@ -13837,376 +14198,376 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function isParenthesizedExpression(node) { - return node.kind === 196 /* ParenthesizedExpression */; + return node.kind === 197 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 315 /* PartiallyEmittedExpression */) { + while (node.kind === 317 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 197 /* FunctionExpression */; + return node.kind === 198 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 198 /* ArrowFunction */; + return node.kind === 199 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 199 /* DeleteExpression */; + return node.kind === 200 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 200 /* TypeOfExpression */; + return node.kind === 201 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 201 /* VoidExpression */; + return node.kind === 202 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 202 /* AwaitExpression */; + return node.kind === 203 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 203 /* PrefixUnaryExpression */; + return node.kind === 204 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 204 /* PostfixUnaryExpression */; + return node.kind === 205 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 205 /* BinaryExpression */; + return node.kind === 206 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 206 /* ConditionalExpression */; + return node.kind === 207 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 207 /* TemplateExpression */; + return node.kind === 208 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 208 /* YieldExpression */; + return node.kind === 209 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 209 /* SpreadElement */; + return node.kind === 210 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 210 /* ClassExpression */; + return node.kind === 211 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 211 /* OmittedExpression */; + return node.kind === 212 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 213 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 213 /* AsExpression */; + return node.kind === 214 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 214 /* NonNullExpression */; + return node.kind === 215 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 215 /* MetaProperty */; + return node.kind === 216 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 217 /* TemplateSpan */; + return node.kind === 218 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 218 /* SemicolonClassElement */; + return node.kind === 219 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 219 /* Block */; + return node.kind === 220 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 220 /* VariableStatement */; + return node.kind === 221 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 221 /* EmptyStatement */; + return node.kind === 222 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 222 /* ExpressionStatement */; + return node.kind === 223 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 223 /* IfStatement */; + return node.kind === 224 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 224 /* DoStatement */; + return node.kind === 225 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 225 /* WhileStatement */; + return node.kind === 226 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 226 /* ForStatement */; + return node.kind === 227 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 227 /* ForInStatement */; + return node.kind === 228 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 228 /* ForOfStatement */; + return node.kind === 229 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 229 /* ContinueStatement */; + return node.kind === 230 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 230 /* BreakStatement */; + return node.kind === 231 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 230 /* BreakStatement */ || node.kind === 229 /* ContinueStatement */; + return node.kind === 231 /* BreakStatement */ || node.kind === 230 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 231 /* ReturnStatement */; + return node.kind === 232 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 232 /* WithStatement */; + return node.kind === 233 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 233 /* SwitchStatement */; + return node.kind === 234 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 234 /* LabeledStatement */; + return node.kind === 235 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 235 /* ThrowStatement */; + return node.kind === 236 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 236 /* TryStatement */; + return node.kind === 237 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 237 /* DebuggerStatement */; + return node.kind === 238 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 238 /* VariableDeclaration */; + return node.kind === 239 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 239 /* VariableDeclarationList */; + return node.kind === 240 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 240 /* FunctionDeclaration */; + return node.kind === 241 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 241 /* ClassDeclaration */; + return node.kind === 242 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 242 /* InterfaceDeclaration */; + return node.kind === 243 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 243 /* TypeAliasDeclaration */; + return node.kind === 244 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 244 /* EnumDeclaration */; + return node.kind === 245 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */; + return node.kind === 246 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 246 /* ModuleBlock */; + return node.kind === 247 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 247 /* CaseBlock */; + return node.kind === 248 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 248 /* NamespaceExportDeclaration */; + return node.kind === 249 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */; + return node.kind === 250 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 250 /* ImportDeclaration */; + return node.kind === 251 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 251 /* ImportClause */; + return node.kind === 252 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 252 /* NamespaceImport */; + return node.kind === 253 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 253 /* NamedImports */; + return node.kind === 254 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 254 /* ImportSpecifier */; + return node.kind === 255 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 255 /* ExportAssignment */; + return node.kind === 256 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 256 /* ExportDeclaration */; + return node.kind === 257 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 257 /* NamedExports */; + return node.kind === 258 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 258 /* ExportSpecifier */; + return node.kind === 259 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 259 /* MissingDeclaration */; + return node.kind === 260 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 260 /* ExternalModuleReference */; + return node.kind === 261 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 261 /* JsxElement */; + return node.kind === 262 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 262 /* JsxSelfClosingElement */; + return node.kind === 263 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 263 /* JsxOpeningElement */; + return node.kind === 264 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 264 /* JsxClosingElement */; + return node.kind === 265 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 265 /* JsxFragment */; + return node.kind === 266 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 266 /* JsxOpeningFragment */; + return node.kind === 267 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 267 /* JsxClosingFragment */; + return node.kind === 268 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 268 /* JsxAttribute */; + return node.kind === 269 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 269 /* JsxAttributes */; + return node.kind === 270 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 270 /* JsxSpreadAttribute */; + return node.kind === 271 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 271 /* JsxExpression */; + return node.kind === 272 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 272 /* CaseClause */; + return node.kind === 273 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 273 /* DefaultClause */; + return node.kind === 274 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 274 /* HeritageClause */; + return node.kind === 275 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 275 /* CatchClause */; + return node.kind === 276 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 276 /* PropertyAssignment */; + return node.kind === 277 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 277 /* ShorthandPropertyAssignment */; + return node.kind === 278 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 278 /* SpreadAssignment */; + return node.kind === 279 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 280 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 285 /* SourceFile */; + return node.kind === 286 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 286 /* Bundle */; + return node.kind === 287 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 287 /* UnparsedSource */; + return node.kind === 288 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; function isUnparsedPrepend(node) { - return node.kind === 281 /* UnparsedPrepend */; + return node.kind === 282 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; function isUnparsedTextLike(node) { switch (node.kind) { - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 283 /* UnparsedText */: + case 284 /* UnparsedInternalText */: return true; default: return false; @@ -14215,105 +14576,105 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 280 /* UnparsedPrologue */ || - node.kind === 284 /* UnparsedSyntheticReference */; + node.kind === 281 /* UnparsedPrologue */ || + node.kind === 285 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 289 /* JSDocTypeExpression */; + return node.kind === 290 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 290 /* JSDocAllType */; + return node.kind === 291 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 291 /* JSDocUnknownType */; + return node.kind === 292 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 292 /* JSDocNullableType */; + return node.kind === 293 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 293 /* JSDocNonNullableType */; + return node.kind === 294 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 294 /* JSDocOptionalType */; + return node.kind === 295 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 295 /* JSDocFunctionType */; + return node.kind === 296 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 296 /* JSDocVariadicType */; + return node.kind === 297 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 297 /* JSDocComment */; + return node.kind === 299 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAuthorTag(node) { - return node.kind === 302 /* JSDocAuthorTag */; + return node.kind === 304 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocAugmentsTag(node) { - return node.kind === 301 /* JSDocAugmentsTag */; + return node.kind === 303 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 303 /* JSDocClassTag */; + return node.kind === 305 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 305 /* JSDocEnumTag */; + return node.kind === 307 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 308 /* JSDocThisTag */; + return node.kind === 310 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 306 /* JSDocParameterTag */; + return node.kind === 308 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 307 /* JSDocReturnTag */; + return node.kind === 309 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 309 /* JSDocTypeTag */; + return node.kind === 311 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 310 /* JSDocTemplateTag */; + return node.kind === 312 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 311 /* JSDocTypedefTag */; + return node.kind === 313 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 312 /* JSDocPropertyTag */; + return node.kind === 314 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 312 /* JSDocPropertyTag */ || node.kind === 306 /* JSDocParameterTag */; + return node.kind === 314 /* JSDocPropertyTag */ || node.kind === 308 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 298 /* JSDocTypeLiteral */; + return node.kind === 300 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 304 /* JSDocCallbackTag */; + return node.kind === 306 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 299 /* JSDocSignature */; + return node.kind === 301 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -14324,7 +14685,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 313 /* SyntaxList */; + return n.kind === 315 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -14334,7 +14695,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 149 /* FirstNode */; + return kind >= 150 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -14343,7 +14704,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 148 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 149 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -14428,7 +14789,7 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 149 /* QualifiedName */ + return kind === 150 /* QualifiedName */ || kind === 73 /* Identifier */; } ts.isEntityName = isEntityName; @@ -14437,14 +14798,14 @@ var ts; return kind === 73 /* Identifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 150 /* ComputedPropertyName */; + || kind === 151 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; return kind === 73 /* Identifier */ - || kind === 185 /* ObjectBindingPattern */ - || kind === 186 /* ArrayBindingPattern */; + || kind === 186 /* ObjectBindingPattern */ + || kind === 187 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -14459,13 +14820,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return true; default: return false; @@ -14474,14 +14835,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 167 /* ConstructorType */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 301 /* JSDocSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 167 /* FunctionType */: + case 296 /* JSDocFunctionType */: + case 168 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -14496,29 +14857,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 155 /* PropertyDeclaration */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 163 /* IndexSignature */ - || kind === 218 /* SemicolonClassElement */; + return kind === 159 /* Constructor */ + || kind === 156 /* PropertyDeclaration */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */ + || kind === 164 /* IndexSignature */ + || kind === 219 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */); + return node && (node.kind === 242 /* ClassDeclaration */ || node.kind === 211 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */); + return node && (node.kind === 160 /* GetAccessor */ || node.kind === 161 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return true; default: return false; @@ -14528,11 +14889,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 162 /* ConstructSignature */ - || kind === 161 /* CallSignature */ - || kind === 154 /* PropertySignature */ - || kind === 156 /* MethodSignature */ - || kind === 163 /* IndexSignature */; + return kind === 163 /* ConstructSignature */ + || kind === 162 /* CallSignature */ + || kind === 155 /* PropertySignature */ + || kind === 157 /* MethodSignature */ + || kind === 164 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -14541,12 +14902,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 276 /* PropertyAssignment */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 278 /* SpreadAssignment */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 277 /* PropertyAssignment */ + || kind === 278 /* ShorthandPropertyAssignment */ + || kind === 279 /* SpreadAssignment */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -14561,8 +14922,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: return true; } return false; @@ -14573,8 +14934,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 186 /* ArrayBindingPattern */ - || kind === 185 /* ObjectBindingPattern */; + return kind === 187 /* ArrayBindingPattern */ + || kind === 186 /* ObjectBindingPattern */; } return false; } @@ -14582,15 +14943,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 188 /* ArrayLiteralExpression */ - || kind === 189 /* ObjectLiteralExpression */; + return kind === 189 /* ArrayLiteralExpression */ + || kind === 190 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 187 /* BindingElement */ - || kind === 211 /* OmittedExpression */; + return kind === 188 /* BindingElement */ + || kind === 212 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -14599,9 +14960,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 239 /* VariableDeclaration */: + case 153 /* Parameter */: + case 188 /* BindingElement */: return true; } return false; @@ -14622,8 +14983,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 186 /* ObjectBindingPattern */: + case 190 /* ObjectLiteralExpression */: return true; } return false; @@ -14635,8 +14996,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 187 /* ArrayBindingPattern */: + case 189 /* ArrayLiteralExpression */: return true; } return false; @@ -14645,26 +15006,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */ - || kind === 184 /* ImportType */; + return kind === 191 /* PropertyAccessExpression */ + || kind === 150 /* QualifiedName */ + || kind === 185 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */; + return kind === 191 /* PropertyAccessExpression */ + || kind === 150 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 153 /* Decorator */: + case 264 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 195 /* TaggedTemplateExpression */: + case 154 /* Decorator */: return true; default: return false; @@ -14672,12 +15033,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 192 /* CallExpression */ || node.kind === 193 /* NewExpression */; + return node.kind === 193 /* CallExpression */ || node.kind === 194 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 207 /* TemplateExpression */ + return kind === 208 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -14688,33 +15049,33 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 193 /* NewExpression */: - case 192 /* CallExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 194 /* TaggedTemplateExpression */: - case 188 /* ArrayLiteralExpression */: - case 196 /* ParenthesizedExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: + case 194 /* NewExpression */: + case 193 /* CallExpression */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 266 /* JsxFragment */: + case 195 /* TaggedTemplateExpression */: + case 189 /* ArrayLiteralExpression */: + case 197 /* ParenthesizedExpression */: + case 190 /* ObjectLiteralExpression */: + case 211 /* ClassExpression */: + case 198 /* FunctionExpression */: case 73 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: case 88 /* FalseKeyword */: case 97 /* NullKeyword */: case 101 /* ThisKeyword */: case 103 /* TrueKeyword */: case 99 /* SuperKeyword */: - case 214 /* NonNullExpression */: - case 215 /* MetaProperty */: + case 215 /* NonNullExpression */: + case 216 /* MetaProperty */: case 93 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: @@ -14728,13 +15089,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 195 /* TypeAssertionExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: + case 200 /* DeleteExpression */: + case 201 /* TypeOfExpression */: + case 202 /* VoidExpression */: + case 203 /* AwaitExpression */: + case 196 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -14743,9 +15104,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return true; - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; default: @@ -14764,15 +15125,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: - case 198 /* ArrowFunction */: - case 205 /* BinaryExpression */: - case 209 /* SpreadElement */: - case 213 /* AsExpression */: - case 211 /* OmittedExpression */: - case 316 /* CommaListExpression */: - case 315 /* PartiallyEmittedExpression */: + case 207 /* ConditionalExpression */: + case 209 /* YieldExpression */: + case 199 /* ArrowFunction */: + case 206 /* BinaryExpression */: + case 210 /* SpreadElement */: + case 214 /* AsExpression */: + case 212 /* OmittedExpression */: + case 318 /* CommaListExpression */: + case 317 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -14780,18 +15141,18 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 195 /* TypeAssertionExpression */ - || kind === 213 /* AsExpression */; + return kind === 196 /* TypeAssertionExpression */ + || kind === 214 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 315 /* PartiallyEmittedExpression */; + return node.kind === 317 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 314 /* NotEmittedStatement */; + return node.kind === 316 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -14802,13 +15163,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: return true; - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -14816,7 +15177,7 @@ var ts; ts.isIterationStatement = isIterationStatement; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 227 /* ForInStatement */ || node.kind === 228 /* ForOfStatement */; + return node.kind === 228 /* ForInStatement */ || node.kind === 229 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -14840,113 +15201,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */ + return kind === 247 /* ModuleBlock */ + || kind === 246 /* ModuleDeclaration */ || kind === 73 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */; + return kind === 247 /* ModuleBlock */ + || kind === 246 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 73 /* Identifier */ - || kind === 245 /* ModuleDeclaration */; + || kind === 246 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 253 /* NamedImports */ - || kind === 252 /* NamespaceImport */; + return kind === 254 /* NamedImports */ + || kind === 253 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ || node.kind === 244 /* EnumDeclaration */; + return node.kind === 246 /* ModuleDeclaration */ || node.kind === 245 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 198 /* ArrowFunction */ - || kind === 187 /* BindingElement */ - || kind === 241 /* ClassDeclaration */ - || kind === 210 /* ClassExpression */ - || kind === 158 /* Constructor */ - || kind === 244 /* EnumDeclaration */ - || kind === 279 /* EnumMember */ - || kind === 258 /* ExportSpecifier */ - || kind === 240 /* FunctionDeclaration */ - || kind === 197 /* FunctionExpression */ - || kind === 159 /* GetAccessor */ - || kind === 251 /* ImportClause */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 254 /* ImportSpecifier */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 268 /* JsxAttribute */ - || kind === 157 /* MethodDeclaration */ - || kind === 156 /* MethodSignature */ - || kind === 245 /* ModuleDeclaration */ - || kind === 248 /* NamespaceExportDeclaration */ - || kind === 252 /* NamespaceImport */ - || kind === 152 /* Parameter */ - || kind === 276 /* PropertyAssignment */ - || kind === 155 /* PropertyDeclaration */ - || kind === 154 /* PropertySignature */ - || kind === 160 /* SetAccessor */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 151 /* TypeParameter */ - || kind === 238 /* VariableDeclaration */ - || kind === 311 /* JSDocTypedefTag */ - || kind === 304 /* JSDocCallbackTag */ - || kind === 312 /* JSDocPropertyTag */; + return kind === 199 /* ArrowFunction */ + || kind === 188 /* BindingElement */ + || kind === 242 /* ClassDeclaration */ + || kind === 211 /* ClassExpression */ + || kind === 159 /* Constructor */ + || kind === 245 /* EnumDeclaration */ + || kind === 280 /* EnumMember */ + || kind === 259 /* ExportSpecifier */ + || kind === 241 /* FunctionDeclaration */ + || kind === 198 /* FunctionExpression */ + || kind === 160 /* GetAccessor */ + || kind === 252 /* ImportClause */ + || kind === 250 /* ImportEqualsDeclaration */ + || kind === 255 /* ImportSpecifier */ + || kind === 243 /* InterfaceDeclaration */ + || kind === 269 /* JsxAttribute */ + || kind === 158 /* MethodDeclaration */ + || kind === 157 /* MethodSignature */ + || kind === 246 /* ModuleDeclaration */ + || kind === 249 /* NamespaceExportDeclaration */ + || kind === 253 /* NamespaceImport */ + || kind === 153 /* Parameter */ + || kind === 277 /* PropertyAssignment */ + || kind === 156 /* PropertyDeclaration */ + || kind === 155 /* PropertySignature */ + || kind === 161 /* SetAccessor */ + || kind === 278 /* ShorthandPropertyAssignment */ + || kind === 244 /* TypeAliasDeclaration */ + || kind === 152 /* TypeParameter */ + || kind === 239 /* VariableDeclaration */ + || kind === 313 /* JSDocTypedefTag */ + || kind === 306 /* JSDocCallbackTag */ + || kind === 314 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 240 /* FunctionDeclaration */ - || kind === 259 /* MissingDeclaration */ - || kind === 241 /* ClassDeclaration */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 244 /* EnumDeclaration */ - || kind === 245 /* ModuleDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */ - || kind === 255 /* ExportAssignment */ - || kind === 248 /* NamespaceExportDeclaration */; + return kind === 241 /* FunctionDeclaration */ + || kind === 260 /* MissingDeclaration */ + || kind === 242 /* ClassDeclaration */ + || kind === 243 /* InterfaceDeclaration */ + || kind === 244 /* TypeAliasDeclaration */ + || kind === 245 /* EnumDeclaration */ + || kind === 246 /* ModuleDeclaration */ + || kind === 251 /* ImportDeclaration */ + || kind === 250 /* ImportEqualsDeclaration */ + || kind === 257 /* ExportDeclaration */ + || kind === 256 /* ExportAssignment */ + || kind === 249 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 230 /* BreakStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 224 /* DoStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 221 /* EmptyStatement */ - || kind === 227 /* ForInStatement */ - || kind === 228 /* ForOfStatement */ - || kind === 226 /* ForStatement */ - || kind === 223 /* IfStatement */ - || kind === 234 /* LabeledStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 233 /* SwitchStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 236 /* TryStatement */ - || kind === 220 /* VariableStatement */ - || kind === 225 /* WhileStatement */ - || kind === 232 /* WithStatement */ - || kind === 314 /* NotEmittedStatement */ - || kind === 318 /* EndOfDeclarationMarker */ - || kind === 317 /* MergeDeclarationMarker */; + return kind === 231 /* BreakStatement */ + || kind === 230 /* ContinueStatement */ + || kind === 238 /* DebuggerStatement */ + || kind === 225 /* DoStatement */ + || kind === 223 /* ExpressionStatement */ + || kind === 222 /* EmptyStatement */ + || kind === 228 /* ForInStatement */ + || kind === 229 /* ForOfStatement */ + || kind === 227 /* ForStatement */ + || kind === 224 /* IfStatement */ + || kind === 235 /* LabeledStatement */ + || kind === 232 /* ReturnStatement */ + || kind === 234 /* SwitchStatement */ + || kind === 236 /* ThrowStatement */ + || kind === 237 /* TryStatement */ + || kind === 221 /* VariableStatement */ + || kind === 226 /* WhileStatement */ + || kind === 233 /* WithStatement */ + || kind === 316 /* NotEmittedStatement */ + || kind === 320 /* EndOfDeclarationMarker */ + || kind === 319 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 151 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 310 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 152 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 312 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14973,10 +15334,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 219 /* Block */) + if (node.kind !== 220 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 236 /* TryStatement */ || node.parent.kind === 275 /* CatchClause */) { + if (node.parent.kind === 237 /* TryStatement */ || node.parent.kind === 276 /* CatchClause */) { return false; } } @@ -14986,8 +15347,8 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 260 /* ExternalModuleReference */ - || kind === 149 /* QualifiedName */ + return kind === 261 /* ExternalModuleReference */ + || kind === 150 /* QualifiedName */ || kind === 73 /* Identifier */; } ts.isModuleReference = isModuleReference; @@ -14997,70 +15358,70 @@ var ts; var kind = node.kind; return kind === 101 /* ThisKeyword */ || kind === 73 /* Identifier */ - || kind === 190 /* PropertyAccessExpression */; + || kind === 191 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 261 /* JsxElement */ - || kind === 271 /* JsxExpression */ - || kind === 262 /* JsxSelfClosingElement */ + return kind === 262 /* JsxElement */ + || kind === 272 /* JsxExpression */ + || kind === 263 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 265 /* JsxFragment */; + || kind === 266 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 268 /* JsxAttribute */ - || kind === 270 /* JsxSpreadAttribute */; + return kind === 269 /* JsxAttribute */ + || kind === 271 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 271 /* JsxExpression */; + || kind === 272 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 263 /* JsxOpeningElement */ - || kind === 262 /* JsxSelfClosingElement */; + return kind === 264 /* JsxOpeningElement */ + || kind === 263 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 272 /* CaseClause */ - || kind === 273 /* DefaultClause */; + return kind === 273 /* CaseClause */ + || kind === 274 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 289 /* FirstJSDocNode */ && node.kind <= 312 /* LastJSDocNode */; + return node.kind >= 290 /* FirstJSDocNode */ && node.kind <= 314 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 297 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 299 /* JSDocComment */ || 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 >= 300 /* FirstJSDocTagNode */ && node.kind <= 312 /* LastJSDocTagNode */; + return node.kind >= 302 /* FirstJSDocTagNode */ && node.kind <= 314 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 161 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 160 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -15090,12 +15451,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 268 /* JsxAttribute */ || node.kind === 270 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 269 /* JsxAttribute */ || node.kind === 271 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 165 /* TypeReference */ || node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 166 /* TypeReference */ || node.kind === 213 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -15131,7 +15492,7 @@ var ts; /* @internal */ (function (ts) { function isNamedImportsOrExports(node) { - return node.kind === 253 /* NamedImports */ || node.kind === 257 /* NamedExports */; + return node.kind === 254 /* NamedImports */ || node.kind === 258 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -15149,7 +15510,7 @@ var ts; this.checker = checker; } } - function Signature() { } // tslint:disable-line no-empty + function Signature() { } function Node(kind, pos, end) { this.pos = pos; this.end = end; @@ -15166,6 +15527,7 @@ var ts; this.text = text; this.skipTrivia = skipTrivia || (function (pos) { return pos; }); } + // eslint-disable-next-line prefer-const ts.objectAllocator = { getNodeConstructor: function () { return Node; }, getTokenConstructor: function () { return Node; }, @@ -15612,7 +15974,7 @@ var ts; var rest = path.substring(rootLength).split(ts.directorySeparator); if (rest.length && !ts.lastOrUndefined(rest)) rest.pop(); - return [root].concat(rest); + return __spreadArrays([root], rest); } /** * Parse a path into an array containing a root component (at index 0) and zero or more path @@ -15712,7 +16074,7 @@ var ts; for (; start < fromComponents.length; start++) { relative.push(".."); } - return [""].concat(relative, components); + return __spreadArrays([""], relative, components); } ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; function getRelativePathFromFile(from, to, getCanonicalFileName) { @@ -15793,7 +16155,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { paths[_i - 1] = arguments[_i]; } - var combined = ts.some(paths) ? combinePaths.apply(void 0, [path].concat(paths)) : ts.normalizeSlashes(path); + var combined = ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : ts.normalizeSlashes(path); var normalized = ts.getPathFromPathComponents(ts.reducePathComponents(ts.getPathComponents(combined))); return normalized && hasTrailingDirectorySeparator(combined) ? ensureTrailingDirectorySeparator(normalized) : normalized; } @@ -16232,14 +16594,14 @@ var ts; ts.supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */]; ts.supportedJSExtensions = [".js" /* Js */, ".jsx" /* Jsx */]; ts.supportedJSAndJsonExtensions = [".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */]; - var allSupportedExtensions = ts.supportedTSExtensions.concat(ts.supportedJSExtensions); - var allSupportedExtensionsWithJson = ts.supportedTSExtensions.concat(ts.supportedJSExtensions, [".json" /* Json */]); + var allSupportedExtensions = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions); + var allSupportedExtensionsWithJson = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions, [".json" /* Json */]); function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && options.allowJs; if (!extraFileExtensions || extraFileExtensions.length === 0) { return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; } - var extensions = (needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions).concat(ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); + var extensions = __spreadArrays(needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions, ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); return ts.deduplicate(extensions, ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } ts.getSupportedExtensions = getSupportedExtensions; @@ -16253,7 +16615,7 @@ var ts; if (supportedExtensions === ts.supportedTSExtensions) { return ts.supportedTSExtensionsWithJson; } - return supportedExtensions.concat([".json" /* Json */]); + return __spreadArrays(supportedExtensions, [".json" /* Json */]); } ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { @@ -16573,6 +16935,7 @@ var ts; } ts.skipTypeChecking = skipTypeChecking; function isJsonEqual(a, b) { + // eslint-disable-next-line no-null/no-null return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && ts.equalOwnProperties(a, b, isJsonEqual); } ts.isJsonEqual = isJsonEqual; @@ -16676,14 +17039,12 @@ var ts; SignatureFlags[SignatureFlags["IgnoreMissingOpenBrace"] = 16] = "IgnoreMissingOpenBrace"; SignatureFlags[SignatureFlags["JSDoc"] = 32] = "JSDoc"; })(SignatureFlags || (SignatureFlags = {})); - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 285 /* SourceFile */) { + if (kind === 286 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 73 /* Identifier */) { @@ -16735,19 +17096,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 <= 148 /* LastToken */) { + if (!node || node.kind <= 149 /* LastToken */) { return; } switch (node.kind) { - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -16755,9 +17116,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 152 /* Parameter */: + case 153 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -16765,7 +17126,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -16773,51 +17134,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 154 /* PropertySignature */: + case 155 /* 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 276 /* PropertyAssignment */: + case 277 /* 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 238 /* VariableDeclaration */: + case 239 /* 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 187 /* BindingElement */: + case 188 /* 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 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -16829,345 +17190,345 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 171 /* TupleType */: + case 172 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 177 /* InferType */: + case 178 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 184 /* ImportType */: + case 185 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 178 /* ParenthesizedType */: - case 180 /* TypeOperator */: + case 179 /* ParenthesizedType */: + case 181 /* TypeOperator */: return visitNode(cbNode, node.type); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 182 /* MappedType */: + case 183 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 183 /* LiteralType */: + case 184 /* LiteralType */: return visitNode(cbNode, node.literal); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 213 /* AsExpression */: + case 214 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return visitNode(cbNode, node.name); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 220 /* Block */: + case 247 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 285 /* SourceFile */: + case 286 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 230 /* ContinueStatement */: + case 231 /* BreakStatement */: return visitNode(cbNode, node.label); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 272 /* CaseClause */: + case 273 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 153 /* Decorator */: + case 154 /* Decorator */: return visitNode(cbNode, node.expression); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* 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 242 /* InterfaceDeclaration */: + case 243 /* 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 243 /* TypeAliasDeclaration */: + case 244 /* 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 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 279 /* EnumMember */: + case 280 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 254 /* NamedImports */: + case 258 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 259 /* MissingDeclaration */: + case 260 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 261 /* JsxElement */: + case 262 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 172 /* OptionalType */: - case 173 /* RestType */: - case 289 /* JSDocTypeExpression */: - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 294 /* JSDocOptionalType */: - case 296 /* JSDocVariadicType */: + case 173 /* OptionalType */: + case 174 /* RestType */: + case 290 /* JSDocTypeExpression */: + case 294 /* JSDocNonNullableType */: + case 293 /* JSDocNullableType */: + case 295 /* JSDocOptionalType */: + case 297 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 297 /* JSDocComment */: + case 299 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: + case 314 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 302 /* JSDocAuthorTag */: + case 304 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName); - case 301 /* JSDocAugmentsTag */: + case 303 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 311 /* JSDocTypedefTag */: + case 313 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 289 /* JSDocTypeExpression */ + node.typeExpression.kind === 290 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 304 /* JSDocCallbackTag */: + case 306 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 308 /* JSDocThisTag */: - case 305 /* JSDocEnumTag */: + case 309 /* JSDocReturnTag */: + case 311 /* JSDocTypeTag */: + case 310 /* JSDocThisTag */: + case 307 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 299 /* JSDocSignature */: + case 301 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 298 /* JSDocTypeLiteral */: + case 300 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 300 /* JSDocTag */: - case 303 /* JSDocClassTag */: + case 302 /* JSDocTag */: + case 305 /* JSDocClassTag */: return visitNode(cbNode, node.tagName); - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -17176,12 +17537,14 @@ var ts; if (setParentNodes === void 0) { setParentNodes = false; } ts.performance.mark("beforeParse"); var result; + ts.perfLogger.logStartParseSourceFile(fileName); if (languageVersion === 100 /* JSON */) { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */); } else { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind); } + ts.perfLogger.logStopParseSourceFile(); ts.performance.mark("afterParse"); ts.performance.measure("Parse", "beforeParse", "afterParse"); return result; @@ -17250,12 +17613,10 @@ var ts; var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); var disallowInAndDecoratorContext = 2048 /* DisallowInContext */ | 8192 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name var sourceFile; var parseDiagnostics; var syntaxCursor; @@ -17265,6 +17626,7 @@ var ts; var identifiers; var identifierCount; var parsingContext; + var notParenthesizedArrow; // Flags that dictate what parsing context we're in. For example: // Whether or not we are in strict parsing mode. All that changes in strict parsing mode is // that some tokens that would be considered identifiers may be considered keywords. @@ -17385,7 +17747,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(222 /* ExpressionStatement */); + var statement = createNode(223 /* ExpressionStatement */); switch (token()) { case 22 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); @@ -17421,6 +17783,9 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; sourceFile.parseDiagnostics = parseDiagnostics; var result = sourceFile; clearState(); @@ -17472,6 +17837,7 @@ var ts; identifiers = undefined; syntaxCursor = undefined; sourceText = undefined; + notParenthesizedArrow = undefined; } function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { var isDeclarationFile = isDeclarationFileName(fileName); @@ -17541,7 +17907,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(285 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(286 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -17681,9 +18047,17 @@ var ts; function token() { return currentToken; } - function nextToken() { + function nextTokenWithoutCheck() { return currentToken = scanner.scan(); } + function nextToken() { + // if the keyword had an escape + if (ts.isKeyword(currentToken) && (scanner.hasUnicodeEscape() || scanner.hasExtendedUnicodeEscape())) { + // issue a parse error for the escape + parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), ts.Diagnostics.Keywords_cannot_contain_escape_characters); + } + return nextTokenWithoutCheck(); + } function nextTokenJSDoc() { return currentToken = scanner.scanJsDocToken(); } @@ -17922,7 +18296,7 @@ var ts; node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); - nextToken(); + nextTokenWithoutCheck(); return finishNode(node); } // Only for end of file because the error gets reported incorrectly on embedded script tags. @@ -17958,7 +18332,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(150 /* ComputedPropertyName */); + var node = createNode(151 /* ComputedPropertyName */); parseExpected(22 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -18392,14 +18766,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 158 /* Constructor */: - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 218 /* SemicolonClassElement */: + case 159 /* Constructor */: + case 164 /* IndexSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 219 /* SemicolonClassElement */: return true; - case 157 /* MethodDeclaration */: + case 158 /* 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. @@ -18414,8 +18788,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: return true; } } @@ -18424,58 +18798,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 220 /* VariableStatement */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 222 /* ExpressionStatement */: - case 235 /* ThrowStatement */: - case 231 /* ReturnStatement */: - case 233 /* SwitchStatement */: - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 221 /* EmptyStatement */: - case 236 /* TryStatement */: - case 234 /* LabeledStatement */: - case 224 /* DoStatement */: - case 237 /* DebuggerStatement */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 241 /* FunctionDeclaration */: + case 221 /* VariableStatement */: + case 220 /* Block */: + case 224 /* IfStatement */: + case 223 /* ExpressionStatement */: + case 236 /* ThrowStatement */: + case 232 /* ReturnStatement */: + case 234 /* SwitchStatement */: + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 227 /* ForStatement */: + case 226 /* WhileStatement */: + case 233 /* WithStatement */: + case 222 /* EmptyStatement */: + case 237 /* TryStatement */: + case 235 /* LabeledStatement */: + case 225 /* DoStatement */: + case 238 /* DebuggerStatement */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 257 /* ExportDeclaration */: + case 256 /* ExportAssignment */: + case 246 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 280 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 154 /* PropertySignature */: - case 161 /* CallSignature */: + case 163 /* ConstructSignature */: + case 157 /* MethodSignature */: + case 164 /* IndexSignature */: + case 155 /* PropertySignature */: + case 162 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 238 /* VariableDeclaration */) { + if (node.kind !== 239 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -18496,7 +18870,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 152 /* Parameter */) { + if (node.kind !== 153 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -18563,7 +18937,7 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */); + parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use @@ -18601,6 +18975,9 @@ var ts; } return result; } + function getExpectedCommaDiagnostic(kind) { + return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + } function createMissingList() { var list = createNodeArray([], getNodePos()); list.isMissingList = true; @@ -18632,7 +19009,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(149 /* QualifiedName */, entity.pos); + var node = createNode(150 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -18669,7 +19046,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(207 /* TemplateExpression */); + var template = createNode(208 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -18681,7 +19058,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(217 /* TemplateSpan */); + var span = createNode(218 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 19 /* CloseBraceToken */) { @@ -18710,6 +19087,16 @@ var ts; function parseLiteralLikeNode(kind) { var node = createNode(kind); node.text = scanner.getTokenValue(); + switch (kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + var isLast = kind === 14 /* NoSubstitutionTemplateLiteral */ || kind === 17 /* TemplateTail */; + var tokenText = scanner.getTokenText(); + node.rawText = tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); + break; + } if (scanner.hasExtendedUnicodeEscape()) { node.hasExtendedUnicodeEscape = true; } @@ -18731,7 +19118,7 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(165 /* TypeReference */); + var node = createNode(166 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); @@ -18741,14 +19128,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: { + case 167 /* FunctionType */: + case 168 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -18756,20 +19143,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(164 /* TypePredicate */, lhs.pos); + var node = createNode(165 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(179 /* ThisType */); + var node = createNode(180 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(290 /* JSDocAllType */); + var result = createNode(291 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(294 /* JSDocOptionalType */, result); + return createPostfixType(295 /* JSDocOptionalType */, result); } else { nextToken(); @@ -18777,7 +19164,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(293 /* JSDocNonNullableType */); + var result = createNode(294 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -18801,28 +19188,28 @@ var ts; token() === 30 /* GreaterThanToken */ || token() === 60 /* EqualsToken */ || token() === 50 /* BarToken */) { - var result = createNode(291 /* JSDocUnknownType */, pos); + var result = createNode(292 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(292 /* JSDocNullableType */, pos); + var result = createNode(293 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(295 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(296 /* JSDocFunctionType */); nextToken(); fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(165 /* TypeReference */); + var node = createNode(166 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(152 /* Parameter */); + var parameter = createNode(153 /* Parameter */); if (token() === 101 /* ThisKeyword */ || token() === 96 /* NewKeyword */) { parameter.name = parseIdentifierName(); parseExpected(57 /* ColonToken */); @@ -18832,27 +19219,44 @@ var ts; } function parseJSDocType() { scanner.setInJSDocType(true); + var moduleSpecifier = parseOptionalToken(131 /* ModuleKeyword */); + if (moduleSpecifier) { + var moduleTag = createNode(298 /* JSDocNamepathType */, moduleSpecifier.pos); + terminate: while (true) { + switch (token()) { + case 19 /* CloseBraceToken */: + case 1 /* EndOfFileToken */: + case 27 /* CommaToken */: + case 5 /* WhitespaceTrivia */: + break terminate; + default: + nextTokenJSDoc(); + } + } + scanner.setInJSDocType(false); + return finishNode(moduleTag); + } var dotdotdot = parseOptionalToken(25 /* DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(296 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(297 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 60 /* EqualsToken */) { - return createPostfixType(294 /* JSDocOptionalType */, type); + return createPostfixType(295 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(168 /* TypeQuery */); + var node = createNode(169 /* TypeQuery */); parseExpected(105 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(152 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(87 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -18897,7 +19301,7 @@ var ts; isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(152 /* Parameter */); + var node = createNodeWithJSDoc(153 /* Parameter */); if (token() === 101 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); @@ -18998,7 +19402,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 162 /* ConstructSignature */) { + if (kind === 163 /* ConstructSignature */) { parseExpected(96 /* NewKeyword */); } fillSignature(57 /* ColonToken */, 4 /* Type */, node); @@ -19059,7 +19463,7 @@ var ts; return token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 163 /* IndexSignature */; + node.kind = 164 /* IndexSignature */; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -19069,13 +19473,13 @@ var ts; node.name = parsePropertyName(); node.questionToken = parseOptionalToken(56 /* QuestionToken */); if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - node.kind = 156 /* MethodSignature */; + node.kind = 157 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] fillSignature(57 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 154 /* PropertySignature */; + node.kind = 155 /* PropertySignature */; node.type = parseTypeAnnotation(); if (token() === 60 /* EqualsToken */) { // Although type literal properties cannot not have initializers, we attempt @@ -19121,10 +19525,10 @@ var ts; } function parseTypeMember() { if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - return parseSignatureMember(161 /* CallSignature */); + return parseSignatureMember(162 /* CallSignature */); } if (token() === 96 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(162 /* ConstructSignature */); + return parseSignatureMember(163 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -19150,7 +19554,7 @@ var ts; return false; } function parseTypeLiteral() { - var node = createNode(169 /* TypeLiteral */); + var node = createNode(170 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -19176,14 +19580,14 @@ var ts; return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 94 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(152 /* TypeParameter */); node.name = parseIdentifier(); parseExpected(94 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(182 /* MappedType */); + var node = createNode(183 /* MappedType */); parseExpected(18 /* OpenBraceToken */); if (token() === 134 /* ReadonlyKeyword */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { node.readonlyToken = parseTokenNode(); @@ -19208,23 +19612,23 @@ var ts; function parseTupleElementType() { var pos = getNodePos(); if (parseOptional(25 /* DotDotDotToken */)) { - var node = createNode(173 /* RestType */, pos); + var node = createNode(174 /* RestType */, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 292 /* JSDocNullableType */ && type.pos === type.type.pos) { - type.kind = 172 /* OptionalType */; + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 293 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 173 /* OptionalType */; } return type; } function parseTupleType() { - var node = createNode(171 /* TupleType */); + var node = createNode(172 /* TupleType */); node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(178 /* ParenthesizedType */); + var node = createNode(179 /* ParenthesizedType */); parseExpected(20 /* OpenParenToken */); node.type = parseType(); parseExpected(21 /* CloseParenToken */); @@ -19232,7 +19636,7 @@ var ts; } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(96 /* NewKeyword */) ? 167 /* ConstructorType */ : 166 /* FunctionType */; + var kind = parseOptional(96 /* NewKeyword */) ? 168 /* ConstructorType */ : 167 /* FunctionType */; var node = createNodeWithJSDoc(kind, pos); fillSignature(37 /* EqualsGreaterThanToken */, 4 /* Type */, node); return finishNode(node); @@ -19242,10 +19646,10 @@ var ts; return token() === 24 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(183 /* LiteralType */); + var node = createNode(184 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(203 /* PrefixUnaryExpression */); + unaryMinusExpression = createNode(204 /* PrefixUnaryExpression */); unaryMinusExpression.operator = 39 /* MinusToken */; nextToken(); } @@ -19266,7 +19670,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(184 /* ImportType */); + var node = createNode(185 /* ImportType */); if (parseOptional(105 /* TypeOfKeyword */)) { node.isTypeOf = true; } @@ -19356,6 +19760,7 @@ var ts; case 134 /* ReadonlyKeyword */: case 140 /* SymbolKeyword */: case 143 /* UniqueKeyword */: + case 148 /* TagKeyword */: case 107 /* VoidKeyword */: case 142 /* UndefinedKeyword */: case 97 /* NullKeyword */: @@ -19402,26 +19807,26 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 52 /* ExclamationToken */: - type = createPostfixType(293 /* JSDocNonNullableType */, type); + type = createPostfixType(294 /* JSDocNonNullableType */, type); break; case 56 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(292 /* JSDocNullableType */, type); + type = createPostfixType(293 /* JSDocNullableType */, type); break; case 22 /* OpenBracketToken */: parseExpected(22 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(181 /* IndexedAccessType */, type.pos); + var node = createNode(182 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(170 /* ArrayType */, type.pos); + var node = createNode(171 /* ArrayType */, type.pos); node.elementType = type; parseExpected(23 /* CloseBracketToken */); type = finishNode(node); @@ -19440,16 +19845,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(180 /* TypeOperator */); + var node = createNode(181 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(177 /* InferType */); + var node = createNode(178 /* InferType */); parseExpected(128 /* InferKeyword */); - var typeParameter = createNode(151 /* TypeParameter */); + var typeParameter = createNode(152 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -19460,6 +19865,7 @@ var ts; case 130 /* KeyOfKeyword */: case 143 /* UniqueKeyword */: case 134 /* ReadonlyKeyword */: + case 148 /* TagKeyword */: return parseTypeOperator(operator); case 128 /* InferKeyword */: return parseInferType(); @@ -19482,10 +19888,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(175 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); + return parseUnionOrIntersectionType(176 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(174 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); + return parseUnionOrIntersectionType(175 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); } function isStartOfFunctionType() { if (token() === 28 /* LessThanToken */) { @@ -19542,7 +19948,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(164 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(165 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -19569,7 +19975,7 @@ var ts; } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(87 /* ExtendsKeyword */)) { - var node = createNode(176 /* ConditionalType */, type.pos); + var node = createNode(177 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); @@ -19763,7 +20169,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(208 /* YieldExpression */); + var node = createNode(209 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -19785,13 +20191,13 @@ var ts; ts.Debug.assert(token() === 37 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(198 /* ArrowFunction */, asyncModifier.pos); + node = createNode(199 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(198 /* ArrowFunction */, identifier.pos); + node = createNode(199 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(152 /* Parameter */, identifier.pos); + var parameter = createNode(153 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); @@ -19955,7 +20361,15 @@ var ts; } } function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + var tokenPos = scanner.getTokenPos(); + if (notParenthesizedArrow && notParenthesizedArrow.has(tokenPos.toString())) { + return undefined; + } + var result = parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + if (!result) { + (notParenthesizedArrow || (notParenthesizedArrow = ts.createMap())).set(tokenPos.toString(), true); + } + return result; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" @@ -19988,7 +20402,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(198 /* ArrowFunction */); + var node = createNodeWithJSDoc(199 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -20054,7 +20468,7 @@ var ts; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(206 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(207 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -20069,7 +20483,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 94 /* InKeyword */ || t === 148 /* OfKeyword */; + return t === 94 /* InKeyword */ || t === 149 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -20134,39 +20548,39 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(205 /* BinaryExpression */, left.pos); + var node = createNode(206 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(213 /* AsExpression */, left.pos); + var node = createNode(214 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(203 /* PrefixUnaryExpression */); + var node = createNode(204 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(199 /* DeleteExpression */); + var node = createNode(200 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(200 /* TypeOfExpression */); + var node = createNode(201 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(201 /* VoidExpression */); + var node = createNode(202 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -20182,7 +20596,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(202 /* AwaitExpression */); + var node = createNode(203 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -20226,7 +20640,7 @@ var ts; if (token() === 41 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 195 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 196 /* 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 { @@ -20323,7 +20737,7 @@ var ts; */ function parseUpdateExpression() { if (token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) { - var node = createNode(203 /* PrefixUnaryExpression */); + var node = createNode(204 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -20336,7 +20750,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(204 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(205 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -20392,7 +20806,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(215 /* MetaProperty */, fullStart); + var node = createNode(216 /* MetaProperty */, fullStart); node.keywordToken = 93 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); @@ -20474,7 +20888,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(190 /* PropertyAccessExpression */, expression.pos); + var node = createNode(191 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -20483,8 +20897,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 263 /* JsxOpeningElement */) { - var node = createNode(261 /* JsxElement */, opening.pos); + if (opening.kind === 264 /* JsxOpeningElement */) { + var node = createNode(262 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -20493,15 +20907,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 266 /* JsxOpeningFragment */) { - var node = createNode(265 /* JsxFragment */, opening.pos); + else if (opening.kind === 267 /* JsxOpeningFragment */) { + var node = createNode(266 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 262 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 263 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -20516,7 +20930,7 @@ var ts; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(205 /* BinaryExpression */, result.pos); + var badNode = createNode(206 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -20575,7 +20989,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(269 /* JsxAttributes */); + var jsxAttributes = createNode(270 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -20584,7 +20998,7 @@ var ts; parseExpected(28 /* LessThanToken */); if (token() === 30 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(266 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(267 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -20596,7 +21010,7 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(263 /* JsxOpeningElement */, fullStart); + node = createNode(264 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -20608,7 +21022,7 @@ var ts; parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(262 /* JsxSelfClosingElement */, fullStart); + node = createNode(263 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -20625,7 +21039,7 @@ var ts; var expression = token() === 101 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(191 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -20633,7 +21047,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(271 /* JsxExpression */); + var node = createNode(272 /* JsxExpression */); if (!parseExpected(18 /* OpenBraceToken */)) { return undefined; } @@ -20659,7 +21073,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(268 /* JsxAttribute */); + var node = createNode(269 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 60 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -20674,7 +21088,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(270 /* JsxSpreadAttribute */); + var node = createNode(271 /* JsxSpreadAttribute */); parseExpected(18 /* OpenBraceToken */); parseExpected(25 /* DotDotDotToken */); node.expression = parseExpression(); @@ -20682,7 +21096,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(264 /* JsxClosingElement */); + var node = createNode(265 /* JsxClosingElement */); parseExpected(29 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -20695,7 +21109,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(267 /* JsxClosingFragment */); + var node = createNode(268 /* JsxClosingFragment */); parseExpected(29 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -20710,7 +21124,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(195 /* TypeAssertionExpression */); + var node = createNode(196 /* TypeAssertionExpression */); parseExpected(28 /* LessThanToken */); node.type = parseType(); parseExpected(30 /* GreaterThanToken */); @@ -20721,7 +21135,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(24 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(191 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -20729,14 +21143,14 @@ var ts; } if (token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(214 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(215 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(22 /* OpenBracketToken */)) { - var indexedAccess = createNode(191 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(192 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; if (token() === 23 /* CloseBracketToken */) { indexedAccess.argumentExpression = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); @@ -20763,7 +21177,7 @@ var ts; return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(194 /* TaggedTemplateExpression */, tag.pos); + var tagExpression = createNode(195 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 14 /* NoSubstitutionTemplateLiteral */ @@ -20788,7 +21202,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(192 /* CallExpression */, expression.pos); + var callExpr = createNode(193 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -20796,7 +21210,7 @@ var ts; continue; } else if (token() === 20 /* OpenParenToken */) { - var callExpr = createNode(192 /* CallExpression */, expression.pos); + var callExpr = createNode(193 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -20834,6 +21248,7 @@ var ts; case 15 /* TemplateHead */: // foo `...${100}...` // these are the only tokens can legally follow a type argument // list. So we definitely want to treat them as type arg lists. + // falls through case 24 /* DotToken */: // foo. case 21 /* CloseParenToken */: // foo) case 23 /* CloseBracketToken */: // foo] @@ -20860,6 +21275,7 @@ var ts; // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. + // falls through default: // Anything else treat as an expression. return false; @@ -20910,28 +21326,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(196 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(197 /* ParenthesizedExpression */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(209 /* SpreadElement */); + var node = createNode(210 /* SpreadElement */); parseExpected(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? createNode(211 /* OmittedExpression */) : + token() === 27 /* CommaToken */ ? createNode(212 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(188 /* ArrayLiteralExpression */); + var node = createNode(189 /* ArrayLiteralExpression */); parseExpected(22 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -20943,17 +21359,17 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(25 /* DotDotDotToken */)) { - node.kind = 278 /* SpreadAssignment */; + node.kind = 279 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + return parseAccessorDeclaration(node, 160 /* GetAccessor */); } if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + return parseAccessorDeclaration(node, 161 /* SetAccessor */); } var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); @@ -20971,7 +21387,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 57 /* ColonToken */); if (isShorthandPropertyAssignment) { - node.kind = 277 /* ShorthandPropertyAssignment */; + node.kind = 278 /* ShorthandPropertyAssignment */; var equalsToken = parseOptionalToken(60 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; @@ -20979,14 +21395,14 @@ var ts; } } else { - node.kind = 276 /* PropertyAssignment */; + node.kind = 277 /* PropertyAssignment */; parseExpected(57 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(189 /* ObjectLiteralExpression */); + var node = createNode(190 /* ObjectLiteralExpression */); parseExpected(18 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21005,7 +21421,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(197 /* FunctionExpression */); + var node = createNodeWithJSDoc(198 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(91 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); @@ -21030,7 +21446,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(96 /* NewKeyword */); if (parseOptional(24 /* DotToken */)) { - var node_2 = createNode(215 /* MetaProperty */, fullStart); + var node_2 = createNode(216 /* MetaProperty */, fullStart); node_2.keywordToken = 96 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -21047,7 +21463,7 @@ var ts; } break; } - var node = createNode(193 /* NewExpression */, fullStart); + var node = createNode(194 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 20 /* OpenParenToken */) { @@ -21057,7 +21473,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(219 /* Block */); + var node = createNode(220 /* Block */); if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21090,12 +21506,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(221 /* EmptyStatement */); + var node = createNode(222 /* EmptyStatement */); parseExpected(26 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(223 /* IfStatement */); + var node = createNode(224 /* IfStatement */); parseExpected(92 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -21105,7 +21521,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(224 /* DoStatement */); + var node = createNode(225 /* DoStatement */); parseExpected(83 /* DoKeyword */); node.statement = parseStatement(); parseExpected(108 /* WhileKeyword */); @@ -21120,7 +21536,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(225 /* WhileStatement */); + var node = createNode(226 /* WhileStatement */); parseExpected(108 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -21143,8 +21559,8 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(148 /* OfKeyword */) : parseOptional(148 /* OfKeyword */)) { - var forOfStatement = createNode(228 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(149 /* OfKeyword */) : parseOptional(149 /* OfKeyword */)) { + var forOfStatement = createNode(229 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -21152,14 +21568,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(94 /* InKeyword */)) { - var forInStatement = createNode(227 /* ForInStatement */, pos); + var forInStatement = createNode(228 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(226 /* ForStatement */, pos); + var forStatement = createNode(227 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(26 /* SemicolonToken */); if (token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */) { @@ -21177,7 +21593,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 230 /* BreakStatement */ ? 74 /* BreakKeyword */ : 79 /* ContinueKeyword */); + parseExpected(kind === 231 /* BreakStatement */ ? 74 /* BreakKeyword */ : 79 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -21185,7 +21601,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(231 /* ReturnStatement */); + var node = createNode(232 /* ReturnStatement */); parseExpected(98 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -21194,7 +21610,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(232 /* WithStatement */); + var node = createNode(233 /* WithStatement */); parseExpected(109 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -21203,7 +21619,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(272 /* CaseClause */); + var node = createNode(273 /* CaseClause */); parseExpected(75 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(57 /* ColonToken */); @@ -21211,7 +21627,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(273 /* DefaultClause */); + var node = createNode(274 /* DefaultClause */); parseExpected(81 /* DefaultKeyword */); parseExpected(57 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -21221,12 +21637,12 @@ var ts; return token() === 75 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(233 /* SwitchStatement */); + var node = createNode(234 /* SwitchStatement */); parseExpected(100 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - var caseBlock = createNode(247 /* CaseBlock */); + var caseBlock = createNode(248 /* CaseBlock */); parseExpected(18 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(19 /* CloseBraceToken */); @@ -21241,7 +21657,7 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(235 /* ThrowStatement */); + var node = createNode(236 /* ThrowStatement */); parseExpected(102 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -21249,7 +21665,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(236 /* TryStatement */); + var node = createNode(237 /* TryStatement */); parseExpected(104 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 76 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -21262,7 +21678,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(275 /* CatchClause */); + var result = createNode(276 /* CatchClause */); parseExpected(76 /* CatchKeyword */); if (parseOptional(20 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -21276,7 +21692,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(237 /* DebuggerStatement */); + var node = createNode(238 /* DebuggerStatement */); parseExpected(80 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -21288,12 +21704,12 @@ var ts; var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); if (expression.kind === 73 /* Identifier */ && parseOptional(57 /* ColonToken */)) { - node.kind = 234 /* LabeledStatement */; + node.kind = 235 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 222 /* ExpressionStatement */; + node.kind = 223 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -21415,6 +21831,7 @@ var ts; case 80 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. + // falls through case 76 /* CatchKeyword */: case 89 /* FinallyKeyword */: return true; @@ -21460,16 +21877,16 @@ var ts; case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); case 106 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(239 /* VariableDeclaration */)); case 112 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(239 /* VariableDeclaration */)); } break; case 91 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(240 /* FunctionDeclaration */)); + return parseFunctionDeclaration(createNodeWithJSDoc(241 /* FunctionDeclaration */)); case 77 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(241 /* ClassDeclaration */)); + return parseClassDeclaration(createNodeWithJSDoc(242 /* ClassDeclaration */)); case 92 /* IfKeyword */: return parseIfStatement(); case 83 /* DoKeyword */: @@ -21479,9 +21896,9 @@ var ts; case 90 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 79 /* ContinueKeyword */: - return parseBreakOrContinueStatement(229 /* ContinueStatement */); + return parseBreakOrContinueStatement(230 /* ContinueStatement */); case 74 /* BreakKeyword */: - return parseBreakOrContinueStatement(230 /* BreakStatement */); + return parseBreakOrContinueStatement(231 /* BreakStatement */); case 98 /* ReturnKeyword */: return parseReturnStatement(); case 109 /* WithKeyword */: @@ -21492,6 +21909,7 @@ var ts; return parseThrowStatement(); case 104 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. + // falls through case 76 /* CatchKeyword */: case 89 /* FinallyKeyword */: return parseTryStatement(); @@ -21527,10 +21945,21 @@ var ts; return modifier.kind === 126 /* DeclareKeyword */; } function parseDeclaration() { + var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); }); + // `parseListElement` attempted to get the reused node at this position, + // but the ambient context flag was not yet set, so the node appeared + // not reusable in that context. + var isAmbient = ts.some(modifiers, isDeclareModifier); + if (isAmbient) { + var node_3 = tryReuseAmbientDeclaration(); + if (node_3) { + return node_3; + } + } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (ts.some(node.modifiers, isDeclareModifier)) { + if (isAmbient) { for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var m = _a[_i]; m.flags |= 4194304 /* Ambient */; @@ -21541,6 +21970,14 @@ var ts; return parseDeclarationWorker(node); } } + function tryReuseAmbientDeclaration() { + return doInsideOfContext(4194304 /* Ambient */, function () { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + }); + } function parseDeclarationWorker(node) { switch (token()) { case 106 /* VarKeyword */: @@ -21578,7 +22015,7 @@ var ts; if (node.decorators || node.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(259 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(260 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -21601,16 +22038,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 27 /* CommaToken */) { - return createNode(211 /* OmittedExpression */); + return createNode(212 /* OmittedExpression */); } - var node = createNode(187 /* BindingElement */); + var node = createNode(188 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(187 /* BindingElement */); + var node = createNode(188 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -21626,14 +22063,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(185 /* ObjectBindingPattern */); + var node = createNode(186 /* ObjectBindingPattern */); parseExpected(18 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(186 /* ArrayBindingPattern */); + var node = createNode(187 /* ArrayBindingPattern */); parseExpected(22 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(23 /* CloseBracketToken */); @@ -21655,7 +22092,7 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(238 /* VariableDeclaration */); + var node = createNode(239 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 73 /* Identifier */ && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { @@ -21668,7 +22105,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(239 /* VariableDeclarationList */); + var node = createNode(240 /* VariableDeclarationList */); switch (token()) { case 106 /* VarKeyword */: break; @@ -21691,7 +22128,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 148 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 149 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -21706,13 +22143,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 220 /* VariableStatement */; + node.kind = 221 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 240 /* FunctionDeclaration */; + node.kind = 241 /* FunctionDeclaration */; parseExpected(91 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); @@ -21736,7 +22173,7 @@ var ts; function tryParseConstructorDeclaration(node) { return tryParse(function () { if (parseConstructorName()) { - node.kind = 158 /* Constructor */; + node.kind = 159 /* Constructor */; fillSignature(57 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); @@ -21744,7 +22181,7 @@ var ts; }); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 157 /* MethodDeclaration */; + node.kind = 158 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; @@ -21753,7 +22190,7 @@ var ts; return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 155 /* PropertyDeclaration */; + node.kind = 156 /* PropertyDeclaration */; if (!node.questionToken && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } @@ -21858,7 +22295,7 @@ var ts; if (!parseOptional(58 /* AtToken */)) { break; } - var decorator = createNode(153 /* Decorator */, decoratorStart); + var decorator = createNode(154 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -21908,7 +22345,7 @@ var ts; } function parseClassElement() { if (token() === 26 /* SemicolonToken */) { - var result = createNode(218 /* SemicolonClassElement */); + var result = createNode(219 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -21916,10 +22353,10 @@ var ts; node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + return parseAccessorDeclaration(node, 160 /* GetAccessor */); } if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + return parseAccessorDeclaration(node, 161 /* SetAccessor */); } if (token() === 125 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(node); @@ -21948,10 +22385,10 @@ var ts; return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 210 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 211 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 241 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 242 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -21994,22 +22431,21 @@ var ts; function parseHeritageClause() { var tok = token(); ts.Debug.assert(tok === 87 /* ExtendsKeyword */ || tok === 110 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(274 /* HeritageClause */); + var node = createNode(275 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(213 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 28 /* LessThanToken */ - ? parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) - : undefined; + return token() === 28 /* LessThanToken */ ? + parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) : undefined; } function isHeritageClause() { return token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; @@ -22018,7 +22454,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 242 /* InterfaceDeclaration */; + node.kind = 243 /* InterfaceDeclaration */; parseExpected(111 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -22027,7 +22463,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 243 /* TypeAliasDeclaration */; + node.kind = 244 /* TypeAliasDeclaration */; parseExpected(141 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -22041,13 +22477,13 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNodeWithJSDoc(279 /* EnumMember */); + var node = createNodeWithJSDoc(280 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 244 /* EnumDeclaration */; + node.kind = 245 /* EnumDeclaration */; parseExpected(85 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(18 /* OpenBraceToken */)) { @@ -22060,7 +22496,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(246 /* ModuleBlock */); + var node = createNode(247 /* ModuleBlock */); if (parseExpected(18 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(19 /* CloseBraceToken */); @@ -22071,7 +22507,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 245 /* ModuleDeclaration */; + node.kind = 246 /* ModuleDeclaration */; // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -22083,7 +22519,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 245 /* ModuleDeclaration */; + node.kind = 246 /* ModuleDeclaration */; if (token() === 146 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); @@ -22129,7 +22565,7 @@ var ts; return nextToken() === 42 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 248 /* NamespaceExportDeclaration */; + node.kind = 249 /* NamespaceExportDeclaration */; parseExpected(120 /* AsKeyword */); parseExpected(132 /* NamespaceKeyword */); node.name = parseIdentifier(); @@ -22147,7 +22583,7 @@ var ts; } } // Import statement - node.kind = 250 /* ImportDeclaration */; + node.kind = 251 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; @@ -22162,7 +22598,7 @@ var ts; return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 249 /* ImportEqualsDeclaration */; + node.kind = 250 /* ImportEqualsDeclaration */; node.name = identifier; parseExpected(60 /* EqualsToken */); node.moduleReference = parseModuleReference(); @@ -22176,7 +22612,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(251 /* ImportClause */, fullStart); + var importClause = createNode(252 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -22186,7 +22622,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(27 /* CommaToken */)) { - importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(253 /* NamedImports */); + importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(254 /* NamedImports */); } return finishNode(importClause); } @@ -22196,7 +22632,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(260 /* ExternalModuleReference */); + var node = createNode(261 /* ExternalModuleReference */); parseExpected(135 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -22219,7 +22655,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(252 /* NamespaceImport */); + var namespaceImport = createNode(253 /* NamespaceImport */); parseExpected(40 /* AsteriskToken */); parseExpected(120 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -22234,14 +22670,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 253 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); + node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 254 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(258 /* ExportSpecifier */); + return parseImportOrExportSpecifier(259 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(254 /* ImportSpecifier */); + return parseImportOrExportSpecifier(255 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -22266,19 +22702,19 @@ var ts; else { node.name = identifierName; } - if (kind === 254 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 255 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 256 /* ExportDeclaration */; + node.kind = 257 /* ExportDeclaration */; if (parseOptional(40 /* AsteriskToken */)) { parseExpected(145 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(257 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(258 /* 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. @@ -22291,7 +22727,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 255 /* ExportAssignment */; + node.kind = 256 /* ExportAssignment */; if (parseOptional(60 /* EqualsToken */)) { node.isExportEquals = true; } @@ -22311,12 +22747,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */ - || node.kind === 250 /* ImportDeclaration */ - || node.kind === 255 /* ExportAssignment */ - || node.kind === 256 /* ExportDeclaration */ - ? node - : undefined; + || node.kind === 250 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 261 /* ExternalModuleReference */ + || node.kind === 251 /* ImportDeclaration */ + || node.kind === 256 /* ExportAssignment */ + || node.kind === 257 /* ExportDeclaration */ ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { return sourceFile.flags & 1048576 /* PossiblyContainsImportMeta */ ? @@ -22378,7 +22812,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(289 /* JSDocTypeExpression */); + var result = createNode(290 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -22390,8 +22824,8 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseIsolatedJSDocComment(content, start, length) { initializeState(content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = { languageVariant: 0 /* Standard */, text: content }; // tslint:disable-line no-object-literal-type-assertion - var jsDoc = parseJSDocCommentWorker(start, length); + sourceFile = { languageVariant: 0 /* Standard */, text: content }; + var jsDoc = doInsideOfContext(2097152 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); var diagnostics = parseDiagnostics; clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -22402,7 +22836,7 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = parseJSDocCommentWorker(start, length); + var comment = doInsideOfContext(2097152 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); if (comment) { comment.parent = parent; } @@ -22541,7 +22975,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(297 /* JSDocComment */, start); + var result = createNode(299 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -22741,7 +23175,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(300 /* JSDocTag */, start); + var result = createNode(302 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -22788,7 +23222,7 @@ var ts; switch (node.kind) { case 137 /* ObjectKeyword */: return true; - case 170 /* ArrayType */: + case 171 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -22804,8 +23238,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(312 /* JSDocPropertyTag */, start) : - createNode(306 /* JSDocParameterTag */, start); + createNode(314 /* JSDocPropertyTag */, start) : + createNode(308 /* JSDocParameterTag */, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -22822,20 +23256,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(289 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(290 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; - var start_2 = scanner.getStartPos(); + var start_3 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 306 /* JSDocParameterTag */ || child.kind === 312 /* JSDocPropertyTag */) { + if (child.kind === 308 /* JSDocParameterTag */ || child.kind === 314 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(298 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(300 /* JSDocTypeLiteral */, start_3); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression.type.kind === 171 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -22847,7 +23281,7 @@ var ts; if (ts.some(tags, ts.isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(307 /* JSDocReturnTag */, start); + var result = createNode(309 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); @@ -22856,13 +23290,13 @@ var ts; if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(309 /* JSDocTypeTag */, start); + var result = createNode(311 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAuthorTag(start, tagName, indent) { - var result = createNode(302 /* JSDocAuthorTag */, start); + var result = createNode(304 /* JSDocAuthorTag */, start); result.tagName = tagName; var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); }); if (!authorInfoWithEmail) { @@ -22916,14 +23350,14 @@ var ts; } } function parseAugmentsTag(start, tagName) { - var result = createNode(301 /* JSDocAugmentsTag */, start); + var result = createNode(303 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18 /* OpenBraceToken */); - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(213 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -22935,7 +23369,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var prop = createNode(190 /* PropertyAccessExpression */, node.pos); + var prop = createNode(191 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -22943,19 +23377,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(303 /* JSDocClassTag */, start); + var tag = createNode(305 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(308 /* JSDocThisTag */, start); + var tag = createNode(310 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(305 /* JSDocEnumTag */, start); + var tag = createNode(307 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); @@ -22964,7 +23398,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(311 /* JSDocTypedefTag */, start); + var typedefTag = createNode(313 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -22978,9 +23412,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(298 /* JSDocTypeLiteral */, start); + jsdocTypeLiteral = createNode(300 /* JSDocTypeLiteral */, start); } - if (child.kind === 309 /* JSDocTypeTag */) { + if (child.kind === 311 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -22993,7 +23427,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 171 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -23012,7 +23446,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(24 /* DotToken */)) { - var jsDocNamespaceNode = createNode(245 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(246 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -23026,14 +23460,14 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(304 /* JSDocCallbackTag */, start); + var callbackTag = createNode(306 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(299 /* JSDocSignature */, start); + var jsdocSignature = createNode(301 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -23041,7 +23475,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(58 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 307 /* JSDocReturnTag */) { + if (tag && tag.kind === 309 /* JSDocReturnTag */) { return tag; } } @@ -23086,7 +23520,7 @@ var ts; case 58 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 306 /* JSDocParameterTag */ || child.kind === 312 /* JSDocPropertyTag */) && + if (child && (child.kind === 308 /* JSDocParameterTag */ || child.kind === 314 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -23150,13 +23584,13 @@ var ts; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(151 /* TypeParameter */); + var typeParameter = createNode(152 /* TypeParameter */); typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); finishNode(typeParameter); skipWhitespace(); typeParameters.push(typeParameter); } while (parseOptionalJsdoc(27 /* CommaToken */)); - var result = createNode(310 /* JSDocTemplateTag */, start); + var result = createNode(312 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -23191,16 +23625,19 @@ var ts; if (!ts.tokenIsIdentifierOrKeyword(token())) { return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } + identifierCount++; var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); var result = createNode(73 /* Identifier */, pos); - result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); + if (token() !== 73 /* Identifier */) { + result.originalKeywordKind = token(); + } + result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); finishNode(result, end); nextTokenJSDoc(); return result; } } - JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {})); })(Parser || (Parser = {})); var IncrementalParser; @@ -24046,6 +24483,7 @@ var ts; type: "boolean", category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_incremental_compilation, + transpileOptionValue: undefined }, { name: "locale", @@ -24055,7 +24493,7 @@ var ts; }, ]; /* @internal */ - ts.optionDeclarations = ts.commonOptionsWithBuild.concat([ + ts.optionDeclarations = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "all", type: "boolean", @@ -24157,7 +24595,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation + description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation, + transpileOptionValue: undefined }, { name: "allowJs", @@ -24194,6 +24633,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "declarationMap", @@ -24202,6 +24642,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "emitDeclarationOnly", @@ -24209,6 +24650,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Only_emit_d_ts_declaration_files, + transpileOptionValue: undefined }, { name: "sourceMap", @@ -24227,6 +24669,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "outDir", @@ -24254,6 +24697,7 @@ var ts; isTSConfigOnly: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_project_compilation, + transpileOptionValue: undefined }, { name: "tsBuildInfoFile", @@ -24263,6 +24707,7 @@ var ts; paramType: ts.Diagnostics.FILE, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, + transpileOptionValue: undefined }, { name: "removeComments", @@ -24279,6 +24724,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Do_not_emit_outputs, + transpileOptionValue: undefined }, { name: "importHelpers", @@ -24298,7 +24744,8 @@ var ts; name: "isolatedModules", type: "boolean", category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule + description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule, + transpileOptionValue: true }, // Strict Type Checks { @@ -24432,7 +24879,8 @@ var ts; affectsModuleResolution: true, isTSConfigOnly: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl + description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl, + transpileOptionValue: undefined }, { // this option can only be specified in tsconfig.json @@ -24447,7 +24895,8 @@ var ts; }, affectsModuleResolution: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime + description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime, + transpileOptionValue: undefined }, { name: "typeRoots", @@ -24471,7 +24920,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation, + transpileOptionValue: undefined }, { name: "allowSyntheticDefaultImports", @@ -24568,6 +25018,7 @@ var ts; category: ts.Diagnostics.Advanced_Options, paramType: ts.Diagnostics.FILE, description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "reactNamespace", @@ -24617,14 +25068,20 @@ var ts; type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts + description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts, + // We are not returning a sourceFile for lib file when asked by the program, + // so pass --noLib to avoid reporting a file not found error. + transpileOptionValue: true }, { name: "noResolve", type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files + description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files, + // We are not doing a full typecheck, we are not resolving the whole context, + // so pass --noResolve to avoid reporting missing file errors. + transpileOptionValue: true }, { name: "stripInternal", @@ -24660,6 +25117,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + transpileOptionValue: undefined }, { name: "preserveConstEnums", @@ -24675,7 +25133,8 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Output_directory_for_generated_declaration_files + description: ts.Diagnostics.Output_directory_for_generated_declaration_files, + transpileOptionValue: undefined }, { name: "skipLibCheck", @@ -24762,7 +25221,11 @@ var ts; return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics; }); /* @internal */ - ts.buildOpts = ts.commonOptionsWithBuild.concat([ + ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) { + return ts.hasProperty(option, "transpileOptionValue"); + }); + /* @internal */ + ts.buildOpts = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "verbose", shortName: "v", @@ -25326,7 +25789,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 276 /* PropertyAssignment */) { + if (element.kind !== 277 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -25390,7 +25853,7 @@ var ts; return false; case 97 /* NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for - return null; // tslint:disable-line:no-null-keyword + return null; // eslint-disable-line no-null/no-null case 10 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); @@ -25408,13 +25871,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: if (valueExpression.operator !== 39 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -25431,7 +25894,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25482,13 +25945,13 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName); }); var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames }); - var config = __assign({ compilerOptions: __assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { + var config = __assign(__assign({ compilerOptions: __assign(__assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { var _a; - return (__assign({}, prev, (_a = {}, _a[cur[0]] = cur[1], _a))); - }, {}), { showConfig: undefined, configFile: undefined, configFilePath: undefined, help: undefined, init: undefined, listFiles: undefined, listEmittedFiles: undefined, project: undefined, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign({}, r, { path: r.originalPath, originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { + return (__assign(__assign({}, prev), (_a = {}, _a[cur[0]] = cur[1], _a))); + }, {})), { showConfig: undefined, configFile: undefined, configFilePath: undefined, help: undefined, init: undefined, listFiles: undefined, listEmittedFiles: undefined, project: undefined, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign(__assign({}, r), { path: r.originalPath ? r.originalPath : "", originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs), exclude: configParseResult.configFileSpecs.validatedExcludeSpecs - } : {}), { compilerOnSave: !!configParseResult.compileOnSave ? true : undefined }); + } : {})), { compileOnSave: !!configParseResult.compileOnSave ? true : undefined }); return config; } ts.convertToTSConfig = convertToTSConfig; @@ -25713,8 +26176,7 @@ var ts; } ts.setConfigFileInOptions = setConfigFileInOptions; function isNullOrUndefined(x) { - // tslint:disable-next-line:no-null-keyword - return x === undefined || x === null; + return x === undefined || x === null; // eslint-disable-line no-null/no-null } function directoryOfCombinedPath(fileName, basePath) { // Use the `getNormalizedAbsolutePath` function to avoid canonicalizing the path, as it must remain noncanonical @@ -25880,7 +26342,7 @@ var ts; basePath = ts.normalizeSlashes(basePath); var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath); if (resolutionStack.indexOf(resolvedPath) >= 0) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))); + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, __spreadArrays(resolutionStack, [resolvedPath]).join(" -> "))); return { raw: json || convertToObject(sourceFile, errors) }; } var ownConfig = json ? @@ -26569,8 +27031,9 @@ var ts; return; } var value = jsonContent[fieldName]; - if (typeof value !== typeOfTag || value === null) { + if (typeof value !== typeOfTag || value === null) { // eslint-disable-line no-null/no-null if (state.traceEnabled) { + // eslint-disable-next-line no-null/no-null trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, fieldName, typeOfTag, value === null ? "null" : typeof value); } return; @@ -26829,7 +27292,7 @@ var ts; var packageJsonPath = ts.combinePaths(root, normalized, "package.json"); // `types-publisher` sometimes creates packages with `"typings": null` for packages that don't provide their own types. // See `createNotNeededPackageJSON` in the types-publisher` repo. - // tslint:disable-next-line:no-null-keyword + // eslint-disable-next-line no-null/no-null var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); @@ -27013,6 +27476,7 @@ var ts; trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); } } + ts.perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/); switch (moduleResolution) { case ts.ModuleResolutionKind.NodeJs: result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); @@ -27023,6 +27487,9 @@ var ts; default: return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); } + if (result && result.resolvedModule) + ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, result); if (!ts.isExternalModuleNameRelative(moduleName)) { @@ -27232,7 +27699,7 @@ var ts; ts.tryResolveJSModule = tryResolveJSModule; var jsOnlyExtensions = [Extensions.JavaScript]; var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript]; - var tsPlusJsonExtensions = tsExtensions.concat([Extensions.Json]); + var tsPlusJsonExtensions = __spreadArrays(tsExtensions, [Extensions.Json]); var tsconfigExtensions = [Extensions.TSConfig]; function tryResolveJSModuleWorker(moduleName, initialDir, host) { return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); @@ -27268,7 +27735,7 @@ var ts; if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) { var path = realPath(resolvedValue.path, host, traceEnabled); var originalPath = path === resolvedValue.path ? undefined : resolvedValue.path; - resolvedValue = __assign({}, resolvedValue, { path: path, originalPath: originalPath }); + resolvedValue = __assign(__assign({}, resolvedValue), { path: path, originalPath: originalPath }); } // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } }; @@ -27289,7 +27756,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); // tslint:disable-line + ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -27777,24 +28244,24 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. other uninstantiated module declarations. - case 246 /* ModuleBlock */: { + case 247 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -27816,7 +28283,7 @@ var ts; }); return state_1; } - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return getModuleInstanceState(node); case 73 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should @@ -27855,7 +28322,9 @@ var ts; var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); + ts.perfLogger.logStartBindFile("" + file.fileName); binder(file, options); + ts.perfLogger.logStopBindFile(); ts.performance.mark("afterBind"); ts.performance.measure("Bind", "beforeBind", "afterBind"); } @@ -27889,7 +28358,7 @@ var ts; // or if compiler options contain alwaysStrict. var inStrictMode; var symbolCount = 0; - var Symbol; // tslint:disable-line variable-name + var Symbol; var classifiableNames; var unreachableFlow = { flags: 1 /* Unreachable */ }; var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; @@ -27957,7 +28426,7 @@ var ts; function addDeclarationToSymbol(symbol, node, symbolFlags) { symbol.flags |= symbolFlags; node.symbol = symbol; - symbol.declarations = ts.append(symbol.declarations, node); + symbol.declarations = ts.appendIfUnique(symbol.declarations, node); if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -27968,7 +28437,7 @@ var ts; if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 67220415 /* Value */) { + if (symbolFlags & 111551 /* Value */) { setValueDeclaration(symbol, node); } } @@ -27984,7 +28453,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 === 255 /* ExportAssignment */) { + if (node.kind === 256 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -27993,7 +28462,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 151 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -28008,36 +28477,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: return "__constructor" /* Constructor */; - case 166 /* FunctionType */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: + case 167 /* FunctionType */: + case 162 /* CallSignature */: + case 301 /* JSDocSignature */: return "__call" /* Call */; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 168 /* ConstructorType */: + case 163 /* ConstructSignature */: return "__new" /* New */; - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: return "__index" /* Index */; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 285 /* SourceFile */: + case 286 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 152 /* Parameter */: + case 153 /* 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 === 295 /* 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 === 296 /* 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; @@ -28137,7 +28606,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 === 255 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 256 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -28155,7 +28624,7 @@ var ts; } }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); - file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInformation_1)) : diag); + file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInformation_1)) : diag); symbol = createSymbol(0 /* None */, name); } } @@ -28172,7 +28641,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 258 /* ExportSpecifier */ || (node.kind === 249 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 259 /* ExportSpecifier */ || (node.kind === 250 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -28197,10 +28666,10 @@ var ts; if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { - if (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node)) { + if (!container.locals || (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } - var exportKind = symbolFlags & 67220415 /* Value */ ? 1048576 /* ExportValue */ : 0; + var exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -28239,7 +28708,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 !== 198 /* ArrowFunction */) { + if (node.kind !== 199 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -28272,7 +28741,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 === 158 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 159 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -28286,13 +28755,13 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 158 /* Constructor */) { + if (node.kind === 159 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -28336,8 +28805,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 241 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 241 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -28370,78 +28839,82 @@ var ts; return; } switch (node.kind) { - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: bindWhileStatement(node); break; - case 224 /* DoStatement */: + case 225 /* DoStatement */: bindDoStatement(node); break; - case 226 /* ForStatement */: + case 227 /* ForStatement */: bindForStatement(node); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 223 /* IfStatement */: + case 224 /* IfStatement */: bindIfStatement(node); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 232 /* ReturnStatement */: + case 236 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 236 /* TryStatement */: + case 237 /* TryStatement */: bindTryStatement(node); break; - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: bindSwitchStatement(node); break; - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: bindCaseBlock(node); break; - case 272 /* CaseClause */: + case 273 /* CaseClause */: bindCaseClause(node); break; - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: bindLabeledStatement(node); break; - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 192 /* CallExpression */: + case 193 /* CallExpression */: bindCallExpressionFlow(node); break; - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; + case 305 /* JSDocClassTag */: + bindJSDocClassTag(node); + break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 285 /* SourceFile */: { + case 286 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 220 /* Block */: + case 247 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -28454,18 +28927,18 @@ var ts; switch (expr.kind) { case 73 /* Identifier */: case 101 /* ThisKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return isNarrowableReference(expr); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return hasNarrowableArgument(expr); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return expr.operator === 52 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; @@ -28473,7 +28946,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 73 /* Identifier */ || expr.kind === 101 /* ThisKeyword */ || expr.kind === 99 /* SuperKeyword */ || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isElementAccessExpression(expr) && expr.argumentExpression && + ts.isElementAccessExpression(expr) && (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && isNarrowableReference(expr.expression); } @@ -28486,7 +28959,7 @@ var ts; } } } - if (expr.expression.kind === 190 /* PropertyAccessExpression */ && + if (expr.expression.kind === 191 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -28519,9 +28992,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 60 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -28599,33 +29072,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 224 /* IfStatement */: + case 226 /* WhileStatement */: + case 225 /* DoStatement */: return parent.expression === node; - case 226 /* ForStatement */: - case 206 /* ConditionalExpression */: + case 227 /* ForStatement */: + case 207 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 196 /* ParenthesizedExpression */) { + if (node.kind === 197 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 203 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { + else if (node.kind === 204 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 205 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || + return node.kind === 206 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 55 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */ || - node.parent.kind === 203 /* PrefixUnaryExpression */ && + while (node.parent.kind === 197 /* ParenthesizedExpression */ || + node.parent.kind === 204 /* PrefixUnaryExpression */ && node.parent.operator === 52 /* ExclamationToken */) { node = node.parent; } @@ -28667,7 +29140,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 234 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 235 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -28701,13 +29174,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 228 /* ForOfStatement */) { + if (node.kind === 229 /* ForOfStatement */) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 239 /* VariableDeclarationList */) { + if (node.initializer.kind !== 240 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -28729,7 +29202,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 231 /* ReturnStatement */) { + if (node.kind === 232 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -28749,7 +29222,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 230 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 231 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -28877,7 +29350,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 273 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 274 /* 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). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -28944,14 +29417,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 224 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 225 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */) { + if (node.kind === 206 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -28962,10 +29435,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 188 /* ArrayLiteralExpression */) { + else if (node.kind === 189 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 209 /* SpreadElement */) { + if (e.kind === 210 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -28973,16 +29446,16 @@ var ts; } } } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 190 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 276 /* PropertyAssignment */) { + if (p.kind === 277 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 277 /* ShorthandPropertyAssignment */) { + else if (p.kind === 278 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 278 /* SpreadAssignment */) { + else if (p.kind === 279 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -29038,7 +29511,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 60 /* EqualsToken */ && node.left.kind === 191 /* ElementAccessExpression */) { + if (operator === 60 /* EqualsToken */ && node.left.kind === 192 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29049,7 +29522,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + if (node.expression.kind === 191 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -29088,19 +29561,26 @@ var ts; } function bindJSDocTypeAlias(node) { node.tagName.parent = node; - if (node.fullName) { + if (node.kind !== 307 /* JSDocEnumTag */ && node.fullName) { setParentPointers(node, node.fullName); } } + function bindJSDocClassTag(node) { + bindEachChild(node); + var host = ts.getHostSignatureFromJSDoc(node); + if (host && host.kind !== 158 /* MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* Class */); + } + } function bindCallExpressionFlow(node) { // If the target of the call expression is a function expression or arrow function we have // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = node.expression; - while (expr.kind === 196 /* ParenthesizedExpression */) { + while (expr.kind === 197 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 197 /* FunctionExpression */ || expr.kind === 198 /* ArrowFunction */) { + if (expr.kind === 198 /* FunctionExpression */ || expr.kind === 199 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -29108,7 +29588,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + if (node.expression.kind === 191 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29117,54 +29597,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 269 /* JsxAttributes */: + case 211 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 190 /* ObjectLiteralExpression */: + case 170 /* TypeLiteral */: + case 300 /* JSDocTypeLiteral */: + case 270 /* JsxAttributes */: return 1 /* IsContainer */; - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 246 /* ModuleDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 183 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 285 /* SourceFile */: + case 286 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: - case 295 /* JSDocFunctionType */: - case 166 /* FunctionType */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 167 /* ConstructorType */: + case 159 /* Constructor */: + case 241 /* FunctionDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 162 /* CallSignature */: + case 301 /* JSDocSignature */: + case 296 /* JSDocFunctionType */: + case 167 /* FunctionType */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 168 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 275 /* CatchClause */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 247 /* CaseBlock */: + case 276 /* CatchClause */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 248 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 219 /* Block */: + case 220 /* 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 @@ -29197,45 +29677,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 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 285 /* SourceFile */: + case 286 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 242 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 189 /* ObjectLiteralExpression */: - case 242 /* InterfaceDeclaration */: - case 269 /* JsxAttributes */: + case 170 /* TypeLiteral */: + case 300 /* JSDocTypeLiteral */: + case 190 /* ObjectLiteralExpression */: + case 243 /* InterfaceDeclaration */: + case 270 /* 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 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 299 /* JSDocSignature */: - case 163 /* IndexSignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 295 /* JSDocFunctionType */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 301 /* JSDocSignature */: + case 164 /* IndexSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 296 /* JSDocFunctionType */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 244 /* TypeAliasDeclaration */: + case 183 /* 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 @@ -29336,7 +29816,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */ || prop.name.kind !== 73 /* Identifier */) { + if (prop.kind === 279 /* SpreadAssignment */ || prop.name.kind !== 73 /* Identifier */) { continue; } var identifier = prop.name; @@ -29348,7 +29828,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 === 276 /* PropertyAssignment */ || prop.kind === 277 /* ShorthandPropertyAssignment */ || prop.kind === 157 /* MethodDeclaration */ + var currentKind = prop.kind === 277 /* PropertyAssignment */ || prop.kind === 278 /* ShorthandPropertyAssignment */ || prop.kind === 158 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -29380,10 +29860,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -29414,9 +29894,37 @@ var ts; currentFlow = { flags: 2 /* Start */ }; parent = typeAlias; bind(typeAlias.typeExpression); - if (!typeAlias.fullName || typeAlias.fullName.kind === 73 /* Identifier */) { + var declName = ts.getNameOfDeclaration(typeAlias); + if ((ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName) && declName && ts.isPropertyAccessEntityNameExpression(declName.parent)) { + // typedef anchored to an A.B.C assignment - we need to bind into B's namespace under name C + var isTopLevel = isTopLevelNamespaceAssignment(declName.parent); + if (isTopLevel) { + bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); + var oldContainer = container; + switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { + case 1 /* ExportsProperty */: + case 2 /* ModuleExports */: + container = file; + break; + case 4 /* ThisProperty */: + container = declName.parent.expression; + break; + case 3 /* PrototypeProperty */: + container = declName.parent.expression.name; + break; + case 5 /* Property */: + container = ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; + break; + case 0 /* None */: + return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); + } + declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + container = oldContainer; + } + } + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 73 /* Identifier */) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); } else { bind(typeAlias.fullName); @@ -29435,7 +29943,8 @@ var ts; node.originalKeywordKind >= 110 /* FirstFutureReservedWord */ && node.originalKeywordKind <= 118 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && - !(node.flags & 4194304 /* Ambient */)) { + !(node.flags & 4194304 /* Ambient */) && + !(node.flags & 2097152 /* JSDoc */)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -29521,8 +30030,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 285 /* SourceFile */ && - blockScopeContainer.kind !== 245 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 286 /* SourceFile */ && + blockScopeContainer.kind !== 246 /* 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. @@ -29583,7 +30092,7 @@ var ts; file.bindDiagnostics.push(diag); } else { - file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } } function bind(node) { @@ -29617,7 +30126,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 > 148 /* LastToken */) { + if (node.kind > 149 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -29688,17 +30197,17 @@ var ts; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); break; } // falls through case 101 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 277 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 278 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -29709,10 +30218,10 @@ var ts; file.commonJsModuleIndicator && ts.isModuleExportsPropertyAccessExpression(node) && !lookupSymbolForNameWorker(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 67220414 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -29740,76 +30249,76 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return checkStrictModeCatchClause(node); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return checkStrictModeWithStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 179 /* ThisType */: + case 180 /* ThisType */: seenThisKeyword = true; return; - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: break; // Binding the children will handle everything - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return bindTypeParameter(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return bindParameter(node); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 187 /* BindingElement */: + case 188 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return bindPropertyWorker(node); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 279 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 280 /* EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* 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 */ : 67212223 /* MethodExcludes */); - case 240 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); + case 241 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 158 /* Constructor */: + case 159 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 159 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 67154879 /* GetAccessorExcludes */); - case 160 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67187647 /* SetAccessorExcludes */); - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 299 /* JSDocSignature */: - case 167 /* ConstructorType */: + case 160 /* GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); + case 161 /* SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); + case 167 /* FunctionType */: + case 296 /* JSDocFunctionType */: + case 301 /* JSDocSignature */: + case 168 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 182 /* MappedType */: + case 170 /* TypeLiteral */: + case 300 /* JSDocTypeLiteral */: + case 183 /* MappedType */: return bindAnonymousTypeWorker(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return bindFunctionExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -29828,64 +30337,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 242 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 242 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 67897736 /* InterfaceExcludes */); - case 243 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); - case 244 /* EnumDeclaration */: + case 243 /* InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); + case 244 /* TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + case 245 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return bindJsxAttributes(node); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 250 /* ImportEqualsDeclaration */: + case 253 /* NamespaceImport */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return bindImportClause(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return bindExportDeclaration(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return bindExportAssignment(node); - case 285 /* SourceFile */: + case 286 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 219 /* Block */: + case 220 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 306 /* JSDocParameterTag */: - if (node.parent.kind === 299 /* JSDocSignature */) { + case 308 /* JSDocParameterTag */: + if (node.parent.kind === 301 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 298 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 300 /* JSDocTypeLiteral */) { break; } // falls through - case 312 /* JSDocPropertyTag */: + case 314 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 294 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 295 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -30029,8 +30539,8 @@ var ts; ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 198 /* 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 === 60 /* EqualsToken */) { @@ -30044,26 +30554,27 @@ var ts; constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable(); // It's acceptable for multiple 'this' assignments of the same identifier to occur declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 159 /* Constructor */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 285 /* SourceFile */: + case 286 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220414 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); } break; default: @@ -30074,7 +30585,7 @@ var ts; if (node.expression.kind === 101 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 285 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 286 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -30088,7 +30599,7 @@ var ts; node.left.parent = node; node.right.parent = node; var lhs = node.left; - bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false); + bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false, /*containerIsClass*/ true); } function bindObjectDefinePrototypeProperty(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); @@ -30107,12 +30618,12 @@ var ts; lhs.parent = parent; constructorFunction.parent = classPrototype; classPrototype.parent = lhs; - bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true); + bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true, /*containerIsClass*/ true); } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); + var isToplevel = node.parent.parent.kind === 286 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } function bindSpecialPropertyAssignment(node) { @@ -30141,10 +30652,10 @@ var ts; */ function bindStaticPropertyAssignment(node) { node.expression.parent = node; - bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } - function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { - if (isToplevel && !isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */))) { + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { + if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* Assignment */; var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; @@ -30160,6 +30671,9 @@ var ts; } }); } + if (containerIsClass && namespaceSymbol) { + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + } return namespaceSymbol; } function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { @@ -30172,15 +30686,18 @@ var ts; (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); var includes = isMethod ? 8192 /* Method */ : 4 /* Property */; - var excludes = isMethod ? 67212223 /* MethodExcludes */ : 0 /* PropertyExcludes */; + var excludes = isMethod ? 103359 /* MethodExcludes */ : 0 /* PropertyExcludes */; declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + function isTopLevelNamespaceAssignment(propertyAccess) { + return ts.isBinaryExpression(propertyAccess.parent) + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 286 /* SourceFile */ + : propertyAccess.parent.parent.kind === 286 /* SourceFile */; + } + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); - var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 285 /* SourceFile */ - : propertyAccess.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } /** @@ -30249,8 +30766,8 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 241 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); + if (node.kind === 242 /* ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { var bindingName = node.name ? node.name.escapedText : "__class" /* Class */; @@ -30283,19 +30800,16 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 68008831 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 68008191 /* RegularEnumExcludes */); + ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - var isEnum = ts.isInJSFile(node) && !!ts.getJSDocEnumTag(node); - var enumFlags = (isEnum ? 256 /* RegularEnum */ : 0 /* None */); - var enumExcludes = (isEnum ? 68008191 /* RegularEnumExcludes */ : 0 /* None */); if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */ | enumFlags, 67220415 /* BlockScopedVariableExcludes */ | enumExcludes); + bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); } else if (ts.isParameterDeclaration(node)) { // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration @@ -30307,15 +30821,15 @@ var ts; // function foo([a,a]) {} // Duplicate Identifier error // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter // // which correctly set excluded symbols - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220415 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */ | enumFlags, 67220414 /* FunctionScopedVariableExcludes */ | enumExcludes); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); } } } function bindParameter(node) { - if (node.kind === 306 /* JSDocParameterTag */ && container.kind !== 299 /* JSDocSignature */) { + if (node.kind === 308 /* JSDocParameterTag */ && container.kind !== 301 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -30327,11 +30841,11 @@ var ts; bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220415 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); } // If this is a property-parameter, then also declare the property symbol into the // containing class. - if (ts.isParameterPropertyDeclaration(node)) { + if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); } @@ -30345,10 +30859,10 @@ var ts; checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16 /* Function */, 67219887 /* FunctionExcludes */); + bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 67219887 /* FunctionExcludes */); + declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */); } } function bindFunctionExpression(node) { @@ -30386,26 +30900,26 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 177 /* InferType */) { + else if (node.parent.kind === 178 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } else { bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } // reachability checks @@ -30420,11 +30934,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 221 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 222 /* EmptyStatement */) || // report error on class declarations - node.kind === 241 /* ClassDeclaration */ || + node.kind === 242 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 245 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 246 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -30468,12 +30982,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: return true; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; @@ -30522,58 +31036,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 192 /* CallExpression */: + case 193 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 152 /* Parameter */: + case 153 /* Parameter */: return computeParameter(node, subtreeFlags); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 158 /* Constructor */: + case 159 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -30618,12 +31132,12 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 189 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 190 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ES2018 if they contain rest transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 188 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 189 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } @@ -30671,8 +31185,8 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 213 /* AsExpression */ - || expressionKind === 195 /* TypeAssertionExpression */) { + if (expressionKind === 214 /* AsExpression */ + || expressionKind === 196 /* TypeAssertionExpression */) { transformFlags |= 1 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -31010,13 +31524,13 @@ var ts; var excludeFlags = 536870912 /* NodeExcludes */; switch (kind) { case 122 /* AsyncKeyword */: - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ES2018 syntax (for async generators) transformFlags |= 16 /* AssertES2018 */ | 32 /* AssertES2017 */; break; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 315 /* PartiallyEmittedExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: + case 317 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; excludeFlags = 536870912 /* OuterExpressionExcludes */; @@ -31027,25 +31541,25 @@ var ts; case 119 /* AbstractKeyword */: case 126 /* DeclareKeyword */: case 78 /* ConstKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 214 /* NonNullExpression */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 215 /* NonNullExpression */: case 134 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: case 11 /* JsxText */: - case 264 /* JsxClosingElement */: - case 265 /* JsxFragment */: - case 266 /* JsxOpeningFragment */: - case 267 /* JsxClosingFragment */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 271 /* JsxExpression */: + case 265 /* JsxClosingElement */: + case 266 /* JsxFragment */: + case 267 /* JsxOpeningFragment */: + case 268 /* JsxClosingFragment */: + case 269 /* JsxAttribute */: + case 270 /* JsxAttributes */: + case 271 /* JsxSpreadAttribute */: + case 272 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 2 /* AssertJsx */; break; @@ -31053,11 +31567,11 @@ var ts; case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: - case 277 /* ShorthandPropertyAssignment */: + case 208 /* TemplateExpression */: + case 195 /* TaggedTemplateExpression */: + case 278 /* ShorthandPropertyAssignment */: case 117 /* StaticKeyword */: - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; @@ -31074,14 +31588,14 @@ var ts; case 9 /* BigIntLiteral */: transformFlags |= 4 /* AssertESNext */; break; - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 16 /* AssertES2018 */; } transformFlags |= 128 /* AssertES2015 */; break; - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 131072 /* ContainsYield */; @@ -31095,49 +31609,49 @@ var ts; case 124 /* BooleanKeyword */: case 140 /* SymbolKeyword */: case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 164 /* TypePredicate */: - case 165 /* TypeReference */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 168 /* TypeQuery */: - case 169 /* TypeLiteral */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 177 /* InferType */: - case 178 /* ParenthesizedType */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: - case 248 /* NamespaceExportDeclaration */: + case 152 /* TypeParameter */: + case 155 /* PropertySignature */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 165 /* TypePredicate */: + case 166 /* TypeReference */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 169 /* TypeQuery */: + case 170 /* TypeLiteral */: + case 171 /* ArrayType */: + case 172 /* TupleType */: + case 173 /* OptionalType */: + case 174 /* RestType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: + case 177 /* ConditionalType */: + case 178 /* InferType */: + case 179 /* ParenthesizedType */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 180 /* ThisType */: + case 181 /* TypeOperator */: + case 182 /* IndexedAccessType */: + case 183 /* MappedType */: + case 184 /* LiteralType */: + case 249 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 1 /* AssertTypeScript */; excludeFlags = -2 /* TypeExcludes */; break; - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. transformFlags |= 16384 /* ContainsComputedPropertyName */; break; - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: transformFlags |= 128 /* AssertES2015 */ | 4096 /* ContainsRestOrSpread */; break; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; break; case 99 /* SuperKeyword */: @@ -31149,28 +31663,28 @@ var ts; // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 2048 /* ContainsLexicalThis */; break; - case 185 /* ObjectBindingPattern */: + case 186 /* ObjectBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; if (subtreeFlags & 4096 /* ContainsRestOrSpread */) { transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; } excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 187 /* BindingElement */: + case 188 /* BindingElement */: transformFlags |= 128 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 4096 /* ContainsRestOrSpread */; } break; - case 153 /* Decorator */: + case 154 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */ | 1024 /* ContainsTypeScriptClassSyntax */; break; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: excludeFlags = 536896512 /* ObjectLiteralExcludes */; if (subtreeFlags & 16384 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -31183,26 +31697,26 @@ var ts; transformFlags |= 16 /* AssertES2018 */; } break; - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: excludeFlags = 536875008 /* ArrayLiteralOrCallOrNewExcludes */; break; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 32768 /* ContainsBlockScopedBinding */) { transformFlags |= 128 /* AssertES2015 */; } break; - case 285 /* SourceFile */: + case 286 /* SourceFile */: break; - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: // Return statements may require an `await` in ES2018. transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */ | 16 /* AssertES2018 */; break; - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 230 /* ContinueStatement */: + case 231 /* BreakStatement */: transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -31220,33 +31734,33 @@ var ts; * than calling this function. */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) { + if (kind >= 165 /* FirstTypeNode */ && kind <= 185 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 188 /* ArrayLiteralExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 189 /* ArrayLiteralExpression */: return 536875008 /* ArrayLiteralOrCallOrNewExcludes */; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return 537168896 /* ModuleExcludes */; - case 152 /* Parameter */: + case 153 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return 537371648 /* ArrowFunctionExcludes */; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: return 537373696 /* FunctionExcludes */; - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return 536944640 /* VariableDeclarationListExcludes */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return 536888320 /* ClassExcludes */; - case 158 /* Constructor */: + case 159 /* Constructor */: return 537372672 /* ConstructorExcludes */; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return 537372672 /* MethodOrAccessorExcludes */; case 121 /* AnyKeyword */: case 136 /* NumberKeyword */: @@ -31257,30 +31771,30 @@ var ts; case 124 /* BooleanKeyword */: case 140 /* SymbolKeyword */: case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 152 /* TypeParameter */: + case 155 /* PropertySignature */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return 536896512 /* ObjectLiteralExcludes */; - case 275 /* CatchClause */: + case 276 /* CatchClause */: return 536879104 /* CatchClauseExcludes */; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: return 536875008 /* BindingPatternExcludes */; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 315 /* PartiallyEmittedExpression */: - case 196 /* ParenthesizedExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: + case 317 /* PartiallyEmittedExpression */: + case 197 /* ParenthesizedExpression */: case 99 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -31455,7 +31969,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 === 168 /* TypeQuery */) { + if (d.type && d.type.kind === 169 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -31506,6 +32020,179 @@ var ts; WideningKind[WideningKind["Normal"] = 0] = "Normal"; WideningKind[WideningKind["GeneratorYield"] = 1] = "GeneratorYield"; })(WideningKind || (WideningKind = {})); + var TypeFacts; + (function (TypeFacts) { + TypeFacts[TypeFacts["None"] = 0] = "None"; + TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; + TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; + TypeFacts[TypeFacts["TypeofEQBigInt"] = 4] = "TypeofEQBigInt"; + TypeFacts[TypeFacts["TypeofEQBoolean"] = 8] = "TypeofEQBoolean"; + TypeFacts[TypeFacts["TypeofEQSymbol"] = 16] = "TypeofEQSymbol"; + TypeFacts[TypeFacts["TypeofEQObject"] = 32] = "TypeofEQObject"; + TypeFacts[TypeFacts["TypeofEQFunction"] = 64] = "TypeofEQFunction"; + TypeFacts[TypeFacts["TypeofEQHostObject"] = 128] = "TypeofEQHostObject"; + TypeFacts[TypeFacts["TypeofNEString"] = 256] = "TypeofNEString"; + TypeFacts[TypeFacts["TypeofNENumber"] = 512] = "TypeofNENumber"; + TypeFacts[TypeFacts["TypeofNEBigInt"] = 1024] = "TypeofNEBigInt"; + TypeFacts[TypeFacts["TypeofNEBoolean"] = 2048] = "TypeofNEBoolean"; + TypeFacts[TypeFacts["TypeofNESymbol"] = 4096] = "TypeofNESymbol"; + TypeFacts[TypeFacts["TypeofNEObject"] = 8192] = "TypeofNEObject"; + TypeFacts[TypeFacts["TypeofNEFunction"] = 16384] = "TypeofNEFunction"; + TypeFacts[TypeFacts["TypeofNEHostObject"] = 32768] = "TypeofNEHostObject"; + TypeFacts[TypeFacts["EQUndefined"] = 65536] = "EQUndefined"; + TypeFacts[TypeFacts["EQNull"] = 131072] = "EQNull"; + TypeFacts[TypeFacts["EQUndefinedOrNull"] = 262144] = "EQUndefinedOrNull"; + TypeFacts[TypeFacts["NEUndefined"] = 524288] = "NEUndefined"; + TypeFacts[TypeFacts["NENull"] = 1048576] = "NENull"; + TypeFacts[TypeFacts["NEUndefinedOrNull"] = 2097152] = "NEUndefinedOrNull"; + TypeFacts[TypeFacts["Truthy"] = 4194304] = "Truthy"; + TypeFacts[TypeFacts["Falsy"] = 8388608] = "Falsy"; + TypeFacts[TypeFacts["All"] = 16777215] = "All"; + // The following members encode facts about particular kinds of types for use in the getTypeFacts function. + // The presence of a particular fact means that the given test is true for some (and possibly all) values + // of that kind of type. + TypeFacts[TypeFacts["BaseStringStrictFacts"] = 3735041] = "BaseStringStrictFacts"; + TypeFacts[TypeFacts["BaseStringFacts"] = 12582401] = "BaseStringFacts"; + TypeFacts[TypeFacts["StringStrictFacts"] = 16317953] = "StringStrictFacts"; + TypeFacts[TypeFacts["StringFacts"] = 16776705] = "StringFacts"; + TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 12123649] = "EmptyStringStrictFacts"; + TypeFacts[TypeFacts["EmptyStringFacts"] = 12582401] = "EmptyStringFacts"; + TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 7929345] = "NonEmptyStringStrictFacts"; + TypeFacts[TypeFacts["NonEmptyStringFacts"] = 16776705] = "NonEmptyStringFacts"; + TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 3734786] = "BaseNumberStrictFacts"; + TypeFacts[TypeFacts["BaseNumberFacts"] = 12582146] = "BaseNumberFacts"; + TypeFacts[TypeFacts["NumberStrictFacts"] = 16317698] = "NumberStrictFacts"; + TypeFacts[TypeFacts["NumberFacts"] = 16776450] = "NumberFacts"; + TypeFacts[TypeFacts["ZeroNumberStrictFacts"] = 12123394] = "ZeroNumberStrictFacts"; + TypeFacts[TypeFacts["ZeroNumberFacts"] = 12582146] = "ZeroNumberFacts"; + TypeFacts[TypeFacts["NonZeroNumberStrictFacts"] = 7929090] = "NonZeroNumberStrictFacts"; + TypeFacts[TypeFacts["NonZeroNumberFacts"] = 16776450] = "NonZeroNumberFacts"; + TypeFacts[TypeFacts["BaseBigIntStrictFacts"] = 3734276] = "BaseBigIntStrictFacts"; + TypeFacts[TypeFacts["BaseBigIntFacts"] = 12581636] = "BaseBigIntFacts"; + TypeFacts[TypeFacts["BigIntStrictFacts"] = 16317188] = "BigIntStrictFacts"; + TypeFacts[TypeFacts["BigIntFacts"] = 16775940] = "BigIntFacts"; + TypeFacts[TypeFacts["ZeroBigIntStrictFacts"] = 12122884] = "ZeroBigIntStrictFacts"; + TypeFacts[TypeFacts["ZeroBigIntFacts"] = 12581636] = "ZeroBigIntFacts"; + TypeFacts[TypeFacts["NonZeroBigIntStrictFacts"] = 7928580] = "NonZeroBigIntStrictFacts"; + TypeFacts[TypeFacts["NonZeroBigIntFacts"] = 16775940] = "NonZeroBigIntFacts"; + TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 3733256] = "BaseBooleanStrictFacts"; + TypeFacts[TypeFacts["BaseBooleanFacts"] = 12580616] = "BaseBooleanFacts"; + TypeFacts[TypeFacts["BooleanStrictFacts"] = 16316168] = "BooleanStrictFacts"; + TypeFacts[TypeFacts["BooleanFacts"] = 16774920] = "BooleanFacts"; + TypeFacts[TypeFacts["FalseStrictFacts"] = 12121864] = "FalseStrictFacts"; + TypeFacts[TypeFacts["FalseFacts"] = 12580616] = "FalseFacts"; + TypeFacts[TypeFacts["TrueStrictFacts"] = 7927560] = "TrueStrictFacts"; + TypeFacts[TypeFacts["TrueFacts"] = 16774920] = "TrueFacts"; + TypeFacts[TypeFacts["SymbolStrictFacts"] = 7925520] = "SymbolStrictFacts"; + TypeFacts[TypeFacts["SymbolFacts"] = 16772880] = "SymbolFacts"; + TypeFacts[TypeFacts["ObjectStrictFacts"] = 7888800] = "ObjectStrictFacts"; + TypeFacts[TypeFacts["ObjectFacts"] = 16736160] = "ObjectFacts"; + TypeFacts[TypeFacts["FunctionStrictFacts"] = 7880640] = "FunctionStrictFacts"; + TypeFacts[TypeFacts["FunctionFacts"] = 16728000] = "FunctionFacts"; + TypeFacts[TypeFacts["UndefinedFacts"] = 9830144] = "UndefinedFacts"; + TypeFacts[TypeFacts["NullFacts"] = 9363232] = "NullFacts"; + TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts"; + TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts"; + })(TypeFacts || (TypeFacts = {})); + var typeofEQFacts = ts.createMapFromTemplate({ + string: 1 /* TypeofEQString */, + number: 2 /* TypeofEQNumber */, + bigint: 4 /* TypeofEQBigInt */, + boolean: 8 /* TypeofEQBoolean */, + symbol: 16 /* TypeofEQSymbol */, + undefined: 65536 /* EQUndefined */, + object: 32 /* TypeofEQObject */, + function: 64 /* TypeofEQFunction */ + }); + var typeofNEFacts = ts.createMapFromTemplate({ + string: 256 /* TypeofNEString */, + number: 512 /* TypeofNENumber */, + bigint: 1024 /* TypeofNEBigInt */, + boolean: 2048 /* TypeofNEBoolean */, + symbol: 4096 /* TypeofNESymbol */, + undefined: 524288 /* NEUndefined */, + object: 8192 /* TypeofNEObject */, + function: 16384 /* TypeofNEFunction */ + }); + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; + TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; + TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); + var CheckMode; + (function (CheckMode) { + CheckMode[CheckMode["Normal"] = 0] = "Normal"; + CheckMode[CheckMode["Contextual"] = 1] = "Contextual"; + CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; + CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive"; + CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; + CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; + })(CheckMode || (CheckMode = {})); + var ContextFlags; + (function (ContextFlags) { + ContextFlags[ContextFlags["None"] = 0] = "None"; + ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; + })(ContextFlags || (ContextFlags = {})); + var AccessFlags; + (function (AccessFlags) { + AccessFlags[AccessFlags["None"] = 0] = "None"; + AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; + AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; + AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; + AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; + })(AccessFlags || (AccessFlags = {})); + var CallbackCheck; + (function (CallbackCheck) { + CallbackCheck[CallbackCheck["None"] = 0] = "None"; + CallbackCheck[CallbackCheck["Bivariant"] = 1] = "Bivariant"; + CallbackCheck[CallbackCheck["Strict"] = 2] = "Strict"; + })(CallbackCheck || (CallbackCheck = {})); + var MappedTypeModifiers; + (function (MappedTypeModifiers) { + MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly"; + MappedTypeModifiers[MappedTypeModifiers["ExcludeReadonly"] = 2] = "ExcludeReadonly"; + MappedTypeModifiers[MappedTypeModifiers["IncludeOptional"] = 4] = "IncludeOptional"; + MappedTypeModifiers[MappedTypeModifiers["ExcludeOptional"] = 8] = "ExcludeOptional"; + })(MappedTypeModifiers || (MappedTypeModifiers = {})); + var ExpandingFlags; + (function (ExpandingFlags) { + ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; + ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; + ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; + ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; + })(ExpandingFlags || (ExpandingFlags = {})); + var MembersOrExportsResolutionKind; + (function (MembersOrExportsResolutionKind) { + MembersOrExportsResolutionKind["resolvedExports"] = "resolvedExports"; + MembersOrExportsResolutionKind["resolvedMembers"] = "resolvedMembers"; + })(MembersOrExportsResolutionKind || (MembersOrExportsResolutionKind = {})); + var UnusedKind; + (function (UnusedKind) { + UnusedKind[UnusedKind["Local"] = 0] = "Local"; + UnusedKind[UnusedKind["Parameter"] = 1] = "Parameter"; + })(UnusedKind || (UnusedKind = {})); + var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); + var DeclarationMeaning; + (function (DeclarationMeaning) { + DeclarationMeaning[DeclarationMeaning["GetAccessor"] = 1] = "GetAccessor"; + DeclarationMeaning[DeclarationMeaning["SetAccessor"] = 2] = "SetAccessor"; + DeclarationMeaning[DeclarationMeaning["PropertyAssignment"] = 4] = "PropertyAssignment"; + DeclarationMeaning[DeclarationMeaning["Method"] = 8] = "Method"; + DeclarationMeaning[DeclarationMeaning["GetOrSetAccessor"] = 3] = "GetOrSetAccessor"; + DeclarationMeaning[DeclarationMeaning["PropertyAssignmentOrMethod"] = 12] = "PropertyAssignmentOrMethod"; + })(DeclarationMeaning || (DeclarationMeaning = {})); + var DeclarationSpaces; + (function (DeclarationSpaces) { + DeclarationSpaces[DeclarationSpaces["None"] = 0] = "None"; + DeclarationSpaces[DeclarationSpaces["ExportValue"] = 1] = "ExportValue"; + DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; + DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; + })(DeclarationSpaces || (DeclarationSpaces = {})); function getNodeId(node) { if (!node.id) { node.id = nextNodeId; @@ -31553,11 +32240,9 @@ var ts; var cancellationToken; var requestedExternalEmitHelpers; var externalHelpersModule; - // tslint:disable variable-name var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); - // tslint:enable variable-name var typeCount = 0; var symbolCount = 0; var enumCount = 0; @@ -31831,7 +32516,7 @@ var ts; // Ensure file is type checked checkSourceFile(file); ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); - diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.get(file.fileName)); + diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); if (!file.isDeclarationFile && (!unusedIsError(0 /* Local */) || !unusedIsError(1 /* Parameter */))) { addUnusedDiagnostics(); } @@ -31843,7 +32528,7 @@ var ts; function addUnusedDiagnostics() { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { if (!ts.containsParseError(containingNode) && !unusedIsError(kind)) { - (diagnostics || (diagnostics = [])).push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); } @@ -31872,6 +32557,7 @@ var ts; var literalTypes = ts.createMap(); var indexedAccessTypes = ts.createMap(); var substitutionTypes = ts.createMap(); + var structuralTags = ts.createMap(); var evolvingArrayTypes = []; var undefinedProperties = ts.createMap(); var unknownSymbol = createSymbol(4 /* Property */, "unknown"); @@ -32055,102 +32741,7 @@ var ts; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); - // Suggestion diagnostics must have a file. Keyed by source file name. - var suggestionDiagnostics = ts.createMultiMap(); - var TypeFacts; - (function (TypeFacts) { - TypeFacts[TypeFacts["None"] = 0] = "None"; - TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; - TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; - TypeFacts[TypeFacts["TypeofEQBigInt"] = 4] = "TypeofEQBigInt"; - TypeFacts[TypeFacts["TypeofEQBoolean"] = 8] = "TypeofEQBoolean"; - TypeFacts[TypeFacts["TypeofEQSymbol"] = 16] = "TypeofEQSymbol"; - TypeFacts[TypeFacts["TypeofEQObject"] = 32] = "TypeofEQObject"; - TypeFacts[TypeFacts["TypeofEQFunction"] = 64] = "TypeofEQFunction"; - TypeFacts[TypeFacts["TypeofEQHostObject"] = 128] = "TypeofEQHostObject"; - TypeFacts[TypeFacts["TypeofNEString"] = 256] = "TypeofNEString"; - TypeFacts[TypeFacts["TypeofNENumber"] = 512] = "TypeofNENumber"; - TypeFacts[TypeFacts["TypeofNEBigInt"] = 1024] = "TypeofNEBigInt"; - TypeFacts[TypeFacts["TypeofNEBoolean"] = 2048] = "TypeofNEBoolean"; - TypeFacts[TypeFacts["TypeofNESymbol"] = 4096] = "TypeofNESymbol"; - TypeFacts[TypeFacts["TypeofNEObject"] = 8192] = "TypeofNEObject"; - TypeFacts[TypeFacts["TypeofNEFunction"] = 16384] = "TypeofNEFunction"; - TypeFacts[TypeFacts["TypeofNEHostObject"] = 32768] = "TypeofNEHostObject"; - TypeFacts[TypeFacts["EQUndefined"] = 65536] = "EQUndefined"; - TypeFacts[TypeFacts["EQNull"] = 131072] = "EQNull"; - TypeFacts[TypeFacts["EQUndefinedOrNull"] = 262144] = "EQUndefinedOrNull"; - TypeFacts[TypeFacts["NEUndefined"] = 524288] = "NEUndefined"; - TypeFacts[TypeFacts["NENull"] = 1048576] = "NENull"; - TypeFacts[TypeFacts["NEUndefinedOrNull"] = 2097152] = "NEUndefinedOrNull"; - TypeFacts[TypeFacts["Truthy"] = 4194304] = "Truthy"; - TypeFacts[TypeFacts["Falsy"] = 8388608] = "Falsy"; - TypeFacts[TypeFacts["All"] = 16777215] = "All"; - // The following members encode facts about particular kinds of types for use in the getTypeFacts function. - // The presence of a particular fact means that the given test is true for some (and possibly all) values - // of that kind of type. - TypeFacts[TypeFacts["BaseStringStrictFacts"] = 3735041] = "BaseStringStrictFacts"; - TypeFacts[TypeFacts["BaseStringFacts"] = 12582401] = "BaseStringFacts"; - TypeFacts[TypeFacts["StringStrictFacts"] = 16317953] = "StringStrictFacts"; - TypeFacts[TypeFacts["StringFacts"] = 16776705] = "StringFacts"; - TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 12123649] = "EmptyStringStrictFacts"; - TypeFacts[TypeFacts["EmptyStringFacts"] = 12582401] = "EmptyStringFacts"; - TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 7929345] = "NonEmptyStringStrictFacts"; - TypeFacts[TypeFacts["NonEmptyStringFacts"] = 16776705] = "NonEmptyStringFacts"; - TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 3734786] = "BaseNumberStrictFacts"; - TypeFacts[TypeFacts["BaseNumberFacts"] = 12582146] = "BaseNumberFacts"; - TypeFacts[TypeFacts["NumberStrictFacts"] = 16317698] = "NumberStrictFacts"; - TypeFacts[TypeFacts["NumberFacts"] = 16776450] = "NumberFacts"; - TypeFacts[TypeFacts["ZeroNumberStrictFacts"] = 12123394] = "ZeroNumberStrictFacts"; - TypeFacts[TypeFacts["ZeroNumberFacts"] = 12582146] = "ZeroNumberFacts"; - TypeFacts[TypeFacts["NonZeroNumberStrictFacts"] = 7929090] = "NonZeroNumberStrictFacts"; - TypeFacts[TypeFacts["NonZeroNumberFacts"] = 16776450] = "NonZeroNumberFacts"; - TypeFacts[TypeFacts["BaseBigIntStrictFacts"] = 3734276] = "BaseBigIntStrictFacts"; - TypeFacts[TypeFacts["BaseBigIntFacts"] = 12581636] = "BaseBigIntFacts"; - TypeFacts[TypeFacts["BigIntStrictFacts"] = 16317188] = "BigIntStrictFacts"; - TypeFacts[TypeFacts["BigIntFacts"] = 16775940] = "BigIntFacts"; - TypeFacts[TypeFacts["ZeroBigIntStrictFacts"] = 12122884] = "ZeroBigIntStrictFacts"; - TypeFacts[TypeFacts["ZeroBigIntFacts"] = 12581636] = "ZeroBigIntFacts"; - TypeFacts[TypeFacts["NonZeroBigIntStrictFacts"] = 7928580] = "NonZeroBigIntStrictFacts"; - TypeFacts[TypeFacts["NonZeroBigIntFacts"] = 16775940] = "NonZeroBigIntFacts"; - TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 3733256] = "BaseBooleanStrictFacts"; - TypeFacts[TypeFacts["BaseBooleanFacts"] = 12580616] = "BaseBooleanFacts"; - TypeFacts[TypeFacts["BooleanStrictFacts"] = 16316168] = "BooleanStrictFacts"; - TypeFacts[TypeFacts["BooleanFacts"] = 16774920] = "BooleanFacts"; - TypeFacts[TypeFacts["FalseStrictFacts"] = 12121864] = "FalseStrictFacts"; - TypeFacts[TypeFacts["FalseFacts"] = 12580616] = "FalseFacts"; - TypeFacts[TypeFacts["TrueStrictFacts"] = 7927560] = "TrueStrictFacts"; - TypeFacts[TypeFacts["TrueFacts"] = 16774920] = "TrueFacts"; - TypeFacts[TypeFacts["SymbolStrictFacts"] = 7925520] = "SymbolStrictFacts"; - TypeFacts[TypeFacts["SymbolFacts"] = 16772880] = "SymbolFacts"; - TypeFacts[TypeFacts["ObjectStrictFacts"] = 7888800] = "ObjectStrictFacts"; - TypeFacts[TypeFacts["ObjectFacts"] = 16736160] = "ObjectFacts"; - TypeFacts[TypeFacts["FunctionStrictFacts"] = 7880640] = "FunctionStrictFacts"; - TypeFacts[TypeFacts["FunctionFacts"] = 16728000] = "FunctionFacts"; - TypeFacts[TypeFacts["UndefinedFacts"] = 9830144] = "UndefinedFacts"; - TypeFacts[TypeFacts["NullFacts"] = 9363232] = "NullFacts"; - TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts"; - TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts"; - })(TypeFacts || (TypeFacts = {})); - var typeofEQFacts = ts.createMapFromTemplate({ - string: 1 /* TypeofEQString */, - number: 2 /* TypeofEQNumber */, - bigint: 4 /* TypeofEQBigInt */, - boolean: 8 /* TypeofEQBoolean */, - symbol: 16 /* TypeofEQSymbol */, - undefined: 65536 /* EQUndefined */, - object: 32 /* TypeofEQObject */, - function: 64 /* TypeofEQFunction */ - }); - var typeofNEFacts = ts.createMapFromTemplate({ - string: 256 /* TypeofNEString */, - number: 512 /* TypeofNENumber */, - bigint: 1024 /* TypeofNEBigInt */, - boolean: 2048 /* TypeofNEBoolean */, - symbol: 4096 /* TypeofNESymbol */, - undefined: 524288 /* NEUndefined */, - object: 8192 /* TypeofNEObject */, - function: 16384 /* TypeofNEFunction */ - }); + var suggestionDiagnostics = ts.createDiagnosticCollection(); var typeofTypesByName = ts.createMapFromTemplate({ string: stringType, number: numberType, @@ -32168,71 +32759,8 @@ var ts; var comparableRelation = ts.createMap(); var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); - var TypeSystemPropertyName; - (function (TypeSystemPropertyName) { - TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; - TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; - TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; - TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; - TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; - })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); - var CheckMode; - (function (CheckMode) { - CheckMode[CheckMode["Normal"] = 0] = "Normal"; - CheckMode[CheckMode["Contextual"] = 1] = "Contextual"; - CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; - CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive"; - CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; - CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; - })(CheckMode || (CheckMode = {})); - var ContextFlags; - (function (ContextFlags) { - ContextFlags[ContextFlags["None"] = 0] = "None"; - ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; - })(ContextFlags || (ContextFlags = {})); - var AccessFlags; - (function (AccessFlags) { - AccessFlags[AccessFlags["None"] = 0] = "None"; - AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; - AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; - AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; - AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; - })(AccessFlags || (AccessFlags = {})); - var CallbackCheck; - (function (CallbackCheck) { - CallbackCheck[CallbackCheck["None"] = 0] = "None"; - CallbackCheck[CallbackCheck["Bivariant"] = 1] = "Bivariant"; - CallbackCheck[CallbackCheck["Strict"] = 2] = "Strict"; - })(CallbackCheck || (CallbackCheck = {})); - var MappedTypeModifiers; - (function (MappedTypeModifiers) { - MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly"; - MappedTypeModifiers[MappedTypeModifiers["ExcludeReadonly"] = 2] = "ExcludeReadonly"; - MappedTypeModifiers[MappedTypeModifiers["IncludeOptional"] = 4] = "IncludeOptional"; - MappedTypeModifiers[MappedTypeModifiers["ExcludeOptional"] = 8] = "ExcludeOptional"; - })(MappedTypeModifiers || (MappedTypeModifiers = {})); - var ExpandingFlags; - (function (ExpandingFlags) { - ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; - ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; - ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; - ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; - })(ExpandingFlags || (ExpandingFlags = {})); - var MembersOrExportsResolutionKind; - (function (MembersOrExportsResolutionKind) { - MembersOrExportsResolutionKind["resolvedExports"] = "resolvedExports"; - MembersOrExportsResolutionKind["resolvedMembers"] = "resolvedMembers"; - })(MembersOrExportsResolutionKind || (MembersOrExportsResolutionKind = {})); - var UnusedKind; - (function (UnusedKind) { - UnusedKind[UnusedKind["Local"] = 0] = "Local"; - UnusedKind[UnusedKind["Parameter"] = 1] = "Parameter"; - })(UnusedKind || (UnusedKind = {})); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); - var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; function getJsxNamespace(location) { @@ -32244,7 +32772,7 @@ var ts; } var jsxPragma = file.pragmas.get("jsx"); if (jsxPragma) { - var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; // TODO: GH#18217 + var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; file.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion); if (file.localJsxFactory) { return file.localJsxNamespace = getFirstIdentifier(file.localJsxFactory).escapedText; @@ -32297,11 +32825,11 @@ var ts; diagnostics.add(diagnostic); } else { - suggestionDiagnostics.add(diagnostic.file.fileName, __assign({}, diagnostic, { category: ts.DiagnosticCategory.Suggestion })); + suggestionDiagnostics.add(__assign(__assign({}, diagnostic), { category: ts.DiagnosticCategory.Suggestion })); } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { - addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); + addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { var diagnostic = error(location, message, arg0, arg1, arg2, arg3); @@ -32323,35 +32851,35 @@ var ts; function getExcludedSymbolFlags(flags) { var result = 0; if (flags & 2 /* BlockScopedVariable */) - result |= 67220415 /* BlockScopedVariableExcludes */; + result |= 111551 /* BlockScopedVariableExcludes */; if (flags & 1 /* FunctionScopedVariable */) - result |= 67220414 /* FunctionScopedVariableExcludes */; + result |= 111550 /* FunctionScopedVariableExcludes */; if (flags & 4 /* Property */) result |= 0 /* PropertyExcludes */; if (flags & 8 /* EnumMember */) - result |= 68008959 /* EnumMemberExcludes */; + result |= 900095 /* EnumMemberExcludes */; if (flags & 16 /* Function */) - result |= 67219887 /* FunctionExcludes */; + result |= 110991 /* FunctionExcludes */; if (flags & 32 /* Class */) - result |= 68008383 /* ClassExcludes */; + result |= 899503 /* ClassExcludes */; if (flags & 64 /* Interface */) - result |= 67897736 /* InterfaceExcludes */; + result |= 788872 /* InterfaceExcludes */; if (flags & 256 /* RegularEnum */) - result |= 68008191 /* RegularEnumExcludes */; + result |= 899327 /* RegularEnumExcludes */; if (flags & 128 /* ConstEnum */) - result |= 68008831 /* ConstEnumExcludes */; + result |= 899967 /* ConstEnumExcludes */; if (flags & 512 /* ValueModule */) result |= 110735 /* ValueModuleExcludes */; if (flags & 8192 /* Method */) - result |= 67212223 /* MethodExcludes */; + result |= 103359 /* MethodExcludes */; if (flags & 32768 /* GetAccessor */) - result |= 67154879 /* GetAccessorExcludes */; + result |= 46015 /* GetAccessorExcludes */; if (flags & 65536 /* SetAccessor */) - result |= 67187647 /* SetAccessorExcludes */; + result |= 78783 /* SetAccessorExcludes */; if (flags & 262144 /* TypeParameter */) - result |= 67635688 /* TypeParameterExcludes */; + result |= 526824 /* TypeParameterExcludes */; if (flags & 524288 /* TypeAlias */) - result |= 67897832 /* TypeAliasExcludes */; + result |= 788968 /* TypeAliasExcludes */; if (flags & 2097152 /* Alias */) result |= 2097152 /* AliasExcludes */; return result; @@ -32574,7 +33102,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 286 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -32604,8 +33132,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 67220415 /* Value */); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 67220415 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* Value */); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -32632,17 +33160,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 187 /* BindingElement */) { + if (declaration.kind === 188 /* 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, 187 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 188 /* 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, 238 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 239 /* VariableDeclaration */), usage); } - else if (declaration.kind === 238 /* VariableDeclaration */) { + else if (declaration.kind === 239 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -32665,12 +33193,12 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 258 /* ExportSpecifier */ || (usage.parent.kind === 255 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 259 /* ExportSpecifier */ || (usage.parent.kind === 256 /* 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 === 255 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 256 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -32678,9 +33206,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 220 /* VariableStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 221 /* VariableStatement */: + case 227 /* ForStatement */: + case 229 /* 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, container)) { @@ -32701,16 +33229,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 155 /* PropertyDeclaration */ && + current.parent.kind === 156 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 157 /* MethodDeclaration */) { + if (declaration.kind === 158 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 156 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -32731,14 +33259,14 @@ var ts; return "quit"; } switch (node.kind) { - case 198 /* ArrowFunction */: - case 155 /* PropertyDeclaration */: + case 199 /* ArrowFunction */: + case 156 /* PropertyDeclaration */: return true; - case 219 /* Block */: + case 220 /* Block */: switch (node.parent.kind) { - case 159 /* GetAccessor */: - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 158 /* MethodDeclaration */: + case 161 /* SetAccessor */: return true; default: return false; @@ -32784,12 +33312,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 & 67897832 /* Type */ && lastLocation.kind !== 297 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 299 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 152 /* Parameter */ || - lastLocation.kind === 151 /* TypeParameter */ + lastLocation.kind === 153 /* Parameter */ || + lastLocation.kind === 152 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -32806,13 +33334,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 === 152 /* Parameter */ || + lastLocation.kind === 153 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 176 /* ConditionalType */) { + else if (location.kind === 177 /* 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; @@ -32827,14 +33355,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 286 /* SourceFile */ || ts.isAmbientModule(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 */)) { @@ -32858,7 +33386,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 258 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 259 /* ExportSpecifier */)) { break; } } @@ -32872,12 +33400,12 @@ var ts; } } break; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 155 /* PropertyDeclaration */: + case 156 /* 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 @@ -32887,20 +33415,20 @@ var ts; if (!ts.hasModifier(location, 32 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 67220415 /* Value */)) { + if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) { // Remember the property node, it will be used later to report appropriate error propertyWithInvalidInitializer = location; } } } break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* 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! - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 67897832 /* Type */)) { + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -32915,7 +33443,7 @@ var ts; } break loop; } - if (location.kind === 210 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 211 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -32923,11 +33451,11 @@ var ts; } } break; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. if (lastLocation === location.expression && location.parent.token === 87 /* ExtendsKeyword */) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 67897832 /* Type */))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -32943,34 +33471,34 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 242 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 243 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67897832 /* Type */)) { + 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); return undefined; } } break; - case 198 /* ArrowFunction */: + case 199 /* 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 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -32983,7 +33511,7 @@ var ts; } } break; - case 153 /* Decorator */: + case 154 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -32992,7 +33520,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 === 152 /* Parameter */) { + if (location.parent && location.parent.kind === 153 /* Parameter */) { location = location.parent; } // @@ -33007,24 +33535,25 @@ 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 === 241 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 242 /* ClassDeclaration */)) { location = location.parent; } break; - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; - case 152 /* Parameter */: + case 153 /* Parameter */: if (lastLocation && lastLocation === location.initializer) { associatedDeclarationForContainingInitializer = location; } break; - case 187 /* BindingElement */: + case 188 /* BindingElement */: if (lastLocation && lastLocation === location.initializer) { var root = ts.getRootDeclaration(location); - if (root.kind === 152 /* Parameter */) { + if (root.kind === 153 /* Parameter */) { associatedDeclarationForContainingInitializer = location; } } @@ -33044,7 +33573,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 285 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 286 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -33110,21 +33639,21 @@ var ts; // we want to check for block-scoped if (errorLocation && (meaning & 2 /* BlockScopedVariable */ || - ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 67220415 /* Value */) === 67220415 /* Value */))) { + ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 67220415 /* Value */) === 67220415 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } // If we're in a parameter initializer, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 67220415 /* Value */) === 67220415 /* Value */) { + if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializer); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself @@ -33140,10 +33669,10 @@ var ts; return result; } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 198 /* ArrowFunction */ && location.kind !== 197 /* FunctionExpression */) { + if (location.kind !== 199 /* ArrowFunction */ && location.kind !== 198 /* 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 === 155 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 156 /* PropertyDeclaration */ && !ts.hasModifier(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; @@ -33156,12 +33685,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: // For `namespace N { N; }` + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 246 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -33173,7 +33702,7 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 151 /* TypeParameter */) { + if (decl.kind === 152 /* 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 @@ -33229,9 +33758,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -33241,9 +33770,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 67220415 /* Value */ : 0); + var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* Value */ : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -33262,8 +33791,8 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (67897832 /* Type */ & ~1920 /* Namespace */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~67897832 /* Type */ & 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1920 /* Namespace */)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here, ts.unescapeLeadingUnderscores(name)); return true; @@ -33272,12 +33801,12 @@ var ts; return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 /* Value */ & ~1024 /* NamespaceModule */)) { + if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) { if (name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never") { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 /* Type */ & ~67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { var message = isES2015OrLaterConstructorName(name) ? ts.Diagnostics._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 @@ -33301,15 +33830,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 /* Value */ & ~1024 /* NamespaceModule */ & ~67897832 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */ & ~788968 /* Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (67897832 /* Type */ & ~1024 /* NamespaceModule */ & ~67220415 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~67897832 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + else if (meaning & (788968 /* Type */ & ~1024 /* NamespaceModule */ & ~111551 /* Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~788968 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -33319,10 +33848,14 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { 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 === 244 /* EnumDeclaration */) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 245 /* EnumDeclaration */); }); if (declaration === undefined) - return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); + return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); @@ -33355,13 +33888,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return node; - case 251 /* ImportClause */: + case 252 /* ImportClause */: return node.parent; - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return node.parent.parent; - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -33371,7 +33904,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 261 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -33472,7 +34005,7 @@ var ts; if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (67897832 /* Type */ | 1920 /* Namespace */)) { + if (valueSymbol.flags & (788968 /* Type */ | 1920 /* Namespace */)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -33562,7 +34095,7 @@ var ts; if (ts.isClassExpression(expression)) { return checkExpression(expression).symbol; } - var aliasLike = resolveEntityName(expression, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); + var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } @@ -33572,20 +34105,20 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 258 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 255 /* ExportAssignment */: - case 205 /* BinaryExpression */: + case 259 /* ExportSpecifier */: + return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); + case 256 /* ExportAssignment */: + case 206 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -33596,7 +34129,7 @@ var ts; * OR Is a JSContainer which may merge an alias with a local declaration */ function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */; } + if (excludes === void 0) { excludes = 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */; } if (!symbol) return false; return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* Assignment */); @@ -33630,7 +34163,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 67220415 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); + ((target.flags & 111551 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -33646,17 +34179,15 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 255 /* ExportAssignment */) { - // export default - checkExpressionCached(node.expression); - } - else if (node.kind === 258 /* ExportSpecifier */) { - // export { } or export { as foo } - checkExpressionCached(node.propertyName || node.name); - } - else if (ts.isInternalModuleImportEqualsDeclaration(node)) { - // import foo = - checkExpressionCached(node.moduleReference); + // We defer checking of the reference of an `import =` until the import itself is referenced, + // This way a chain of imports can be elided if ultimately the final input is only used in a type + // position. + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + var target = resolveSymbol(symbol); + if (target === unknownSymbol || target.flags & 111551 /* Value */) { + // import foo = + checkExpressionCached(node.moduleReference); + } } } } @@ -33672,14 +34203,14 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 73 /* Identifier */ || entityName.parent.kind === 149 /* QualifiedName */) { + if (entityName.kind === 73 /* Identifier */ || entityName.parent.kind === 150 /* 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 === 249 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 250 /* ImportEqualsDeclaration */); + return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { @@ -33692,7 +34223,7 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 67220415 /* Value */ : 0); + var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; if (name.kind === 73 /* Identifier */) { var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name)); @@ -33702,9 +34233,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 149 /* QualifiedName */ || name.kind === 190 /* PropertyAccessExpression */) { - var left = name.kind === 149 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 149 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 150 /* QualifiedName */ || name.kind === 191 /* PropertyAccessExpression */) { + var left = name.kind === 150 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 150 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -33795,6 +34326,20 @@ var ts; undefined; return initializer || decl; } + /** + * Get the real symbol of a declaration with an expando initializer. + * + * Normally, declarations have an associated symbol, but when a declaration has an expando + * initializer, the expando's symbol is the one that has all the members merged into it. + */ + function getExpandoSymbol(symbol) { + var decl = symbol.valueDeclaration; + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */) { + return undefined; + } + var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); + return init && getSymbolOfNode(init) || undefined; + } function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0); } @@ -33806,9 +34351,6 @@ var ts; } function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReference === undefined) { - return; - } if (ts.startsWith(moduleReference, "@types/")) { var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1; var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/"); @@ -33937,7 +34479,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 285 /* SourceFile */)) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 286 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -34193,13 +34735,13 @@ var ts; return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? symbol.exportSymbol : symbol); } function symbolIsValue(symbol) { - return !!(symbol.flags & 67220415 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 67220415 /* Value */); + return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 158 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 159 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -34285,12 +34827,12 @@ var ts; } } switch (location.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -34301,7 +34843,7 @@ var ts; } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 67220415 /* Value */ ? 67220415 /* Value */ : 1920 /* Namespace */; + return rightMeaning === 111551 /* Value */ ? 111551 /* Value */ : 1920 /* Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = ts.createMap(); } @@ -34354,7 +34896,7 @@ var ts; && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) // 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, 258 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 259 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -34390,7 +34932,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, 258 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 259 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -34405,10 +34947,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: continue; default: return false; @@ -34419,11 +34961,11 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67897832 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 788968 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); return access.accessibility === 0 /* Accessible */; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67220415 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 111551 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false); return access.accessibility === 0 /* Accessible */; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible) { @@ -34466,7 +35008,7 @@ var ts; // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. var firstDecl = ts.first(symbol.declarations); - if (!ts.length(containers) && meaning & 67220415 /* Value */ && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { + if (!ts.length(containers) && meaning & 111551 /* Value */ && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { if (firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent) && firstDecl === firstDecl.parent.initializer) { containers = [getSymbolOfNode(firstDecl.parent)]; } @@ -34525,10 +35067,10 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 286 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 286 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -34575,21 +35117,21 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 168 /* TypeQuery */ || + if (entityName.parent.kind === 169 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 150 /* ComputedPropertyName */) { + entityName.parent.kind === 151 /* ComputedPropertyName */) { // Typeof value - meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; + meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 149 /* QualifiedName */ || entityName.kind === 190 /* PropertyAccessExpression */ || - entityName.parent.kind === 249 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 150 /* QualifiedName */ || entityName.kind === 191 /* PropertyAccessExpression */ || + entityName.parent.kind === 250 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; } else { // Type Reference or TypeAlias entity = Identifier - meaning = 67897832 /* Type */; + meaning = 788968 /* Type */; } var firstIdentifier = getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); @@ -34631,15 +35173,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 167 /* ConstructorType */ : 166 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 168 /* ConstructorType */ : 167 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 162 /* ConstructSignature */ : 161 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 163 /* ConstructSignature */ : 162 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } @@ -34662,14 +35204,17 @@ var ts; return result; } function getTypeNamesForErrorDisplay(left, right) { - var leftStr = typeToString(left); - var rightStr = typeToString(right); + var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left); + var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right); if (leftStr === rightStr) { leftStr = typeToString(left, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); rightStr = typeToString(right, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); } return [leftStr, rightStr]; } + function symbolValueDeclarationIsContextSensitive(symbol) { + return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0 /* None */; } return flags & 9469291 /* NodeBuilderFlagsMask */; @@ -34761,14 +35306,14 @@ var ts; } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 67897832 /* Type */); + var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */); var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), /*typeArguments*/ undefined)); return enumLiteralName; } if (type.flags & 1056 /* EnumLike */) { - return symbolToTypeNode(type.symbol, context, 67897832 /* Type */); + return symbolToTypeNode(type.symbol, context, 788968 /* Type */); } if (type.flags & 128 /* StringLiteral */) { context.approximateLength += (type.value.length + 2); @@ -34791,7 +35336,7 @@ var ts; if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 67220415 /* Value */); + return symbolToTypeNode(type.symbol, context, 111551 /* Value */); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); @@ -34854,14 +35399,14 @@ var ts; } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. return type.symbol - ? symbolToTypeNode(type.symbol, context, 67897832 /* Type */) + ? symbolToTypeNode(type.symbol, context, 788968 /* Type */) : ts.createTypeReferenceNode(ts.createIdentifier("?"), /*typeArguments*/ undefined); } if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 67897832 /* Type */, typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); } if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; @@ -34870,7 +35415,7 @@ var ts; } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 174 /* UnionType */ : 175 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 175 /* UnionType */ : 176 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -34911,6 +35456,36 @@ var ts; if (type.flags & 33554432 /* Substitution */) { return typeToTypeNodeHelper(type.typeVariable, context); } + if (type.flags & 134217728 /* StructuralTag */) { + var innerType = type.type; + if (innerType.flags & 2097152 /* Intersection */) { + // If some inner type of the intersection has an alias when hoisted out, (attempt to) hoist out all of the aliasable things + if (ts.some(innerType.types, function (t) { return !!getStructuralTagForType(t).aliasSymbol; })) { + var aliasingTypes = []; + var nonAliasingTypes = []; + for (var _i = 0, _a = innerType.types; _i < _a.length; _i++) { + var t = _a[_i]; + var taggedVersion = getStructuralTagForType(t); + if (taggedVersion.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(taggedVersion.aliasSymbol, context.enclosingDeclaration))) { + aliasingTypes.push(taggedVersion); + } + else { + nonAliasingTypes.push(t); + } + } + if (ts.length(aliasingTypes)) { + if (ts.length(nonAliasingTypes)) { + aliasingTypes.push(getStructuralTagForType(getIntersectionType(nonAliasingTypes))); + } + // Do note: this can make an intersection become nested within another intersection - this _is_ handled correctly + // during emit, so is fine (and honestly is more clear, since it groups all the tags together) + return ts.createUnionOrIntersectionTypeNode(176 /* IntersectionType */, ts.map(aliasingTypes, function (t) { return typeToTypeNodeHelper(t, context); })); + } + } + } + context.approximateLength += 4; + return ts.createTypeOperatorNode(148 /* TagKeyword */, typeToTypeNodeHelper(innerType, context)); + } return ts.Debug.fail("Should be unreachable."); function createMappedTypeNodeFromType(type) { ts.Debug.assert(!!(type.flags & 524288 /* Object */)); @@ -34940,21 +35515,21 @@ var ts; id = (isConstructorObject ? "+" : "") + getSymbolId(symbol); if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. - var isInstanceType = type === getInferredClassType(symbol) ? 67897832 /* Type */ : 67220415 /* Value */; + var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 /* Type */ : 111551 /* Value */; 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 === 210 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 211 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { - return symbolToTypeNode(symbol, context, 67220415 /* Value */); + return symbolToTypeNode(symbol, context, 111551 /* Value */); } else if (context.visitedTypes && context.visitedTypes.has(typeId)) { // If type is an anonymous type literal in a type alias declaration, use type alias name var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags - return symbolToTypeNode(typeAlias, context, 67897832 /* Type */); + return symbolToTypeNode(typeAlias, context, 788968 /* Type */); } else { return createElidedInformationPlaceholder(context); @@ -34991,12 +35566,12 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 285 /* SourceFile */ || declaration.parent.kind === 246 /* ModuleBlock */; + return declaration.parent.kind === 286 /* SourceFile */ || declaration.parent.kind === 247 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedTypes && context.visitedTypes.has(typeId))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // TODO: GH#18217 // And the build is going to succeed without visibility error or there is no structural fallback allowed + (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } @@ -35012,12 +35587,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 166 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 167 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 167 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 168 /* ConstructorType */, context); return signatureNode; } } @@ -35087,7 +35662,7 @@ var ts; var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_2 = context.flags; context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var ref = symbolToTypeNode(parent, context, 67897832 /* Type */, typeArgumentSlice); + var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice); context.flags = flags_2; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -35100,7 +35675,7 @@ var ts; } var flags = context.flags; context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var finalRef = symbolToTypeNode(type.symbol, context, 67897832 /* Type */, typeArgumentNodes); + var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* Type */, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -35152,11 +35727,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 161 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 162 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 162 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 163 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; @@ -35217,7 +35792,7 @@ var ts; trackComputedName(decl.name, saveEnclosingDeclaration, context); } } - var propertyName = symbolToName(propertySymbol, context, 67220415 /* Value */, /*expectsIdentifier*/ true); + var propertyName = symbolToName(propertySymbol, context, 111551 /* Value */, /*expectsIdentifier*/ true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(56 /* QuestionToken */) : undefined; @@ -35225,7 +35800,7 @@ var ts; var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 156 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 157 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; if (propertySymbol.valueDeclaration) { @@ -35321,7 +35896,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 158 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 159 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -35365,9 +35940,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 152 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 153 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 306 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 308 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -35377,13 +35952,12 @@ var ts; var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(25 /* DotDotDotToken */) : undefined; - var name = parameterDeclaration - ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 73 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 149 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : - cloneBindingName(parameterDeclaration.name) : - ts.symbolName(parameterSymbol) - : ts.symbolName(parameterSymbol); + var name = parameterDeclaration ? parameterDeclaration.name ? + parameterDeclaration.name.kind === 73 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 150 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + cloneBindingName(parameterDeclaration.name) : + ts.symbolName(parameterSymbol) : + ts.symbolName(parameterSymbol); var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */; var questionToken = isOptional ? ts.createToken(56 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( @@ -35399,7 +35973,7 @@ var ts; } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 187 /* BindingElement */) { + if (clone.kind === 188 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); @@ -35411,9 +35985,9 @@ var ts; return; // get symbol of the first identifier of the entityName var firstIdentifier = getFirstIdentifier(node.expression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 67220415 /* Value */); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { @@ -35530,7 +36104,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 285 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 286 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -35566,7 +36140,7 @@ var ts; // using the `baseUrl` compiler option (which we would otherwise never use in declaration emit) and a non-relative // specifier preference var moduleResolverHost = context.tracker.moduleResolverHost; - var specifierCompilerOptions = isBundle_1 ? __assign({}, compilerOptions, { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; + var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, host.getSourceFiles(), { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative" }, host.redirectTargetsMap)); links.specifierCache = links.specifierCache || ts.createMap(); links.specifierCache.set(contextFile.path, specifier); @@ -35575,7 +36149,7 @@ var ts; } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - var isTypeOf = meaning === 67220415 /* Value */; + var isTypeOf = meaning === 111551 /* Value */; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; @@ -35654,7 +36228,7 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context) { - return !!resolveName(context.enclosingDeclaration, escapedName, 67897832 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + return !!resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); } function typeParameterToName(type, context) { if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { @@ -35663,7 +36237,7 @@ var ts; return cached; } } - var result = symbolToName(type.symbol, context, 67897832 /* Type */, /*expectsIdentifier*/ true); + var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = 0; @@ -35709,9 +36283,6 @@ var ts; function createExpressionFromSymbolChain(chain, index) { var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; - if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { - return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); - } if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; } @@ -35720,6 +36291,9 @@ var ts; context.flags ^= 16777216 /* InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); + if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); + } var canUsePropertyAccess = ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); @@ -35797,8 +36371,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 178 /* ParenthesizedType */; }); - if (node.kind === 243 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 179 /* ParenthesizedType */; }); + if (node.kind === 244 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -35806,11 +36380,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 246 /* ModuleBlock */ && + node.parent.kind === 247 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 286 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -35848,9 +36422,9 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - var name_2 = ts.getNameOfDeclaration(declaration); - if (name_2) { + var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; }); // Try using a declaration with a name, first + var name_2 = declaration && ts.getNameOfDeclaration(declaration); + if (declaration && name_2) { if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } @@ -35863,17 +36437,20 @@ var ts; } return ts.declarationNameToString(name_2); } - if (declaration.parent && declaration.parent.kind === 238 /* VariableDeclaration */) { + if (!declaration) { + declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway + } + if (declaration.parent && declaration.parent.kind === 239 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 211 /* ClassExpression */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 210 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 211 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -35890,27 +36467,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 307 /* 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 187 /* BindingElement */: + case 188 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 238 /* VariableDeclaration */: + case 239 /* 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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 240 /* FunctionDeclaration */: - case 244 /* EnumDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 246 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 241 /* FunctionDeclaration */: + case 245 /* EnumDeclaration */: + case 250 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -35918,53 +36496,54 @@ 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 !== 249 /* ImportEqualsDeclaration */ && parent.kind !== 285 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 250 /* ImportEqualsDeclaration */ && parent.kind !== 286 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.hasModifier(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 158 /* Constructor */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 152 /* Parameter */: - case 246 /* ModuleBlock */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 165 /* TypeReference */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 178 /* ParenthesizedType */: + case 159 /* Constructor */: + case 163 /* ConstructSignature */: + case 162 /* CallSignature */: + case 164 /* IndexSignature */: + case 153 /* Parameter */: + case 247 /* ModuleBlock */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 170 /* TypeLiteral */: + case 166 /* TypeReference */: + case 171 /* ArrayType */: + case 172 /* TupleType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: + case 179 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: + case 252 /* ImportClause */: + case 253 /* NamespaceImport */: + case 255 /* ImportSpecifier */: return false; // Type parameters are always visible - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: // Source file and namespace export are always visible - case 285 /* SourceFile */: - case 248 /* NamespaceExportDeclaration */: + // falls through + case 286 /* SourceFile */: + case 249 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return false; default: return false; @@ -35973,11 +36552,11 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 255 /* ExportAssignment */) { - exportSymbol = resolveName(node, node.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); + if (node.parent && node.parent.kind === 256 /* ExportAssignment */) { + exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 258 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + else if (node.parent.kind === 259 /* ExportSpecifier */) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; if (exportSymbol) { @@ -35998,7 +36577,7 @@ var ts; // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); if (importSymbol) { buildVisibleNodeList(importSymbol.declarations); } @@ -36062,8 +36641,10 @@ var ts; } return ts.Debug.assertNever(propertyName); } - // Pop an entry from the type resolution stack and return its associated result value. The result value will - // be true if no circularities were detected, or false if a circularity was found. + /** + * Pop an entry from the type resolution stack and return its associated result value. The result value will + * be true if no circularities were detected, or false if a circularity was found. + */ function popTypeResolution() { resolutionTargets.pop(); resolutionPropertyNames.pop(); @@ -36072,12 +36653,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 238 /* VariableDeclaration */: - case 239 /* VariableDeclarationList */: - case 254 /* ImportSpecifier */: - case 253 /* NamedImports */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + case 239 /* VariableDeclaration */: + case 240 /* VariableDeclarationList */: + case 255 /* ImportSpecifier */: + case 254 /* NamedImports */: + case 253 /* NamespaceImport */: + case 252 /* ImportClause */: return false; default: return true; @@ -36110,7 +36691,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 150 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 151 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); @@ -36162,7 +36743,7 @@ var ts; if (parentAccess && parentAccess.flowNode) { var propName = getDestructuringPropertyName(node); if (propName) { - var result = ts.createNode(191 /* ElementAccessExpression */, node.pos, node.end); + var result = ts.createNode(192 /* ElementAccessExpression */, node.pos, node.end); result.parent = node; result.expression = parentAccess; var literal = ts.createNode(10 /* StringLiteral */, node.pos, node.end); @@ -36177,23 +36758,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 187 /* BindingElement */: - case 276 /* PropertyAssignment */: + case 188 /* BindingElement */: + case 277 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ancestor.initializer; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 187 /* BindingElement */ && parent.kind === 185 /* ObjectBindingPattern */) { + if (node.kind === 188 /* BindingElement */ && parent.kind === 186 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 276 /* PropertyAssignment */ || node.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.kind === 277 /* PropertyAssignment */ || node.kind === 278 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -36215,7 +36796,7 @@ var ts; parentType = getNonNullableType(parentType); } var type; - if (pattern.kind === 185 /* ObjectBindingPattern */) { + if (pattern.kind === 186 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -36287,26 +36868,26 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 188 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 189 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function isParameterOfContextuallyTypedFunction(node) { - return node.kind === 152 /* Parameter */ && - (node.parent.kind === 197 /* FunctionExpression */ || node.parent.kind === 198 /* ArrowFunction */) && + return node.kind === 153 /* Parameter */ && + (node.parent.kind === 198 /* FunctionExpression */ || node.parent.kind === 199 /* ArrowFunction */) && !!getContextualType(node.parent); } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 227 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 228 /* 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 === 228 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 229 /* 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, @@ -36325,7 +36906,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 238 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 239 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no @@ -36339,11 +36920,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 152 /* Parameter */) { + if (declaration.kind === 153 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 160 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 159 /* GetAccessor */); + if (func.kind === 161 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 160 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -36553,9 +37134,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 === 158 /* Constructor */ || - thisContainer.kind === 240 /* FunctionDeclaration */ || - (thisContainer.kind === 197 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 159 /* Constructor */ || + thisContainer.kind === 241 /* FunctionDeclaration */ || + (thisContainer.kind === 198 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -36630,7 +37211,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 187 /* BindingElement */ && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 188 /* BindingElement */ && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -36653,7 +37234,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 185 /* ObjectBindingPattern */ + return pattern.kind === 186 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -36692,7 +37273,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 152 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 153 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -36754,7 +37335,7 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 255 /* ExportAssignment */) { + if (declaration.kind === 256 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } else if (ts.isInJSFile(declaration) && @@ -36818,7 +37399,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 160 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -36845,8 +37426,8 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 160 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 160 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 161 /* SetAccessor */); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -36876,7 +37457,9 @@ var ts; // Otherwise, fall back to 'any'. else { if (setter) { - errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); + 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 existed getter as we are current checking either setter or getter in this function"); @@ -36889,7 +37472,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 160 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -36905,19 +37488,10 @@ var ts; if (!links.type) { var jsDeclaration = ts.getDeclarationOfExpando(symbol.valueDeclaration); if (jsDeclaration) { - var jsSymbol = getSymbolOfNode(jsDeclaration); - if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { - symbol = cloneSymbol(symbol); + var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration)); + if (merged) { // note:we overwrite links because we just cloned the symbol - links = symbol; - if (ts.hasEntries(jsSymbol.exports)) { - symbol.exports = symbol.exports || ts.createSymbolTable(); - mergeSymbolTable(symbol.exports, jsSymbol.exports); - } - if (ts.hasEntries(jsSymbol.members)) { - symbol.members = symbol.members || ts.createSymbolTable(); - mergeSymbolTable(symbol.members, jsSymbol.members); - } + symbol = links = merged; } } originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol); @@ -36929,8 +37503,8 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 205 /* BinaryExpression */ || - declaration.kind === 190 /* PropertyAccessExpression */ && declaration.parent.kind === 205 /* BinaryExpression */) { + else if (declaration.kind === 206 /* BinaryExpression */ || + declaration.kind === 191 /* PropertyAccessExpression */ && declaration.parent.kind === 206 /* BinaryExpression */) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -36969,7 +37543,7 @@ var ts; // 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 & 67220415 /* Value */ + links.type = targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) : errorType; } @@ -36997,7 +37571,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 152 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 153 /* 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 @@ -37078,39 +37652,50 @@ var ts; function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; // TODO: GH#18217 Use SourceFile kind check instead + if (node && ts.isBinaryExpression(node)) { + // prototype assignments get the outer type parameters of their constructor function + var assignmentKind = ts.getAssignmentDeclarationKind(node); + if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + var symbol = getSymbolOfNode(node.left); + if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { + node = symbol.parent.valueDeclaration; + } + } + } if (!node) { return undefined; } switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 182 /* MappedType */: - case 176 /* ConditionalType */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 157 /* MethodSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 296 /* JSDocFunctionType */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 244 /* TypeAliasDeclaration */: + case 312 /* JSDocTemplateTag */: + case 313 /* JSDocTypedefTag */: + case 307 /* JSDocEnumTag */: + case 306 /* JSDocCallbackTag */: + case 183 /* MappedType */: + case 177 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 182 /* MappedType */) { + if (node.kind === 183 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 176 /* ConditionalType */) { + else if (node.kind === 177 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */ || node.kind === 242 /* InterfaceDeclaration */) && + (node.kind === 242 /* ClassDeclaration */ || node.kind === 211 /* ClassExpression */ || node.kind === 243 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -37118,7 +37703,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 243 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -37127,9 +37712,10 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 241 /* ClassDeclaration */ || - node.kind === 210 /* ClassExpression */ || + if (node.kind === 243 /* InterfaceDeclaration */ || + node.kind === 242 /* ClassDeclaration */ || + node.kind === 211 /* ClassExpression */ || + isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -37160,7 +37746,7 @@ var ts; var constraint = getBaseConstraintOfType(type); return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } - return isJSConstructorType(type); + return false; } function getBaseTypeNodeOfClass(type) { return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); @@ -37255,9 +37841,7 @@ var ts; var baseTypeNode = getBaseTypeNodeOfClass(type); var typeArgs = typeArgumentsFromTypeReferenceNode(baseTypeNode); var baseType; - var originalBaseType = isJSConstructorType(baseConstructorType) ? baseConstructorType : - baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : - undefined; + var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the @@ -37268,9 +37852,6 @@ var ts; else if (baseConstructorType.flags & 1 /* Any */) { baseType = baseConstructorType; } - else if (isJSConstructorType(baseConstructorType)) { - baseType = !baseTypeNode.typeArguments && getJSClassType(baseConstructorType.symbol) || anyType; - } else { // The class derives from a "class-like" constructor function, check that we have at least one construct signature // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere @@ -37323,7 +37904,7 @@ var ts; 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 === 242 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 243 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -37359,7 +37940,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242 /* InterfaceDeclaration */) { + if (declaration.kind === 243 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -37368,7 +37949,7 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 67897832 /* Type */, /*ignoreErrors*/ true); + var baseSymbol = resolveEntityName(node.expression, 788968 /* Type */, /*ignoreErrors*/ true); if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } @@ -37381,9 +37962,15 @@ var ts; } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); + var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; - var type = links.declaredType = createObjectType(kind, symbol); + var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + if (merged) { + // note:we overwrite links because we just cloned the symbol + symbol = links = merged; + } + var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type @@ -37415,9 +38002,10 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return errorType; } - var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 243 /* TypeAliasDeclaration */; - }); + var declaration = ts.find(symbol.declarations, ts.isTypeAlias); + if (!declaration) { + return ts.Debug.fail("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; @@ -37433,7 +38021,7 @@ var ts; } else { type = errorType; - error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + error(ts.isJSDocEnumTag(declaration) ? declaration : declaration.name || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } links.declaredType = type; } @@ -37443,7 +38031,7 @@ var ts; if (expr.kind === 10 /* StringLiteral */) { return true; } - else if (expr.kind === 205 /* BinaryExpression */) { + else if (expr.kind === 206 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -37457,12 +38045,12 @@ var ts; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return true; - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return expr.operator === 39 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; case 73 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -37476,7 +38064,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 245 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && member.initializer.kind === 10 /* StringLiteral */) { @@ -37503,7 +38091,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 245 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -37587,11 +38175,11 @@ var ts; case 142 /* UndefinedKeyword */: case 97 /* NullKeyword */: case 133 /* NeverKeyword */: - case 183 /* LiteralType */: + case 184 /* LiteralType */: return true; - case 170 /* ArrayType */: + case 171 /* ArrayType */: return isThislessType(node.elementType); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -37617,7 +38205,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 158 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 159 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -37633,14 +38221,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -37750,7 +38338,7 @@ var ts; else { symbol.declarations.push(member); } - if (symbolFlags & 67220415 /* Value */) { + if (symbolFlags & 111551 /* Value */) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -38012,7 +38600,7 @@ var ts; var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; // TODO: GH#18217 + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -38056,8 +38644,9 @@ var ts; } var result; for (var i = 0; i < signatureLists.length; i++) { - // Allow matching non-generic signatures to have excess parameters and different return types - var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true); + // Allow matching non-generic signatures to have excess parameters and different return types. + // Prefer matching this types if possible. + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true); if (!match) { return undefined; } @@ -38081,7 +38670,7 @@ var ts; for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { var signature = _a[_i]; // Only process signatures with parameter lists that aren't already in the result list - if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true)) { + if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true)) { var unionSignatures = findMatchingSignatures(signatureLists, signature, i); if (unionSignatures) { var s = signature; @@ -38090,7 +38679,7 @@ var ts; var thisParameter = signature.thisParameter; var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; }); if (firstThisParameterOfUnionSignatures) { - var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType; }), 2 /* Subtype */); + var thisType = getIntersectionType(ts.mapDefined(unionSignatures, function (sig) { return sig.thisParameter && getTypeOfSymbol(sig.thisParameter); })); thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType); } s = createUnionSignature(signature, unionSignatures); @@ -38134,8 +38723,8 @@ var ts; } // 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 - // permissive when calling, for now, we'll union the `this` types just like the overlapping-union-signature check does - var thisType = getUnionType([getTypeOfSymbol(left), getTypeOfSymbol(right)], 2 /* Subtype */); + // permissive when calling, for now, we'll intersect the `this` types just like we do for param types in union signatures. + var thisType = getIntersectionType([getTypeOfSymbol(left), getTypeOfSymbol(right)]); return createSymbolWithType(left, thisType); } function combineUnionParameters(left, right) { @@ -38289,7 +38878,7 @@ var ts; * Converts an AnonymousType to a ResolvedType. */ function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; + var symbol = getMergedSymbol(type.symbol); if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); @@ -38345,14 +38934,18 @@ var ts; // will never be observed because a qualified name can't reference signatures. if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); - type.constructSignatures = ts.filter(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration); }); } // And likewise for construct signatures for classes if (symbol.flags & 32 /* Class */) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)); + var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* Function */) { + constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes) : + undefined; })); + } if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); + constructSignatures = getDefaultConstructSignatures(classType_1); } type.constructSignatures = constructSignatures; } @@ -38495,7 +39088,7 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 180 /* TypeOperator */ && + return constraintDeclaration.kind === 181 /* TypeOperator */ && constraintDeclaration.operator === 130 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { @@ -38509,7 +39102,7 @@ var ts; else { // Otherwise, get the declared constraint type, and if the constraint type is a type parameter, // get the constraint of that type parameter. If the resulting type is an indexed type 'keyof T', - // the modifiers type is T. Otherwise, the modifiers type is {}. + // the modifiers type is T. Otherwise, the modifiers type is unknown. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; @@ -38563,9 +39156,16 @@ var ts; else if (type.flags & 2097152 /* Intersection */) { resolveIntersectionTypeMembers(type); } + else if (type.flags & 134217728 /* StructuralTag */) { + resolveStructuralTagTypeMembers(type); + } } return type; } + function resolveStructuralTagTypeMembers(type) { + // Explicitly do nothing - structured tags, despite "containing structure" (in their argument), do not have any visible structure. + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { if (type.flags & 524288 /* Object */) { @@ -38880,6 +39480,9 @@ var ts; if (t.flags & 33554432 /* Substitution */) { return getBaseConstraint(t.substitute); } + if (t.flags & 134217728 /* StructuralTag */) { + return unknownType; + } return t; } } @@ -39126,7 +39729,7 @@ var ts; return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 137887744 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; } @@ -39140,7 +39743,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 137887744 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* String */ ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -39199,10 +39802,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 === 294 /* JSDocOptionalType */ + node.type && node.type.kind === 295 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 295 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -39236,7 +39839,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 295 /* JSDocOptionalType */; } function createIdentifierTypePredicate(parameterName, parameterIndex, type) { return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -39308,7 +39911,7 @@ var ts; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; // Include parameter symbol instead of property symbol in the signature if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 67220415 /* Value */, undefined, undefined, /*isUse*/ false); + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } if (i === 0 && paramSymbol.escapedName === "this" /* This */) { @@ -39318,7 +39921,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 183 /* LiteralType */) { + if (type && type.kind === 184 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -39332,16 +39935,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 === 159 /* GetAccessor */ || declaration.kind === 160 /* SetAccessor */) && + if ((declaration.kind === 160 /* GetAccessor */ || declaration.kind === 161 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = declaration.kind === 160 /* GetAccessor */ ? 161 /* SetAccessor */ : 160 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 158 /* Constructor */ ? + var classType = declaration.kind === 159 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -39401,11 +40004,11 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return node.name.kind === 150 /* ComputedPropertyName */ + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + return node.name.kind === 151 /* ComputedPropertyName */ && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -39495,7 +40098,6 @@ var ts; var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) : getReturnTypeFromAnnotation(signature.declaration) || - isJSConstructor(signature.declaration) && getJSClassType(getSymbolOfNode(signature.declaration)) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); if (!popTypeResolution()) { if (signature.declaration) { @@ -39521,7 +40123,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 158 /* Constructor */) { + if (declaration.kind === 159 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -39531,12 +40133,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 159 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 160 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 160 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 161 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -39626,7 +40228,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 === 158 /* Constructor */ || kind === 162 /* ConstructSignature */ || kind === 167 /* ConstructorType */; + var isConstructor = kind === 159 /* Constructor */ || kind === 163 /* ConstructSignature */ || kind === 168 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -39667,7 +40269,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 151 /* TypeParameter */); + var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 152 /* TypeParameter */); return decl && ts.getEffectiveConstraintOfTypeParameter(decl); } function getInferredTypeParameterConstraint(typeParameter) { @@ -39675,13 +40277,13 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 177 /* InferType */) { + if (declaration.parent.kind === 178 /* 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 grandParent = declaration.parent.parent; - if (grandParent.kind === 165 /* TypeReference */) { + if (grandParent.kind === 166 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -39706,7 +40308,7 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter // declaration, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 152 /* Parameter */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 153 /* Parameter */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -39730,7 +40332,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 151 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 152 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -39807,13 +40409,13 @@ var ts; var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent); - var diag = minTypeArgumentCount === typeParameters.length - ? missingAugmentsTag - ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : missingAugmentsTag - ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; + var diag = minTypeArgumentCount === typeParameters.length ? + missingAugmentsTag ? + ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + missingAugmentsTag ? + ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { @@ -39852,9 +40454,9 @@ var ts; var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { - error(node, minTypeArgumentCount === typeParameters.length - ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); + error(node, minTypeArgumentCount === typeParameters.length ? + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } return getTypeAliasInstantiation(symbol, typeArguments); @@ -39863,9 +40465,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -39876,34 +40478,23 @@ var ts; } return undefined; } - function resolveTypeReferenceName(typeReferenceName, meaning) { + function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) { if (!typeReferenceName) { return unknownSymbol; } - return resolveEntityName(typeReferenceName, meaning) || unknownSymbol; + return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. if (symbol === unknownSymbol) { return errorType; } - var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); - if (type) { - return type; + symbol = getExpandoSymbol(symbol) || symbol; + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); } - // JS enums are 'string' or 'number', not an enum type. - var enumTag = ts.isInJSFile(node) && symbol.valueDeclaration && ts.getJSDocEnumTag(symbol.valueDeclaration); - if (enumTag) { - var links = getNodeLinks(enumTag); - if (!pushTypeResolution(enumTag, 5 /* EnumTagType */)) { - return errorType; - } - var type_4 = enumTag.typeExpression ? getTypeFromTypeNode(enumTag.typeExpression) : errorType; - if (!popTypeResolution()) { - type_4 = errorType; - error(node, ts.Diagnostics.Enum_type_0_circularly_references_itself, symbolToString(symbol)); - } - return (links.resolvedEnumType = type_4); + if (symbol.flags & 524288 /* TypeAlias */) { + return getTypeFromTypeAliasReference(node, symbol, typeArguments); } // Get type from reference to named type that cannot be generic (enum or type parameter) var res = tryGetDeclaredTypeOfSymbol(symbol); @@ -39912,55 +40503,31 @@ var ts; res.flags & 262144 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } - if (!(symbol.flags & 67220415 /* Value */ && isJSDocTypeReference(node))) { - return errorType; - } - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; + if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + var jsdocType = getTypeFromJSAlias(node, symbol); + if (jsdocType) { + return jsdocType; + } + else { + // Resolve the type reference as a Type for the purpose of reporting errors. + resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */); + return getTypeOfSymbol(symbol); + } } - // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(getTypeReferenceName(node), 67897832 /* Type */); - return getTypeOfSymbol(symbol); + return errorType; } /** - * A jsdoc TypeReference may have resolved to a value (as opposed to a type). If - * the symbol is a constructor function, return the inferred class type; otherwise, - * the type of this reference is just the type of the value we resolved to. + * A JSdoc TypeReference may be to a value imported from commonjs. + * These should really be aliases, but this special-case code fakes alias resolution + * by producing a type from a value. */ - function getJSDocTypeReference(node, symbol, typeArguments) { - // In the case of an assignment of a function expression (binary expressions, variable declarations, etc.), we will get the - // correct instance type for the symbol on the LHS by finding the type for RHS. For example if we want to get the type of the symbol `foo`: - // var foo = function() {} - // We will find the static type of the assigned anonymous function. - var staticType = getTypeOfSymbol(symbol); - var instanceType = staticType.symbol && - staticType.symbol !== symbol && // Make sure this is an assignment like expression by checking that symbol -> type -> symbol doesn't roundtrips. - getTypeReferenceTypeWorker(node, staticType.symbol, typeArguments); // Get the instance type of the RHS symbol. - if (instanceType) { - return getSymbolLinks(symbol).resolvedJSDocType = instanceType; - } - } - function getTypeReferenceTypeWorker(node, symbol, typeArguments) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (symbol.valueDeclaration && symbol.valueDeclaration.parent && ts.isBinaryExpression(symbol.valueDeclaration.parent)) { - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; - } - } - return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); - } - if (symbol.flags & 524288 /* TypeAlias */) { - return getTypeFromTypeAliasReference(node, symbol, typeArguments); - } - if (symbol.flags & 16 /* Function */ && - isJSDocTypeReference(node) && - isJSConstructor(symbol.valueDeclaration)) { - var resolved = resolveStructuredTypeMembers(getTypeOfSymbol(symbol)); - if (resolved.callSignatures.length === 1) { - return getReturnTypeOfSignature(resolved.callSignatures[0]); - } + function getTypeFromJSAlias(node, symbol) { + var valueType = getTypeOfSymbol(symbol); + var typeType = valueType.symbol && + valueType.symbol !== symbol && // Make sure this is a commonjs export by checking that symbol -> type -> symbol doesn't roundtrip. + getTypeReferenceType(node, valueType.symbol); + if (typeType) { + return getSymbolLinks(symbol).resolvedJSDocType = typeType; } } function getSubstitutionType(typeVariable, substitute) { @@ -39979,7 +40546,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 171 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 172 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -39988,9 +40555,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 297 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 299 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 176 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 177 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -40001,7 +40568,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 165 /* TypeReference */ || node.kind === 184 /* ImportType */); + return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 166 /* TypeReference */ || node.kind === 185 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -40038,10 +40605,10 @@ var ts; return globalFunctionType; case "Array": case "array": - return !typeArgs || !typeArgs.length ? anyArrayType : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined; case "Promise": case "promise": - return !typeArgs || !typeArgs.length ? createPromiseType(anyType) : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined; case "Object": if (typeArgs && typeArgs.length === 2) { if (ts.isJSDocIndexSignature(node)) { @@ -40053,7 +40620,7 @@ var ts; return anyType; } checkNoTypeArguments(node); - return anyType; + return !noImplicitAny ? anyType : undefined; } } } @@ -40066,10 +40633,19 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - var meaning = 67897832 /* Type */; + var meaning = 788968 /* Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); - meaning |= 67220415 /* Value */; + if (!type) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, /*ignoreErrors*/ true); + if (symbol === unknownSymbol) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551 /* Value */); + } + else { + resolveTypeReferenceName(getTypeReferenceName(node), meaning); // Resolve again to mark errors, if any + } + type = getTypeReferenceType(node, symbol); + } } if (!type) { symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning); @@ -40102,9 +40678,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: return declaration; } } @@ -40124,10 +40700,10 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67220415 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67897832 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { // Don't track references for global symbols anyway, so value if `isReference` is arbitrary @@ -40196,7 +40772,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 67897832 /* Type */, /*diagnostic*/ undefined); + var symbol = getGlobalSymbol(name, 788968 /* Type */, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -40306,8 +40882,8 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 173 /* RestType */ ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 172 /* OptionalType */ && n !== restElement_1; }) + 1; + var restElement_1 = lastElement && lastElement.kind === 174 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 173 /* OptionalType */ && n !== restElement_1; }) + 1; var elementTypes = ts.map(node.elementTypes, function (n) { var type = getTypeFromTypeNode(n); return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; @@ -40350,7 +40926,7 @@ var ts; // We ignore 'never' types in unions if (!(flags & 131072 /* Never */)) { includes |= flags & 68943871 /* IncludesMask */; - if (flags & 66846720 /* StructuredOrInstantiable */) + if (flags & 201064448 /* StructuredOrInstantiable */) includes |= 262144 /* IncludesStructuredOrInstantiable */; if (type === wildcardType) includes |= 4194304 /* IncludesWildcard */; @@ -40482,7 +41058,7 @@ var ts; neverType; } } - return getUnionTypeFromSortedList(typeSet, includes & 66994211 /* NotPrimitiveUnion */ ? 0 : 131072 /* PrimitiveUnion */, aliasSymbol, aliasTypeArguments); + return getUnionTypeFromSortedList(typeSet, includes & 201211939 /* NotPrimitiveUnion */ ? 0 : 131072 /* PrimitiveUnion */, aliasSymbol, aliasTypeArguments); } function getUnionTypePredicate(signatures) { var first; @@ -40552,10 +41128,10 @@ var ts; } return links.resolvedType; } - function addTypeToIntersection(typeSet, includes, type) { + function addTypeToIntersection(typeSet, includes, type, tagSet) { var flags = type.flags; if (flags & 2097152 /* Intersection */) { - return addTypesToIntersection(typeSet, includes, type.types); + return addTypesToIntersection(typeSet, includes, type.types, tagSet); } if (isEmptyAnonymousObjectType(type)) { if (!(includes & 8388608 /* IncludesEmptyObject */)) { @@ -40568,6 +41144,9 @@ var ts; if (type === wildcardType) includes |= 4194304 /* IncludesWildcard */; } + else if (flags & 134217728 /* StructuralTag */) { + tagSet.set(type.id.toString(), type); + } else if ((strictNullChecks || !(flags & 98304 /* Nullable */)) && !typeSet.has(type.id.toString())) { if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) { // We have seen two distinct unit types which means we should reduce to an @@ -40582,10 +41161,27 @@ var ts; } // Add the given types to the given type set. Order is preserved, freshness is removed from literal // types, duplicates are removed, and nested types of the given kind are flattened into the set. - function addTypesToIntersection(typeSet, includes, types) { + function addTypesToIntersection(typeSet, includes, types, tagSet) { + var isTopLevel = !tagSet; + tagSet = tagSet || ts.createMap(); for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { var type = types_8[_i]; - includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); + includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type), tagSet); + } + if (isTopLevel && tagSet.size) { + var tag = void 0; + if (tagSet.size === 1) { + tag = tagSet.values().next().value; + } + else { + var tagTypes_1 = []; + tagSet.forEach(function (t) { return tagTypes_1.push(t.type); }); + tag = getStructuralTagForType(getIntersectionType(tagTypes_1)); + if (tag.flags & 1048576 /* Union */) { + includes |= 1048576 /* Union */; + } + } + typeSet.set(tag.id.toString(), tag); } return includes; } @@ -40622,6 +41218,15 @@ var ts; } return true; } + function extractIrreducible(types, flag) { + if (ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); })) { + for (var i = 0; i < types.length; i++) { + types[i] = filterType(types[i], function (t) { return !(t.flags & flag); }); + } + return true; + } + return false; + } // If the given list of types contains more than one union of primitive types, replace the // first with a union containing an intersection of those primitive types, then remove the // other unions and return true. Otherwise, do nothing and return false. @@ -40740,6 +41345,12 @@ var ts; // reduced we'll never reduce again, so this occurs at most once. result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } + else if (extractIrreducible(typeSet, 32768 /* Undefined */)) { + result = getUnionType([getIntersectionType(typeSet), undefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + } + else if (extractIrreducible(typeSet, 65536 /* Null */)) { + result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + } else { // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain. @@ -40855,9 +41466,16 @@ var ts; case 134 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; + case 148 /* TagKeyword */: + var aliasSymbol = getAliasSymbolForTypeNode(node); + var aliasParams = getTypeArgumentsForAliasSymbol(aliasSymbol); + links.resolvedType = getStructuralTagForType(getTypeFromTypeNode(node.type), aliasSymbol, aliasParams); + break; + default: + throw ts.Debug.assertNever(node.operator); } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function createIndexedAccessType(objectType, indexType) { var type = createType(8388608 /* IndexedAccess */); @@ -40865,6 +41483,26 @@ var ts; type.indexType = indexType; return type; } + function getStructuralTagForType(type, aliasSymbol, aliasTypeArguments) { + if (typeof aliasSymbol === "number") { + aliasSymbol = undefined; + } + var tid = "" + getTypeId(type); + if (structuralTags.has(tid)) { + return structuralTags.get(tid); + } + if (type.flags & 1048576 /* Union */) { + var union = getUnionType(ts.map(type.types, getStructuralTagForType), 2 /* Subtype */, aliasSymbol, aliasTypeArguments); + structuralTags.set(tid, union); + return union; + } + var tag = createType(134217728 /* StructuralTag */); + tag.type = type; + tag.aliasSymbol = aliasSymbol; + tag.aliasTypeArguments = aliasTypeArguments; + structuralTags.set(tid, tag); + return tag; + } /** * Returns if a type is or consists of a JSLiteral object type * In addition to objects which are directly literals, @@ -40893,7 +41531,7 @@ var ts; return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 192 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -40904,7 +41542,7 @@ var ts; undefined; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 192 /* ElementAccessExpression */ ? accessNode : undefined; var propName = getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); @@ -41041,13 +41679,10 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 191 /* ElementAccessExpression */ - ? accessNode.argumentExpression - : accessNode.kind === 181 /* IndexedAccessType */ - ? accessNode.indexType - : accessNode.kind === 150 /* ComputedPropertyName */ - ? accessNode.expression - : accessNode; + return accessNode.kind === 192 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 182 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 151 /* ComputedPropertyName */ ? accessNode.expression : + accessNode; } function isGenericObjectType(type) { return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 131072 /* GenericMappedType */); @@ -41172,7 +41807,7 @@ var ts; // object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in // an expression. This is to preserve backwards compatibility. For example, an element access 'this["foo"]' // has always been resolved eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 181 /* IndexedAccessType */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 182 /* IndexedAccessType */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -41384,7 +42019,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 67220415 /* Value */ : node.flags & 2097152 /* JSDoc */ ? 67220415 /* Value */ | 67897832 /* Type */ : 67897832 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 2097152 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { @@ -41407,14 +42042,14 @@ var ts; getNodeLinks(current.parent).resolvedSymbol = next; currentNamespace = next; } - resolveImportSymbolType(node, links, currentNamespace, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning); } else { if (moduleSymbol.flags & targetMeaning) { - resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 67220415 /* Value */ + var errorMessage = targetMeaning === 111551 /* Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -41423,16 +42058,16 @@ var ts; } } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 67220415 /* Value */) { - return links.resolvedType = getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias + if (meaning === 111551 /* Value */) { + return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { - return links.resolvedType = getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol + return getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol } } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { @@ -41456,7 +42091,11 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined; + var host = node.parent; + while (ts.isParenthesizedTypeNode(host)) { + host = host.parent; + } + return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; } function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; @@ -41645,12 +42284,26 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 242 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 243 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 158 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } + // inside x.prototype = { ... } + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; + } + // /** @return {this} */ + // x.prototype.m = function() { ... } + var host = node.flags & 2097152 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; + } + // inside constructor function C() { ... } + if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType; + } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); return errorType; } @@ -41664,8 +42317,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 121 /* AnyKeyword */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 291 /* JSDocAllType */: + case 292 /* JSDocUnknownType */: return anyType; case 144 /* UnknownKeyword */: return unknownType; @@ -41689,63 +42342,63 @@ var ts; return neverType; case 137 /* ObjectKeyword */: return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 179 /* ThisType */: + case 180 /* ThisType */: case 101 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 183 /* LiteralType */: + case 184 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return getTypeFromTypeReference(node); - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return booleanType; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 171 /* TupleType */: + case 172 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 172 /* OptionalType */: + case 173 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 174 /* UnionType */: + case 175 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 175 /* IntersectionType */: + case 176 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 292 /* JSDocNullableType */: + case 293 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 294 /* JSDocOptionalType */: + case 295 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 178 /* ParenthesizedType */: - case 173 /* RestType */: - case 293 /* JSDocNonNullableType */: - case 289 /* JSDocTypeExpression */: + case 179 /* ParenthesizedType */: + case 174 /* RestType */: + case 294 /* JSDocNonNullableType */: + case 290 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 296 /* JSDocVariadicType */: + case 297 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 295 /* JSDocFunctionType */: - case 299 /* JSDocSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 170 /* TypeLiteral */: + case 300 /* JSDocTypeLiteral */: + case 296 /* JSDocFunctionType */: + case 301 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 182 /* MappedType */: + case 183 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 177 /* InferType */: + case 178 /* InferType */: return getTypeFromInferTypeNode(node); - case 184 /* ImportType */: + case 185 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -41874,7 +42527,7 @@ var ts; } function instantiateSymbol(symbol, mapper) { var links = getSymbolLinks(symbol); - if (links.type && !maybeTypeOfKind(links.type, 524288 /* Object */ | 63176704 /* Instantiable */)) { + if (links.type && !maybeTypeOfKind(links.type, 524288 /* Object */ | 63176704 /* Instantiable */ | 134217728 /* StructuralTag */)) { // If the type of the symbol is already resolved, and if that type could not possibly // be affected by instantiation, simply return the symbol itself. return symbol; @@ -41954,8 +42607,9 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 149 /* QualifiedName */ || - node.parent.kind === 165 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 150 /* QualifiedName */ || + node.parent.kind === 166 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 185 /* 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 @@ -41964,7 +42618,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 219 /* Block */ || n.kind === 176 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 220 /* Block */ || n.kind === 177 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -41973,12 +42627,12 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 179 /* ThisType */: + case 180 /* ThisType */: return !!tp.isThisType; case 73 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return true; } return !!ts.forEachChild(node, containsReference); @@ -42172,6 +42826,10 @@ var ts; return sub; } } + if (flags & 134217728 /* StructuralTag */) { + var newType = instantiateType(type.type, mapper); + return newType !== type ? getStructuralTagForType(newType, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; + } return type; } function getPermissiveInstantiation(type) { @@ -42200,35 +42858,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 !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return node.operatorToken.kind === 55 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 268 /* JsxAttribute */: { + case 269 /* 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 271 /* JsxExpression */: { + case 272 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -42248,7 +42906,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 198 /* ArrowFunction */) { + if (node.kind !== 199 /* 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); @@ -42260,7 +42918,7 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !!node.body && node.body.kind !== 219 /* Block */ && isContextSensitive(node.body); + return !!node.body && node.body.kind !== 220 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -42363,23 +43021,23 @@ var ts; return true; } switch (node.kind) { - case 271 /* JsxExpression */: - case 196 /* ParenthesizedExpression */: + case 272 /* JsxExpression */: + case 197 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (node.operatorToken.kind) { case 60 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -42551,7 +43209,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -42560,9 +43218,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 266 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -42636,7 +43294,7 @@ var ts; var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName); var childrenTargetType = getIndexedAccessType(target, getLiteralType(childrenPropName)); var diagnostic = ts.Diagnostics._0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2; - invalidTextDiagnostic = __assign({}, diagnostic, { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); + invalidTextDiagnostic = __assign(__assign({}, diagnostic), { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); } return invalidTextDiagnostic; } @@ -42704,11 +43362,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 160 /* SetAccessor */: return [3 /*break*/, 2]; - case 159 /* GetAccessor */: return [3 /*break*/, 2]; - case 157 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 277 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 276 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 161 /* SetAccessor */: return [3 /*break*/, 2]; + case 160 /* GetAccessor */: return [3 /*break*/, 2]; + case 158 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 278 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 277 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -42780,8 +43438,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 157 /* MethodDeclaration */ && - kind !== 156 /* MethodSignature */ && kind !== 158 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 158 /* MethodDeclaration */ && + kind !== 157 /* MethodSignature */ && kind !== 159 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -42829,15 +43487,17 @@ var ts; result &= related; } if (!ignoreReturnTypes) { - // If a signature reolution is already in-flight, skip issuing a circularity error + // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly - var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType : (target.declaration && isJSConstructor(target.declaration)) ? - getJSClassType(target.declaration.symbol) : getReturnTypeOfSignature(target); + var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType + : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(target.declaration.symbol) + : getReturnTypeOfSignature(target); if (targetReturnType === voidType) { return result; } - var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType : (source.declaration && isJSConstructor(source.declaration)) ? - getJSClassType(source.declaration.symbol) : getReturnTypeOfSignature(source); + var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType + : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(source.declaration.symbol) + : getReturnTypeOfSignature(source); // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions var targetTypePredicate = getTypePredicateOfSignature(target); if (targetTypePredicate) { @@ -43023,7 +43683,7 @@ var ts; return related === 1 /* Succeeded */; } } - if (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */) { + if (source.flags & 201064448 /* StructuredOrInstantiable */ || target.flags & 201064448 /* StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; @@ -43084,7 +43744,7 @@ var ts; } var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); if (relatedInfo) { - ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInfo)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInfo)); } if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -43129,8 +43789,8 @@ var ts; reportError(message, sourceType, targetType); } function tryElaborateErrorsForPrimitivesAndObjects(source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); + var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source); + var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target); if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || @@ -43223,7 +43883,7 @@ var ts; isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); - var isPerformingExcessPropertyChecks = (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); + var isPerformingExcessPropertyChecks = !isApparentIntersectionConstituent && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); if (isPerformingExcessPropertyChecks) { var discriminantType = target.flags & 1048576 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { @@ -43233,11 +43893,11 @@ var ts; return 0 /* False */; } } - if (relation !== comparableRelation && !isApparentIntersectionConstituent && + var isPerformingCommonPropertyChecks = relation !== comparableRelation && !isApparentIntersectionConstituent && source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType && target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) && - (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)) && - !hasCommonProperties(source, target, isComparingJsxAttributes)) { + (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); + if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var calls = getSignaturesOfType(source, 0 /* Call */); var constructs = getSignaturesOfType(source, 1 /* Construct */); @@ -43259,16 +43919,16 @@ var ts; // and we need to handle "each" relations before "some" relations for the same kind of type. if (source.flags & 1048576 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)) : + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), isIntersectionConstituent) : eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)); } else { if (target.flags & 1048576 /* Union */) { result = typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { // Validate against excess props using the original `source` var discriminantType = findMatchingDiscriminantType(source, target) || filterPrimitivesIfContainsNonPrimitive(target); - if (!propertiesRelatedTo(source, discriminantType, reportErrors, /*excludedProperties*/ undefined)) { + if (!propertiesRelatedTo(source, discriminantType, reportErrors, /*excludedProperties*/ undefined, isIntersectionConstituent)) { return 0 /* False */; } } @@ -43276,9 +43936,9 @@ var ts; else if (target.flags & 2097152 /* Intersection */) { isIntersectionConstituent = true; // set here to affect the following trio of checks result = typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { // Validate against excess props using the original `source` - if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined)) { + if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, /*isIntersectionConstituent*/ false)) { return 0 /* False */; } } @@ -43297,9 +43957,9 @@ var ts; // // - For a primitive type or type parameter (such as 'number = A & B') there is no point in // breaking the intersection apart. - result = someTypeRelatedToType(source, target, /*reportErrors*/ false); + result = someTypeRelatedToType(source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ true); } - if (!result && (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */)) { + if (!result && (source.flags & 201064448 /* StructuredOrInstantiable */ || target.flags & 201064448 /* StructuredOrInstantiable */)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { errorInfo = saveErrorInfo; } @@ -43566,14 +44226,14 @@ var ts; } return result; } - function someTypeRelatedToType(source, target, reportErrors) { + function someTypeRelatedToType(source, target, reportErrors, isIntersectionConstituent) { var sourceTypes = source.types; if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, isIntersectionConstituent); if (related) { return related; } @@ -43593,7 +44253,7 @@ var ts; } return result; } - function typeArgumentsRelatedTo(sources, targets, variances, reportErrors) { + function typeArgumentsRelatedTo(sources, targets, variances, reportErrors, isIntersectionConstituent) { if (sources === void 0) { sources = ts.emptyArray; } if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } @@ -43620,10 +44280,10 @@ var ts; related = relation === identityRelation ? isRelatedTo(s, t, /*reportErrors*/ false) : compareTypesIdentical(s, t); } else if (variance === 1 /* Covariant */) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } else if (variance === 2 /* Contravariant */) { - related = isRelatedTo(t, s, reportErrors); + related = isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } else if (variance === 3 /* Bivariant */) { // In the bivariant case we first compare contravariantly without reporting @@ -43632,16 +44292,16 @@ var ts; // which is generally easier to reason about. related = isRelatedTo(t, s, /*reportErrors*/ false); if (!related) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } else { // In the invariant case we first compare covariantly, and only when that // succeeds do we proceed to compare contravariantly. Thus, error elaboration // will typically be based on the covariant check. - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); if (related) { - related &= isRelatedTo(t, s, reportErrors); + related &= isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } if (!related) { @@ -43771,6 +44431,9 @@ var ts; if (flags & 33554432 /* Substitution */) { return isRelatedTo(source.substitute, target.substitute, /*reportErrors*/ false); } + if (flags & 134217728 /* StructuralTag */) { + return isRelatedTo(source.type, target.type, /*reportErrors*/ false); + } return 0 /* False */; } var result; @@ -43784,7 +44447,7 @@ var ts; source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) { var variances = getAliasVariances(source.aliasSymbol); - var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances); + var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -43870,6 +44533,12 @@ var ts; } } } + else if (target.flags & 134217728 /* StructuralTag */) { + if (source.flags & 134217728 /* StructuralTag */) { + return isRelatedTo(source.type, target.type, reportErrors); + } + return 0 /* False */; + } 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. @@ -43913,9 +44582,19 @@ var ts; // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. - if (isTypeIdenticalTo(source.extendsType, target.extendsType) && + var sourceParams = source.root.inferTypeParameters; + var sourceExtends = source.extendsType; + var mapper = void 0; + if (sourceParams) { + // If the source has infer type parameters, we instantiate them in the context of the target + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedTo); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 64 /* NoConstraints */ | 128 /* AlwaysStrict */); + sourceExtends = instantiateType(sourceExtends, ctx.mapper); + mapper = ctx.mapper; + } + if (isTypeIdenticalTo(sourceExtends, target.extendsType) && (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { - if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } if (result) { @@ -43968,7 +44647,7 @@ var ts; // type references (which are intended by be compared structurally). Obtain the variance // information for the type parameters and relate the type arguments accordingly. var variances = getVariances(source.target); - var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances); + var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -43996,7 +44675,7 @@ var ts; if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 524288 /* Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; - result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined); + result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, isIntersectionConstituent); if (result) { result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); if (result) { @@ -44031,8 +44710,8 @@ var ts; } } return 0 /* False */; - function relateVariances(sourceTypeArguments, targetTypeArguments, variances) { - if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors)) { + function relateVariances(sourceTypeArguments, targetTypeArguments, variances, isIntersectionConstituent) { + if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, isIntersectionConstituent)) { return result; } if (ts.some(variances, function (v) { return !!(v & 24 /* AllowsStructuralFallback */); })) { @@ -44157,7 +44836,7 @@ var ts; if (sourceProperty === targetProperty) return "continue"; // We compare the source property to the target in the context of a single discriminant type. - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, /*isIntersectionConstituent*/ false); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -44187,7 +44866,7 @@ var ts; var result = -1 /* True */; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties); + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, /*isIntersectionConstituent*/ false); if (result) { result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false); if (result) { @@ -44222,7 +44901,7 @@ var ts; } return result || properties; } - function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); var source = getTypeOfSourceProperty(sourceProp); if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { @@ -44262,10 +44941,10 @@ var ts; return result_7; } else { - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } - function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { @@ -44303,7 +44982,7 @@ var ts; return 0 /* False */; } // If the target comes from a partial union prop, allow `undefined` in the target type - var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors); + var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); @@ -44326,7 +45005,7 @@ var ts; } return related; } - function propertiesRelatedTo(source, target, reportErrors, excludedProperties) { + function propertiesRelatedTo(source, target, reportErrors, excludedProperties, isIntersectionConstituent) { if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } @@ -44342,7 +45021,7 @@ var ts; } if (props.length === 1) { var propName = symbolToString(unmatchedProperty); - reportError.apply(void 0, [ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName].concat(getTypeNamesForErrorDisplay(source, target))); + reportError.apply(void 0, __spreadArrays([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target))); if (ts.length(unmatchedProperty.declarations)) { associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); } @@ -44415,7 +45094,7 @@ var ts; if (!(targetProp.flags & 4194304 /* Prototype */)) { var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp && sourceProp !== targetProp) { - var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors); + var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, isIntersectionConstituent); if (!related) { return 0 /* False */; } @@ -44594,7 +45273,7 @@ var ts; if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U } // if T is related to U. - return (kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); // TODO: GH#18217 + return kind === 0 /* String */ ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) : 0 /* False */; } if (isObjectTypeWithInferableIndex(source)) { var related = -1 /* True */; @@ -44650,23 +45329,27 @@ var ts; } } function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue) { - var match; + // undefined=unknown, true=discriminated, false=not discriminated + // The state of each type progresses from left to right. Discriminated types stop at 'true'. + var discriminable = target.types.map(function (_) { return undefined; }); for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; + var i = 0; for (var _b = 0, _c = target.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, propertyName); if (targetType && related(getDiscriminatingType(), targetType)) { - if (match) { - if (type === match) - continue; // Finding multiple fields which discriminate to the same type is fine - return defaultValue; - } - match = type; + discriminable[i] = discriminable[i] === undefined ? true : discriminable[i]; + } + else { + discriminable[i] = false; } + i++; } } - return match || defaultValue; + var match = discriminable.indexOf(/*searchElement*/ true); + // make sure exactly 1 matches before returning it + return match === -1 || discriminable.indexOf(/*searchElement*/ true, match + 1) !== -1 ? defaultValue : target.types[match]; } /** * A type is 'weak' if it is an object type with at least one optional property @@ -44869,6 +45552,9 @@ var ts; // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least 5 // levels, but unequal at some level beyond that. + // In addition, this will also detect when an indexed access has been chained off of 5 or more times (which is essentially + // the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding false positives + // for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`). function isDeeplyNestedType(type, stack, depth) { // We track all object types that have an associated symbol (representing the origin of the type) if (depth >= 5 && type.flags & 524288 /* Object */) { @@ -44885,8 +45571,30 @@ var ts; } } } + if (depth >= 5 && type.flags & 8388608 /* IndexedAccess */) { + var root = getRootObjectTypeFromIndexedAccessChain(type); + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (getRootObjectTypeFromIndexedAccessChain(t) === root) { + count++; + if (count >= 5) + return true; + } + } + } return false; } + /** + * Gets the leftmost object type in a chain of indexed accesses, eg, in A[P][Q], returns A + */ + function getRootObjectTypeFromIndexedAccessChain(type) { + var t = type; + while (t.flags & 8388608 /* IndexedAccess */) { + t = t.objectType; + } + return t; + } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; } @@ -45248,8 +45956,8 @@ var ts; * with no call or construct signatures. */ function isObjectTypeWithInferableIndex(type) { - return type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && - !typeHasCallOrConstructSignatures(type); + return !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); @@ -45468,17 +46176,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 205 /* BinaryExpression */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 206 /* BinaryExpression */: + case 156 /* PropertyDeclaration */: + case 155 /* 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 152 /* Parameter */: + case 153 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 67897832 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || + (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, ts.declarationNameToString(param.name)); @@ -45488,23 +46196,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 187 /* BindingElement */: + case 188 /* 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 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 1 /* 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); @@ -45518,7 +46226,7 @@ var ts; wideningKind === 1 /* 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 182 /* MappedType */: + case 183 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -45639,10 +46347,11 @@ var ts; function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); return !!(type.flags & 63176704 /* Instantiable */ || + type.flags & 134217728 /* StructuralTag */ && couldContainTypeVariables(type.type) || objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, 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 */ || - type.flags & 3145728 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { @@ -45797,8 +46506,7 @@ var ts; var visited; var bivariant = false; var propagationType; - var inferenceCount = 0; - var inferenceIncomplete = false; + var inferencePriority = 256 /* MaxValue */; var allowComplexConstraintInference = true; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { @@ -45821,50 +46529,57 @@ var ts; inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); return; } - if (source.flags & 1048576 /* Union */ && target.flags & 1048576 /* Union */ && !(source.flags & 1024 /* EnumLiteral */ && target.flags & 1024 /* EnumLiteral */) || - source.flags & 2097152 /* Intersection */ && target.flags & 2097152 /* Intersection */) { - // Source and target are both unions or both intersections. If source and target - // are the same type, just relate each constituent type to itself. - if (source === target) { - for (var _i = 0, _a = source.types; _i < _a.length; _i++) { - var t = _a[_i]; - inferFromTypes(t, t); - } - return; - } - // Find each source constituent type that has an identically matching target constituent - // type, and for each such type infer from the type to itself. When inferring from a - // type to itself we effectively find all type parameter occurrences within that type - // and infer themselves as their type arguments. We have special handling for numeric - // and string literals because the number and string types are not represented as unions - // of all their possible values. - var matchingTypes = void 0; - for (var _b = 0, _c = source.types; _b < _c.length; _b++) { - var t = _c[_b]; - var matched = findMatchedType(t, target); - if (matched) { - (matchingTypes || (matchingTypes = [])).push(matched); - inferFromTypes(matched, matched); - } - } - // Next, to improve the quality of inferences, reduce the source and target types by - // removing the identically matched constituents. For example, when inferring from - // 'string | string[]' to 'string | T' we reduce the types to 'string[]' and 'T'. - if (matchingTypes) { - var s = removeTypesFromUnionOrIntersection(source, matchingTypes); - var t = removeTypesFromUnionOrIntersection(target, matchingTypes); - if (!(s && t)) - return; - source = s; - target = t; + if (source === target && source.flags & 3145728 /* UnionOrIntersection */) { + // When source and target are the same union or intersection type, just relate each constituent + // type to itself. + for (var _i = 0, _a = source.types; _i < _a.length; _i++) { + var t = _a[_i]; + inferFromTypes(t, t); } + return; } - else if (target.flags & 1048576 /* Union */ && !(target.flags & 1024 /* EnumLiteral */) || target.flags & 2097152 /* Intersection */) { - var matched = findMatchedType(source, target); - if (matched) { - inferFromTypes(matched, matched); + if (target.flags & 1048576 /* Union */) { + // First, infer between identically matching source and target constituents and remove the + // matching types. + var _b = inferFromMatchingTypes(source.flags & 1048576 /* Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + // Next, infer between closely matching source and target constituents and remove + // the matching types. Types closely match when they are instantiations of the same + // object type or instantiations of the same type alias. + var _c = inferFromMatchingTypes(tempSources, tempTargets, isTypeCloselyMatchedBy), sources = _c[0], targets = _c[1]; + if (targets.length === 0) { return; } + target = getUnionType(targets); + if (sources.length === 0) { + // All source constituents have been matched and there is nothing further to infer from. + // However, simply making no inferences is undesirable because it could ultimately mean + // inferring a type parameter constraint. Instead, make a lower priority inference from + // the full source to whatever remains in the target. For example, when inferring from + // string to 'string | T', make a lower priority inference of string for T. + var savePriority = priority; + priority |= 1 /* NakedTypeVariable */; + inferFromTypes(source, target); + priority = savePriority; + return; + } + source = getUnionType(sources); + } + else if (target.flags & 2097152 /* Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + // We reduce intersection types only when they contain naked type parameters. For example, when + // inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and + // infer { extra: any } for T. But when inferring to 'string[] & Iterable' we want to keep the + // string[] on the source side and infer string for T. + // Likewise, we consider a homomorphic mapped type constrainted to the target type parameter as similar to a "naked type variable" + // in such scenarios. + if (!(source.flags & 1048576 /* Union */)) { + // Infer between identically matching source and target constituents and remove the matching types. + var _d = inferFromMatchingTypes(source.flags & 2097152 /* Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + if (sources.length === 0 || targets.length === 0) { + return; + } + source = getIntersectionType(sources); + target = getIntersectionType(targets); + } } else if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) { target = getActualTypeVariable(target); @@ -45909,7 +46624,7 @@ var ts; clearCachedInferences(inferences); } } - inferenceCount++; + inferencePriority = Math.min(inferencePriority, priority); return; } else { @@ -45940,6 +46655,9 @@ var ts; inferFromTypes(source.type, target.type); contravariant = !contravariant; } + else if (source.flags & 134217728 /* StructuralTag */ && target.flags & 134217728 /* StructuralTag */) { + inferFromTypes(source.type, target.type); + } else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; @@ -45966,11 +46684,17 @@ var ts; else if (target.flags & 3145728 /* UnionOrIntersection */) { inferToMultipleTypes(source, target.types, target.flags); } + else if (target.flags & 134217728 /* StructuralTag */ && source.flags & 2097152 /* Intersection */) { + var tagsOnly = getIntersectionType(ts.filter(source.types, function (t) { return !!(t.flags & 134217728 /* StructuralTag */); })); + if (tagsOnly !== source) { + inferFromTypes(tagsOnly, target); + } + } else if (source.flags & 1048576 /* Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; - for (var _d = 0, sourceTypes_3 = sourceTypes; _d < sourceTypes_3.length; _d++) { - var sourceType = sourceTypes_3[_d]; + for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { + var sourceType = sourceTypes_3[_e]; inferFromTypes(sourceType, target); } } @@ -46000,15 +46724,36 @@ var ts; } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; - var count = visited && visited.get(key); - if (count !== undefined) { - inferenceCount += count; + var status = visited && visited.get(key); + if (status !== undefined) { + inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = ts.createMap())).set(key, 0); - var startCount = inferenceCount; + (visited || (visited = ts.createMap())).set(key, -1 /* Circularity */); + var saveInferencePriority = inferencePriority; + inferencePriority = 256 /* MaxValue */; action(source, target); - visited.set(key, inferenceCount - startCount); + visited.set(key, inferencePriority); + inferencePriority = Math.min(inferencePriority, saveInferencePriority); + } + function inferFromMatchingTypes(sources, targets, matches) { + var matchedSources; + var matchedTargets; + for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { + var t = targets_1[_i]; + for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) { + var s = sources_1[_a]; + if (matches(s, t)) { + inferFromTypes(s, t); + matchedSources = ts.appendIfUnique(matchedSources, s); + matchedTargets = ts.appendIfUnique(matchedTargets, t); + } + } + } + return [ + matchedSources ? ts.filter(sources, function (t) { return !ts.contains(matchedSources, t); }) : sources, + matchedTargets ? ts.filter(targets, function (t) { return !ts.contains(matchedTargets, t); }) : targets, + ]; } function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; @@ -46048,31 +46793,34 @@ var ts; var nakedTypeVariable = void 0; var sources = source.flags & 1048576 /* Union */ ? source.types : [source]; var matched_1 = new Array(sources.length); - var saveInferenceIncomplete = inferenceIncomplete; - inferenceIncomplete = false; + var inferenceCircularity = false; // First infer to types that are not naked type variables. For each source type we - // track whether inferences were made from that particular type to some target. - for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { - var t = targets_1[_i]; + // track whether inferences were made from that particular type to some target with + // equal priority (i.e. of equal quality) to what we would infer for a naked type + // parameter. + for (var _i = 0, targets_2 = targets; _i < targets_2.length; _i++) { + var t = targets_2[_i]; if (getInferenceInfoForType(t)) { nakedTypeVariable = t; typeVariableCount++; } else { for (var i = 0; i < sources.length; i++) { - var count = inferenceCount; + var saveInferencePriority = inferencePriority; + inferencePriority = 256 /* MaxValue */; inferFromTypes(sources[i], t); - if (count !== inferenceCount) + if (inferencePriority === priority) matched_1[i] = true; + inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* Circularity */; + inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } } - var inferenceComplete = !inferenceIncomplete; - inferenceIncomplete = inferenceIncomplete || saveInferenceIncomplete; - // If the target has a single naked type variable and inference completed (meaning we - // explored the types fully), create a union of the source types from which no inferences - // have been made so far and infer from that union to the naked type variable. - if (typeVariableCount === 1 && inferenceComplete) { + // If the target has a single naked type variable and no inference circularities were + // encountered above (meaning we explored the types fully), create a union of the source + // types from which no inferences have been made so far and infer from that union to the + // naked type variable. + if (typeVariableCount === 1 && !inferenceCircularity) { var unmatched = ts.flatMap(sources, function (s, i) { return matched_1[i] ? undefined : s; }); if (unmatched.length) { inferFromTypes(getUnionType(unmatched), nakedTypeVariable); @@ -46084,8 +46832,8 @@ var ts; // We infer from types that are not naked type variables first so that inferences we // make from nested naked type variables and given slightly higher priority by virtue // of being first in the candidates array. - for (var _a = 0, targets_2 = targets; _a < targets_2.length; _a++) { - var t = targets_2[_a]; + for (var _a = 0, targets_3 = targets; _a < targets_3.length; _a++) { + var t = targets_3[_a]; if (getInferenceInfoForType(t)) { typeVariableCount++; } @@ -46101,8 +46849,8 @@ var ts; if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { var savePriority = priority; priority |= 1 /* NakedTypeVariable */; - for (var _b = 0, targets_3 = targets; _b < targets_3.length; _b++) { - var t = targets_3[_b]; + for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { + var t = targets_4[_b]; if (getInferenceInfoForType(t)) { inferFromTypes(source, t); } @@ -46176,7 +46924,7 @@ var ts; var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { if (ts.contains(symbolStack, symbol)) { - inferenceIncomplete = true; + inferencePriority = -1 /* Circularity */; return; } (symbolStack || (symbolStack = [])).push(symbol); @@ -46260,7 +47008,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 === 157 /* MethodDeclaration */ || kind === 156 /* MethodSignature */ || kind === 158 /* Constructor */; + bivariant = bivariant || kind === 158 /* MethodDeclaration */ || kind === 157 /* MethodSignature */ || kind === 159 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -46286,46 +47034,12 @@ var ts; } } } - function isMatchableType(type) { - // We exclude non-anonymous object types because some frameworks (e.g. Ember) rely on the ability to - // infer between types that don't witness their type variables. Such types would otherwise be eliminated - // because they appear identical. - return !(type.flags & 524288 /* Object */) || !!(ts.getObjectFlags(type) & 16 /* Anonymous */); + function isTypeOrBaseIdenticalTo(s, t) { + return isTypeIdenticalTo(s, t) || !!(s.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) && isTypeIdenticalTo(getBaseTypeOfLiteralType(s), t); } - function typeMatchedBySomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; - if (t === type || isMatchableType(t) && isMatchableType(type) && isTypeIdenticalTo(t, type)) { - return true; - } - } - return false; - } - function findMatchedType(type, target) { - if (typeMatchedBySomeType(type, target.types)) { - return type; - } - if (type.flags & (256 /* NumberLiteral */ | 128 /* StringLiteral */) && target.flags & 1048576 /* Union */) { - var base = getBaseTypeOfLiteralType(type); - if (typeMatchedBySomeType(base, target.types)) { - return base; - } - } - return undefined; - } - /** - * Return a new union or intersection type computed by removing a given set of types - * from a given union or intersection type. - */ - function removeTypesFromUnionOrIntersection(type, typesToRemove) { - var reducedTypes = []; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (!typeMatchedBySomeType(t, typesToRemove)) { - reducedTypes.push(t); - } - } - return reducedTypes.length ? type.flags & 1048576 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes) : undefined; + function isTypeCloselyMatchedBy(s, t) { + return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || + s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); @@ -46464,7 +47178,7 @@ var ts; case "AsyncIterator": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later; default: - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 278 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -46476,7 +47190,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), + resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), /*excludeGlobals*/ false, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; } return links.resolvedSymbol; @@ -46485,7 +47199,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 168 /* TypeQuery */ ? true : n.kind === 73 /* Identifier */ || n.kind === 149 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 169 /* TypeQuery */ ? true : n.kind === 73 /* Identifier */ || n.kind === 150 /* 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 @@ -46500,11 +47214,11 @@ var ts; return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; case 101 /* ThisKeyword */: return "0"; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 215 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -46515,24 +47229,24 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 196 /* ParenthesizedExpression */: - case 214 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: + case 215 /* NonNullExpression */: return isMatchingReference(source, target.expression); } switch (source.kind) { case 73 /* Identifier */: return target.kind === 73 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 238 /* VariableDeclaration */ || target.kind === 187 /* BindingElement */) && + (target.kind === 239 /* VariableDeclaration */ || target.kind === 188 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 101 /* ThisKeyword */: return target.kind === 101 /* ThisKeyword */; case 99 /* SuperKeyword */: return target.kind === 99 /* SuperKeyword */; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 215 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); @@ -46540,7 +47254,7 @@ var ts; return false; } function getAccessedPropertyName(access) { - return access.kind === 190 /* PropertyAccessExpression */ ? access.name.escapedText : + return access.kind === 191 /* PropertyAccessExpression */ ? access.name.escapedText : ts.isStringLiteral(access.argumentExpression) || ts.isNumericLiteral(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } @@ -46624,7 +47338,7 @@ var ts; } } } - if (callExpression.expression.kind === 190 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 191 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -46673,8 +47387,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; result |= getTypeFacts(t); } return result; @@ -46779,15 +47493,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 188 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 189 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 277 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 205 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 228 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 206 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 229 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -46804,21 +47518,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return stringType; - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return undefinedType; - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -46826,7 +47540,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 185 /* ObjectBindingPattern */ ? + var type = pattern.kind === 186 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -46844,35 +47558,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 227 /* ForInStatement */) { + if (node.parent.parent.kind === 228 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.parent.kind === 229 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 238 /* VariableDeclaration */ ? + return node.kind === 239 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */ ? + return getConstraintForLocation(node.kind === 239 /* VariableDeclaration */ || node.kind === 188 /* BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } function isEmptyArrayAssignment(node) { - return node.kind === 238 /* VariableDeclaration */ && node.initializer && + return node.kind === 239 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 187 /* BindingElement */ && node.parent.kind === 205 /* BinaryExpression */ && + node.kind !== 188 /* BindingElement */ && node.parent.kind === 206 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (node.operatorToken.kind) { case 60 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -46884,13 +47598,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 196 /* ParenthesizedExpression */ || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */ && parent.left === node || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 197 /* ParenthesizedExpression */ || + parent.kind === 206 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */ && parent.left === node || + parent.kind === 206 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 273 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -46912,7 +47626,7 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 273 /* CaseClause */) { if (clause.expression.kind === 10 /* StringLiteral */) { witnesses.push(clause.expression.text); continue; @@ -46996,8 +47710,7 @@ var ts; return mapType(typeWithPrimitives, function (t) { return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */) : t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : - t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : - t; + t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -47049,8 +47762,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -47073,11 +47786,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 190 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 192 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 191 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 191 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 193 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 192 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 205 /* BinaryExpression */ && + parent.parent.kind === 206 /* BinaryExpression */ && parent.parent.operatorToken.kind === 60 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -47115,7 +47828,7 @@ var ts; if (flowAnalysisDisabled) { return errorType; } - if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943 /* Narrowable */)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 268188671 /* Narrowable */)) { return declaredType; } var sharedFlowStart = sharedFlowCount; @@ -47126,7 +47839,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 (reference.parent && reference.parent.kind === 214 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (reference.parent && reference.parent.kind === 215 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -47223,8 +47936,8 @@ var ts; // Check if we should continue with the control flow of the containing function. var container = flow.container; if (container && container !== flowContainer && - reference.kind !== 190 /* PropertyAccessExpression */ && - reference.kind !== 191 /* ElementAccessExpression */ && + reference.kind !== 191 /* PropertyAccessExpression */ && + reference.kind !== 192 /* ElementAccessExpression */ && reference.kind !== 101 /* ThisKeyword */) { flow = container.flowNode; continue; @@ -47277,14 +47990,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 === 197 /* FunctionExpression */ || init.kind === 198 /* ArrowFunction */)) { + if (init && (init.kind === 198 /* FunctionExpression */ || init.kind === 199 /* 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 === 227 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 228 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference @@ -47293,7 +48006,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 192 /* CallExpression */ ? + var expr = node.kind === 193 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -47301,7 +48014,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 193 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -47354,7 +48067,7 @@ var ts; else if (isMatchingReferenceDiscriminant(expr, type)) { type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); } - else if (expr.kind === 200 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 201 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else if (containsMatchingReferenceDiscriminant(reference, expr)) { @@ -47529,10 +48242,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 201 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 201 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -47610,7 +48323,7 @@ var ts; return type; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { - // We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands + // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { // For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the @@ -47892,16 +48605,16 @@ var ts; case 73 /* Identifier */: case 101 /* ThisKeyword */: case 99 /* SuperKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: if (expr.operator === 52 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -47937,9 +48650,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 246 /* ModuleBlock */ || - node.kind === 285 /* SourceFile */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 247 /* ModuleBlock */ || + node.kind === 286 /* SourceFile */ || + node.kind === 156 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -47961,7 +48674,7 @@ var ts; if (node.kind === 73 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 152 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 153 /* Parameter */) { symbol.isAssigned = true; } } @@ -47976,7 +48689,7 @@ var ts; /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 152 /* Parameter */ && + declaration.kind === 153 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -47984,10 +48697,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 190 /* PropertyAccessExpression */ || - parent.kind === 192 /* CallExpression */ && parent.expression === node || - parent.kind === 191 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 187 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 191 /* PropertyAccessExpression */ || + parent.kind === 193 /* CallExpression */ && parent.expression === node || + parent.kind === 192 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 188 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); @@ -48002,8 +48715,11 @@ var ts; } return type; } + function isExportOrExportExpression(location) { + return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); + } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 67220415 /* Value */) && !isInTypeQuery(location) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && ((compilerOptions.preserveConstEnums && isExportOrExportExpression(location)) || !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol)))) { markAliasSymbolAsReferenced(symbol); } } @@ -48021,7 +48737,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 198 /* ArrowFunction */) { + if (container.kind === 199 /* 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.hasModifier(container, 256 /* Async */)) { @@ -48042,7 +48758,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 241 /* ClassDeclaration */ + if (declaration.kind === 242 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -48054,14 +48770,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 210 /* ClassExpression */) { + else if (declaration.kind === 211 /* 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 !== 285 /* SourceFile */) { + while (container.kind !== 286 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 155 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 156 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -48110,7 +48826,7 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 152 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 153 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -48119,8 +48835,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 === 197 /* FunctionExpression */ || - flowContainer.kind === 198 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 198 /* FunctionExpression */ || + flowContainer.kind === 199 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -48128,10 +48844,10 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 258 /* ExportSpecifier */) || - node.parent.kind === 214 /* NonNullExpression */ || - declaration.kind === 238 /* VariableDeclaration */ && declaration.exclamationToken || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 259 /* ExportSpecifier */) || + node.parent.kind === 215 /* NonNullExpression */ || + declaration.kind === 239 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 4194304 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -48166,7 +48882,7 @@ var ts; if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 275 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 276 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -48189,7 +48905,7 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container) && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 240 /* VariableDeclarationList */).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -48207,8 +48923,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 226 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container && + if (container.kind === 227 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 240 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -48226,7 +48942,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 196 /* ParenthesizedExpression */) { + while (current.parent.kind === 197 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -48234,7 +48950,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 203 /* PrefixUnaryExpression */ || current.parent.kind === 204 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 204 /* PrefixUnaryExpression */ || current.parent.kind === 205 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; } @@ -48247,7 +48963,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 155 /* PropertyDeclaration */ || container.kind === 158 /* Constructor */) { + if (container.kind === 156 /* PropertyDeclaration */ || container.kind === 159 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -48315,37 +49031,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 158 /* Constructor */) { + if (container.kind === 159 /* 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 === 198 /* ArrowFunction */) { + if (container.kind === 199 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 245 /* ModuleDeclaration */: + case 246 /* 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 244 /* EnumDeclaration */: + case 245 /* 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 158 /* Constructor */: + case 159 /* 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 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: if (ts.hasModifier(container, 32 /* Static */)) { 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 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -48384,10 +49100,8 @@ var ts; if (isInJS && className) { var classSymbol = checkExpression(className).symbol; if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { - var classType = getJSClassType(classSymbol); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(classSymbol).thisType; + return getFlowTypeOfReference(node, classType); } } // Check if it's a constructor definition, can be either a variable decl or function decl @@ -48395,12 +49109,10 @@ var ts; // * /** @constructor */ function [name]() { ... } // * /** @constructor */ var x = function() { ... } else if (isInJS && - (container.kind === 197 /* FunctionExpression */ || container.kind === 240 /* FunctionDeclaration */) && + (container.kind === 198 /* FunctionExpression */ || container.kind === 241 /* FunctionDeclaration */) && ts.getJSDocClassTag(container)) { - var classType = getJSClassType(getMergedSymbol(container.symbol)); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType; + return getFlowTypeOfReference(node, classType); } var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { @@ -48431,7 +49143,7 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 197 /* FunctionExpression */ && + if (container.kind === 198 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -48441,16 +49153,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 157 /* MethodDeclaration */ && - container.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 158 /* MethodDeclaration */ && + container.parent.kind === 190 /* 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 === 197 /* FunctionExpression */ && - container.parent.kind === 276 /* PropertyAssignment */ && - container.parent.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 198 /* FunctionExpression */ && + container.parent.kind === 277 /* PropertyAssignment */ && + container.parent.parent.kind === 190 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -48458,7 +49170,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 === 197 /* FunctionExpression */ && + else if (container.kind === 198 /* 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") && @@ -48483,7 +49195,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 295 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 296 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -48497,15 +49209,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 152 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 153 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 192 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 193 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); 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 === 198 /* ArrowFunction */) { + while (container && container.kind === 199 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -48518,14 +49230,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 150 /* ComputedPropertyName */; }); - if (current && current.kind === 150 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 151 /* ComputedPropertyName */; }); + if (current && current.kind === 151 /* 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 === 189 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 190 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -48533,7 +49245,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 158 /* Constructor */) { + if (!isCallExpression && container.kind === 159 /* 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.hasModifier(container, 32 /* Static */) || isCallExpression) { @@ -48602,7 +49314,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 === 157 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 158 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -48616,7 +49328,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 189 /* ObjectLiteralExpression */) { + if (container.parent.kind === 190 /* 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; @@ -48637,7 +49349,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 158 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 159 /* 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; @@ -48652,7 +49364,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 === 158 /* Constructor */; + return container.kind === 159 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -48660,21 +49372,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 === 189 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 190 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */; + return container.kind === 158 /* MethodDeclaration */ || + container.kind === 157 /* MethodSignature */ || + container.kind === 160 /* GetAccessor */ || + container.kind === 161 /* SetAccessor */; } else { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */ || - container.kind === 155 /* PropertyDeclaration */ || - container.kind === 154 /* PropertySignature */ || - container.kind === 158 /* Constructor */; + return container.kind === 158 /* MethodDeclaration */ || + container.kind === 157 /* MethodSignature */ || + container.kind === 160 /* GetAccessor */ || + container.kind === 161 /* SetAccessor */ || + container.kind === 156 /* PropertyDeclaration */ || + container.kind === 155 /* PropertySignature */ || + container.kind === 159 /* Constructor */; } } } @@ -48682,10 +49394,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 157 /* MethodDeclaration */ || - func.kind === 159 /* GetAccessor */ || - func.kind === 160 /* SetAccessor */) && func.parent.kind === 189 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 197 /* FunctionExpression */ && func.parent.kind === 276 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 158 /* MethodDeclaration */ || + func.kind === 160 /* GetAccessor */ || + func.kind === 161 /* SetAccessor */) && func.parent.kind === 190 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 198 /* FunctionExpression */ && func.parent.kind === 277 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -48697,7 +49409,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 199 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -48724,7 +49436,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 276 /* PropertyAssignment */) { + if (literal.parent.kind !== 277 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -48738,9 +49450,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent.kind === 206 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */) { var target = parent.left; - if (target.kind === 190 /* PropertyAccessExpression */ || target.kind === 191 /* ElementAccessExpression */) { + if (target.kind === 191 /* PropertyAccessExpression */ || target.kind === 192 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -48804,9 +49516,9 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 152 /* Parameter */: + case 153 /* Parameter */: return getContextuallyTypedParameterType(declaration, /*forCache*/ false); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return getContextualTypeForBindingElement(declaration); // By default, do nothing and return undefined - only parameters and binding elements have context implied by a parent } @@ -48896,6 +49608,15 @@ var ts; } return false; } + function getContextualIterationType(kind, functionDecl) { + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */); + var contextualReturnType = getContextualReturnType(functionDecl); + if (contextualReturnType) { + return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) + || undefined; + } + return undefined; + } function getContextualReturnType(functionDecl) { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed @@ -48927,7 +49648,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 194 /* TaggedTemplateExpression */) { + if (template.parent.kind === 195 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -48989,7 +49710,7 @@ var ts; } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 67220415 /* Value */, undefined, id.escapedText, /*isUse*/ true); + var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated) { @@ -49040,7 +49761,7 @@ var ts; return substituteIndexedMappedType(t, propertyNameType); } } - else if (t.flags & 3670016 /* StructuredType */) { + else if (t.flags & 137887744 /* StructuredType */) { var prop = getPropertyOfType(t, name); if (prop) { return getTypeOfSymbol(prop); @@ -49160,26 +49881,29 @@ var ts; case 73 /* Identifier */: case 142 /* UndefinedKeyword */: return true; - case 190 /* PropertyAccessExpression */: - case 196 /* ParenthesizedExpression */: + case 191 /* PropertyAccessExpression */: + case 197 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 271 /* JsxExpression */: + case 272 /* 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 === 276 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 277 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 268 /* 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.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 269 /* 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 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. function getApparentTypeOfContextualType(node, contextFlags) { - var contextualType = instantiateContextualType(getContextualType(node, contextFlags), node, contextFlags); - if (contextualType) { - var apparentType = mapType(contextualType, getApparentType, /*noReductions*/ true); + var contextualType = ts.isObjectLiteralMethod(node) ? + getContextualTypeForObjectLiteralMethod(node, contextFlags) : + getContextualType(node, contextFlags); + var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); + if (instantiatedType) { + var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); if (apparentType.flags & 1048576 /* Union */) { if (ts.isObjectLiteralExpression(node)) { return discriminateContextualTypeByObjectMembers(node, apparentType); @@ -49217,7 +49941,7 @@ var ts; // are classified as instantiable (i.e. it doesn't instantiate object types), and (b) it performs // no reductions on instantiated union types. function instantiateInstantiableTypes(type, mapper) { - if (type.flags & 63176704 /* Instantiable */) { + if (type.flags & (63176704 /* Instantiable */ | 134217728 /* StructuralTag */)) { return instantiateType(type, mapper); } if (type.flags & 1048576 /* Union */) { @@ -49255,58 +49979,58 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 187 /* BindingElement */: + case 239 /* VariableDeclaration */: + case 153 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 188 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 198 /* ArrowFunction */: - case 231 /* ReturnStatement */: + case 199 /* ArrowFunction */: + case 232 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent); - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (parent.expression.kind === 93 /* ImportKeyword */) { return stringType; } /* falls through */ - case 193 /* NewExpression */: + case 194 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 188 /* ArrayLiteralExpression */: { + case 189 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 217 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 207 /* TemplateExpression */); + case 218 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 208 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 196 /* ParenthesizedExpression */: { + case 197 /* 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 271 /* JsxExpression */: + case 272 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: + case 269 /* JsxAttribute */: + case 271 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -49461,7 +50185,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 197 /* FunctionExpression */ || node.kind === 198 /* ArrowFunction */; + return node.kind === 198 /* FunctionExpression */ || node.kind === 199 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -49475,14 +50199,12 @@ 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 !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = ts.isObjectLiteralMethod(node) ? - getContextualTypeForObjectLiteralMethod(node, 1 /* Signature */) : - getApparentTypeOfContextualType(node, 1 /* Signature */); + var type = getApparentTypeOfContextualType(node, 1 /* Signature */); if (!type) { return undefined; } @@ -49491,8 +50213,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var current = types_13[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -49522,8 +50244,8 @@ var ts; return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); } function hasDefaultValue(node) { - return (node.kind === 187 /* BindingElement */ && !!node.initializer) || - (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */); + return (node.kind === 188 /* BindingElement */ && !!node.initializer) || + (node.kind === 206 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -49535,7 +50257,7 @@ var ts; var inConstContext = isConstContext(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 209 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 210 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -49560,12 +50282,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 209 /* SpreadElement */) { + if (index < elementCount - 1 && e.kind === 210 /* SpreadElement */) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 209 /* SpreadElement */; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 210 /* SpreadElement */; var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". @@ -49607,7 +50329,7 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return isNumericComputedName(name); case 73 /* Identifier */: return isNumericLiteralName(name.escapedText); @@ -49697,7 +50419,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 185 /* ObjectBindingPattern */ || contextualType.pattern.kind === 189 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 186 /* ObjectBindingPattern */ || contextualType.pattern.kind === 190 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -49712,13 +50434,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 150 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 151 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 276 /* PropertyAssignment */ || - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 277 /* PropertyAssignment */ || + memberDecl.kind === 278 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 276 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 277 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 278 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -49741,8 +50463,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 === 276 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 277 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 277 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 278 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -49767,7 +50489,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 278 /* SpreadAssignment */) { + else if (memberDecl.kind === 279 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -49793,7 +50515,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 === 159 /* GetAccessor */ || memberDecl.kind === 160 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 160 /* GetAccessor */ || memberDecl.kind === 161 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -49853,7 +50575,13 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (3 /* AnyOrUnknown */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || + if (type.flags & 63176704 /* Instantiable */) { + var constraint = getBaseConstraintOfType(type); + if (constraint !== undefined) { + return isValidSpreadType(constraint); + } + } + return !!(type.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 134217728 /* StructuralTag */ | 58982400 /* InstantiableNonPrimitive */) || getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } @@ -49946,7 +50674,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 270 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 271 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -49969,7 +50697,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 261 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 262 /* 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); @@ -50043,7 +50771,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 67897832 /* Type */); + var typeSymbol = exports && getSymbol(exports, name, 788968 /* Type */); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** @@ -50117,7 +50845,7 @@ var ts; */ function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 67897832 /* Type */); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* Type */); // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute @@ -50141,7 +50869,7 @@ var ts; } function getJsxLibraryManagedAttributes(jsxNamespace) { // JSX.LibraryManagedAttributes [symbol] - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67897832 /* Type */); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* Type */); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -50293,13 +51021,13 @@ var ts; var reactRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var reactNamespace = getJsxNamespace(node); var reactLocation = isNodeOpeningLikeElement ? node.tagName : node; - var reactSym = resolveName(reactLocation, reactNamespace, 67220415 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); + var reactSym = resolveName(reactLocation, reactNamespace, 111551 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); if (reactSym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not react as there wont be error being emitted reactSym.isReferenced = 67108863 /* All */; - // If react symbol is alias, mark it as referenced - if (reactSym.flags & 2097152 /* Alias */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { + // If react symbol is alias, mark it as refereced + if (reactSym.flags & 2097152 /* Alias */) { markAliasSymbolAsReferenced(reactSym); } } @@ -50388,7 +51116,7 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 149 /* QualifiedName */ ? node.right : node.kind === 184 /* ImportType */ ? node : node.name; + var errorNode = node.kind === 150 /* QualifiedName */ ? node.right : node.kind === 185 /* ImportType */ ? node : node.name; if (ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */) { // Synthetic property with private constituent property error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); @@ -50523,7 +51251,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } function isMethodAccessForCall(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */) { + while (node.parent.kind === 197 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -50589,7 +51317,7 @@ var ts; // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (node.kind !== 191 /* ElementAccessExpression */ && node.kind !== 190 /* PropertyAccessExpression */ || + if (node.kind !== 192 /* ElementAccessExpression */ && node.kind !== 191 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; @@ -50603,7 +51331,7 @@ var ts; var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 158 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 159 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -50624,7 +51352,7 @@ var ts; } function checkPropertyNotUsedBeforeDeclaration(prop, node, right) { var valueDeclaration = prop.valueDeclaration; - if (!valueDeclaration) { + if (!valueDeclaration || ts.getSourceFileOfNode(node).isDeclarationFile) { return; } var diagnosticMessage; @@ -50634,8 +51362,8 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 241 /* ClassDeclaration */ && - node.parent.kind !== 165 /* TypeReference */ && + else if (valueDeclaration.kind === 242 /* ClassDeclaration */ && + node.parent.kind !== 166 /* TypeReference */ && !(valueDeclaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -50647,22 +51375,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return true; - case 276 /* PropertyAssignment */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 278 /* SpreadAssignment */: - case 150 /* ComputedPropertyName */: - case 217 /* TemplateSpan */: - case 271 /* JsxExpression */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 263 /* JsxOpeningElement */: - case 212 /* ExpressionWithTypeArguments */: - case 274 /* HeritageClause */: + case 277 /* PropertyAssignment */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 279 /* SpreadAssignment */: + case 151 /* ComputedPropertyName */: + case 218 /* TemplateSpan */: + case 272 /* JsxExpression */: + case 269 /* JsxAttribute */: + case 270 /* JsxAttributes */: + case 271 /* JsxSpreadAttribute */: + case 264 /* JsxOpeningElement */: + case 213 /* ExpressionWithTypeArguments */: + case 275 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -50702,7 +51430,7 @@ var ts; if (containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; - if (!getPropertyOfType(subtype, propNode.escapedText)) { + if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0 /* String */)) { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); break; } @@ -50740,7 +51468,7 @@ var ts; return prop !== undefined && prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 32 /* Static */); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { - return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67220415 /* Value */); + return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551 /* Value */); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -50835,16 +51563,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return isValidPropertyAccessWithType(node, node.expression.kind === 99 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 184 /* ImportType */: + case 185 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 190 /* PropertyAccessExpression */ && node.expression.kind === 99 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 191 /* PropertyAccessExpression */ && node.expression.kind === 99 /* 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) { @@ -50861,7 +51589,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer.kind === 240 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -50890,7 +51618,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 227 /* ForInStatement */ && + if (node.kind === 228 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -50907,20 +51635,6 @@ var ts; var exprType = checkNonNullExpression(node.expression); var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; - if (!indexExpression) { - var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 193 /* NewExpression */ && node.parent.expression === node) { - var start = ts.skipTrivia(sourceFile.text, node.expression.end); - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - return errorType; - } var indexType = checkExpression(indexExpression); if (objectType === errorType || objectType === silentNeverType) { return objectType; @@ -50980,13 +51694,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 195 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 153 /* Decorator */) { + else if (node.kind !== 154 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -51050,7 +51764,7 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 209 /* SpreadElement */ || arg.kind === 216 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 210 /* SpreadElement */ || arg.kind === 217 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -51064,9 +51778,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 === 194 /* TaggedTemplateExpression */) { + if (node.kind === 195 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 207 /* TemplateExpression */) { + if (node.template.kind === 208 /* 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. @@ -51081,7 +51795,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 153 /* Decorator */) { + else if (node.kind === 154 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -51096,7 +51810,7 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 193 /* NewExpression */); + ts.Debug.assert(node.kind === 194 /* NewExpression */); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -51189,7 +51903,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 !== 153 /* Decorator */) { + if (node.kind !== 154 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -51232,7 +51946,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 !== 211 /* OmittedExpression */) { + if (arg.kind !== 212 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -51256,7 +51970,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 arg.kind === 216 /* SyntheticExpression */ ? + return arg.kind === 217 /* SyntheticExpression */ ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0 /* Normal */)); } @@ -51331,12 +52045,12 @@ var ts; if (ts.isJsxOpeningLikeElement(node)) { if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 193 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 194 /* 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. @@ -51346,7 +52060,7 @@ var ts; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; @@ -51354,7 +52068,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 !== 211 /* OmittedExpression */) { + if (arg.kind !== 212 /* 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), @@ -51364,7 +52078,7 @@ var ts; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } } @@ -51374,7 +52088,7 @@ var ts; if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, /*containingMessageChain*/ undefined, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(errorNode, spreadType, restType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } return undefined; @@ -51395,15 +52109,15 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 193 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 190 /* PropertyAccessExpression */ || callee.kind === 191 /* ElementAccessExpression */) { + if (callee.kind === 191 /* PropertyAccessExpression */ || callee.kind === 192 /* ElementAccessExpression */) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(216 /* SyntheticExpression */, parent.pos, parent.end); + var result = ts.createNode(217 /* SyntheticExpression */, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; @@ -51413,17 +52127,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 195 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 207 /* TemplateExpression */) { + if (template.kind === 208 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 153 /* Decorator */) { + if (node.kind === 154 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -51453,30 +52167,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* 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 152 /* Parameter */: + case 153 /* 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 === 158 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 159 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* 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 !== 155 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 156 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -51490,17 +52204,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return 1; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return 2; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* 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 152 /* Parameter */: + case 153 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -51625,8 +52339,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, fallbackError) { - var isTaggedTemplate = node.kind === 194 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 153 /* Decorator */; + var isTaggedTemplate = node.kind === 195 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 154 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; @@ -51688,7 +52402,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 === 192 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 193 /* 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 @@ -52224,8 +52938,8 @@ var ts; if (apparentType.flags & 1048576 /* Union */) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var constituent = types_15[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var constituent = types_14[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -52323,16 +53037,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 152 /* Parameter */: + case 153 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -52376,8 +53090,8 @@ var ts; var exports = namespace && getExportsOfSymbol(namespace); // We fake up a SFC signature for each intrinsic, however a more specific per-element signature drawn from the JSX declaration // file would probably be preferable. - var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 67897832 /* Type */); - var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 67897832 /* Type */, node); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node); var declaration = ts.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.createKeywordTypeNode(121 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; @@ -52425,16 +53139,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 192 /* CallExpression */: + case 193 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 153 /* Decorator */: + case 154 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -52485,43 +53199,45 @@ var ts; return true; // If the symbol of the node has members, treat it like a constructor. var symbol = getSymbolOfNode(func); - return !!symbol && (symbol.members !== undefined || symbol.exports !== undefined && symbol.exports.get("prototype") !== undefined); + return !!symbol && ts.hasEntries(symbol.members); } return false; } - function isJSConstructorType(type) { - if (type.flags & 524288 /* Object */) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); - } - return false; - } - function getJSClassType(symbol) { - var inferred; - if (isJSConstructor(symbol.valueDeclaration)) { - inferred = getInferredClassType(symbol); + function mergeJSSymbols(target, source) { + if (source && (ts.hasEntries(source.exports) || ts.hasEntries(source.members))) { + var links = getSymbolLinks(source); + if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) { + var inferred = isTransientSymbol(target) ? target : cloneSymbol(target); + inferred.exports = inferred.exports || ts.createSymbolTable(); + inferred.members = inferred.members || ts.createSymbolTable(); + inferred.flags |= source.flags & 32 /* Class */; + if (ts.hasEntries(source.exports)) { + mergeSymbolTable(inferred.exports, source.exports); + } + if (ts.hasEntries(source.members)) { + mergeSymbolTable(inferred.members, source.members); + } + (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred); + return inferred; + } + return links.inferredClassSymbol.get("" + getSymbolId(target)); } - var assigned = getAssignedClassType(symbol); - return assigned && inferred ? - getIntersectionType([inferred, assigned]) : - assigned || inferred; } - function getAssignedClassType(symbol) { - var decl = symbol.valueDeclaration; + function getAssignedClassSymbol(decl) { var assignmentSymbol = decl && decl.parent && (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype"); var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration); - return init ? getWidenedType(checkExpressionCached(init)) : undefined; + return init ? getSymbolOfNode(init) : undefined; } function getAssignedJSPrototype(node) { if (!node.parent) { return false; } var parent = node.parent; - while (parent && parent.kind === 190 /* PropertyAccessExpression */) { + while (parent && parent.kind === 191 /* PropertyAccessExpression */) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 60 /* EqualsToken */) { @@ -52529,13 +53245,6 @@ var ts; return ts.isObjectLiteralExpression(right) && right; } } - function getInferredClassType(symbol) { - var links = getSymbolLinks(symbol); - if (!links.inferredClassType) { - links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol) || emptySymbols, ts.emptyArray, ts.emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined); - } - return links.inferredClassType; - } /** * Syntactically and semantically checks a call or new expression. * @param node The call/new expression to be checked. @@ -52553,12 +53262,12 @@ var ts; if (node.expression.kind === 99 /* SuperKeyword */) { return voidType; } - if (node.kind === 193 /* NewExpression */) { + if (node.kind === 194 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 158 /* Constructor */ && - declaration.kind !== 162 /* ConstructSignature */ && - declaration.kind !== 167 /* ConstructorType */ && + declaration.kind !== 159 /* Constructor */ && + declaration.kind !== 163 /* ConstructSignature */ && + declaration.kind !== 168 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -52606,7 +53315,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } function checkImportCallExpression(node) { // Check grammar of dynamic import @@ -52666,7 +53375,7 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } @@ -52675,9 +53384,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 240 /* FunctionDeclaration */ + ? 241 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 238 /* VariableDeclaration */ + ? 239 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -52704,18 +53413,18 @@ var ts; case 9 /* BigIntLiteral */: case 103 /* TrueKeyword */: case 88 /* FalseKeyword */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return true; - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; return op === 39 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || op === 38 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -52765,7 +53474,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 === 158 /* Constructor */) { + else if (container.kind === 159 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -52775,8 +53484,8 @@ var ts; } } function checkImportMetaProperty(node) { - if (languageVersion < 99 /* ESNext */ || moduleKind < ts.ModuleKind.ESNext) { - error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options); + if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) { + error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system); } var file = ts.getSourceFileOfNode(node); ts.Debug.assert(!!(file.flags & 1048576 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); @@ -52966,7 +53675,7 @@ var ts; links.type = contextualType; var decl = parameter.valueDeclaration; if (decl.name.kind !== 73 /* Identifier */) { - // if inference didn't come up with anything but {}, fall back to the binding pattern if present. + // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(decl.name); } @@ -53020,7 +53729,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 219 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 220 /* 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 @@ -53092,7 +53801,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* Next */, func) || unknownType, isAsync); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -53206,14 +53915,14 @@ var ts; if (!node.possiblyExhaustive) { return false; } - if (node.expression.kind === 200 /* TypeOfExpression */) { + if (node.expression.kind === 201 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); // This cast is safe because the switch is possibly exhaustive and does not contain a default case, so there can be no undefined. var witnesses = getSwitchClauseTypeOfWitnesses(node); // notEqualFacts states that the type of the switched value is not equal to every type in the switch. var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true); - var type_5 = getBaseConstraintOfType(operandType) || operandType; - return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); + var type_4 = getBaseConstraintOfType(operandType) || operandType; + return !!(filterType(type_4, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -53229,7 +53938,7 @@ var ts; if (!(func.flags & 128 /* HasImplicitReturn */)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 233 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 234 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -53272,11 +53981,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return true; - case 157 /* MethodDeclaration */: - return func.parent.kind === 189 /* ObjectLiteralExpression */; + case 158 /* MethodDeclaration */: + return func.parent.kind === 190 /* ObjectLiteralExpression */; default: return false; } @@ -53302,7 +54011,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 156 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 219 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 157 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 220 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -53335,7 +54044,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 /* 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)) { @@ -53355,7 +54064,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 197 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 198 /* FunctionExpression */) { checkGrammarForGenerator(node); } var type = getTypeOfSymbol(getMergedSymbol(node.symbol)); @@ -53409,7 +54118,7 @@ var ts; type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -53422,7 +54131,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 219 /* Block */) { + if (node.body.kind === 220 /* Block */) { checkSourceElement(node.body); } else { @@ -53503,11 +54212,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) && + (expr.kind === 191 /* PropertyAccessExpression */ || expr.kind === 192 /* ElementAccessExpression */) && expr.expression.kind === 101 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 158 /* Constructor */)) { + if (!(func && func.kind === 159 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -53520,13 +54229,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) { + if (expr.kind === 191 /* PropertyAccessExpression */ || expr.kind === 192 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); if (node.kind === 73 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 252 /* NamespaceImport */; + return !!declaration && declaration.kind === 253 /* NamespaceImport */; } } } @@ -53535,7 +54244,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 73 /* Identifier */ && node.kind !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 73 /* Identifier */ && node.kind !== 191 /* PropertyAccessExpression */ && node.kind !== 192 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -53544,7 +54253,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 190 /* PropertyAccessExpression */ && expr.kind !== 191 /* ElementAccessExpression */) { + if (expr.kind !== 191 /* PropertyAccessExpression */ && expr.kind !== 192 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -53573,7 +54282,7 @@ var ts; var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); var func = ts.getContainingFunction(node); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 159 /* 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); @@ -53586,7 +54295,11 @@ var ts; } } var operandType = checkExpression(node.expression); - return checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + var awaitedType = checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + if (awaitedType === operandType && awaitedType !== errorType && !(operandType.flags & 3 /* AnyOrUnknown */)) { + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); + } + return awaitedType; } function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); @@ -53620,7 +54333,7 @@ var ts; } if (node.operator === 38 /* PlusToken */) { if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { - error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(operandType)); + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } @@ -53671,8 +54384,8 @@ var ts; } if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -53761,7 +54474,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 276 /* PropertyAssignment */ || property.kind === 277 /* ShorthandPropertyAssignment */) { + if (property.kind === 277 /* PropertyAssignment */ || property.kind === 278 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -53774,9 +54487,9 @@ var ts; } var elementType = getIndexedAccessType(objectLiteralType, exprType, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 277 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 278 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 278 /* SpreadAssignment */) { + else if (property.kind === 279 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -53819,8 +54532,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 211 /* OmittedExpression */) { - if (element.kind !== 209 /* SpreadElement */) { + if (element.kind !== 212 /* OmittedExpression */) { + if (element.kind !== 210 /* SpreadElement */) { var indexType = getLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused @@ -53838,7 +54551,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 205 /* BinaryExpression */ && restExpression.operatorToken.kind === 60 /* EqualsToken */) { + if (restExpression.kind === 206 /* BinaryExpression */ && restExpression.operatorToken.kind === 60 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -53854,7 +54567,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 277 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 278 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -53870,21 +54583,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 205 /* BinaryExpression */ && target.operatorToken.kind === 60 /* EqualsToken */) { + if (target.kind === 206 /* BinaryExpression */ && target.operatorToken.kind === 60 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 189 /* ObjectLiteralExpression */) { + if (target.kind === 190 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 188 /* ArrayLiteralExpression */) { + if (target.kind === 189 /* 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 === 278 /* SpreadAssignment */ ? + var error = target.parent.kind === 279 /* 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; if (checkReferenceExpression(target, error)) { @@ -53906,8 +54619,8 @@ var ts; case 73 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 194 /* TaggedTemplateExpression */: - case 207 /* TemplateExpression */: + case 195 /* TaggedTemplateExpression */: + case 208 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: @@ -53915,27 +54628,27 @@ var ts; case 88 /* FalseKeyword */: case 97 /* NullKeyword */: case 142 /* UndefinedKeyword */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 200 /* TypeOfExpression */: - case 214 /* NonNullExpression */: - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: + case 198 /* FunctionExpression */: + case 211 /* ClassExpression */: + case 199 /* ArrowFunction */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: + case 201 /* TypeOfExpression */: + case 215 /* NonNullExpression */: + case 263 /* JsxSelfClosingElement */: + case 262 /* JsxElement */: return true; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -53947,9 +54660,9 @@ var ts; } return false; // Some forms listed here for clarity - case 201 /* VoidExpression */: // Explicit opt-out - case 195 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 213 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 202 /* VoidExpression */: // Explicit opt-out + case 196 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 214 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -53965,7 +54678,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 60 /* EqualsToken */ && (left.kind === 189 /* ObjectLiteralExpression */ || left.kind === 188 /* ArrayLiteralExpression */)) { + if (operator === 60 /* EqualsToken */ && (left.kind === 190 /* ObjectLiteralExpression */ || left.kind === 189 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 101 /* ThisKeyword */); } var leftType; @@ -54025,7 +54738,7 @@ var ts; resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */)) { + else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { case 48 /* GreaterThanGreaterThanGreaterThanToken */: case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: @@ -54035,7 +54748,7 @@ var ts; } // Exactly one of leftType/rightType is assignable to bigint else { - reportOperatorError(function (awaitedLeft, awaitedRight) { return isTypeAssignableToKind(awaitedLeft, 2112 /* BigIntLike */) && isTypeAssignableToKind(awaitedRight, 2112 /* BigIntLike */); }); + reportOperatorError(bothAreBigIntLike); resultType_1 = errorType; } if (leftOk && rightOk) { @@ -54081,9 +54794,9 @@ var ts; // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 3 /* AnyOrUnknown */; - reportOperatorError(function (awaitedLeft, awaitedRight) { - return isTypeAssignableToKind(awaitedLeft, closeEnoughKind_1) && - isTypeAssignableToKind(awaitedRight, closeEnoughKind_1); + reportOperatorError(function (left, right) { + return isTypeAssignableToKind(left, closeEnoughKind_1) && + isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } @@ -54148,6 +54861,9 @@ var ts; default: return ts.Debug.fail(); } + function bothAreBigIntLike(left, right) { + return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + } function checkAssignmentDeclaration(kind, rightType) { if (kind === 2 /* ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { @@ -54155,7 +54871,7 @@ var ts; var propType = getTypeOfSymbol(prop); if (propType.symbol && propType.symbol.flags & 32 /* Class */) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 67897832 /* Type */, undefined, name, /*isUse*/ false); + var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) { grammarErrorOnNode(symbol.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); return grammarErrorOnNode(prop.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); @@ -54235,17 +54951,23 @@ var ts; } return false; } - function reportOperatorError(awaitedTypesAreCompatible) { + function reportOperatorError(isRelated) { + var _a; var wouldWorkWithAwait = false; var errNode = errorNode || operatorToken; - var _a = getTypeNamesForErrorDisplay(leftType, rightType), leftStr = _a[0], rightStr = _a[1]; - if (awaitedTypesAreCompatible) { + if (isRelated) { var awaitedLeftType = getAwaitedType(leftType); var awaitedRightType = getAwaitedType(rightType); wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType) && !!(awaitedLeftType && awaitedRightType) - && awaitedTypesAreCompatible(awaitedLeftType, awaitedRightType); + && isRelated(awaitedLeftType, awaitedRightType); + } + var effectiveLeft = leftType; + var effectiveRight = rightType; + if (!wouldWorkWithAwait && isRelated) { + _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1]; } + var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1]; if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) { errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); } @@ -54267,6 +54989,17 @@ var ts; return undefined; } } + function getBaseTypesIfUnrelated(leftType, rightType, isRelated) { + var effectiveLeft = leftType; + var effectiveRight = rightType; + var leftBase = getBaseTypeOfLiteralType(leftType); + var rightBase = getBaseTypeOfLiteralType(rightType); + if (!isRelated(leftBase, rightBase)) { + effectiveLeft = leftBase; + effectiveRight = rightBase; + } + return [effectiveLeft, effectiveRight]; + } function isYieldExpressionInClass(node) { var current = node; var parent = node.parent; @@ -54334,12 +55067,7 @@ var ts; return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync) || anyType; } - var contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, contextualReturnType, isAsync) - || anyType; - } - return anyType; + return getContextualIterationType(2 /* Next */, func) || anyType; } function checkConditionalExpression(node, checkMode) { checkTruthinessExpression(node.condition); @@ -54361,7 +55089,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 269 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 270 /* 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; @@ -54400,12 +55128,12 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 195 /* TypeAssertionExpression */ || node.kind === 213 /* AsExpression */; + return node.kind === 196 /* TypeAssertionExpression */ || node.kind === 214 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, /*cache*/ true); - var padded = ts.isParameter(declaration) && declaration.name.kind === 186 /* ArrayBindingPattern */ && + var padded = ts.isParameter(declaration) && declaration.name.kind === 187 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || @@ -54430,7 +55158,7 @@ var ts; var elementTypes = arity ? type.typeArguments.slice() : []; for (var i = arity; i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 187 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 188 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); @@ -54482,7 +55210,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -54493,7 +55221,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -54636,7 +55364,7 @@ var ts; var expr = ts.skipParentheses(node); // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (expr.kind === 192 /* CallExpression */ && expr.expression.kind !== 99 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (expr.kind === 193 /* CallExpression */ && expr.expression.kind !== 99 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var funcType = checkNonNullExpression(expr.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -54686,10 +55414,11 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 191 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 168 /* TypeQuery */ && node.parent.exprName === node)); + var ok = (node.parent.kind === 191 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 192 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 73 /* Identifier */ || node.kind === 150 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 169 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 259 /* ExportSpecifier */ && (compilerOptions.preserveConstEnums || node.flags & 4194304 /* Ambient */)); // 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); } @@ -54709,7 +55438,18 @@ var ts; return checkExpression(node.expression, checkMode); } function checkExpressionWorker(node, checkMode, forceTuple) { - switch (node.kind) { + var kind = node.kind; + if (cancellationToken) { + // 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 211 /* ClassExpression */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + cancellationToken.throwIfCancellationRequested(); + } + } + switch (kind) { case 73 /* Identifier */: return checkIdentifier(node); case 101 /* ThisKeyword */: @@ -54731,78 +55471,78 @@ var ts; return trueType; case 88 /* FalseKeyword */: return falseType; - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return checkQualifiedName(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (node.expression.kind === 93 /* ImportKeyword */) { return checkImportCallExpression(node); } - /* falls through */ - case 193 /* NewExpression */: + // falls through + case 194 /* NewExpression */: return checkCallExpression(node, checkMode); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return checkClassExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: return checkAssertion(node); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: return checkNonNullAssertion(node); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return checkMetaProperty(node); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return checkDeleteExpression(node); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return checkVoidExpression(node); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return checkAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 211 /* OmittedExpression */: + case 212 /* OmittedExpression */: return undefinedWideningType; - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return checkYieldExpression(node); - case 216 /* SyntheticExpression */: + case 217 /* SyntheticExpression */: return node.type; - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 261 /* JsxElement */: + case 262 /* JsxElement */: return checkJsxElement(node, checkMode); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return checkJsxFragment(node); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 263 /* JsxOpeningElement */: + case 264 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -54839,7 +55579,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 158 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 159 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -54850,10 +55590,10 @@ 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 === 158 /* Constructor */ || func.kind === 162 /* ConstructSignature */ || func.kind === 167 /* ConstructorType */) { + if (func.kind === 159 /* Constructor */ || func.kind === 163 /* ConstructSignature */ || func.kind === 168 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 199 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -54909,13 +55649,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 198 /* ArrowFunction */: - case 161 /* CallSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 166 /* FunctionType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 199 /* ArrowFunction */: + case 162 /* CallSignature */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 167 /* FunctionType */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -54933,7 +55673,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 === 186 /* ArrayBindingPattern */ || name.kind === 185 /* ObjectBindingPattern */) { + else if (name.kind === 187 /* ArrayBindingPattern */ || name.kind === 186 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -54942,13 +55682,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 164 /* 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 === 166 /* FunctionType */ || node.kind === 240 /* FunctionDeclaration */ || node.kind === 167 /* ConstructorType */ || - node.kind === 161 /* CallSignature */ || node.kind === 158 /* Constructor */ || - node.kind === 162 /* ConstructSignature */) { + else if (node.kind === 167 /* FunctionType */ || node.kind === 241 /* FunctionDeclaration */ || node.kind === 168 /* ConstructorType */ || + node.kind === 162 /* CallSignature */ || node.kind === 159 /* Constructor */ || + node.kind === 163 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -54978,10 +55718,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 161 /* CallSignature */: + case 162 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -55011,28 +55751,21 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 163 /* IndexSignature */ && node.kind !== 295 /* JSDocFunctionType */) { + if (node.kind !== 164 /* IndexSignature */ && node.kind !== 296 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } } function checkClassForDuplicateDeclarations(node) { - var Declaration; - (function (Declaration) { - Declaration[Declaration["Getter"] = 1] = "Getter"; - Declaration[Declaration["Setter"] = 2] = "Setter"; - Declaration[Declaration["Method"] = 4] = "Method"; - Declaration[Declaration["Property"] = 3] = "Property"; - })(Declaration || (Declaration = {})); var instanceNames = ts.createUnderscoreEscapedMap(); var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 158 /* Constructor */) { + if (member.kind === 159 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; - if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { - addName(instanceNames, param.name, param.name.escapedText, 3 /* Property */); + if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { + addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); } } } @@ -55043,17 +55776,17 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 159 /* GetAccessor */: - addName(names, name, memberName, 1 /* Getter */); + case 160 /* GetAccessor */: + addName(names, name, memberName, 1 /* GetAccessor */); break; - case 160 /* SetAccessor */: - addName(names, name, memberName, 2 /* Setter */); + case 161 /* SetAccessor */: + addName(names, name, memberName, 2 /* SetAccessor */); break; - case 155 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* Property */); + case 156 /* PropertyDeclaration */: + addName(names, name, memberName, 3 /* GetOrSetAccessor */); break; - case 157 /* MethodDeclaration */: - addName(names, name, memberName, 4 /* Method */); + case 158 /* MethodDeclaration */: + addName(names, name, memberName, 8 /* Method */); break; } } @@ -55062,8 +55795,8 @@ var ts; function addName(names, location, name, meaning) { var prev = names.get(name); if (prev) { - if (prev & 4 /* Method */) { - if (meaning !== 4 /* Method */) { + if (prev & 8 /* Method */) { + if (meaning !== 8 /* Method */) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } } @@ -55115,7 +55848,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154 /* PropertySignature */) { + if (member.kind === 155 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -55140,7 +55873,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 243 /* 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 @@ -55195,7 +55928,7 @@ var ts; 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.hasModifier(node, 128 /* Abstract */) && node.kind === 157 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 158 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -55220,7 +55953,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 155 /* PropertyDeclaration */ && + return n.kind === 156 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -55250,7 +55983,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 223 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -55275,7 +56008,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 160 /* GetAccessor */) { if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -55285,13 +56018,13 @@ 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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(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 === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = node.kind === 160 /* GetAccessor */ ? 161 /* SetAccessor */ : 160 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -55309,7 +56042,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 160 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -55357,7 +56090,7 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 165 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 166 /* 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); } var type = getTypeFromTypeReference(node); @@ -55405,7 +56138,7 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 173 /* RestType */) { + if (e.kind === 174 /* RestType */) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; @@ -55414,7 +56147,7 @@ var ts; error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 172 /* OptionalType */) { + else if (e.kind === 173 /* OptionalType */) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -55435,7 +56168,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 191 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 192 /* 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)); } @@ -55486,7 +56219,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 176 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 177 /* 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); @@ -55503,9 +56236,9 @@ var ts; var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 242 /* InterfaceDeclaration */ && - n.parent.kind !== 241 /* ClassDeclaration */ && - n.parent.kind !== 210 /* ClassExpression */ && + if (n.parent.kind !== 243 /* InterfaceDeclaration */ && + n.parent.kind !== 242 /* ClassDeclaration */ && + n.parent.kind !== 211 /* ClassExpression */ && n.flags & 4194304 /* 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 @@ -55596,7 +56329,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */) && + var reportError = (node.kind === 158 /* MethodDeclaration */ || node.kind === 157 /* MethodSignature */) && ts.hasModifier(node, 32 /* Static */) !== ts.hasModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -55631,11 +56364,12 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; + var hasNonAmbientClass = false; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 242 /* InterfaceDeclaration */ || node.parent.kind === 169 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 243 /* InterfaceDeclaration */ || node.parent.kind === 170 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -55646,7 +56380,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 240 /* FunctionDeclaration */ || node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */ || node.kind === 158 /* Constructor */) { + if ((node.kind === 242 /* ClassDeclaration */ || node.kind === 211 /* ClassExpression */) && !inAmbientContext) { + hasNonAmbientClass = true; + } + if (node.kind === 241 /* FunctionDeclaration */ || node.kind === 158 /* MethodDeclaration */ || node.kind === 157 /* MethodSignature */ || node.kind === 159 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -55687,6 +56424,15 @@ var ts; error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Duplicate_function_implementation); }); } + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */) { + // A non-ambient class cannot be an implementation for a non-constructor function/class merge + // TODO: The below just replicates our older error from when classes and functions were + // entirely unable to merge - a more helpful message like "Class declaration cannot implement overload list" + // might be warranted. :shrug: + ts.forEach(declarations, function (declaration) { + addDuplicateDeclarationError(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), ts.filter(declarations, function (d) { return d !== declaration; })); + }); + } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && !ts.hasModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { @@ -55708,13 +56454,6 @@ var ts; } } } - var DeclarationSpaces; - (function (DeclarationSpaces) { - DeclarationSpaces[DeclarationSpaces["None"] = 0] = "None"; - DeclarationSpaces[DeclarationSpaces["ExportValue"] = 1] = "ExportValue"; - DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; - DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; - })(DeclarationSpaces || (DeclarationSpaces = {})); function checkExportsOnMergedDeclarations(node) { if (!produceDiagnostics) { return; @@ -55775,40 +56514,42 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - // A jsdoc typedef and callback are, by definition, type aliases - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + // A jsdoc typedef and callback are, by definition, type aliases. + // falls through + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: return 2 /* ExportType */; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 285 /* SourceFile */: + case 286 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; } d = d.expression; - /* falls through */ - // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + // The below options all declare an Alias, which is allowed to merge with other values within the importing module. + // falls through + case 250 /* ImportEqualsDeclaration */: + case 253 /* NamespaceImport */: + case 252 /* ImportClause */: var result_8 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_8 |= getDeclarationSpaces(d); }); return result_8; - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 240 /* FunctionDeclaration */: - case 254 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 239 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 241 /* FunctionDeclaration */: + case 255 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); @@ -55877,9 +56618,6 @@ var ts; */ function checkAwaitedType(type, errorNode, diagnosticMessage, arg0) { var awaitedType = getAwaitedType(type, errorNode, diagnosticMessage, arg0); - if (awaitedType === type && !(type.flags & 3 /* AnyOrUnknown */)) { - addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(errorNode, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); - } return awaitedType || errorType; } function getAwaitedType(type, errorNode, diagnosticMessage, arg0) { @@ -56038,7 +56776,7 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67220415 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { if (promiseConstructorName.kind === 73 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { @@ -56061,7 +56799,7 @@ var ts; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 67220415 /* Value */); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -56080,24 +56818,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 152 /* Parameter */: + case 153 /* 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 155 /* PropertyDeclaration */: + case 156 /* 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 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -56118,7 +56856,7 @@ var ts; if (!typeName) return; var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 73 /* Identifier */ ? 67897832 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 73 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -56143,23 +56881,23 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 176 /* IntersectionType */: + case 175 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return node.typeName; } } } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var typeNode = types_17[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var typeNode = types_16[_i]; + while (typeNode.kind === 179 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 133 /* NeverKeyword */) { @@ -56211,14 +56949,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 152 /* Parameter */) { + if (node.kind === 153 /* 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 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -56227,23 +56965,23 @@ var ts; } } break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - var otherKind = node.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + var otherKind = node.kind === 160 /* GetAccessor */ ? 161 /* SetAccessor */ : 160 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 157 /* MethodDeclaration */: + case 158 /* 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 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 152 /* Parameter */: + case 153 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -56306,7 +57044,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 === 149 /* 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 === 150 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -56341,7 +57079,7 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return node; - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -56354,7 +57092,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 151 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -56383,7 +57121,7 @@ var ts; } } } - var body = node.kind === 156 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 157 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -56425,42 +57163,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 285 /* SourceFile */: - case 245 /* ModuleDeclaration */: - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 286 /* SourceFile */: + case 246 /* ModuleDeclaration */: + case 220 /* Block */: + case 248 /* CaseBlock */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 159 /* Constructor */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 177 /* InferType */: + case 178 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -56480,11 +57218,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 157 /* MethodDeclaration */: - case 155 /* PropertyDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - if (member.kind === 160 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 158 /* MethodDeclaration */: + case 156 /* PropertyDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + if (member.kind === 161 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -56493,7 +57231,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 158 /* Constructor */: + case 159 /* Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { @@ -56501,8 +57239,8 @@ var ts; } } break; - case 163 /* IndexSignature */: - case 218 /* SemicolonClassElement */: + case 164 /* IndexSignature */: + case 219 /* SemicolonClassElement */: // Can't be private break; default: @@ -56529,7 +57267,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 177 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 178 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) // Whole @template tag @@ -56599,7 +57337,7 @@ var ts; var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -56614,7 +57352,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 252 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 253 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -56632,7 +57370,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 === 238 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 239 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 239 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 240 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -56653,7 +57391,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 === 220 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 221 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -56667,22 +57405,22 @@ var ts; switch (name.kind) { case 73 /* Identifier */: return ts.idText(name); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 251 /* ImportClause */ || node.kind === 254 /* ImportSpecifier */ || node.kind === 252 /* NamespaceImport */; + return node.kind === 252 /* ImportClause */ || node.kind === 255 /* ImportSpecifier */ || node.kind === 253 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 251 /* ImportClause */ ? decl : decl.kind === 252 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 252 /* ImportClause */ ? decl : decl.kind === 253 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 219 /* Block */) { + if (node.kind === 220 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -56712,12 +57450,12 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 155 /* PropertyDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 157 /* MethodDeclaration */ || - node.kind === 156 /* MethodSignature */ || - node.kind === 159 /* GetAccessor */ || - node.kind === 160 /* SetAccessor */) { + if (node.kind === 156 /* PropertyDeclaration */ || + node.kind === 155 /* PropertySignature */ || + node.kind === 158 /* MethodDeclaration */ || + node.kind === 157 /* MethodSignature */ || + node.kind === 160 /* GetAccessor */ || + node.kind === 161 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -56726,7 +57464,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 152 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 153 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -56777,7 +57515,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 === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 286 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -56792,7 +57530,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 === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 286 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(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)); } @@ -56827,7 +57565,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 === 238 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 239 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -56839,17 +57577,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 239 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 220 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 240 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 221 /* 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 === 219 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 246 /* ModuleBlock */ || - container.kind === 245 /* ModuleDeclaration */ || - container.kind === 285 /* SourceFile */); + (container.kind === 220 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 247 /* ModuleBlock */ || + container.kind === 246 /* ModuleDeclaration */ || + container.kind === 286 /* 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 @@ -56879,18 +57617,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 187 /* BindingElement */) { - if (node.parent.kind === 185 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (node.kind === 188 /* BindingElement */) { + if (node.parent.kind === 186 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 150 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -56911,19 +57649,19 @@ var ts; } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 186 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 187 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 152 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 153 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 227 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 228 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -56960,7 +57698,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 227 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 228 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -56986,10 +57724,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */) { + if (node.kind !== 156 /* PropertyDeclaration */ && node.kind !== 155 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 239 /* VariableDeclaration */ || node.kind === 188 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -56998,7 +57736,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 155 /* PropertyDeclaration */ || nextDeclaration.kind === 154 /* PropertySignature */ + var message = nextDeclaration.kind === 156 /* PropertyDeclaration */ || nextDeclaration.kind === 155 /* 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); @@ -57008,8 +57746,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 152 /* Parameter */ && right.kind === 238 /* VariableDeclaration */) || - (left.kind === 238 /* VariableDeclaration */ && right.kind === 152 /* Parameter */)) { + if ((left.kind === 153 /* Parameter */ && right.kind === 239 /* VariableDeclaration */) || + (left.kind === 239 /* VariableDeclaration */ && right.kind === 153 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -57048,7 +57786,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkTruthinessExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 221 /* EmptyStatement */) { + if (node.thenStatement.kind === 222 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -57075,12 +57813,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 240 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 240 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -57114,14 +57852,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 === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 240 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 189 /* ArrayLiteralExpression */ || varExpr.kind === 190 /* 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. @@ -57153,7 +57891,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 === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 240 /* 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); @@ -57167,7 +57905,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 === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 189 /* ArrayLiteralExpression */ || varExpr.kind === 190 /* 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)) { @@ -57831,12 +58569,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 === 160 /* SetAccessor */) { + if (func.kind === 161 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 158 /* Constructor */) { + else if (func.kind === 159 /* 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); } @@ -57854,7 +58592,7 @@ var ts; } } } - else if (func.kind !== 158 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 159 /* 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); } @@ -57883,7 +58621,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 === 273 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 274 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -57895,7 +58633,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 272 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 273 /* 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. @@ -57924,7 +58662,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 234 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 235 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -58031,8 +58769,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 === 205 /* BinaryExpression */ || - name.kind === 150 /* ComputedPropertyName */ || + (propDeclaration.kind === 206 /* BinaryExpression */ || + name.kind === 151 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -58109,7 +58847,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 165 /* TypeReference */) { + if (node.kind === 166 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -58358,7 +59096,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 241 /* ClassDeclaration */ || d.kind === 242 /* InterfaceDeclaration */; + return d.kind === 242 /* ClassDeclaration */ || d.kind === 243 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -58377,7 +59115,7 @@ var ts; // derived class instance member variables and accessors, but not by other kinds of members. // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfType(baseType); - for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { + basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); if (base.flags & 4194304 /* Prototype */) { @@ -58386,53 +59124,64 @@ var ts; var derived = getTargetSymbol(getPropertyOfObjectType(type, base.escapedName)); // TODO: GH#18217 var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base); ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); - if (derived) { - // In order to resolve whether the inherited method was overridden in the base class or not, - // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* - // type declaration, derived and base resolve to the same symbol even in the case of generic classes. - if (derived === base) { - // derived class inherits base without override/redeclaration - var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); - // It is an error to inherit an abstract member without implementing it or being declared abstract. - // If there is no declaration for the derived class (as in the case of class expressions), - // then the class cannot be declared abstract. - if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 210 /* ClassExpression */) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); - } - else { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + // In order to resolve whether the inherited method was overridden in the base class or not, + // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* + // type declaration, derived and base resolve to the same symbol even in the case of generic classes. + if (derived === base) { + // derived class inherits base without override/redeclaration + var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); + // It is an error to inherit an abstract member without implementing it or being declared abstract. + // If there is no declaration for the derived class (as in the case of class expressions), + // then the class cannot be declared abstract. + if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { + // 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]; + if (otherBaseType === baseType) + continue; + var baseSymbol = getPropertyOfObjectType(otherBaseType, base.escapedName); + var derivedElsewhere = baseSymbol && getTargetSymbol(baseSymbol); + if (derivedElsewhere && derivedElsewhere !== base) { + continue basePropertyCheck; } } - } - else { - // derived overrides base. - var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { - // either base or derived property is private - not override, skip it - continue; - } - if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; + if (derivedClassDecl.kind === 211 /* ClassExpression */) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } - var errorMessage = void 0; - if (isPrototypeProperty(base)) { - if (derived.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } - else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); } - else if (base.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + } + else { + // derived overrides base. + var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); + if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + // either base or derived property is private - not override, skip it + continue; + } + if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { + // method is overridden with method or property/accessor is overridden with property/accessor - correct case + continue; + } + var errorMessage = void 0; + if (isPrototypeProperty(base)) { + if (derived.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } - error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } + else if (base.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } @@ -58489,7 +59238,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 155 /* PropertyDeclaration */ && + return node.kind === 156 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -58513,7 +59262,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 243 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -58618,7 +59367,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -58628,7 +59377,7 @@ var ts; } } break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -58656,7 +59405,7 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return evaluate(expr.expression); case 73 /* Identifier */: var identifier = expr; @@ -58664,20 +59413,18 @@ var ts; return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: + case 191 /* 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 === 190 /* PropertyAccessExpression */) { + if (ex.kind === 191 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { - var argument = ex.argumentExpression; - ts.Debug.assert(ts.isLiteralExpression(argument)); - name = ts.escapeLeadingUnderscores(argument.text); + name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text); } return evaluateEnumMember(expr, type.symbol, name); } @@ -58703,8 +59450,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 73 /* Identifier */ || - node.kind === 190 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 191 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.kind === 191 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 192 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && node.argumentExpression.kind === 10 /* StringLiteral */; } function checkEnumDeclaration(node) { @@ -58739,7 +59486,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 !== 244 /* EnumDeclaration */) { + if (declaration.kind !== 245 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -58762,8 +59509,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 241 /* ClassDeclaration */ || - (declaration.kind === 240 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 242 /* ClassDeclaration */ || + (declaration.kind === 241 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304 /* Ambient */)) { return declaration; } @@ -58826,7 +59573,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, 241 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 242 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -58876,23 +59623,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* 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]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 256 /* ExportAssignment */: + case 257 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 239 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -58903,12 +59650,12 @@ var ts; break; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 240 /* FunctionDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 241 /* FunctionDeclaration */: + case 243 /* InterfaceDeclaration */: + case 246 /* ModuleDeclaration */: + case 244 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -58931,12 +59678,12 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return node; - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: do { node = node.left; } while (node.kind !== 73 /* Identifier */); return node; - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 73 /* Identifier */); @@ -58953,9 +59700,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 256 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 247 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 286 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 257 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -58977,26 +59724,27 @@ var ts; function checkAliasSymbol(node) { var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); - if (target !== unknownSymbol) { - // For external modules symbol represent local symbol for an alias. + var shouldSkipWithJSExpandoTargets = symbol.flags & 67108864 /* Assignment */; + if (!shouldSkipWithJSExpandoTargets && target !== unknownSymbol) { + // For external modules symbol represents local symbol for an alias. // This local symbol will merge any other local declarations (excluding other aliases) // and symbol.flags will contains combined representation for all merged declaration. // Based on symbol.flags we can compute a set of excluded meanings (meaning that resolved alias should not have, // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export* // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). - var excludedMeanings = (symbol.flags & (67220415 /* Value */ | 1048576 /* ExportValue */) ? 67220415 /* Value */ : 0) | - (symbol.flags & 67897832 /* Type */ ? 67897832 /* Type */ : 0) | + var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | + (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 258 /* ExportSpecifier */ ? + var message = node.kind === 259 /* 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 === 258 /* ExportSpecifier */ - && !(target.flags & 67220415 /* Value */) + && node.kind === 259 /* ExportSpecifier */ + && !(target.flags & 111551 /* Value */) && !(node.flags & 4194304 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); } @@ -59022,7 +59770,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 253 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -59046,17 +59794,17 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 261 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 67220415 /* Value */) { + if (target.flags & 111551 /* Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name var moduleName = getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 67220415 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { + if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 67897832 /* Type */) { + if (target.flags & 788968 /* Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } @@ -59082,10 +59830,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 246 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 247 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 247 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 286 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -59102,7 +59850,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 285 /* SourceFile */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 245 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 286 /* SourceFile */ || node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 246 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -59116,13 +59864,17 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) - var symbol = resolveName(exportedName, exportedName.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || 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 { markExportAsReferenced(node); + var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) { + checkExpressionCached(node.propertyName || node.name); + } } } } @@ -59131,8 +59883,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 286 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 246 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -59146,7 +59898,17 @@ var ts; grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 73 /* Identifier */) { - markExportAsReferenced(node); + var id = node.expression; + var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); + if (sym) { + markAliasReferenced(sym, id); + // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`) + var target = sym.flags & 2097152 /* Alias */ ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551 /* Value */) { + // However if it is a value, we need to check it's being used correctly + checkExpressionCached(node.expression); + } + } if (ts.getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression, /*setVisibility*/ true); } @@ -59215,14 +59977,6 @@ var ts; links.exportsChecked = true; } } - function isNotAccessor(declaration) { - // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks - return !ts.isAccessor(declaration); - } - function isNotOverload(declaration) { - return (declaration.kind !== 240 /* FunctionDeclaration */ && declaration.kind !== 157 /* MethodDeclaration */) || - !!declaration.body; - } function checkSourceElement(node) { if (node) { var saveCurrentNode = currentNode; @@ -59244,158 +59998,159 @@ 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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 241 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return checkTypeParameter(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return checkParameter(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return checkPropertyDeclaration(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: return checkSignatureDeclaration(node); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: return checkMethodDeclaration(node); - case 158 /* Constructor */: + case 159 /* Constructor */: return checkConstructorDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return checkAccessorDeclaration(node); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return checkTypeReferenceNode(node); - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return checkTypePredicate(node); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return checkTypeQuery(node); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return checkTypeLiteral(node); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return checkArrayType(node); - case 171 /* TupleType */: + case 172 /* TupleType */: return checkTupleType(node); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 178 /* ParenthesizedType */: - case 172 /* OptionalType */: - case 173 /* RestType */: + case 179 /* ParenthesizedType */: + case 173 /* OptionalType */: + case 174 /* RestType */: return checkSourceElement(node.type); - case 179 /* ThisType */: + case 180 /* ThisType */: return checkThisType(node); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: return checkTypeOperator(node); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return checkConditionalType(node); - case 177 /* InferType */: + case 178 /* InferType */: return checkInferType(node); - case 184 /* ImportType */: + case 185 /* ImportType */: return checkImportType(node); - case 301 /* JSDocAugmentsTag */: + case 303 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 309 /* JSDocTypeTag */: + case 311 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 306 /* JSDocParameterTag */: + case 308 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: - case 298 /* JSDocTypeLiteral */: + case 294 /* JSDocNonNullableType */: + case 293 /* JSDocNullableType */: + case 291 /* JSDocAllType */: + case 292 /* JSDocUnknownType */: + case 300 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 296 /* JSDocVariadicType */: + case 297 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 289 /* JSDocTypeExpression */: + case 290 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 182 /* MappedType */: + case 183 /* MappedType */: return checkMappedType(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 220 /* Block */: + case 247 /* ModuleBlock */: return checkBlock(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return checkVariableStatement(node); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return checkExpressionStatement(node); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return checkIfStatement(node); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return checkDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return checkWhileStatement(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return checkForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return checkForInStatement(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return checkForOfStatement(node); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 230 /* ContinueStatement */: + case 231 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return checkReturnStatement(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return checkWithStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return checkSwitchStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return checkLabeledStatement(node); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return checkThrowStatement(node); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return checkTryStatement(node); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return checkBindingElement(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return checkClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return checkImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return checkExportDeclaration(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return checkExportAssignment(node); - case 221 /* EmptyStatement */: - case 237 /* DebuggerStatement */: + case 222 /* EmptyStatement */: + case 238 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 259 /* MissingDeclaration */: + case 260 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -59490,23 +60245,23 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 261 /* JsxElement */: + case 262 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -59636,35 +60391,35 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; // falls through - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - // falls through // this fall-through is necessary because we would like to handle - // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. + // falls through + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!isStatic) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67897832 /* Type */); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -59712,11 +60467,11 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 151 /* TypeParameter */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 152 /* TypeParameter */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 245 /* EnumDeclaration */: return true; default: return false; @@ -59724,16 +60479,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 150 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 165 /* TypeReference */; + return node.parent.kind === 166 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 190 /* PropertyAccessExpression */) { + while (node.parent.kind === 191 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 212 /* ExpressionWithTypeArguments */; + return node.parent.kind === 213 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -59761,13 +60516,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 149 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 150 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 249 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 250 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 255 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 256 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -59793,7 +60548,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 184 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 185 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -59803,7 +60558,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 190 /* PropertyAccessExpression */ && + entityName.parent.kind === 191 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -59811,17 +60566,17 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 255 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 256 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, - /*all meanings*/ 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); + /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); if (success && success !== unknownSymbol) { return success; } } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 249 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 250 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -59839,11 +60594,11 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 212 /* ExpressionWithTypeArguments */) { - meaning = 67897832 /* Type */; + if (entityName.parent.kind === 213 /* ExpressionWithTypeArguments */) { + meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { - meaning |= 67220415 /* Value */; + meaning |= 111551 /* Value */; } } else { @@ -59855,10 +60610,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 306 /* JSDocParameterTag */) { + if (entityName.parent.kind === 308 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 151 /* TypeParameter */ && entityName.parent.parent.kind === 310 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 152 /* TypeParameter */ && entityName.parent.parent.kind === 312 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -59873,14 +60628,14 @@ var ts; var symbol = getIntrinsicTagSymbol(entityName.parent); return symbol === unknownSymbol ? undefined : symbol; } - return resolveEntityName(entityName, 67220415 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); + return resolveEntityName(entityName, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 190 /* PropertyAccessExpression */ || entityName.kind === 149 /* QualifiedName */) { + else if (entityName.kind === 191 /* PropertyAccessExpression */ || entityName.kind === 150 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 190 /* PropertyAccessExpression */) { + if (entityName.kind === 191 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -59890,17 +60645,17 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 165 /* TypeReference */ ? 67897832 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 166 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - if (entityName.parent.kind === 164 /* TypePredicate */) { + if (entityName.parent.kind === 165 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -59923,8 +60678,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 187 /* BindingElement */ && - grandParent.kind === 185 /* ObjectBindingPattern */ && + else if (parent.kind === 188 /* BindingElement */ && + grandParent.kind === 186 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -59935,8 +60690,8 @@ var ts; } switch (node.kind) { case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 191 /* PropertyAccessExpression */: + case 150 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 101 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); @@ -59950,14 +60705,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 179 /* ThisType */: + case 180 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; case 99 /* SuperKeyword */: return checkExpression(node).symbol; case 125 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 158 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 159 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -59968,7 +60723,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 === 250 /* ImportDeclaration */ || node.parent.kind === 256 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 251 /* ImportDeclaration */ || node.parent.kind === 257 /* 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); @@ -59990,7 +60745,7 @@ var ts; case 37 /* EqualsGreaterThanToken */: case 77 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 184 /* ImportType */: + case 185 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; case 86 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; @@ -59999,8 +60754,8 @@ var ts; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 277 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 67220415 /* Value */ | 2097152 /* Alias */); + if (location && location.kind === 278 /* ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; } @@ -60008,7 +60763,7 @@ var ts; function getExportSpecifierLocalTargetSymbol(node) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } function getTypeOfNode(node) { if (node.flags & 8388608 /* InWithStatement */) { @@ -60067,27 +60822,27 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 189 /* ObjectLiteralExpression */ || expr.kind === 188 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 190 /* ObjectLiteralExpression */ || expr.kind === 189 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 228 /* ForOfStatement */) { + if (expr.parent.kind === 229 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 205 /* BinaryExpression */) { + if (expr.parent.kind === 206 /* 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 === 276 /* 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); + if (expr.parent.kind === 277 /* PropertyAssignment */) { + var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); + var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType; + var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex); } // Array literal assignment - array destructuring pattern var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); @@ -60131,7 +60886,7 @@ var ts; case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: @@ -60188,7 +60943,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 191 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -60209,13 +60964,13 @@ var ts; // for export assignments - check if resolved symbol for RHS is itself a value // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 67220415 /* Value */) + ? !!(moduleSymbol.flags & 111551 /* Value */) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 67220415 /* Value */); + return s && !!(s.flags & 111551 /* Value */); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -60244,7 +60999,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 285 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 286 /* 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. @@ -60264,7 +61019,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 67220415 /* Value */)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -60272,7 +61027,7 @@ var ts; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 276 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { @@ -60281,7 +61036,7 @@ var ts; var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { + if (resolveName(container.parent, symbol.escapedName, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } @@ -60303,7 +61058,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 === 219 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 220 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -60344,26 +61099,25 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 250 /* ImportEqualsDeclaration */: + case 252 /* ImportClause */: + case 253 /* NamespaceImport */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 255 /* ExportAssignment */: - return node.expression - && node.expression.kind === 73 /* Identifier */ - ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) - : true; + case 256 /* ExportAssignment */: + return node.expression && node.expression.kind === 73 /* Identifier */ ? + isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : + true; } return false; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 285 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 286 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -60377,7 +61131,7 @@ var ts; } // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true - return !!(target.flags & 67220415 /* Value */) && + return !!(target.flags & 111551 /* Value */) && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -60391,7 +61145,7 @@ var ts; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 if (target && ts.getModifierFlags(node) & 1 /* Export */ && - target.flags & 67220415 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { + target.flags & 111551 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -60445,7 +61199,7 @@ var ts; if (!symbol || !(symbol.flags & 16 /* Function */)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 67220415 /* Value */ && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -60464,15 +61218,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 279 /* EnumMember */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 280 /* EnumMember */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 279 /* EnumMember */) { + if (node.kind === 280 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -60499,9 +61253,9 @@ var ts; return ts.TypeReferenceSerializationKind.Unknown; } // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. - var valueSymbol = resolveEntityName(typeName, 67220415 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 67897832 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (valueSymbol && valueSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { @@ -60606,7 +61360,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + return resolveName(location, reference.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -60627,7 +61381,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 67220415 /* Value */, enclosing, /*flags*/ undefined, tracker) + var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse(); return enumResult || ts.createLiteral(type.value); } @@ -60708,12 +61462,12 @@ var ts; getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 160 /* SetAccessor */ ? 159 /* GetAccessor */ : 160 /* SetAccessor */; + var otherKind = accessor.kind === 161 /* SetAccessor */ ? 160 /* GetAccessor */ : 161 /* 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 === 160 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 159 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 161 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 160 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -60729,7 +61483,7 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 212 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 274 /* HeritageClause */; + return node.parent && node.parent.kind === 213 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 275 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -60740,9 +61494,9 @@ var ts; // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = 67897832 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 73 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 190 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { - meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; + var meaning = 788968 /* Type */ | 1920 /* Namespace */; + if ((node.kind === 73 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 191 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -60792,7 +61546,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 285 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 286 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -60820,12 +61574,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 245 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 246 /* 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, 285 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 286 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -60965,7 +61719,7 @@ var ts; for (var helper = 1 /* FirstEmitHelper */; helper <= 131072 /* LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 67220415 /* Value */); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); if (!symbol) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); } @@ -61014,14 +61768,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 157 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 158 /* 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 === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */) { + else if (node.kind === 160 /* GetAccessor */ || node.kind === 161 /* 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); @@ -61039,16 +61793,16 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 134 /* ReadonlyKeyword */) { - if (node.kind === 154 /* PropertySignature */ || node.kind === 156 /* MethodSignature */) { + if (node.kind === 155 /* PropertySignature */ || node.kind === 157 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 164 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 78 /* ConstKeyword */: - if (node.kind !== 244 /* EnumDeclaration */) { + if (node.kind !== 245 /* EnumDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(78 /* ConstKeyword */)); } break; @@ -61068,7 +61822,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 === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 286 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -61091,10 +61845,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 286 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 153 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -61107,7 +61861,7 @@ var ts; if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */ && node.kind !== 163 /* IndexSignature */ && node.kind !== 152 /* Parameter */) { + else if (node.kind !== 156 /* PropertyDeclaration */ && node.kind !== 155 /* PropertySignature */ && node.kind !== 164 /* IndexSignature */ && node.kind !== 153 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report 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); } @@ -61127,17 +61881,17 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 153 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; case 81 /* DefaultKeyword */: - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 286 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 246 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; @@ -61149,13 +61903,13 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 153 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 246 /* ModuleBlock */) { + else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 247 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -61165,14 +61919,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 241 /* ClassDeclaration */) { - if (node.kind !== 157 /* MethodDeclaration */ && - node.kind !== 155 /* PropertyDeclaration */ && - node.kind !== 159 /* GetAccessor */ && - node.kind !== 160 /* SetAccessor */) { + if (node.kind !== 242 /* ClassDeclaration */) { + if (node.kind !== 158 /* MethodDeclaration */ && + node.kind !== 156 /* PropertyDeclaration */ && + node.kind !== 160 /* GetAccessor */ && + node.kind !== 161 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 241 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 242 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -61191,7 +61945,7 @@ var ts; else if (flags & 2 /* Ambient */ || node.parent.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 153 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -61199,7 +61953,7 @@ var ts; break; } } - if (node.kind === 158 /* Constructor */) { + if (node.kind === 159 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -61214,13 +61968,13 @@ var ts; } return false; } - else if ((node.kind === 250 /* ImportDeclaration */ || node.kind === 249 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 251 /* ImportDeclaration */ || node.kind === 250 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 153 /* Parameter */ && (flags & 92 /* 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 === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 153 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -61241,37 +61995,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 245 /* ModuleDeclaration */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 152 /* Parameter */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 159 /* Constructor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 164 /* IndexSignature */: + case 246 /* ModuleDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 257 /* ExportDeclaration */: + case 256 /* ExportAssignment */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 153 /* Parameter */: return false; default: - if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 286 /* SourceFile */) { return false; } switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 122 /* AsyncKeyword */); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 119 /* AbstractKeyword */); - case 242 /* InterfaceDeclaration */: - case 220 /* VariableStatement */: - case 243 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 221 /* VariableStatement */: + case 244 /* TypeAliasDeclaration */: return true; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 78 /* ConstKeyword */); default: ts.Debug.fail(); @@ -61284,10 +62038,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -61350,7 +62104,7 @@ var ts; ts.addRelatedInfo(error(parameter, ts.Diagnostics.This_parameter_is_not_allowed_with_use_strict_directive), ts.createDiagnosticForNode(useStrictDirective_1, ts.Diagnostics.use_strict_directive_used_here)); }); var diagnostics_1 = nonSimpleParameters.map(function (parameter, index) { return (index === 0 ? ts.createDiagnosticForNode(parameter, ts.Diagnostics.Non_simple_parameter_declared_here) : ts.createDiagnosticForNode(parameter, ts.Diagnostics.and_here)); }); - ts.addRelatedInfo.apply(void 0, [error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)].concat(diagnostics_1)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)], diagnostics_1)); return true; } } @@ -61438,7 +62192,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 === 211 /* OmittedExpression */) { + if (arg.kind === 212 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -61515,20 +62269,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 150 /* ComputedPropertyName */) { + if (node.kind !== 151 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 205 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 206 /* 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 === 240 /* FunctionDeclaration */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 157 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 241 /* FunctionDeclaration */ || + node.kind === 198 /* FunctionExpression */ || + node.kind === 158 /* MethodDeclaration */); if (node.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -61544,17 +62298,10 @@ var ts; return !!exclamationToken && grammarErrorOnNode(exclamationToken, message); } function checkGrammarObjectLiteralExpression(node, inDestructuring) { - var Flags; - (function (Flags) { - Flags[Flags["Property"] = 1] = "Property"; - Flags[Flags["GetAccessor"] = 2] = "GetAccessor"; - Flags[Flags["SetAccessor"] = 4] = "SetAccessor"; - Flags[Flags["GetOrSetAccessor"] = 6] = "GetOrSetAccessor"; - })(Flags || (Flags = {})); var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */) { + if (prop.kind === 279 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -61565,11 +62312,11 @@ var ts; continue; } var name = prop.name; - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 151 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 277 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 278 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -61578,7 +62325,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 157 /* MethodDeclaration */) { + if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 158 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -61593,24 +62340,25 @@ 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 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); - /* tslint:disable:no-switch-case-fall-through */ - case 276 /* PropertyAssignment */: + // falls through + case 277 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name); } - // falls through - case 157 /* MethodDeclaration */: - currentKind = 1 /* Property */; + currentKind = 4 /* PropertyAssignment */; + break; + case 158 /* MethodDeclaration */: + currentKind = 8 /* Method */; break; - case 159 /* GetAccessor */: - currentKind = 2 /* GetAccessor */; + case 160 /* GetAccessor */: + currentKind = 1 /* GetAccessor */; break; - case 160 /* SetAccessor */: - currentKind = 4 /* SetAccessor */; + case 161 /* SetAccessor */: + currentKind = 2 /* SetAccessor */; break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); @@ -61624,11 +62372,11 @@ var ts; seen.set(effectiveName, currentKind); } else { - if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { + if ((currentKind & 12 /* PropertyAssignmentOrMethod */) && (existingKind & 12 /* PropertyAssignmentOrMethod */)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 6 /* GetOrSetAccessor */) && (existingKind & 6 /* GetOrSetAccessor */)) { - if (existingKind !== 6 /* GetOrSetAccessor */ && currentKind !== existingKind) { + else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) { + if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -61646,7 +62394,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 270 /* JsxSpreadAttribute */) { + if (attr.kind === 271 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -61656,7 +62404,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 271 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 272 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -61670,14 +62418,14 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 228 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 229 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { // use of 'for-await-of' in non-async function var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 159 /* 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); @@ -61688,7 +62436,7 @@ var ts; return false; } } - if (forInOrOfStatement.initializer.kind === 239 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 240 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -61703,20 +62451,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 228 /* 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 === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 228 /* 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 === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 228 /* 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); @@ -61726,42 +62474,38 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - var kind = accessor.kind; - if (languageVersion < 1 /* ES5 */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (accessor.flags & 4194304 /* Ambient */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); - } - else if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { - return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + if (!(accessor.flags & 4194304 /* Ambient */)) { + if (languageVersion < 1 /* ES5 */) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { + return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + } } - else if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { + if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - else if (accessor.typeParameters) { + if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 159 /* GetAccessor */ ? + if (!doesAccessorHaveCorrectParameterCount(accessor)) { + return grammarErrorOnNode(accessor.name, accessor.kind === 160 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 160 /* SetAccessor */) { + if (accessor.kind === 161 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } - else { - var parameter = accessor.parameters[0]; - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); - } - else if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); - } - else if (parameter.initializer) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); - } + var parameter = ts.Debug.assertDefined(ts.getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion."); + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); + } + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); + } + if (parameter.initializer) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); } } return false; @@ -61771,10 +62515,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 === 159 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 160 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 159 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 160 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -61785,7 +62529,7 @@ var ts; } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: var decl = parent; if (decl.name.kind !== 73 /* Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); @@ -61797,13 +62541,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: if (!ts.hasModifier(parent, 32 /* Static */) || !ts.hasModifier(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 154 /* PropertySignature */: + case 155 /* PropertySignature */: if (!ts.hasModifier(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); } @@ -61813,7 +62557,7 @@ var ts; } } else if (node.operator === 134 /* ReadonlyKeyword */) { - if (node.type.kind !== 170 /* ArrayType */ && node.type.kind !== 171 /* TupleType */) { + if (node.type.kind !== 171 /* ArrayType */ && node.type.kind !== 172 /* TupleType */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(140 /* SymbolKeyword */)); } } @@ -61827,8 +62571,8 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 157 /* MethodDeclaration */) { - if (node.parent.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 158 /* MethodDeclaration */) { + if (node.parent.kind === 190 /* 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 === 122 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -61856,14 +62600,14 @@ var ts; if (node.flags & 4194304 /* 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 === 157 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 158 /* 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 === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 243 /* 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 === 169 /* TypeLiteral */) { + else if (node.parent.kind === 170 /* 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); } } @@ -61874,11 +62618,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 234 /* LabeledStatement */: + case 235 /* 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 === 229 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 230 /* 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); @@ -61886,8 +62630,8 @@ var ts; return false; } break; - case 233 /* SwitchStatement */: - if (node.kind === 230 /* BreakStatement */ && !node.label) { + case 234 /* SwitchStatement */: + if (node.kind === 231 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -61902,13 +62646,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 230 /* BreakStatement */ + var message = node.kind === 231 /* 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 === 230 /* BreakStatement */ + var message = node.kind === 231 /* 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); @@ -61932,12 +62676,12 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 10 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.kind === 204 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.kind === 204 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -61967,7 +62711,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 227 /* ForInStatement */ && node.parent.parent.kind !== 228 /* ForOfStatement */) { + if (node.parent.parent.kind !== 228 /* ForInStatement */ && node.parent.parent.kind !== 229 /* ForOfStatement */) { if (node.flags & 4194304 /* Ambient */) { checkAmbientInitializer(node); } @@ -61980,7 +62724,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 220 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 221 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && @@ -62042,15 +62786,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 224 /* IfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 233 /* WithStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: return false; - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -62131,7 +62875,7 @@ var ts; return true; } } - else if (node.parent.kind === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 243 /* 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; } @@ -62139,7 +62883,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 169 /* TypeLiteral */) { + else if (node.parent.kind === 170 /* 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; } @@ -62168,13 +62912,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 243 /* TypeAliasDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 256 /* ExportDeclaration */ || - node.kind === 255 /* ExportAssignment */ || - node.kind === 248 /* NamespaceExportDeclaration */ || + if (node.kind === 243 /* InterfaceDeclaration */ || + node.kind === 244 /* TypeAliasDeclaration */ || + node.kind === 251 /* ImportDeclaration */ || + node.kind === 250 /* ImportEqualsDeclaration */ || + node.kind === 257 /* ExportDeclaration */ || + node.kind === 256 /* ExportAssignment */ || + node.kind === 249 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -62183,7 +62927,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 === 220 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 221 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -62196,13 +62940,9 @@ var ts; } function checkGrammarStatementInAmbientContext(node) { if (node.flags & 4194304 /* Ambient */) { - // An accessors is already reported about the ambient context - if (ts.isAccessor(node.parent)) { - return getNodeLinks(node).hasReportedStatementInAmbientContext = true; - } // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); - if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { + if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } // We are either parented by another statement, or some sort of block. @@ -62210,7 +62950,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 === 219 /* Block */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 220 /* Block */ || node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 286 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -62232,10 +62972,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, 183 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 184 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 279 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 280 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -62244,8 +62984,27 @@ var ts; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + // Realism (size) checking + checkNumericLiteralValueSize(node); return false; } + function checkNumericLiteralValueSize(node) { + // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint + // Literals with 15 or fewer characters aren't long enough to reach past 2^53 - 1 + // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway + if (node.numericLiteralFlags & 16 /* Scientific */ || node.text.length <= 15 || node.text.indexOf(".") !== -1) { + return; + } + // We can't rely on the runtime to accurately store and compare extremely large numeric values + // Even for internal use, we use getTextOfNode: https://github.com/microsoft/TypeScript/issues/33298 + // Thus, if the runtime claims a too-large number is lower than Number.MAX_SAFE_INTEGER, + // it's likely addition operations on it will fail too + var apparentValue = +ts.getTextOfNode(node); + if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) { + return; + } + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers)); + } function checkGrammarBigIntLiteral(node) { var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); @@ -62300,11 +63059,19 @@ var ts; } } ts.createTypeChecker = createTypeChecker; + function isNotAccessor(declaration) { + // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks + return !ts.isAccessor(declaration); + } + function isNotOverload(declaration) { + return (declaration.kind !== 241 /* FunctionDeclaration */ && declaration.kind !== 158 /* 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 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -62312,21 +63079,20 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 251 /* ImportClause */: // For default import - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: // For rename import `x as y` + case 252 /* ImportClause */: // For default import + case 250 /* ImportEqualsDeclaration */: + case 253 /* NamespaceImport */: + case 255 /* ImportSpecifier */: // For rename import `x as y` return true; case 73 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 254 /* ImportSpecifier */; + return decl.parent.kind === 255 /* ImportSpecifier */; default: return false; } } var JsxNames; (function (JsxNames) { - // tslint:disable variable-name JsxNames.JSX = "JSX"; JsxNames.IntrinsicElements = "IntrinsicElements"; JsxNames.ElementClass = "ElementClass"; @@ -62336,7 +63102,6 @@ var ts; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; - // tslint:enable variable-name })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { @@ -62407,6 +63172,7 @@ var ts; if (typeof value === "number") { return createNumericLiteral(value + ""); } + // eslint-disable-next-line no-in-operator if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n"); } @@ -62599,7 +63365,7 @@ var ts; ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(149 /* QualifiedName */); + var node = createSynthesizedNode(150 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -62618,7 +63384,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(150 /* ComputedPropertyName */); + var node = createSynthesizedNode(151 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -62631,7 +63397,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(151 /* TypeParameter */); + var node = createSynthesizedNode(152 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -62647,7 +63413,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(152 /* Parameter */); + var node = createSynthesizedNode(153 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -62671,7 +63437,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(153 /* Decorator */); + var node = createSynthesizedNode(154 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -62684,7 +63450,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(154 /* PropertySignature */); + var node = createSynthesizedNode(155 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -62704,7 +63470,7 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(155 /* PropertyDeclaration */); + var node = createSynthesizedNode(156 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62728,7 +63494,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(156 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(157 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -62745,7 +63511,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(157 /* MethodDeclaration */); + var node = createSynthesizedNode(158 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -62773,7 +63539,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(158 /* Constructor */); + var node = createSynthesizedNode(159 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -62793,7 +63559,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(159 /* GetAccessor */); + var node = createSynthesizedNode(160 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62816,7 +63582,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(160 /* SetAccessor */); + var node = createSynthesizedNode(161 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62837,7 +63603,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(161 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(162 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -62845,7 +63611,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(162 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(163 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -62853,7 +63619,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(163 /* IndexSignature */); + var node = createSynthesizedNode(164 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -62893,7 +63659,7 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(164 /* TypePredicate */); + var node = createSynthesizedNode(165 /* TypePredicate */); node.parameterName = asName(parameterName); node.type = type; return node; @@ -62907,7 +63673,7 @@ var ts; } ts.updateTypePredicateNode = updateTypePredicateNode; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(165 /* TypeReference */); + var node = createSynthesizedNode(166 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -62921,7 +63687,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(166 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(167 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -62929,7 +63695,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(167 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(168 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -62937,7 +63703,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(168 /* TypeQuery */); + var node = createSynthesizedNode(169 /* TypeQuery */); node.exprName = exprName; return node; } @@ -62949,7 +63715,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(169 /* TypeLiteral */); + var node = createSynthesizedNode(170 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -62961,7 +63727,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(170 /* ArrayType */); + var node = createSynthesizedNode(171 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -62973,7 +63739,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(171 /* TupleType */); + var node = createSynthesizedNode(172 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -62985,7 +63751,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(172 /* OptionalType */); + var node = createSynthesizedNode(173 /* OptionalType */); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -62997,7 +63763,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(173 /* RestType */); + var node = createSynthesizedNode(174 /* RestType */); node.type = type; return node; } @@ -63009,7 +63775,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(174 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(175 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -63017,7 +63783,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(175 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(176 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -63036,7 +63802,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(176 /* ConditionalType */); + var node = createSynthesizedNode(177 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -63054,7 +63820,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(177 /* InferType */); + var node = createSynthesizedNode(178 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -63066,7 +63832,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(184 /* ImportType */); + var node = createSynthesizedNode(185 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = ts.parenthesizeTypeParameters(typeArguments); @@ -63084,7 +63850,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(178 /* ParenthesizedType */); + var node = createSynthesizedNode(179 /* ParenthesizedType */); node.type = type; return node; } @@ -63096,11 +63862,11 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(179 /* ThisType */); + return createSynthesizedNode(180 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(180 /* TypeOperator */); + var node = createSynthesizedNode(181 /* TypeOperator */); node.operator = typeof operatorOrType === "number" ? operatorOrType : 130 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; @@ -63111,7 +63877,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(181 /* IndexedAccessType */); + var node = createSynthesizedNode(182 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -63125,7 +63891,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(182 /* MappedType */); + var node = createSynthesizedNode(183 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -63143,7 +63909,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(183 /* LiteralType */); + var node = createSynthesizedNode(184 /* LiteralType */); node.literal = literal; return node; } @@ -63156,7 +63922,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(185 /* ObjectBindingPattern */); + var node = createSynthesizedNode(186 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63168,7 +63934,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(186 /* ArrayBindingPattern */); + var node = createSynthesizedNode(187 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63180,7 +63946,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(187 /* BindingElement */); + var node = createSynthesizedNode(188 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -63199,7 +63965,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(188 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(189 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -63213,7 +63979,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(189 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(190 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -63227,7 +63993,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(190 /* PropertyAccessExpression */); + var node = createSynthesizedNode(191 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072 /* NoIndentation */); @@ -63244,7 +64010,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(191 /* ElementAccessExpression */); + var node = createSynthesizedNode(192 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -63258,7 +64024,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(192 /* CallExpression */); + var node = createSynthesizedNode(193 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -63274,7 +64040,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(193 /* NewExpression */); + var node = createSynthesizedNode(194 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -63290,7 +64056,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(194 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(195 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -63313,7 +64079,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(195 /* TypeAssertionExpression */); + var node = createSynthesizedNode(196 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -63327,7 +64093,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(196 /* ParenthesizedExpression */); + var node = createSynthesizedNode(197 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -63339,7 +64105,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(197 /* FunctionExpression */); + var node = createSynthesizedNode(198 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -63363,7 +64129,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(198 /* ArrowFunction */); + var node = createSynthesizedNode(199 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); @@ -63385,7 +64151,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(199 /* DeleteExpression */); + var node = createSynthesizedNode(200 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63397,7 +64163,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(200 /* TypeOfExpression */); + var node = createSynthesizedNode(201 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63409,7 +64175,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(201 /* VoidExpression */); + var node = createSynthesizedNode(202 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63421,7 +64187,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(202 /* AwaitExpression */); + var node = createSynthesizedNode(203 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63433,7 +64199,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(203 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(204 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -63446,7 +64212,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(204 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(205 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -63459,7 +64225,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(205 /* BinaryExpression */); + var node = createSynthesizedNode(206 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -63476,7 +64242,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(206 /* ConditionalExpression */); + var node = createSynthesizedNode(207 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); @@ -63496,7 +64262,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(207 /* TemplateExpression */); + var node = createSynthesizedNode(208 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -63509,32 +64275,91 @@ var ts; : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createTemplateHead(text) { - var node = createSynthesizedNode(15 /* TemplateHead */); + var rawTextScanner; + var invalidValueSentinel = {}; + function getCookedText(kind, rawText) { + if (!rawTextScanner) { + rawTextScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + } + switch (kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + rawTextScanner.setText("`" + rawText + "`"); + break; + case 15 /* TemplateHead */: + rawTextScanner.setText("`" + rawText + "${"); + break; + case 16 /* TemplateMiddle */: + rawTextScanner.setText("}" + rawText + "${"); + break; + case 17 /* TemplateTail */: + rawTextScanner.setText("}" + rawText + "`"); + break; + } + var token = rawTextScanner.scan(); + if (token === 23 /* CloseBracketToken */) { + token = rawTextScanner.reScanTemplateToken(); + } + if (rawTextScanner.isUnterminated()) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + var tokenValue; + switch (token) { + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + tokenValue = rawTextScanner.getTokenValue(); + break; + } + if (rawTextScanner.scan() !== 1 /* EndOfFileToken */) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + rawTextScanner.setText(undefined); + return tokenValue; + } + function createTemplateLiteralLikeNode(kind, text, rawText) { + var node = createSynthesizedNode(kind); + node.text = text; + if (rawText === undefined || text === rawText) { + node.rawText = rawText; + } + else { + var cooked = getCookedText(kind, rawText); + if (typeof cooked === "object") { + return ts.Debug.fail("Invalid raw text"); + } + ts.Debug.assert(text === cooked, "Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'."); + node.rawText = rawText; + } + return node; + } + function createTemplateHead(text, rawText) { + var node = createTemplateLiteralLikeNode(15 /* TemplateHead */, text, rawText); node.text = text; return node; } ts.createTemplateHead = createTemplateHead; - function createTemplateMiddle(text) { - var node = createSynthesizedNode(16 /* TemplateMiddle */); + function createTemplateMiddle(text, rawText) { + var node = createTemplateLiteralLikeNode(16 /* TemplateMiddle */, text, rawText); node.text = text; return node; } ts.createTemplateMiddle = createTemplateMiddle; - function createTemplateTail(text) { - var node = createSynthesizedNode(17 /* TemplateTail */); + function createTemplateTail(text, rawText) { + var node = createTemplateLiteralLikeNode(17 /* TemplateTail */, text, rawText); node.text = text; return node; } ts.createTemplateTail = createTemplateTail; - function createNoSubstitutionTemplateLiteral(text) { - var node = createSynthesizedNode(14 /* NoSubstitutionTemplateLiteral */); - node.text = text; + function createNoSubstitutionTemplateLiteral(text, rawText) { + var node = createTemplateLiteralLikeNode(14 /* NoSubstitutionTemplateLiteral */, text, rawText); return node; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(208 /* YieldExpression */); + var node = createSynthesizedNode(209 /* YieldExpression */); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; @@ -63548,7 +64373,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(209 /* SpreadElement */); + var node = createSynthesizedNode(210 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -63560,7 +64385,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(210 /* ClassExpression */); + var node = createSynthesizedNode(211 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63581,11 +64406,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(211 /* OmittedExpression */); + return createSynthesizedNode(212 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(212 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(213 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -63599,7 +64424,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(213 /* AsExpression */); + var node = createSynthesizedNode(214 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -63613,7 +64438,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(214 /* NonNullExpression */); + var node = createSynthesizedNode(215 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -63625,7 +64450,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(215 /* MetaProperty */); + var node = createSynthesizedNode(216 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -63639,7 +64464,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(217 /* TemplateSpan */); + var node = createSynthesizedNode(218 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -63653,12 +64478,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(218 /* SemicolonClassElement */); + return createSynthesizedNode(219 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(219 /* Block */); + var block = createSynthesizedNode(220 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -63672,7 +64497,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(220 /* VariableStatement */); + var node = createSynthesizedNode(221 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -63687,11 +64512,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(221 /* EmptyStatement */); + return createSynthesizedNode(222 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(222 /* ExpressionStatement */); + var node = createSynthesizedNode(223 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -63707,7 +64532,7 @@ var ts; /** @deprecated Use `updateExpressionStatement` instead. */ ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(223 /* IfStatement */); + var node = createSynthesizedNode(224 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -63723,7 +64548,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(224 /* DoStatement */); + var node = createSynthesizedNode(225 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; return node; @@ -63737,7 +64562,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(225 /* WhileStatement */); + var node = createSynthesizedNode(226 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -63751,7 +64576,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(226 /* ForStatement */); + var node = createSynthesizedNode(227 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -63769,7 +64594,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(227 /* ForInStatement */); + var node = createSynthesizedNode(228 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -63785,7 +64610,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(228 /* ForOfStatement */); + var node = createSynthesizedNode(229 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -63803,7 +64628,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(229 /* ContinueStatement */); + var node = createSynthesizedNode(230 /* ContinueStatement */); node.label = asName(label); return node; } @@ -63815,7 +64640,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(230 /* BreakStatement */); + var node = createSynthesizedNode(231 /* BreakStatement */); node.label = asName(label); return node; } @@ -63827,7 +64652,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(231 /* ReturnStatement */); + var node = createSynthesizedNode(232 /* ReturnStatement */); node.expression = expression; return node; } @@ -63839,7 +64664,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(232 /* WithStatement */); + var node = createSynthesizedNode(233 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -63853,7 +64678,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(233 /* SwitchStatement */); + var node = createSynthesizedNode(234 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -63867,7 +64692,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(234 /* LabeledStatement */); + var node = createSynthesizedNode(235 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); return node; @@ -63881,7 +64706,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(235 /* ThrowStatement */); + var node = createSynthesizedNode(236 /* ThrowStatement */); node.expression = expression; return node; } @@ -63893,7 +64718,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(236 /* TryStatement */); + var node = createSynthesizedNode(237 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -63909,11 +64734,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(237 /* DebuggerStatement */); + return createSynthesizedNode(238 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(238 /* VariableDeclaration */); + var node = createSynthesizedNode(239 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -63930,7 +64755,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* VariableDeclarationList */); + var node = createSynthesizedNode(240 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -63943,7 +64768,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(240 /* FunctionDeclaration */); + var node = createSynthesizedNode(241 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -63969,7 +64794,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(241 /* ClassDeclaration */); + var node = createSynthesizedNode(242 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63991,7 +64816,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(242 /* InterfaceDeclaration */); + var node = createSynthesizedNode(243 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64013,7 +64838,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(243 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(244 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64033,7 +64858,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(244 /* EnumDeclaration */); + var node = createSynthesizedNode(245 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64052,7 +64877,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(245 /* ModuleDeclaration */); + var node = createSynthesizedNode(246 /* ModuleDeclaration */); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -64071,7 +64896,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(246 /* ModuleBlock */); + var node = createSynthesizedNode(247 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -64083,7 +64908,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(247 /* CaseBlock */); + var node = createSynthesizedNode(248 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -64095,7 +64920,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(248 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(249 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -64107,7 +64932,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(249 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(250 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64125,7 +64950,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ImportDeclaration */); + var node = createSynthesizedNode(251 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -64143,7 +64968,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(251 /* ImportClause */); + var node = createSynthesizedNode(252 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -64157,7 +64982,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(252 /* NamespaceImport */); + var node = createSynthesizedNode(253 /* NamespaceImport */); node.name = name; return node; } @@ -64169,7 +64994,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(253 /* NamedImports */); + var node = createSynthesizedNode(254 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -64181,7 +65006,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(254 /* ImportSpecifier */); + var node = createSynthesizedNode(255 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -64195,7 +65020,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(255 /* ExportAssignment */); + var node = createSynthesizedNode(256 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -64212,7 +65037,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(256 /* ExportDeclaration */); + var node = createSynthesizedNode(257 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -64230,7 +65055,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(257 /* NamedExports */); + var node = createSynthesizedNode(258 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -64242,7 +65067,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(258 /* ExportSpecifier */); + var node = createSynthesizedNode(259 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -64257,7 +65082,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(260 /* ExternalModuleReference */); + var node = createSynthesizedNode(261 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -64271,14 +65096,14 @@ var ts; // JSDoc /* @internal */ function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(289 /* JSDocTypeExpression */); + var node = createSynthesizedNode(290 /* JSDocTypeExpression */); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; /* @internal */ function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(309 /* JSDocTypeTag */, "type"); + var tag = createJSDocTag(311 /* JSDocTypeTag */, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64286,7 +65111,7 @@ var ts; ts.createJSDocTypeTag = createJSDocTypeTag; /* @internal */ function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(307 /* JSDocReturnTag */, "returns"); + var tag = createJSDocTag(309 /* JSDocReturnTag */, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64294,14 +65119,14 @@ var ts; ts.createJSDocReturnTag = createJSDocReturnTag; /** @internal */ function createJSDocThisTag(typeExpression) { - var tag = createJSDocTag(308 /* JSDocThisTag */, "this"); + var tag = createJSDocTag(310 /* JSDocThisTag */, "this"); tag.typeExpression = typeExpression; return tag; } ts.createJSDocThisTag = createJSDocThisTag; /* @internal */ function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(306 /* JSDocParameterTag */, "param"); + var tag = createJSDocTag(308 /* JSDocParameterTag */, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -64311,7 +65136,7 @@ var ts; ts.createJSDocParamTag = createJSDocParamTag; /* @internal */ function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(297 /* JSDocComment */); + var node = createSynthesizedNode(299 /* JSDocComment */); node.comment = comment; node.tags = tags; return node; @@ -64325,7 +65150,7 @@ var ts; } // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(261 /* JsxElement */); + var node = createSynthesizedNode(262 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -64341,7 +65166,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(262 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(263 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64357,7 +65182,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(263 /* JsxOpeningElement */); + var node = createSynthesizedNode(264 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64373,7 +65198,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(264 /* JsxClosingElement */); + var node = createSynthesizedNode(265 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -64385,7 +65210,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(265 /* JsxFragment */); + var node = createSynthesizedNode(266 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -64407,11 +65232,11 @@ var ts; } ts.updateJsxText = updateJsxText; function createJsxOpeningFragment() { - return createSynthesizedNode(266 /* JsxOpeningFragment */); + return createSynthesizedNode(267 /* JsxOpeningFragment */); } ts.createJsxOpeningFragment = createJsxOpeningFragment; function createJsxJsxClosingFragment() { - return createSynthesizedNode(267 /* JsxClosingFragment */); + return createSynthesizedNode(268 /* JsxClosingFragment */); } ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment; function updateJsxFragment(node, openingFragment, children, closingFragment) { @@ -64423,7 +65248,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(268 /* JsxAttribute */); + var node = createSynthesizedNode(269 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -64437,7 +65262,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(269 /* JsxAttributes */); + var node = createSynthesizedNode(270 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -64449,7 +65274,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(270 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(271 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -64461,7 +65286,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(271 /* JsxExpression */); + var node = createSynthesizedNode(272 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -64475,7 +65300,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(272 /* CaseClause */); + var node = createSynthesizedNode(273 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -64489,7 +65314,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(273 /* DefaultClause */); + var node = createSynthesizedNode(274 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -64501,7 +65326,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(274 /* HeritageClause */); + var node = createSynthesizedNode(275 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -64514,7 +65339,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(275 /* CatchClause */); + var node = createSynthesizedNode(276 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -64529,7 +65354,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(276 /* PropertyAssignment */); + var node = createSynthesizedNode(277 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -64544,7 +65369,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(277 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(278 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -64558,7 +65383,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(278 /* SpreadAssignment */); + var node = createSynthesizedNode(279 /* SpreadAssignment */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -64571,7 +65396,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(279 /* EnumMember */); + var node = createSynthesizedNode(280 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -64592,7 +65417,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(285 /* SourceFile */); + var updated = createSynthesizedNode(286 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -64676,7 +65501,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(314 /* NotEmittedStatement */); + var node = createSynthesizedNode(316 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -64688,7 +65513,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(318 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(320 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -64700,7 +65525,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(317 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(319 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -64715,7 +65540,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(315 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(317 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -64731,7 +65556,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 316 /* CommaListExpression */) { + if (node.kind === 318 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { @@ -64741,7 +65566,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(316 /* CommaListExpression */); + var node = createSynthesizedNode(318 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -64754,7 +65579,7 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(286 /* Bundle */); + var node = ts.createNode(287 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -64785,7 +65610,7 @@ var ts; ], function (helper) { return helper.name; })); } function createUnparsedSource() { - var node = ts.createNode(287 /* UnparsedSource */); + var node = ts.createNode(288 /* UnparsedSource */); node.prologues = ts.emptyArray; node.referencedFiles = ts.emptyArray; node.libReferenceDirectives = ts.emptyArray; @@ -64917,10 +65742,10 @@ var ts; } function mapBundleFileSectionKindToSyntaxKind(kind) { switch (kind) { - case "prologue" /* Prologue */: return 280 /* UnparsedPrologue */; - case "prepend" /* Prepend */: return 281 /* UnparsedPrepend */; - case "internal" /* Internal */: return 283 /* UnparsedInternalText */; - case "text" /* Text */: return 282 /* UnparsedText */; + case "prologue" /* Prologue */: return 281 /* UnparsedPrologue */; + case "prepend" /* Prepend */: return 282 /* UnparsedPrepend */; + case "internal" /* Internal */: return 284 /* UnparsedInternalText */; + case "text" /* Text */: return 283 /* UnparsedText */; case "emitHelpers" /* EmitHelpers */: case "no-default-lib" /* NoDefaultLib */: case "reference" /* Reference */: @@ -64938,14 +65763,14 @@ var ts; return node; } function createUnparsedSyntheticReference(section, parent) { - var node = ts.createNode(284 /* UnparsedSyntheticReference */, section.pos, section.end); + var node = ts.createNode(285 /* UnparsedSyntheticReference */, section.pos, section.end); node.parent = parent; node.data = section.data; node.section = section; return node; } function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { - var node = ts.createNode(288 /* InputFiles */); + var node = ts.createNode(289 /* InputFiles */); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -64991,8 +65816,8 @@ var ts; node.declarationMapPath = declarationMapPath; node.declarationMapText = declarationMapTextOrBuildInfoPath; node.javascriptPath = javascriptPath; - node.declarationPath = declarationPath, - node.buildInfoPath = buildInfoPath; + node.declarationPath = declarationPath; + node.buildInfoPath = buildInfoPath; node.buildInfo = buildInfo; node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } @@ -65135,7 +65960,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 === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -65200,7 +66025,6 @@ var ts; return node; } ts.setSourceMapRange = setSourceMapRange; - // tslint:disable-next-line variable-name var SourceMapSource; /** * Create an external source map source file reference @@ -65486,9 +66310,9 @@ var ts; ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createFunctionCall(func, thisArg, argumentsList, location) { return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ thisArg - ].concat(argumentsList)), location); + ], argumentsList)), location); } ts.createFunctionCall = createFunctionCall; function createFunctionApply(func, thisArg, argumentsExpression, location) { @@ -65589,29 +66413,34 @@ var ts; } ts.createExpressionForJsxFragment = createExpressionForJsxFragment; // Helpers - function getHelperName(name) { + /** + * Gets an identifier for the name of an *unscoped* emit helper. + */ + function getUnscopedHelperName(name) { return ts.setEmitFlags(ts.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } - ts.getHelperName = getHelperName; + ts.getUnscopedHelperName = getUnscopedHelperName; ts.valuesHelper = { name: "typescript:values", + importName: "__values", scoped: false, - text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };" + text: "\n var __values = (this && this.__values) || function(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n };" }; function createValuesHelper(context, expression, location) { context.requestEmitHelper(ts.valuesHelper); - return ts.setTextRange(ts.createCall(getHelperName("__values"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__values"), /*typeArguments*/ undefined, [expression]), location); } ts.createValuesHelper = createValuesHelper; ts.readHelper = { name: "typescript:read", + importName: "__read", scoped: false, text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };" }; function createReadHelper(context, iteratorRecord, count, location) { context.requestEmitHelper(ts.readHelper); - return ts.setTextRange(ts.createCall(getHelperName("__read"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__read"), /*typeArguments*/ undefined, count !== undefined ? [iteratorRecord, ts.createLiteral(count)] : [iteratorRecord]), location); @@ -65619,24 +66448,26 @@ var ts; ts.createReadHelper = createReadHelper; ts.spreadHelper = { name: "typescript:spread", + importName: "__spread", scoped: false, text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" }; function createSpreadHelper(context, argumentList, location) { context.requestEmitHelper(ts.readHelper); context.requestEmitHelper(ts.spreadHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spread"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spread"), /*typeArguments*/ undefined, argumentList), location); } ts.createSpreadHelper = createSpreadHelper; ts.spreadArraysHelper = { name: "typescript:spreadArrays", + importName: "__spreadArrays", scoped: false, text: "\n var __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n };" }; function createSpreadArraysHelper(context, argumentList, location) { context.requestEmitHelper(ts.spreadArraysHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spreadArrays"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spreadArrays"), /*typeArguments*/ undefined, argumentList), location); } ts.createSpreadArraysHelper = createSpreadArraysHelper; @@ -65658,7 +66489,7 @@ var ts; ts.createForOfBindingStatement = createForOfBindingStatement; function insertLeadingStatement(dest, source) { if (ts.isBlock(dest)) { - return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray([source].concat(dest.statements)), dest.statements)); + return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray(__spreadArrays([source], dest.statements)), dest.statements)); } else { return ts.createBlock(ts.createNodeArray([dest, source]), /*multiLine*/ true); @@ -65669,7 +66500,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 234 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 235 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -65688,13 +66519,13 @@ var ts; case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -65721,7 +66552,7 @@ var ts; } else { switch (callee.kind) { - case 190 /* PropertyAccessExpression */: { + case 191 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -65734,7 +66565,7 @@ var ts; } break; } - case 191 /* ElementAccessExpression */: { + case 192 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -65791,14 +66622,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -66105,9 +66936,9 @@ var ts; function ensureUseStrict(statements) { var foundUseStrict = findUseStrictPrologue(statements); if (!foundUseStrict) { - return ts.setTextRange(ts.createNodeArray([ + return ts.setTextRange(ts.createNodeArray(__spreadArrays([ startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) - ].concat(statements)), statements); + ], statements)), statements); } return statements; } @@ -66124,7 +66955,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 === 196 /* ParenthesizedExpression */) { + if (skipped.kind === 197 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -66158,10 +66989,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(205 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(205 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(206 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(206 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 198 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 199 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -66173,7 +67004,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 208 /* YieldExpression */) { + && operand.kind === 209 /* YieldExpression */) { return false; } return true; @@ -66261,22 +67092,20 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { + if (node.kind === 206 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0 /* Unknown */; + var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind : + 0 /* Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(206 /* ConditionalExpression */, 56 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(207 /* ConditionalExpression */, 56 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -66311,8 +67140,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: + case 211 /* ClassExpression */: + case 198 /* FunctionExpression */: needsParens = true; } } @@ -66328,9 +67157,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 192 /* CallExpression */: + case 193 /* CallExpression */: return ts.createParen(expression); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -66353,7 +67182,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 193 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 194 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -66391,7 +67220,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(205 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(206 /* BinaryExpression */, 27 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -66402,29 +67231,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 197 /* FunctionExpression */ || kind === 198 /* ArrowFunction */) { + if (kind === 198 /* FunctionExpression */ || kind === 199 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 189 /* ObjectLiteralExpression */ || leftmostExpressionKind === 197 /* FunctionExpression */) { + if (leftmostExpressionKind === 190 /* ObjectLiteralExpression */ || leftmostExpressionKind === 198 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 176 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 177 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -66432,9 +67261,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 168 /* TypeQuery */: - case 180 /* TypeOperator */: - case 177 /* InferType */: + case 169 /* TypeQuery */: + case 181 /* TypeOperator */: + case 178 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -66460,28 +67289,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: node = node.operand; continue; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: node = node.left; continue; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: node = node.condition; continue; - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: node = node.tag; continue; - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 213 /* AsExpression */: - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: - case 214 /* NonNullExpression */: - case 315 /* PartiallyEmittedExpression */: + case 214 /* AsExpression */: + case 192 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 215 /* NonNullExpression */: + case 317 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -66490,15 +67319,15 @@ var ts; } ts.getLeftmostExpression = getLeftmostExpression; function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 189 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 190 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 316 /* CommaListExpression */; + return node.kind === 206 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 318 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -66511,13 +67340,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 214 /* NonNullExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: + case 215 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -66542,7 +67371,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 214 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 215 /* NonNullExpression */) { node = node.expression; } return node; @@ -66550,11 +67379,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 196 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 195 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 213 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 214 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 315 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 197 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 196 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 214 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 215 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 317 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -66572,7 +67401,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 196 /* ParenthesizedExpression */ + return node.kind === 197 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -66597,6 +67426,60 @@ var ts; return emitNode && emitNode.externalHelpersModuleName; } ts.getExternalHelpersModuleName = getExternalHelpersModuleName; + function hasRecordedExternalHelpers(sourceFile) { + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = parseNode && parseNode.emitNode; + return !!emitNode && (!!emitNode.externalHelpersModuleName || !!emitNode.externalHelpers); + } + ts.hasRecordedExternalHelpers = hasRecordedExternalHelpers; + function createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault) { + if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + var namedBindings = void 0; + var moduleKind = ts.getEmitModuleKind(compilerOptions); + if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) { + // use named imports + var helpers = ts.getEmitHelpers(sourceFile); + if (helpers) { + var helperNames = []; + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; + if (!helper.scoped) { + var importName = helper.importName; + if (importName) { + ts.pushIfUnique(helperNames, importName); + } + } + } + if (ts.some(helperNames)) { + helperNames.sort(ts.compareStringsCaseSensitive); + // Alias the imports if the names are used somewhere in the file. + // NOTE: We don't need to care about global import collisions as this is a module. + namedBindings = ts.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name) + ? ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name)) + : ts.createImportSpecifier(ts.createIdentifier(name), getUnscopedHelperName(name)); })); + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = ts.getOrCreateEmitNode(parseNode); + emitNode.externalHelpers = true; + } + } + } + else { + // use a namespace import + var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar || hasImportDefault); + if (externalHelpersModuleName) { + namedBindings = ts.createNamespaceImport(externalHelpersModuleName); + } + } + if (namedBindings) { + var externalHelpersImportDeclaration = ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, namedBindings), ts.createLiteral(ts.externalHelpersModuleNameText)); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); + return externalHelpersImportDeclaration; + } + } + } + ts.createExternalHelpersImportDeclarationIfNeeded = createExternalHelpersImportDeclarationIfNeeded; function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault) { if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(node, compilerOptions)) { var externalHelpersModuleName = getExternalHelpersModuleName(node); @@ -66611,8 +67494,8 @@ var ts; if (!create) { var helpers = ts.getEmitHelpers(node); if (helpers) { - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; + for (var _i = 0, helpers_3 = helpers; _i < helpers_3.length; _i++) { + var helper = helpers_3[_i]; if (!helper.scoped) { create = true; break; @@ -66637,10 +67520,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 250 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 251 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 256 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 257 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -66759,7 +67642,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -66771,11 +67654,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -66807,12 +67690,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 153 /* Parameter */: + case 188 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 209 /* SpreadElement */: - case 278 /* SpreadAssignment */: + case 210 /* SpreadElement */: + case 279 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -66824,7 +67707,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 187 /* BindingElement */: + case 188 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -66836,7 +67719,7 @@ var ts; : propertyName; } break; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -66848,7 +67731,7 @@ var ts; : propertyName; } break; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -66871,13 +67754,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: + case 189 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -66917,11 +67800,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 187 /* ArrayBindingPattern */: + case 189 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 186 /* ObjectBindingPattern */: + case 190 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -67044,11 +67927,9 @@ var ts; function visitLexicalEnvironment(statements, visitor, context, start, ensureUseStrict) { context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); - if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); - } - var declarations = context.endLexicalEnvironment(); - return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); + if (ensureUseStrict) + statements = ts.ensureUseStrict(statements); // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier + return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment()); } ts.visitLexicalEnvironment = visitLexicalEnvironment; /** @@ -67082,278 +67963,278 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */) || kind === 179 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 149 /* LastToken */) || kind === 180 /* ThisType */) { return node; } switch (kind) { // Names case 73 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 152 /* Parameter */: + case 153 /* Parameter */: return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 153 /* Decorator */: + case 154 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 154 /* PropertySignature */: + case 155 /* PropertySignature */: return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too visitNode(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 156 /* MethodSignature */: + case 157 /* MethodSignature */: return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 158 /* Constructor */: + case 159 /* Constructor */: return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 159 /* GetAccessor */: + case 160 /* GetAccessor */: return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 161 /* CallSignature */: + case 162 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); // Types - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 166 /* FunctionType */: + case 167 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 167 /* ConstructorType */: + case 168 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 171 /* TupleType */: + case 172 /* TupleType */: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 172 /* OptionalType */: + case 173 /* OptionalType */: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 173 /* RestType */: + case 174 /* RestType */: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174 /* UnionType */: + case 175 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 175 /* IntersectionType */: + case 176 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 177 /* InferType */: + case 178 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 184 /* ImportType */: + case 185 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 182 /* MappedType */: + case 183 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 183 /* LiteralType */: + case 184 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 186 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 213 /* AsExpression */: + case 214 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 219 /* Block */: + case 220 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 229 /* ContinueStatement */: + case 230 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 230 /* BreakStatement */: + case 231 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 253 /* NamedImports */: + case 254 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 257 /* NamedExports */: + case 258 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 258 /* ExportSpecifier */: + case 259 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 261 /* JsxElement */: + case 262 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 263 /* JsxOpeningElement */: + case 264 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 272 /* CaseClause */: + case 273 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 279 /* EnumMember */: + case 280 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 285 /* SourceFile */: + case 286 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -67395,58 +68276,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 149 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 164 /* TypePredicate */ && kind <= 183 /* LiteralType */)) { + if ((kind >= 165 /* TypePredicate */ && kind <= 184 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 218 /* SemicolonClassElement */: - case 221 /* EmptyStatement */: - case 211 /* OmittedExpression */: - case 237 /* DebuggerStatement */: - case 314 /* NotEmittedStatement */: + case 219 /* SemicolonClassElement */: + case 222 /* EmptyStatement */: + case 212 /* OmittedExpression */: + case 238 /* DebuggerStatement */: + case 316 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 152 /* Parameter */: + case 153 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 153 /* Decorator */: + case 154 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 154 /* PropertySignature */: + case 155 /* PropertySignature */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67455,12 +68336,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 158 /* Constructor */: + case 159 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 159 /* GetAccessor */: + case 160 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67468,7 +68349,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67476,50 +68357,50 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 187 /* BindingElement */: + case 188 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 192 /* CallExpression */: + case 193 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 193 /* NewExpression */: + case 194 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -67527,123 +68408,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 196 /* ParenthesizedExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: + case 200 /* DeleteExpression */: + case 201 /* TypeOfExpression */: + case 202 /* VoidExpression */: + case 203 /* AwaitExpression */: + case 209 /* YieldExpression */: + case 210 /* SpreadElement */: + case 215 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 213 /* AsExpression */: + case 214 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 219 /* Block */: + case 220 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 223 /* IfStatement */: + case 224 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 224 /* DoStatement */: + case 225 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 225 /* WhileStatement */: - case 232 /* WithStatement */: + case 226 /* WhileStatement */: + case 233 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 226 /* ForStatement */: + case 227 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 232 /* ReturnStatement */: + case 236 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 236 /* TryStatement */: + case 237 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67652,7 +68533,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67660,140 +68541,140 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.members, cbNodes, result); break; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 251 /* ImportClause */: + case 252 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 254 /* NamedImports */: + case 258 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // Module references - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 261 /* JsxElement */: + case 262 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 272 /* CaseClause */: + case 273 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 275 /* CatchClause */: + case 276 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 279 /* EnumMember */: + case 280 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 285 /* SourceFile */: + case 286 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -67866,7 +68747,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 212 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 213 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -67939,19 +68820,20 @@ var ts; exit(); return sourceIndex; } + /* eslint-disable boolean-trivia, no-null/no-null */ function setSourceContent(sourceIndex, content) { enter(); if (content !== null) { if (!sourcesContent) sourcesContent = []; while (sourcesContent.length < sourceIndex) { - // tslint:disable-next-line:no-null-keyword boolean-trivia sourcesContent.push(null); } sourcesContent[sourceIndex] = content; } exit(); } + /* eslint-enable boolean-trivia, no-null/no-null */ function addName(name) { enter(); if (!nameToNameIndexMap) @@ -68154,12 +69036,11 @@ var ts; } } ts.tryGetSourceMappingURL = tryGetSourceMappingURL; + /* eslint-disable no-null/no-null */ function isStringOrNull(x) { - // tslint:disable-next-line:no-null-keyword return typeof x === "string" || x === null; } function isRawSourceMap(x) { - // tslint:disable-next-line:no-null-keyword return x !== null && typeof x === "object" && x.version === 3 @@ -68171,6 +69052,7 @@ var ts; && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString)); } ts.isRawSourceMap = isRawSourceMap; + /* eslint-enable no-null/no-null */ function tryParseRawSourceMap(text) { try { var parsed = JSON.parse(text); @@ -68539,7 +69421,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 285 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 286 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -68581,25 +69463,31 @@ var ts; var hasExportDefault = false; var exportEquals; var hasExportStarsToExportValues = false; - var hasImportStarOrImportDefault = false; + var hasImportStar = false; + var hasImportDefault = false; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); - hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); + if (!hasImportStar && getImportNeedsImportStarHelper(node)) { + hasImportStar = true; + } + if (!hasImportDefault && getImportNeedsImportDefaultHelper(node)) { + hasImportDefault = true; + } break; - case 249 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + case 250 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 261 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -68629,13 +69517,13 @@ var ts; } } break; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -68643,7 +69531,7 @@ var ts; } } break; - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -68663,7 +69551,7 @@ var ts; } } break; - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -68685,12 +69573,8 @@ var ts; break; } } - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault); - var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault); if (externalHelpersImportDeclaration) { - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); externalImports.unshift(externalHelpersImportDeclaration); } return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames, externalHelpersImportDeclaration: externalHelpersImportDeclaration }; @@ -68765,7 +69649,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 223 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -68829,7 +69713,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 155 /* PropertyDeclaration */ + return member.kind === 156 /* PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; @@ -69278,6 +70162,7 @@ var ts; } ts.restHelper = { name: "typescript:rest", + importName: "__rest", scoped: false, text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n };" }; @@ -69302,7 +70187,7 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), + return ts.createCall(ts.getUnscopedHelperName("__rest"), /*typeArguments*/ undefined, [ value, ts.setTextRange(ts.createArrayLiteral(propertyNames), location) @@ -69355,8 +70240,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(191 /* PropertyAccessExpression */); + context.enableSubstitution(192 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -69382,14 +70267,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 286 /* Bundle */) { + if (node.kind === 287 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288 /* InputFiles */) { + if (prepend.kind === 289 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -69440,16 +70325,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 246 /* ModuleBlock */: - case 219 /* Block */: + case 286 /* SourceFile */: + case 248 /* CaseBlock */: + case 247 /* ModuleBlock */: + case 220 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 241 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -69461,7 +70346,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 === 241 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 242 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -69504,10 +70389,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 256 /* ExportAssignment */: + case 257 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -69528,13 +70413,13 @@ var ts; return node; } switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -69554,11 +70439,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 256 /* ExportDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 251 /* ImportClause */ || - (node.kind === 249 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 260 /* ExternalModuleReference */)) { + if (node.kind === 257 /* ExportDeclaration */ || + node.kind === 251 /* ImportDeclaration */ || + node.kind === 252 /* ImportClause */ || + (node.kind === 250 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 261 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -69582,19 +70467,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: return visitConstructor(node); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 164 /* IndexSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 158 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 218 /* SemicolonClassElement */: + case 219 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -69632,14 +70517,15 @@ var ts; case 78 /* ConstKeyword */: case 126 /* DeclareKeyword */: case 134 /* ReadonlyKeyword */: - // TypeScript accessibility and readonly modifiers are elided. - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 169 /* TypeLiteral */: - case 164 /* TypePredicate */: - case 151 /* TypeParameter */: + // TypeScript accessibility and readonly modifiers are elided + // falls through + case 171 /* ArrayType */: + case 172 /* TupleType */: + case 173 /* OptionalType */: + case 174 /* RestType */: + case 170 /* TypeLiteral */: + case 165 /* TypePredicate */: + case 152 /* TypeParameter */: case 121 /* AnyKeyword */: case 144 /* UnknownKeyword */: case 124 /* BooleanKeyword */: @@ -69648,40 +70534,43 @@ var ts; case 133 /* NeverKeyword */: case 107 /* VoidKeyword */: case 140 /* SymbolKeyword */: - case 167 /* ConstructorType */: - case 166 /* FunctionType */: - case 168 /* TypeQuery */: - case 165 /* TypeReference */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 178 /* ParenthesizedType */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: + case 168 /* ConstructorType */: + case 167 /* FunctionType */: + case 169 /* TypeQuery */: + case 166 /* TypeReference */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: + case 177 /* ConditionalType */: + case 179 /* ParenthesizedType */: + case 180 /* ThisType */: + case 181 /* TypeOperator */: + case 182 /* IndexedAccessType */: + case 183 /* MappedType */: + case 184 /* LiteralType */: // TypeScript type nodes are elided. - case 163 /* IndexSignature */: + // falls through + case 164 /* IndexSignature */: // TypeScript index signatures are elided. - case 153 /* Decorator */: + // falls through + case 154 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 243 /* TypeAliasDeclaration */: + // falls through + case 244 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 155 /* PropertyDeclaration */: + case 156 /* 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 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 158 /* Constructor */: + case 159 /* Constructor */: return visitConstructor(node); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -69691,7 +70580,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -69701,35 +70590,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 159 /* GetAccessor */: + case 160 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 152 /* Parameter */: + case 153 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -69739,35 +70628,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return visitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -70071,7 +70960,7 @@ var ts; var members = []; var constructor = ts.getFirstConstructorWithBody(node); var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (parametersWithPropertyAssignments) { for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) { var parameter = parametersWithPropertyAssignments_1[_i]; @@ -70177,12 +71066,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -70335,7 +71224,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 155 /* PropertyDeclaration */ + ? member.kind === 156 /* 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`. ? ts.createVoidZero() @@ -70458,10 +71347,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 155 /* PropertyDeclaration */; + return kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */ + || kind === 156 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -70471,7 +71360,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 158 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -70482,12 +71371,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return true; } return false; @@ -70504,15 +71393,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 153 /* Parameter */: return serializeTypeNode(node.type); - case 160 /* SetAccessor */: - case 159 /* GetAccessor */: + case 161 /* SetAccessor */: + case 160 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 157 /* MethodDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 158 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -70549,7 +71438,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 159 /* GetAccessor */) { + if (container && node.kind === 160 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -70599,26 +71488,26 @@ var ts; case 97 /* NullKeyword */: case 133 /* NeverKeyword */: return ts.createVoidZero(); - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: return ts.createIdentifier("Function"); - case 170 /* ArrayType */: - case 171 /* TupleType */: + case 171 /* ArrayType */: + case 172 /* TupleType */: return ts.createIdentifier("Array"); - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: case 124 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); case 139 /* StringKeyword */: return ts.createIdentifier("String"); case 137 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 183 /* LiteralType */: + case 184 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: return ts.createIdentifier("String"); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); case 9 /* BigIntLiteral */: @@ -70637,26 +71526,26 @@ var ts; return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return serializeTypeReferenceNode(node); - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 176 /* IntersectionType */: + case 175 /* UnionType */: return serializeTypeList(node.types); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: if (node.operator === 134 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 168 /* TypeQuery */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 169 /* TypeLiteral */: + case 169 /* TypeQuery */: + case 182 /* IndexedAccessType */: + case 183 /* MappedType */: + case 170 /* TypeLiteral */: case 121 /* AnyKeyword */: case 144 /* UnknownKeyword */: - case 179 /* ThisType */: - case 184 /* ImportType */: + case 180 /* ThisType */: + case 185 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -70667,9 +71556,9 @@ var ts; // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var typeNode = types_18[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var typeNode = types_17[_i]; + while (typeNode.kind === 179 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 133 /* NeverKeyword */) { @@ -70784,7 +71673,7 @@ var ts; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. return name; - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -70918,7 +71807,7 @@ var ts; } function transformConstructorBody(body, constructor) { var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (!ts.some(parametersWithPropertyAssignments)) { return ts.visitFunctionBody(body, visitor, context); } @@ -71331,12 +72220,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 285 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 286 /* 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 === 244 /* EnumDeclaration */) { + if (node.kind === 245 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -71461,7 +72350,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 246 /* ModuleBlock */) { + if (body.kind === 247 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -71507,13 +72396,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 (body.kind !== 246 /* ModuleBlock */) { + if (body.kind !== 247 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 246 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -71554,7 +72443,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 252 /* NamespaceImport */) { + if (node.kind === 253 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -71786,16 +72675,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(73 /* Identifier */); - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); + context.enableSubstitution(278 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(245 /* ModuleDeclaration */); + context.enableEmitNotification(246 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 245 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 246 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 244 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 245 /* EnumDeclaration */; } /** * Hook for node emit. @@ -71856,9 +72745,9 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return substituteExpressionIdentifier(node); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -71896,9 +72785,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 !== 285 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 245 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 244 /* EnumDeclaration */); + if (container && container.kind !== 286 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 246 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 245 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -71948,18 +72837,19 @@ var ts; } } context.requestEmitHelper(ts.decorateHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray), location); } ts.decorateHelper = { name: "typescript:decorate", + importName: "__decorate", scoped: false, priority: 2, text: "\n var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n };" }; function createMetadataHelper(context, metadataKey, metadataValue) { context.requestEmitHelper(ts.metadataHelper); - return ts.createCall(ts.getHelperName("__metadata"), + return ts.createCall(ts.getUnscopedHelperName("__metadata"), /*typeArguments*/ undefined, [ ts.createLiteral(metadataKey), metadataValue @@ -71967,13 +72857,14 @@ var ts; } ts.metadataHelper = { name: "typescript:metadata", + importName: "__metadata", scoped: false, priority: 3, text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(ts.paramHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__param"), /*typeArguments*/ undefined, [ ts.createLiteral(parameterOffset), expression @@ -71981,6 +72872,7 @@ var ts; } ts.paramHelper = { name: "typescript:param", + importName: "__param", scoped: false, priority: 4, text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" @@ -72034,11 +72926,11 @@ var ts; if (!(node.transformFlags & 1048576 /* ContainsClassFields */)) return node; switch (node.kind) { - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return visitClassExpression(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); } return ts.visitEachChild(node, visitor, context); @@ -72050,20 +72942,20 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 158 /* MethodDeclaration */: // Visit the name of the member (if it's a computed property name). return ts.visitEachChild(node, classElementVisitor, context); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 218 /* SemicolonClassElement */: + case 219 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -72073,7 +72965,7 @@ var ts; var savedPendingStatements = pendingStatements; pendingStatements = []; var visitedNode = ts.visitEachChild(node, visitor, context); - var statement = ts.some(pendingStatements) ? [visitedNode].concat(pendingStatements) : + var statement = ts.some(pendingStatements) ? __spreadArrays([visitedNode], pendingStatements) : visitedNode; pendingStatements = savedPendingStatements; return statement; @@ -72243,7 +73135,7 @@ var ts; if (constructor && constructor.body) { var parameterPropertyDeclarationCount = 0; for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) { - if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]))) { + if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) { parameterPropertyDeclarationCount++; } else { @@ -72425,6 +73317,7 @@ var ts; var hasSuperElementAccess; /** A set of node IDs for generated super accessors (variable statements). */ var substitutedSuperAccessors = []; + var topLevel; // Save the previous transformation hooks. var previousOnEmitNode = context.onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; @@ -72436,10 +73329,23 @@ var ts; if (node.isDeclarationFile) { return node; } + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitor(node) { if ((node.transformFlags & 32 /* ContainsES2017 */) === 0) { return node; @@ -72448,26 +73354,32 @@ var ts; case 122 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return visitAwaitExpression(node); - case 157 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 240 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: - return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 241 /* FunctionDeclaration */: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 198 /* FunctionExpression */: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 199 /* ArrowFunction */: return visitArrowFunction(node); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 159 /* Constructor */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -72475,27 +73387,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 219 /* Block */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 232 /* WithStatement */: - case 234 /* LabeledStatement */: + case 220 /* Block */: + case 234 /* SwitchStatement */: + case 248 /* CaseBlock */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: + case 237 /* TryStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 224 /* IfStatement */: + case 233 /* WithStatement */: + case 235 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -72696,7 +73608,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 === 198 /* ArrowFunction */; + var isArrowFunction = node.kind === 199 /* 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 @@ -72719,7 +73631,7 @@ var ts; if (!isArrowFunction) { var statements = []; var statementOffset = ts.addPrologue(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); - statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); + statements.push(ts.createReturn(createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. @@ -72746,7 +73658,7 @@ var ts; result = block; } else { - var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); + var expression = createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); @@ -72787,17 +73699,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(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(193 /* CallExpression */); + context.enableSubstitution(191 /* PropertyAccessExpression */); + context.enableSubstitution(192 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(242 /* ClassDeclaration */); + context.enableEmitNotification(158 /* MethodDeclaration */); + context.enableEmitNotification(160 /* GetAccessor */); + context.enableEmitNotification(161 /* SetAccessor */); + context.enableEmitNotification(159 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(221 /* VariableStatement */); } } /** @@ -72845,11 +73757,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -72873,19 +73785,19 @@ var ts; ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 242 /* ClassDeclaration */ + || kind === 159 /* Constructor */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -72945,11 +73857,12 @@ var ts; ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; ts.awaiterHelper = { name: "typescript:awaiter", + importName: "__awaiter", scoped: false, priority: 5, text: "\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };" }; - function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { + function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression( /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), @@ -72959,9 +73872,9 @@ var ts; /*type*/ undefined, body); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; - return ts.createCall(ts.getHelperName("__awaiter"), + return ts.createCall(ts.getUnscopedHelperName("__awaiter"), /*typeArguments*/ undefined, [ - ts.createThis(), + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), generatorFunc @@ -72995,9 +73908,11 @@ var ts; context.onEmitNode = onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; + var exportedVariableStatement = false; var enabledSubstitutions; var enclosingFunctionFlags; var enclosingSuperContainerFlags = 0; + var topLevel; /** Keeps track of property names accessed on super (`super.x`) within async functions. */ var capturedSuperProperties; /** Whether the async function contains an element access on super (`super[x]`). */ @@ -73009,6 +73924,8 @@ var ts; if (node.isDeclarationFile) { return node; } + exportedVariableStatement = false; + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -73025,63 +73942,80 @@ var ts; } return node; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitorWorker(node, noDestructuringValue) { if ((node.transformFlags & 16 /* ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return visitAwaitExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return visitYieldExpression(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitReturnStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitLabeledStatement(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClause(node); - case 238 /* VariableDeclaration */: + case 221 /* VariableStatement */: + return visitVariableStatement(node); + case 239 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return visitVoidExpression(node); - case 158 /* Constructor */: - return visitConstructorDeclaration(node); - case 157 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - return visitGetAccessorDeclaration(node); - case 160 /* SetAccessor */: - return visitSetAccessorDeclaration(node); - case 240 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: - return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 159 /* Constructor */: + return doOutsideOfTopLevel(visitConstructorDeclaration, node); + case 158 /* MethodDeclaration */: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 160 /* GetAccessor */: + return doOutsideOfTopLevel(visitGetAccessorDeclaration, node); + case 161 /* SetAccessor */: + return doOutsideOfTopLevel(visitSetAccessorDeclaration, node); + case 241 /* FunctionDeclaration */: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 198 /* FunctionExpression */: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 199 /* ArrowFunction */: return visitArrowFunction(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return visitParameter(node); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return visitExpressionStatement(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -73114,7 +74048,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 228 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 229 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -73126,7 +74060,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 === 278 /* SpreadAssignment */) { + if (e.kind === 279 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -73135,7 +74069,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 276 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 277 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -73169,7 +74103,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 !== 189 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 190 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } var expression = objects[0]; @@ -73214,23 +74148,44 @@ var ts; var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { - block = ts.updateBlock(block, [ + block = ts.updateBlock(block, __spreadArrays([ ts.createVariableStatement(/*modifiers*/ undefined, visitedBindings) - ].concat(block.statements)); + ], block.statements)); } return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, /*type*/ undefined, /*initializer*/ undefined), block); } return ts.visitEachChild(node, visitor, context); } + function visitVariableStatement(node) { + if (ts.hasModifier(node, 1 /* Export */)) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = true; + var visited = ts.visitEachChild(node, visitor, context); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return ts.visitEachChild(node, visitor, context); + } /** * Visits a VariableDeclaration node with a binding pattern. * * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { + if (exportedVariableStatement) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = false; + var visited = visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ true); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ false); + } + 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 & 8192 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */); + return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, + /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); } @@ -73448,7 +74403,7 @@ var ts; /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))))); + /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !topLevel)); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); @@ -73514,17 +74469,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(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(193 /* CallExpression */); + context.enableSubstitution(191 /* PropertyAccessExpression */); + context.enableSubstitution(192 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(242 /* ClassDeclaration */); + context.enableEmitNotification(158 /* MethodDeclaration */); + context.enableEmitNotification(160 /* GetAccessor */); + context.enableEmitNotification(161 /* SetAccessor */); + context.enableEmitNotification(159 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(221 /* VariableStatement */); } } /** @@ -73572,11 +74527,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -73600,19 +74555,19 @@ var ts; ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 242 /* ClassDeclaration */ + || kind === 159 /* Constructor */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -73628,65 +74583,69 @@ var ts; ts.transformES2018 = transformES2018; ts.assignHelper = { name: "typescript:assign", + importName: "__assign", scoped: false, priority: 1, text: "\n var __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n };" }; function createAssignHelper(context, attributesSegments) { if (context.getCompilerOptions().target >= 2 /* ES2015 */) { - return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), - /*typeArguments*/ undefined, attributesSegments); + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } context.requestEmitHelper(ts.assignHelper); - return ts.createCall(ts.getHelperName("__assign"), + return ts.createCall(ts.getUnscopedHelperName("__assign"), /*typeArguments*/ undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; ts.awaitHelper = { name: "typescript:await", + importName: "__await", scoped: false, text: "\n var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }" }; function createAwaitHelper(context, expression) { context.requestEmitHelper(ts.awaitHelper); - return ts.createCall(ts.getHelperName("__await"), /*typeArguments*/ undefined, [expression]); + return ts.createCall(ts.getUnscopedHelperName("__await"), /*typeArguments*/ undefined, [expression]); } ts.asyncGeneratorHelper = { name: "typescript:asyncGenerator", + importName: "__asyncGenerator", scoped: false, text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n };" }; - function createAsyncGeneratorHelper(context, generatorFunc) { + function createAsyncGeneratorHelper(context, generatorFunc, hasLexicalThis) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */; - return ts.createCall(ts.getHelperName("__asyncGenerator"), + return ts.createCall(ts.getUnscopedHelperName("__asyncGenerator"), /*typeArguments*/ undefined, [ - ts.createThis(), + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), ts.createIdentifier("arguments"), generatorFunc ]); } ts.asyncDelegator = { name: "typescript:asyncDelegator", + importName: "__asyncDelegator", scoped: false, text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\n };" }; function createAsyncDelegatorHelper(context, expression, location) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncDelegator); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncDelegator"), /*typeArguments*/ undefined, [expression]), location); } ts.asyncValues = { name: "typescript:asyncValues", + importName: "__asyncValues", scoped: false, text: "\n var __asyncValues = (this && this.__asyncValues) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n };" }; function createAsyncValuesHelper(context, expression, location) { context.requestEmitHelper(ts.asyncValues); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncValues"), /*typeArguments*/ undefined, [expression]), location); } })(ts || (ts = {})); @@ -73706,7 +74665,7 @@ var ts; return node; } switch (node.kind) { - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -73775,13 +74734,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 261 /* JsxElement */: + case 262 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -73791,13 +74750,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return visitJsxExpression(node); - case 261 /* JsxElement */: + case 262 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -73872,7 +74831,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 271 /* JsxExpression */) { + else if (node.kind === 272 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -73966,7 +74925,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 261 /* JsxElement */) { + if (node.kind === 262 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -74272,7 +75231,7 @@ var ts; return node; } switch (node.kind) { - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74485,13 +75444,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 231 /* ReturnStatement */ + && node.kind === 232 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */))) + || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 220 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -74513,63 +75472,63 @@ var ts; switch (node.kind) { case 117 /* StaticKeyword */: return undefined; // elide static keyword - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return visitClassExpression(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return visitParameter(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return visitArrowFunction(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return visitFunctionExpression(node); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return visitVariableDeclaration(node); case 73 /* Identifier */: return visitIdentifier(node); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return visitCaseBlock(node); - case 219 /* Block */: + case 220 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitLabeledStatement(node); - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return visitExpressionStatement(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClause(node); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return visitNewExpression(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -74580,28 +75539,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return visitTemplateExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return visitYieldExpression(node); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return visitSpreadElement(node); case 99 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); case 101 /* ThisKeyword */: return visitThisKeyword(node); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return visitMetaProperty(node); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -74692,14 +75651,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 === 230 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 231 /* 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 === 230 /* BreakStatement */) { + if (node.kind === 231 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -74710,7 +75669,7 @@ var ts; } } else { - if (node.kind === 230 /* BreakStatement */) { + if (node.kind === 231 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -75106,11 +76065,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 231 /* ReturnStatement */) { + if (statement.kind === 232 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 223 /* IfStatement */) { + else if (statement.kind === 224 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -75118,7 +76077,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 219 /* Block */) { + else if (statement.kind === 220 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -75316,7 +76275,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 199 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, ts.createThis()); return true; } @@ -75337,22 +76296,22 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return statements; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 158 /* Constructor */: + case 159 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 198 /* 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 = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 95 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); @@ -75384,20 +76343,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 218 /* SemicolonClassElement */: + case 219 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 158 /* Constructor */: + case 159 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -75585,7 +76544,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 === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 241 /* FunctionDeclaration */ || node.kind === 198 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -75629,7 +76588,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 198 /* ArrowFunction */); + ts.Debug.assert(node.kind === 199 /* 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 @@ -75697,9 +76656,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -75718,9 +76677,9 @@ var ts; // expression. If we are in a state where we do not need the destructuring value, // we pass that information along to the children that care about it. switch (node.expression.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -75929,14 +76888,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -76124,7 +77083,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 150 /* ComputedPropertyName */) { + if (property.name.kind === 151 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -76245,11 +77204,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 226 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 227 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 228 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 224 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 225 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 227 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 228 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 229 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 225 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 226 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -76274,11 +77233,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 240 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -76677,20 +77636,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -76766,7 +77725,7 @@ var ts; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); - return ts.updateBlock(block, [statement].concat(transformedStatements)); + return ts.updateBlock(block, __spreadArrays([statement], transformedStatements)); } /** * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a @@ -76797,7 +77756,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 160 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -77034,7 +77993,7 @@ var ts; // [output] // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray(__spreadArrays([ts.createVoidZero()], node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), /*typeArguments*/ undefined, []); } return ts.visitEachChild(node, visitor, context); @@ -77198,13 +78157,16 @@ var ts; // Find original source text, since we need to emit the raw strings of the tagged template. // The raw strings contain the (escaped) strings of what the user wrote. // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), - // thus we need to remove those characters. - // First template piece starts with "`", others with "}" - // Last template piece ends with "`", others with "${" - var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; - text = text.substring(1, text.length - (isLast ? 1 : 2)); + var text = node.rawText; + if (text === undefined) { + text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), + // thus we need to remove those characters. + // First template piece starts with "`", others with "}" + // Last template piece ends with "`", others with "${" + var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; + text = text.substring(1, text.length - (isLast ? 1 : 2)); + } // Newline normalization: // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's // and LineTerminatorSequences are normalized to for both TV and TRV. @@ -77295,10 +78257,8 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ - && !isExpressionOfCall - ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") - : ts.createFileLevelUniqueName("_super"); + return hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") : + ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { if (node.keywordToken === 96 /* NewKeyword */ && node.name.escapedText === "target") { @@ -77344,13 +78304,13 @@ var ts; if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; context.enableSubstitution(101 /* ThisKeyword */); - context.enableEmitNotification(158 /* Constructor */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(198 /* ArrowFunction */); - context.enableEmitNotification(197 /* FunctionExpression */); - context.enableEmitNotification(240 /* FunctionDeclaration */); + context.enableEmitNotification(159 /* Constructor */); + context.enableEmitNotification(158 /* MethodDeclaration */); + context.enableEmitNotification(160 /* GetAccessor */); + context.enableEmitNotification(161 /* SetAccessor */); + context.enableEmitNotification(199 /* ArrowFunction */); + context.enableEmitNotification(198 /* FunctionExpression */); + context.enableEmitNotification(241 /* FunctionDeclaration */); } } /** @@ -77391,10 +78351,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 238 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 239 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -77476,11 +78436,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 222 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 223 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 192 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 193 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -77488,7 +78448,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 209 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 210 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -77498,7 +78458,7 @@ var ts; ts.transformES2015 = transformES2015; function createExtendsHelper(context, name) { context.requestEmitHelper(ts.extendsHelper); - return ts.createCall(ts.getHelperName("__extends"), + return ts.createCall(ts.getUnscopedHelperName("__extends"), /*typeArguments*/ undefined, [ name, ts.createFileLevelUniqueName("_super") @@ -77506,7 +78466,7 @@ var ts; } function createTemplateObjectHelper(context, cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); - return ts.createCall(ts.getHelperName("__makeTemplateObject"), + return ts.createCall(ts.getUnscopedHelperName("__makeTemplateObject"), /*typeArguments*/ undefined, [ cooked, raw @@ -77514,12 +78474,14 @@ var ts; } ts.extendsHelper = { name: "typescript:extends", + importName: "__extends", scoped: false, priority: 0, text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; ts.templateObjectHelper = { name: "typescript:makeTemplateObject", + importName: "__makeTemplateObject", scoped: false, priority: 0, text: "\n var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n };" @@ -77541,15 +78503,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(263 /* JsxOpeningElement */); - context.enableEmitNotification(264 /* JsxClosingElement */); - context.enableEmitNotification(262 /* JsxSelfClosingElement */); + context.enableEmitNotification(264 /* JsxOpeningElement */); + context.enableEmitNotification(265 /* JsxClosingElement */); + context.enableEmitNotification(263 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(276 /* PropertyAssignment */); + context.enableSubstitution(191 /* PropertyAccessExpression */); + context.enableSubstitution(277 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -77568,9 +78530,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 265 /* JsxClosingElement */: + case 263 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -77902,13 +78864,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 224 /* DoStatement */: + case 225 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return visitWhileStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return visitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -77921,24 +78883,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return visitFunctionExpression(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatement(node); - case 230 /* BreakStatement */: + case 231 /* BreakStatement */: return visitBreakStatement(node); - case 229 /* ContinueStatement */: + case 230 /* ContinueStatement */: return visitContinueStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 131072 /* ContainsYield */) { @@ -77959,21 +78921,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return visitConditionalExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return visitYieldExpression(node); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -77986,9 +78948,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -78216,7 +79178,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -78228,7 +79190,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -78454,13 +79416,13 @@ var ts; temp = declareLocal(); var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements); emitAssignment(temp, ts.createArrayLiteral(leadingElement - ? [leadingElement].concat(initialElements) : initialElements)); + ? __spreadArrays([leadingElement], initialElements) : initialElements)); leadingElement = undefined; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return temp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { var hasAssignedTemp = temp !== undefined; @@ -78469,7 +79431,7 @@ var ts; } emitAssignment(temp, hasAssignedTemp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); + : ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine)); leadingElement = undefined; expressions = []; } @@ -78604,35 +79566,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 219 /* Block */: + case 220 /* Block */: return transformAndEmitBlock(node); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return transformAndEmitIfStatement(node); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return transformAndEmitDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return transformAndEmitForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 229 /* ContinueStatement */: + case 230 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 230 /* BreakStatement */: + case 231 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return transformAndEmitWithStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -79062,7 +80024,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 273 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 274 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -79075,7 +80037,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 273 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -79248,11 +80210,10 @@ var ts; return node; } function cacheExpression(node) { - var temp; if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { return node; } - temp = ts.createTempVariable(hoistVariableDeclaration); + var temp = ts.createTempVariable(hoistVariableDeclaration); emitAssignment(temp, node, /*location*/ node); return temp; } @@ -80213,7 +81174,7 @@ var ts; ts.transformGenerators = transformGenerators; function createGeneratorHelper(context, body) { context.requestEmitHelper(ts.generatorHelper); - return ts.createCall(ts.getHelperName("__generator"), + return ts.createCall(ts.getUnscopedHelperName("__generator"), /*typeArguments*/ undefined, [ts.createThis(), body]); } // The __generator helper is used by down-level transformations to emulate the runtime @@ -80277,6 +81238,7 @@ var ts; // For examples of how these are used, see the comments in ./transformers/generators.ts ts.generatorHelper = { name: "typescript:generator", + importName: "__generator", scoped: false, priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" @@ -80304,11 +81266,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(206 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(204 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(205 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(278 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(286 /* 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. @@ -80406,14 +81368,14 @@ var ts; // define(moduleName?, ["module1", "module2"], function ... var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createExpressionStatement(ts.createCall(define, - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ + /*typeArguments*/ undefined, __spreadArrays((moduleName ? [moduleName] : []), [ // Add the dependency array argument: // // ["require", "exports", module1", "module2", ...] - ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : [ + ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : __spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), // Add the module body function argument: // // function (require, exports, module1, module2) ... @@ -80423,10 +81385,10 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ + /*typeParameters*/ undefined, __spreadArrays([ ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), + ], importAliasNames), /*type*/ undefined, transformAsynchronousModuleBody(node)) ]))) ]), @@ -80461,11 +81423,11 @@ var ts; ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ - ts.createArrayLiteral([ + /*typeArguments*/ undefined, __spreadArrays((moduleName ? [moduleName] : []), [ + ts.createArrayLiteral(__spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), ts.createIdentifier("factory") ]))) ]))) @@ -80493,10 +81455,10 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ + /*typeParameters*/ undefined, __spreadArrays([ ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), + ], importAliasNames), /*type*/ undefined, transformAsynchronousModuleBody(node)) ])) ]), @@ -80636,23 +81598,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return visitExportDeclaration(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitExportAssignment(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return visitClassDeclaration(node); - case 317 /* MergeDeclarationMarker */: + case 319 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 318 /* EndOfDeclarationMarker */: + case 320 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -80679,24 +81641,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -80811,7 +81773,7 @@ var ts; var promise = ts.createNew(ts.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getHelperName("__importStar")]); + return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getUnscopedHelperName("__importStar")]); } return promise; } @@ -80825,7 +81787,7 @@ var ts; var requireCall = ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - requireCall = ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); + requireCall = ts.createCall(ts.getUnscopedHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); } var func; if (languageVersion >= 2 /* ES2015 */) { @@ -80859,11 +81821,11 @@ var ts; } if (ts.getImportNeedsImportStarHelper(node)) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); } if (ts.getImportNeedsImportDefaultHelper(node)) { context.requestEmitHelper(ts.importDefaultHelper); - return ts.createCall(ts.getHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); } return innerExpr; } @@ -81174,7 +82136,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 221 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -81229,10 +82191,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 254 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -81431,7 +82393,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -81495,10 +82457,10 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return substituteBinaryExpression(node); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -81519,7 +82481,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 286 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -81594,7 +82556,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 /* PostfixUnaryExpression */ + var expression = node.kind === 205 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 /* PlusPlusToken */ ? 61 /* PlusEqualsToken */ : 62 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; @@ -81635,7 +82597,7 @@ var ts; function createExportStarHelper(context, module) { var compilerOptions = context.getCompilerOptions(); return compilerOptions.importHelpers - ? ts.createCall(ts.getHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]) + ? ts.createCall(ts.getUnscopedHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]) : ts.createCall(ts.createIdentifier("__export"), /*typeArguments*/ undefined, [module]); } // emit helper for dynamic import @@ -81647,12 +82609,14 @@ var ts; // emit helper for `import * as Name from "foo"` ts.importStarHelper = { name: "typescript:commonjsimportstar", + importName: "__importStar", scoped: false, text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};" }; // emit helper for `import Name from "foo"` ts.importDefaultHelper = { name: "typescript:commonjsimportdefault", + importName: "__importDefault", scoped: false, text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};" }; @@ -81670,15 +82634,17 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(278 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(206 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(204 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(205 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(216 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(286 /* 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. var noSubstitutionMap = []; // Set of nodes for which substitution rules should be ignored for each file. + var contextObjectMap = []; // The context object associated with a source file. var currentSourceFile; // The current file. var moduleInfo; // ExternalModuleInfo for the current file. var exportFunction; // The export function for the current file. @@ -81717,7 +82683,7 @@ var ts; // existing identifiers. exportFunction = ts.createUniqueName("exports"); exportFunctionsMap[id] = exportFunction; - contextObject = ts.createUniqueName("context"); + contextObject = contextObjectMap[id] = ts.createUniqueName("context"); // Add the body of the module. var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups); @@ -81895,7 +82861,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 256 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 257 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -81920,7 +82886,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 256 /* ExportDeclaration */) { + if (externalImport.kind !== 257 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -81998,19 +82964,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -82060,15 +83026,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -82244,7 +83210,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 === 285 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 286 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -82308,7 +83274,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 === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 221 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -82370,10 +83336,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 254 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -82553,43 +83519,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatement(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatement(node); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return visitWhileStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitLabeledStatement(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return visitWithStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return visitCaseBlock(node); - case 272 /* CaseClause */: + case 273 /* CaseClause */: return visitCaseClause(node); - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: return visitDefaultClause(node); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return visitTryStatement(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClause(node); - case 219 /* Block */: + case 220 /* Block */: return visitBlock(node); - case 317 /* MergeDeclarationMarker */: + case 319 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 318 /* EndOfDeclarationMarker */: + case 320 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -82836,7 +83802,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 285 /* SourceFile */; + return container !== undefined && container.kind === 286 /* SourceFile */; } else { return false; @@ -82869,12 +83835,13 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; exportFunction = exportFunctionsMap[id]; noSubstitution = noSubstitutionMap[id]; + contextObject = contextObjectMap[id]; if (noSubstitution) { delete noSubstitutionMap[id]; } @@ -82882,6 +83849,7 @@ var ts; currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; + contextObject = undefined; noSubstitution = undefined; } else { @@ -82917,7 +83885,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -82953,11 +83921,13 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return substituteBinaryExpression(node); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); + case 216 /* MetaProperty */: + return substituteMetaProperty(node); } return node; } @@ -83049,14 +84019,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 /* PostfixUnaryExpression */ + var expression = node.kind === 205 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(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 === 204 /* PostfixUnaryExpression */) { + if (node.kind === 205 /* PostfixUnaryExpression */) { expression = node.operator === 44 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -83066,6 +84036,12 @@ var ts; } return node; } + function substituteMetaProperty(node) { + if (ts.isImportMeta(node)) { + return ts.createPropertyAccess(contextObject, ts.createIdentifier("meta")); + } + return node; + } /** * Gets the exports of a name. * @@ -83078,7 +84054,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 286 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -83117,24 +84093,20 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(285 /* SourceFile */); + context.enableEmitNotification(286 /* SourceFile */); context.enableSubstitution(73 /* Identifier */); - var currentSourceFile; + var helperNameSubstitutions; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { return node; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); - if (externalHelpersModuleName) { + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(node, compilerOptions); + if (externalHelpersImportDeclaration) { var statements = []; var statementOffset = ts.addPrologue(statements, node.statements); - var tslibImport = ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); - ts.addEmitFlags(tslibImport, 67108864 /* NeverApplyImportHelper */); - ts.append(statements, tslibImport); + ts.append(statements, externalHelpersImportDeclaration); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } @@ -83146,10 +84118,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -83170,9 +84142,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { if (ts.isSourceFile(node)) { - currentSourceFile = node; + helperNameSubstitutions = ts.createMap(); previousOnEmitNode(hint, node, emitCallback); - currentSourceFile = undefined; + helperNameSubstitutions = undefined; } else { previousOnEmitNode(hint, node, emitCallback); @@ -83189,19 +84161,18 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (ts.isIdentifier(node) && hint === 1 /* Expression */) { - return substituteExpressionIdentifier(node); + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* HelperName */) { + return substituteHelperName(node); } return node; } - function substituteExpressionIdentifier(node) { - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { - var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); - if (externalHelpersModuleName) { - return ts.createPropertyAccess(externalHelpersModuleName, node); - } + function substituteHelperName(node) { + var name = ts.idText(node); + var substitution = helperNameSubstitutions.get(name); + if (!substitution) { + helperNameSubstitutions.set(name, substitution = ts.createFileLevelUniqueName(name)); } - return node; + return substitution; } } ts.transformES2015Module = transformES2015Module; @@ -83257,7 +84228,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 242 /* 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 : @@ -83286,7 +84257,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 242 /* 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 : @@ -83312,7 +84283,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node) && ts.hasModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8 /* Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -83333,7 +84304,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 === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 239 /* VariableDeclaration */ || node.kind === 188 /* 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 : @@ -83342,8 +84313,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 === 155 /* PropertyDeclaration */ || node.kind === 190 /* PropertyAccessExpression */ || node.kind === 154 /* PropertySignature */ || - (node.kind === 152 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 156 /* PropertyDeclaration */ || node.kind === 191 /* PropertyAccessExpression */ || node.kind === 155 /* PropertySignature */ || + (node.kind === 153 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -83352,7 +84323,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 === 241 /* ClassDeclaration */ || node.kind === 152 /* Parameter */) { + else if (node.parent.kind === 242 /* ClassDeclaration */ || node.kind === 153 /* 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 : @@ -83377,7 +84348,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 161 /* 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.hasModifier(node, 32 /* Static */)) { @@ -83416,26 +84387,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 162 /* ConstructSignature */: + case 163 /* 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 161 /* CallSignature */: + case 162 /* 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 163 /* IndexSignature */: + case 164 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -83443,7 +84414,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 242 /* 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 : @@ -83457,7 +84428,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 240 /* FunctionDeclaration */: + case 241 /* 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 : @@ -83482,30 +84453,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 158 /* Constructor */: + case 159 /* 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 162 /* ConstructSignature */: - case 167 /* ConstructorType */: + case 163 /* ConstructSignature */: + case 168 /* 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 161 /* CallSignature */: + case 162 /* 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 163 /* IndexSignature */: + case 164 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -83513,7 +84484,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 === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 242 /* 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 : @@ -83526,8 +84497,8 @@ 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 240 /* FunctionDeclaration */: - case 166 /* FunctionType */: + case 241 /* FunctionDeclaration */: + case 167 /* 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 : @@ -83541,39 +84512,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 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 182 /* MappedType */: + case 183 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 168 /* ConstructorType */: + case 163 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 161 /* CallSignature */: + case 162 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.hasModifier(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 === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 242 /* 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 166 /* FunctionType */: - case 240 /* FunctionDeclaration */: + case 167 /* FunctionType */: + case 241 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -83588,7 +84559,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + if (node.parent.parent.kind === 242 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 110 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -83639,7 +84610,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 152 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 153 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -83700,6 +84671,7 @@ var ts; var currentSourceFile; var refs; var libs; + var emittedImports; // must be declared in container so it can be `undefined` while transformer's first pass var resolver = context.getEmitResolver(); var options = context.getCompilerOptions(); var newLine = ts.getNewLineCharacter(options); @@ -83789,10 +84761,10 @@ var ts; return ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createNamedExports([]), /*moduleSpecifier*/ undefined); } function transformRoot(node) { - if (node.kind === 285 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 286 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { return node; } - if (node.kind === 286 /* Bundle */) { + if (node.kind === 287 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); @@ -83822,7 +84794,7 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288 /* InputFiles */) { + if (prepend.kind === 289 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -83862,9 +84834,9 @@ var ts; var statements = ts.visitNodes(node.statements, visitDeclarationStatements); var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); refs.forEach(referenceVisitor); - var emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { - combinedStatements = ts.setTextRange(ts.createNodeArray(combinedStatements.concat([createEmptyExports()])), combinedStatements); + combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [createEmptyExports()])), combinedStatements); } var updated = ts.updateSourceFileNode(node, combinedStatements, /*isDeclarationFile*/ true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences()); updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit; @@ -83906,6 +84878,15 @@ 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, host.getSourceFiles(), + /*preferences*/ undefined, host.redirectTargetsMap); + if (!ts.pathIsRelative(specifier)) { + // If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration + // via a non-relative name, emit a type reference directive to that non-relative name, rather than + // a relative path to the declaration file + recordTypeReferenceDirectivesIfNecessary([specifier]); + return; + } var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); if (ts.startsWith(fileName, "./") && ts.hasExtension(fileName)) { @@ -83946,7 +84927,7 @@ var ts; return name; } else { - if (name.kind === 186 /* ArrayBindingPattern */) { + if (name.kind === 187 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -83954,20 +84935,20 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 211 /* OmittedExpression */) { + if (elem.kind === 212 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); } } - function ensureParameter(p, modifierMask) { + function ensureParameter(p, modifierMask, type) { var oldDiag; if (!suppressNewDiagnosticContexts) { oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } var newParam = ts.updateParameter(p, - /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(56 /* QuestionToken */)) : undefined, ensureType(p, p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param + /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(56 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -83992,7 +84973,7 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 152 /* Parameter */ && + var shouldUseResolverType = node.kind === 153 /* Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { @@ -84001,7 +84982,7 @@ var ts; if (!ts.getParseTreeNode(node)) { return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(121 /* AnyKeyword */); } - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 161 /* 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 ts.createKeywordTypeNode(121 /* AnyKeyword */); @@ -84012,12 +84993,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 239 /* VariableDeclaration */ || node.kind === 188 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 152 /* Parameter */ - || node.kind === 155 /* PropertyDeclaration */ - || node.kind === 154 /* PropertySignature */) { + if (node.kind === 153 /* Parameter */ + || node.kind === 156 /* PropertyDeclaration */ + || node.kind === 155 /* 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)); @@ -84034,20 +85015,20 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 241 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 243 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 245 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 250 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: + case 256 /* ExportAssignment */: return false; } return false; @@ -84074,6 +85055,33 @@ var ts; } return ts.createNodeArray(newParams, params.hasTrailingComma); } + function updateAccessorParamsList(input, isPrivate) { + var newParams; + if (!isPrivate) { + var thisParameter = ts.getThisParameter(input); + if (thisParameter) { + newParams = [ensureParameter(thisParameter)]; + } + } + if (ts.isSetAccessorDeclaration(input)) { + var newValueParameter = void 0; + if (!isPrivate) { + var valueParameter = ts.getSetAccessorValueParameter(input); + if (valueParameter) { + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + newValueParameter = ensureParameter(valueParameter, /*modifierMask*/ undefined, accessorType); + } + } + if (!newValueParameter) { + newValueParameter = ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "value"); + } + newParams = ts.append(newParams, newValueParameter); + } + return ts.createNodeArray(newParams || ts.emptyArray); + } function ensureTypeParams(node, params) { return ts.hasModifier(node, 8 /* Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } @@ -84101,7 +85109,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 245 /* ModuleDeclaration */ && parent.kind !== 184 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 246 /* ModuleDeclaration */ && parent.kind !== 185 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -84121,7 +85129,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 261 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -84148,7 +85156,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 253 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -84240,6 +85248,11 @@ var ts; enclosingDeclaration = input; } var oldDiag = getSymbolAccessibilityDiagnostic; + // Setup diagnostic-related flags before first potential `cleanup` call, otherwise + // We'd see a TDZ violation at runtime + var canProduceDiagnostic = ts.canProduceDiagnostics(input); + var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 170 /* TypeLiteral */ || input.kind === 183 /* MappedType */) && input.parent.kind !== 244 /* TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { if (ts.hasModifier(input, 8 /* Private */)) { @@ -84248,76 +85261,87 @@ var ts; return cleanup(ts.createProperty(/*decorators*/ undefined, ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); } } - var canProdiceDiagnostic = ts.canProduceDiagnostics(input); - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input); } if (ts.isTypeQueryNode(input)) { checkEntityNameVisibility(input.exprName, enclosingDeclaration); } - var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 169 /* TypeLiteral */ || input.kind === 182 /* MappedType */) && input.parent.kind !== 243 /* TypeAliasDeclaration */); if (shouldEnterSuppressNewDiagnosticsContextContext) { // We stop making new diagnostic contexts within object literal types. Unless it's an object type on the RHS of a type alias declaration. Then we do. suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 212 /* ExpressionWithTypeArguments */: { + case 213 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 165 /* TypeReference */: { + case 166 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 158 /* Constructor */: { + case 159 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(158 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + var ctor = ts.createSignatureDeclaration(159 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), // TODO: GH#18217 isPrivate ? undefined : updateParamsList(input, input.parameters, 0 /* None */), /*type*/ undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 157 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(156 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 158 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(157 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 159 /* GetAccessor */: { + case 160 /* GetAccessor */: { + // For now, only emit class accessors as accessors if they were already declared in an ambient context. + if (input.flags & 4194304 /* Ambient */) { + var isPrivate = ts.hasModifier(input, 8 /* Private */); + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + return cleanup(ts.updateGetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, + /*body*/ undefined)); + } var newNode = ensureAccessor(input); return cleanup(newNode); } - case 160 /* SetAccessor */: { + case 161 /* SetAccessor */: { + // For now, only emit class accessors as accessors if they were already declared in an ambient context. + if (input.flags & 4194304 /* Ambient */) { + return cleanup(ts.updateSetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8 /* Private */)), + /*body*/ undefined)); + } var newNode = ensureAccessor(input); return cleanup(newNode); } - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return cleanup(ts.updateProperty(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 154 /* PropertySignature */: + case 155 /* PropertySignature */: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 156 /* MethodSignature */: { + case 157 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 161 /* CallSignature */: { + case 162 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 163 /* IndexSignature */: { + case 164 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(121 /* AnyKeyword */))); } - case 238 /* VariableDeclaration */: { + case 239 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -84325,13 +85349,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(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 151 /* TypeParameter */: { + case 152 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 176 /* ConditionalType */: { + case 177 /* 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); @@ -84343,13 +85367,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 166 /* FunctionType */: { + case 167 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 167 /* ConstructorType */: { + case 168 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 184 /* ImportType */: { + case 185 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -84359,13 +85383,13 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { - if (returnValue && canProdiceDiagnostic && ts.hasDynamicName(input)) { + if (returnValue && canProduceDiagnostic && ts.hasDynamicName(input)) { checkName(input); } if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; } - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } if (shouldEnterSuppressNewDiagnosticsContextContext) { @@ -84378,7 +85402,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 157 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 158 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -84388,7 +85412,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 256 /* ExportDeclaration */: { + case 257 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -84397,7 +85421,7 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 255 /* ExportAssignment */: { + case 256 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; @@ -84438,10 +85462,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249 /* ImportEqualsDeclaration */: { + case 250 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 250 /* ImportDeclaration */: { + case 251 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -84462,14 +85486,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 243 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 244 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 242 /* InterfaceDeclaration */: { + case 243 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 240 /* FunctionDeclaration */: { + case 241 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -84517,10 +85541,10 @@ var ts; return clean; } } - case 245 /* ModuleDeclaration */: { + case 246 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 246 /* ModuleBlock */) { + if (inner && inner.kind === 247 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; @@ -84536,7 +85560,7 @@ var ts; // 3. Some things are exported, some are not, and there's no marker - add an empty marker if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) { if (needsScopeFixMarker) { - lateStatements = ts.createNodeArray(lateStatements.concat([createEmptyExports()])); + lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [createEmptyExports()])); } else { lateStatements = ts.visitNodes(lateStatements, stripExportModifiers); @@ -84563,7 +85587,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 241 /* ClassDeclaration */: { + case 242 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -84634,10 +85658,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 220 /* VariableStatement */: { + case 221 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 244 /* EnumDeclaration */: { + case 245 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -84656,7 +85680,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 245 /* ModuleDeclaration */) { + if (input.kind === 246 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -84677,7 +85701,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 211 /* OmittedExpression */) { + if (e.kind === 212 /* OmittedExpression */) { return; } if (e.name) { @@ -84727,24 +85751,33 @@ var ts; function ensureModifierFlags(node) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 285 /* SourceFile */; + var parentIsFile = node.parent.kind === 286 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; } return maskModifierFlags(node, mask, additions); } - function ensureAccessor(node) { - var accessors = resolver.getAllAccessorDeclarations(node); - if (node.kind !== accessors.firstAccessor.kind) { - return; - } + function getTypeAnnotationFromAllAccessorDeclarations(node, accessors) { var accessorType = getTypeAnnotationFromAccessor(node); - if (!accessorType && accessors.secondAccessor) { + if (!accessorType && node !== accessors.firstAccessor) { + accessorType = getTypeAnnotationFromAccessor(accessors.firstAccessor); + // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message + getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.firstAccessor); + } + if (!accessorType && accessors.secondAccessor && node !== accessors.secondAccessor) { accessorType = getTypeAnnotationFromAccessor(accessors.secondAccessor); // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.secondAccessor); } + return accessorType; + } + function ensureAccessor(node) { + var accessors = resolver.getAllAccessorDeclarations(node); + if (node.kind !== accessors.firstAccessor.kind) { + return; + } + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(node, accessors); var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); if (leadingsSyntheticCommentRanges) { @@ -84755,7 +85788,7 @@ var ts; if (lines.length > 1) { var lastLines = lines.slice(1); var indentation_1 = ts.guessIndentation(lastLines); - text = [lines[0]].concat(ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); + text = __spreadArrays([lines[0]], ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); } ts.addSyntheticLeadingComment(prop, range.kind, text, range.hasTrailingNewLine); } @@ -84775,7 +85808,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 243 /* InterfaceDeclaration */) { return true; } return false; @@ -84800,7 +85833,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 159 /* GetAccessor */ + return accessor.kind === 160 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -84809,52 +85842,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return !ts.hasModifier(node, 8 /* Private */); - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 153 /* Parameter */: + case 239 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 220 /* VariableStatement */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 241 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 243 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 245 /* EnumDeclaration */: + case 221 /* VariableStatement */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: + case 256 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 238 /* VariableDeclaration */: - case 151 /* TypeParameter */: - case 212 /* ExpressionWithTypeArguments */: - case 165 /* TypeReference */: - case 176 /* ConditionalType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 184 /* ImportType */: + case 163 /* ConstructSignature */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 164 /* IndexSignature */: + case 239 /* VariableDeclaration */: + case 152 /* TypeParameter */: + case 213 /* ExpressionWithTypeArguments */: + case 166 /* TypeReference */: + case 177 /* ConditionalType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 185 /* ImportType */: return true; } return false; @@ -84983,7 +86016,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(319 /* Count */); + var enabledSyntaxKindFeatures = new Array(321 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -85190,7 +86223,7 @@ var ts; var statements; if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) { if (lexicalEnvironmentFunctionDeclarations) { - statements = lexicalEnvironmentFunctionDeclarations.slice(); + statements = __spreadArrays(lexicalEnvironmentFunctionDeclarations); } if (lexicalEnvironmentVariableDeclarations) { var statement = ts.createVariableStatement( @@ -85268,15 +86301,15 @@ var ts; * If an array, the full list of source files to emit. * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) { + if (forceDtsEmit === void 0) { forceDtsEmit = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { var prepends = host.getPrependNodes(); if (sourceFiles.length || prepends.length) { var bundle = ts.createBundle(sourceFiles, prepends); - var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); + var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle); if (result) { return result; } @@ -85286,7 +86319,7 @@ var ts; if (!onlyBuildInfo) { for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { var sourceFile = sourceFiles_1[_a]; - var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); + var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile); if (result) { return result; } @@ -85339,7 +86372,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 286 /* Bundle */) { + if (sourceFile.kind === 287 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -85397,6 +86430,8 @@ var ts; } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; function getOutputJSFileName(inputFileName, configFile, ignoreCase) { + if (configFile.options.emitDeclarationOnly) + return undefined; var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ? ".json" /* Json */ : @@ -85428,7 +86463,7 @@ var ts; addOutput(js); if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) continue; - if (configFile.options.sourceMap) { + if (js && configFile.options.sourceMap) { addOutput(js + ".map"); } if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { @@ -85457,6 +86492,11 @@ var ts; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase); if (jsFilePath) return jsFilePath; + if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + continue; + if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { + return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + } } var buildInfoPath = getOutputPathForBuildInfo(configFile.options); if (buildInfoPath) @@ -85466,7 +86506,7 @@ var ts; ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo) { + function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) { var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers; var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; @@ -85480,7 +86520,7 @@ var ts; var exportedModulesFromDeclarationEmit; // Emit each output file enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), forceDtsEmit, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -85618,7 +86658,7 @@ var ts; }); var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit; emitSkipped = emitSkipped || declBlocked; - if (!declBlocked || emitOnlyDtsFiles) { + 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, @@ -85626,12 +86666,8 @@ var ts; mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 285 /* SourceFile */) { - // Improved narrowing in master/3.6 makes this cast unnecessary, triggering a lint rule. - // But at the same time, the LKG (3.5) necessitates it because it doesn’t narrow. - // Once the LKG is updated to 3.6, this comment, the cast to `SourceFile`, and the - // tslint directive can be all be removed. - var sourceFile = declarationTransform.transformed[0]; // tslint:disable-line + if (forceDtsEmit && declarationTransform.transformed[0].kind === 286 /* SourceFile */) { + var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } } @@ -85653,8 +86689,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 286 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 285 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 287 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 286 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -85695,7 +86731,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 285 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 286 /* 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 @@ -85805,7 +86841,7 @@ var ts; }; function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) { var sourceFiles = bundle.sourceFiles.map(function (fileName) { - var sourceFile = ts.createNode(285 /* SourceFile */, 0, 0); + var sourceFile = ts.createNode(286 /* SourceFile */, 0, 0); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = ""; sourceFile.statements = ts.createNodeArray(); @@ -85817,7 +86853,7 @@ var ts; sourceFile.text = prologueInfo.text; sourceFile.end = prologueInfo.text.length; sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { - var statement = ts.createNode(222 /* ExpressionStatement */, directive.pos, directive.end); + var statement = ts.createNode(223 /* ExpressionStatement */, directive.pos, directive.end); statement.expression = ts.createNode(10 /* StringLiteral */, directive.expression.pos, directive.expression.end); statement.expression.text = directive.expression.text; return statement; @@ -85856,7 +86892,7 @@ var ts; var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); }); var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host); var emitHost = { - getPrependNodes: ts.memoize(function () { return prependNodes.concat([ownPrependInput]); }), + getPrependNodes: ts.memoize(function () { return __spreadArrays(prependNodes, [ownPrependInput]); }), getCanonicalFileName: host.getCanonicalFileName, getCommonSourceDirectory: function () { return ts.getNormalizedAbsolutePath(buildInfo.bundle.commonSourceDirectory, buildInfoDirectory); }, getCompilerOptions: function () { return config.options; }, @@ -85910,6 +86946,7 @@ var ts; useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: ts.returnUndefined, getSourceFileFromReference: ts.returnUndefined, + redirectTargetsMap: ts.createMultiMap() }; emitFiles(ts.notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers)); @@ -85990,9 +87027,9 @@ var ts; break; } switch (node.kind) { - case 285 /* SourceFile */: return printFile(node); - case 286 /* Bundle */: return printBundle(node); - case 287 /* UnparsedSource */: return printUnparsedSource(node); + case 286 /* SourceFile */: return printFile(node); + case 287 /* Bundle */: return printBundle(node); + case 288 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -86174,7 +87211,7 @@ var ts; } function setWriter(_writer, _sourceMapGenerator) { if (_writer && printerOptions.omitTrailingSemicolon) { - _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + _writer = ts.getTrailingSemicolonDeferringWriter(_writer); } writer = _writer; // TODO: GH#18217 sourceMapGenerator = _sourceMapGenerator; @@ -86228,12 +87265,12 @@ var ts; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 285 /* SourceFile */) { + if (!commentsDisabled && node.kind !== 286 /* SourceFile */) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 285 /* SourceFile */ && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 286 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through @@ -86270,272 +87307,272 @@ var ts; case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node); - case 287 /* UnparsedSource */: - case 281 /* UnparsedPrepend */: + case 288 /* UnparsedSource */: + case 282 /* UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 280 /* UnparsedPrologue */: + case 281 /* UnparsedPrologue */: return writeUnparsedNode(node); - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 283 /* UnparsedText */: + case 284 /* UnparsedInternalText */: return emitUnparsedTextLike(node); - case 284 /* UnparsedSyntheticReference */: + case 285 /* UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Identifiers case 73 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return emitQualifiedName(node); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return emitTypeParameter(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return emitParameter(node); - case 153 /* Decorator */: + case 154 /* Decorator */: return emitDecorator(node); // Type members - case 154 /* PropertySignature */: + case 155 /* PropertySignature */: return emitPropertySignature(node); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 156 /* MethodSignature */: + case 157 /* MethodSignature */: return emitMethodSignature(node); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 158 /* Constructor */: + case 159 /* Constructor */: return emitConstructor(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return emitAccessorDeclaration(node); - case 161 /* CallSignature */: + case 162 /* CallSignature */: return emitCallSignature(node); - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: return emitConstructSignature(node); - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: return emitIndexSignature(node); // Types - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return emitTypePredicate(node); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return emitTypeReference(node); - case 166 /* FunctionType */: + case 167 /* FunctionType */: return emitFunctionType(node); - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 167 /* ConstructorType */: + case 168 /* ConstructorType */: return emitConstructorType(node); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return emitTypeQuery(node); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return emitTypeLiteral(node); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return emitArrayType(node); - case 171 /* TupleType */: + case 172 /* TupleType */: return emitTupleType(node); - case 172 /* OptionalType */: + case 173 /* OptionalType */: return emitOptionalType(node); - case 174 /* UnionType */: + case 175 /* UnionType */: return emitUnionType(node); - case 175 /* IntersectionType */: + case 176 /* IntersectionType */: return emitIntersectionType(node); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return emitConditionalType(node); - case 177 /* InferType */: + case 178 /* InferType */: return emitInferType(node); - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return emitParenthesizedType(node); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 179 /* ThisType */: + case 180 /* ThisType */: return emitThisType(); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: return emitTypeOperator(node); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 182 /* MappedType */: + case 183 /* MappedType */: return emitMappedType(node); - case 183 /* LiteralType */: + case 184 /* LiteralType */: return emitLiteralType(node); - case 184 /* ImportType */: + case 185 /* ImportType */: return emitImportTypeNode(node); - case 290 /* JSDocAllType */: + case 291 /* JSDocAllType */: writePunctuation("*"); return; - case 291 /* JSDocUnknownType */: + case 292 /* JSDocUnknownType */: writePunctuation("?"); return; - case 292 /* JSDocNullableType */: + case 293 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 293 /* JSDocNonNullableType */: + case 294 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 294 /* JSDocOptionalType */: + case 295 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 173 /* RestType */: - case 296 /* JSDocVariadicType */: + case 174 /* RestType */: + case 297 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 186 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return emitBindingElement(node); // Misc - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return emitTemplateSpan(node); - case 218 /* SemicolonClassElement */: + case 219 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 219 /* Block */: + case 220 /* Block */: return emitBlock(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return emitVariableStatement(node); - case 221 /* EmptyStatement */: + case 222 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return emitExpressionStatement(node); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return emitIfStatement(node); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return emitDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return emitWhileStatement(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return emitForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return emitForInStatement(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return emitForOfStatement(node); - case 229 /* ContinueStatement */: + case 230 /* ContinueStatement */: return emitContinueStatement(node); - case 230 /* BreakStatement */: + case 231 /* BreakStatement */: return emitBreakStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return emitReturnStatement(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return emitWithStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return emitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return emitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return emitThrowStatement(node); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return emitTryStatement(node); - case 237 /* DebuggerStatement */: + case 238 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return emitClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return emitModuleBlock(node); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return emitCaseBlock(node); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return emitImportDeclaration(node); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return emitImportClause(node); - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return emitNamespaceImport(node); - case 253 /* NamedImports */: + case 254 /* NamedImports */: return emitNamedImports(node); - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return emitImportSpecifier(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return emitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return emitExportDeclaration(node); - case 257 /* NamedExports */: + case 258 /* NamedExports */: return emitNamedExports(node); - case 258 /* ExportSpecifier */: + case 259 /* ExportSpecifier */: return emitExportSpecifier(node); - case 259 /* MissingDeclaration */: + case 260 /* MissingDeclaration */: return; // Module references - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: + case 264 /* JsxOpeningElement */: + case 267 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 264 /* JsxClosingElement */: - case 267 /* JsxClosingFragment */: + case 265 /* JsxClosingElement */: + case 268 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return emitJsxAttribute(node); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return emitJsxAttributes(node); - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 272 /* CaseClause */: + case 273 /* CaseClause */: return emitCaseClause(node); - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: return emitDefaultClause(node); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: return emitHeritageClause(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 279 /* EnumMember */: + case 280 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: + case 314 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 308 /* JSDocThisTag */: - case 305 /* JSDocEnumTag */: + case 309 /* JSDocReturnTag */: + case 311 /* JSDocTypeTag */: + case 310 /* JSDocThisTag */: + case 307 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); - case 301 /* JSDocAugmentsTag */: + case 303 /* JSDocAugmentsTag */: return emitJSDocAugmentsTag(node); - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 311 /* JSDocTypedefTag */: + case 313 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 304 /* JSDocCallbackTag */: + case 306 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); - case 299 /* JSDocSignature */: + case 301 /* JSDocSignature */: return emitJSDocSignature(node); - case 298 /* JSDocTypeLiteral */: + case 300 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 303 /* JSDocClassTag */: - case 300 /* JSDocTag */: + case 305 /* JSDocClassTag */: + case 302 /* JSDocTag */: return emitJSDocSimpleTag(node); - case 297 /* JSDocComment */: + case 299 /* JSDocComment */: return emitJSDoc(node); // Transformation nodes (ignored) } @@ -86572,71 +87609,71 @@ var ts; writeTokenNode(node, writeKeyword); return; // Expressions - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return emitCallExpression(node); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return emitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return emitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return emitArrowFunction(node); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return emitDeleteExpression(node); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return emitVoidExpression(node); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return emitAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return emitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return emitConditionalExpression(node); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return emitTemplateExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return emitYieldExpression(node); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return emitSpreadExpression(node); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return emitClassExpression(node); - case 211 /* OmittedExpression */: + case 212 /* OmittedExpression */: return; - case 213 /* AsExpression */: + case 214 /* AsExpression */: return emitAsExpression(node); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: return emitNonNullExpression(node); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 261 /* JsxElement */: + case 262 /* JsxElement */: return emitJsxElement(node); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: return emitCommaList(node); } } @@ -86664,8 +87701,8 @@ var ts; var helpers = getSortedEmitHelpers(sourceFile); if (!helpers) continue; - for (var _c = 0, helpers_3 = helpers; _c < helpers_3.length; _c++) { - var helper = helpers_3[_c]; + for (var _c = 0, helpers_4 = helpers; _c < helpers_4.length; _c++) { + var helper = helpers_4[_c]; if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) { bundledHelpers.set(helper.name, true); (result || (result = [])).push(helper.name); @@ -86676,7 +87713,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 286 /* Bundle */ ? node : undefined; + var bundle = node.kind === 287 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -86685,12 +87722,12 @@ var ts; for (var i = 0; i < numNodes; i++) { var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node; var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile; - var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.hasRecordedExternalHelpers(sourceFile)); var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit; var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode); if (helpers) { - for (var _a = 0, helpers_4 = helpers; _a < helpers_4.length; _a++) { - var helper = helpers_4[_a]; + for (var _a = 0, helpers_5 = helpers; _a < helpers_5.length; _a++) { + var helper = helpers_5[_a]; if (!helper.scoped) { // Skip the helper if it can be skipped and the noEmitHelpers compiler // option is set, or if it can be imported and the importHelpers compiler @@ -86776,7 +87813,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 282 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 283 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -86845,7 +87882,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 295 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 296 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -86907,7 +87944,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 159 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 160 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -87314,7 +88351,7 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 203 /* PrefixUnaryExpression */ + return operand.kind === 204 /* PrefixUnaryExpression */ && ((node.operator === 38 /* PlusToken */ && (operand.operator === 38 /* PlusToken */ || operand.operator === 44 /* PlusPlusToken */)) || (node.operator === 39 /* MinusToken */ && (operand.operator === 39 /* MinusToken */ || operand.operator === 45 /* MinusMinusToken */))); } @@ -87443,7 +88480,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); emitTokenWithComment(84 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 223 /* IfStatement */) { + if (node.elseStatement.kind === 224 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -87469,7 +88506,7 @@ var ts; writeLineOrSpace(node); } emitWhileClause(node, node.statement.end); - writePunctuation(";"); + writeTrailingSemicolon(); } function emitWhileStatement(node) { emitWhileClause(node, node.pos); @@ -87506,7 +88543,7 @@ var ts; emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(148 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(149 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -87514,7 +88551,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 240 /* VariableDeclarationList */) { emit(node); } else { @@ -87629,7 +88666,7 @@ var ts; writeKeyword("function"); emit(node.asteriskToken); writeSpace(); - emitIdentifierName(node.name); // TODO: GH#18217 + emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } function emitBlockCallback(_hint, body) { @@ -87809,7 +88846,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 245 /* ModuleDeclaration */) { + while (body.kind === 246 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -88130,7 +89167,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 309 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 311 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -88164,7 +89201,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 290 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -88183,7 +89220,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 298 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 300 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -88317,8 +89354,8 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } - for (var _d = 0, types_19 = types; _d < types_19.length; _d++) { - var directive = types_19[_d]; + for (var _d = 0, types_18 = types; _d < types_18.length; _d++) { + var directive = types_18[_d]; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) @@ -88961,7 +89998,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 197 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -89026,81 +90063,81 @@ var ts; if (!node) return; switch (node.kind) { - case 219 /* Block */: + case 220 /* Block */: ts.forEach(node.statements, generateNames); break; - case 234 /* LabeledStatement */: - case 232 /* WithStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 235 /* LabeledStatement */: + case 233 /* WithStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: generateNames(node.statement); break; - case 223 /* IfStatement */: + case 224 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 227 /* ForStatement */: + case 229 /* ForOfStatement */: + case 228 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 236 /* TryStatement */: + case 237 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 275 /* CatchClause */: + case 276 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: generateNames(node.declarationList); break; - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: + case 239 /* VariableDeclaration */: + case 153 /* Parameter */: + case 188 /* BindingElement */: + case 242 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: generateNames(node.importClause); break; - case 251 /* ImportClause */: + case 252 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 253 /* NamedImports */: + case 254 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -89109,12 +90146,12 @@ var ts; if (!node) return; switch (node.kind) { - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -89172,7 +90209,7 @@ var ts; if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (local && local.flags & (67220415 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { + if (local && local.flags & (111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { return false; } } @@ -89296,23 +90333,23 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 255 /* ExportAssignment */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 256 /* ExportAssignment */: return generateNameForExportDefault(); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return generateNameForClassExpression(); - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -89359,7 +90396,7 @@ var ts; hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 314 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 316 /* 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 */; @@ -89383,7 +90420,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 240 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -89640,7 +90677,7 @@ var ts; 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 !== 314 /* NotEmittedStatement */ + if (node.kind !== 316 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -89653,7 +90690,7 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 314 /* NotEmittedStatement */ + if (node.kind !== 316 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); @@ -90021,6 +91058,9 @@ var ts; var createFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile); var createFilePathWatcher = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher; var createDirectoryWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory); + if (watchLogLevel === WatchLogLevel.Verbose && ts.sysLog === ts.noop) { + ts.sysLog = function (s) { return log(s); }; + } return { watchFile: function (host, file, callback, pollingInterval, detailInfo1, detailInfo2) { return createFileWatcher(host, file, callback, pollingInterval, /*passThrough*/ undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo); @@ -90376,7 +91416,7 @@ var ts; } ts.changeCompilerHostLikeToUseCache = changeCompilerHostLikeToUseCache; function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { - var diagnostics = program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (ts.getEmitDeclarations(program.getCompilerOptions())) { ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } @@ -90565,8 +91605,8 @@ var ts; } var resolutions = []; var cache = ts.createMap(); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name = names_1[_i]; + for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { + var name = names_2[_i]; var result = void 0; if (cache.has(name)) { result = cache.get(name); @@ -90653,7 +91693,7 @@ var ts; } ts.isProgramUptoDate = isProgramUptoDate; function getConfigFileParsingDiagnostics(configFileParseResult) { - return configFileParseResult.options.configFile ? configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : + return configFileParseResult.options.configFile ? __spreadArrays(configFileParseResult.options.configFile.parseDiagnostics, configFileParseResult.errors) : configFileParseResult.errors; } ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; @@ -90683,7 +91723,6 @@ var ts; var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217 var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; var oldProgram = createProgramOptions.oldProgram; - var program; var processingDefaultLibFiles; var processingOtherFiles; var files; @@ -90692,6 +91731,8 @@ var ts; var noDiagnosticsTypeChecker; var classifiableNames; var ambientModuleNameToUnmodifiedFileName = ts.createMap(); + // Todo:: Use this to report why file was included in --extendedDiagnostics + var refFileMap; var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -90727,7 +91768,7 @@ var ts; var resolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference).map(function (resolved) { + resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).map(function (resolved) { // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName. if (!resolved || resolved.extension !== undefined) { return resolved; @@ -90744,7 +91785,7 @@ var ts; } var resolveTypeReferenceDirectiveNamesWorker; if (host.resolveTypeReferenceDirectives) { - resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference); }; + resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); }; } else { var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 @@ -90774,7 +91815,10 @@ var ts; var projectReferenceRedirects; var mapFromFileToProjectReferenceRedirects; var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); - var structuralIsReused = tryReuseStructureFromOldProgram(); + // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks + // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. + var structuralIsReused; + structuralIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const if (structuralIsReused !== 2 /* Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -90861,12 +91905,13 @@ var ts; } // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; - program = { + var program = { getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFileByPath: getSourceFileByPath, getSourceFiles: function () { return files; }, getMissingFilePaths: function () { return missingFilePaths; }, + getRefFileMap: function () { return refFileMap; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, getOptionsDiagnostics: getOptionsDiagnostics, @@ -91298,6 +92343,7 @@ var ts; return oldProgram.structureIsReused = 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); + refFileMap = oldProgram.getRefFileMap(); // update fileName -> file mapping for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) { var newSourceFile = newSourceFiles_1[_f]; @@ -91320,7 +92366,7 @@ var ts; return oldProgram.structureIsReused = 2 /* Completely */; } function getEmitHost(writeFileCallback) { - return __assign({ getPrependNodes: getPrependNodes, + return __assign(__assign({ getPrependNodes: getPrependNodes, getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { // Use local caches @@ -91331,7 +92377,7 @@ var ts; return false; // Before falling back to the host return host.fileExists(f); - } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); } }); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); }, redirectTargetsMap: redirectTargetsMap }); } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!options.out && !options.outFile); @@ -91387,15 +92433,15 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.has(toPath(emitFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) { var declarationDiagnostics = []; - if (!emitOnlyDtsFiles) { + if (!forceDtsEmit) { if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; } @@ -91403,7 +92449,7 @@ var ts; // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we // get any preEmit diagnostics, not just the ones if (options.noEmitOnError) { - var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (diagnostics.length === 0 && ts.getEmitDeclarations(program.getCompilerOptions())) { declarationDiagnostics = program.getDeclarationDiagnostics(/*sourceFile*/ undefined, cancellationToken); } @@ -91427,7 +92473,8 @@ var ts; // checked is to not pass the file to getEmitResolver. var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, + /*onlyBuildInfo*/ false, forceDtsEmit); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -91569,22 +92616,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 152 /* Parameter */: - case 155 /* PropertyDeclaration */: + case 153 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 238 /* VariableDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: + case 239 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -91592,41 +92639,41 @@ var ts; } } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 110 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 213 /* AsExpression */: + case 214 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -91639,28 +92686,28 @@ 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 241 /* ClassDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // falls through - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 220 /* VariableStatement */); + return checkModifiers(parent.modifiers, parent.kind === 221 /* VariableStatement */); } break; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { @@ -91672,18 +92719,19 @@ var ts; return; } break; - case 152 /* Parameter */: + case 153 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 213 /* ExpressionWithTypeArguments */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 195 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -91874,7 +92922,7 @@ var ts; } function collectDynamicImportOrRequireCalls(file) { var r = /import|require/g; - while (r.exec(file.text) !== null) { + while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null var node = getNodeAtPosition(file, r.lastIndex); if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { imports = ts.append(imports, node.arguments[0]); @@ -91955,24 +93003,18 @@ var ts; } } /** This has side effects through `findSourceFile`. */ - function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId); }, // TODO: GH#18217 + function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, // TODO: GH#18217 function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined - ? ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(args)) : ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(args))); - }, refFile); + return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args))); + }, refFile && refFile.file); } - function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile) { + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { var redirect = Object.create(redirectTarget); @@ -91995,7 +93037,7 @@ var ts; return redirect; } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId) { + function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) { var originalFileName = fileName; if (filesByName.has(path)) { var file_1 = filesByName.get(path); @@ -92012,7 +93054,7 @@ var ts; var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory); var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory); if (checkedAbsolutePath !== inputAbsolutePath) { - reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile); } } // If the file was previously found via a node_modules search, but is now being processed as a root file, @@ -92036,6 +93078,7 @@ var ts; processImportedModules(file_1); } } + addFileToRefFileMap(file_1 || undefined, refFile); return file_1 || undefined; } var redirectedPath; @@ -92057,14 +93100,7 @@ var ts; } } // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }, shouldCreateNewSourceFile); + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { return fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); }, shouldCreateNewSourceFile); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); @@ -92095,7 +93131,7 @@ var ts; // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case var existingFile = filesByNameIgnoreCase.get(pathLowerCase); if (existingFile) { - reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile); } else { filesByNameIgnoreCase.set(pathLowerCase, file); @@ -92118,8 +93154,18 @@ var ts; processingOtherFiles.push(file); } } + addFileToRefFileMap(file, refFile); return file; } + function addFileToRefFileMap(file, refFile) { + if (refFile && file) { + (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, { + kind: refFile.kind, + index: refFile.index, + file: refFile.file.path + }); + } + } function addFileToFilesByName(file, path, redirectedPath) { if (redirectedPath) { filesByName.set(redirectedPath, file); @@ -92208,9 +93254,17 @@ var ts; return projectReferenceRedirects.get(projectReferencePath) || undefined; } function processReferencedFiles(file, isDefaultLib) { - ts.forEach(file.referencedFiles, function (ref) { + ts.forEach(file.referencedFiles, function (ref, index) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); - processSourceFile(referencedFileName, isDefaultLib, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, + /*ignoreNoDefaultLib*/ false, + /*packageId*/ undefined, { + kind: ts.RefFileKind.ReferenceFile, + index: index, + file: file, + pos: ref.pos, + end: ref.end + }); }); } function processTypeReferenceDirectives(file) { @@ -92226,10 +93280,16 @@ var ts; // store resolved type directive on the file var fileName = ref.fileName.toLocaleLowerCase(); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); - processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); + processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { + kind: ts.RefFileKind.TypeReferenceDirective, + index: i, + file: file, + pos: ref.pos, + end: ref.end + }); } } - function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { + function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) { // If we already found this library as a primary reference - nothing to do var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { @@ -92241,7 +93301,7 @@ var ts; currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); // TODO: GH#18217 } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -92251,8 +93311,7 @@ var ts; if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, // TODO: GH#18217 - ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); } } // don't overwrite previous resolution result @@ -92260,14 +93319,14 @@ var ts; } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); } } if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--; } else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); @@ -92285,20 +93344,20 @@ var ts; var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts"); var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; - fileProcessingDiagnostics.add(createDiagnostic(file, libReference.pos, libReference.end, message, libName, suggestion)); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion)); } }); } - function createDiagnostic(refFile, refPos, refEnd, message) { + function createRefFileDiagnostic(refFile, message) { var args = []; - for (var _i = 4; _i < arguments.length; _i++) { - args[_i - 4] = arguments[_i]; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; } - if (refFile === undefined || refPos === undefined || refEnd === undefined) { - return ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)); + if (!refFile) { + return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)); } else { - return ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, message].concat(args)); + return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args)); } } function getCanonicalFileName(fileName) { @@ -92345,7 +93404,15 @@ var ts; else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, file, pos, file.imports[i].end, resolution.packageId); + findSourceFile(resolvedFileName, path, + /*isDefaultLib*/ false, + /*ignoreNoDefaultLib*/ false, { + kind: ts.RefFileKind.Import, + index: i, + file: file, + pos: pos, + end: file.imports[i].end + }, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -92364,12 +93431,15 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + var rootPaths; for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { var sourceFile = sourceFiles_2[_i]; if (!sourceFile.isDeclarationFile) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory)); + if (!rootPaths) + rootPaths = ts.arrayToSet(rootNames, toPath); + addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory); allFilesBelongToPath = false; } } @@ -92463,17 +93533,20 @@ var ts; else if (options.incremental && !options.outFile && !options.out && !options.configFilePath) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified)); } + if (options.noEmit && ts.isIncrementalCompilation(options)) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", options.incremental ? "incremental" : "composite"); + } verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { - var rootPaths = rootNames.map(toPath); + var rootPaths = ts.arrayToSet(rootNames, toPath); for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { var file = files_3[_i]; // Ignore file that is not emitted if (!ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) continue; - if (rootPaths.indexOf(file.path) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || "")); + if (!rootPaths.has(file.path)) { + addProgramDiagnosticAtRefPath(file, rootPaths, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || ""); } } } @@ -92655,6 +93728,39 @@ var ts; } } } + function addProgramDiagnosticAtRefPath(file, rootPaths, message) { + var _a, _b; + var args = []; + for (var _i = 3; _i < arguments.length; _i++) { + args[_i - 3] = arguments[_i]; + } + var refPaths = refFileMap && refFileMap.get(file.path); + var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) || + ts.elementAt(refPaths, 0); + if (refPathToReportErrorOn) { + var refFile = ts.Debug.assertDefined(getSourceFileByPath(refPathToReportErrorOn.file)); + var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index; + var pos = void 0, end = void 0; + switch (kind) { + case ts.RefFileKind.Import: + pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos); + end = refFile.imports[index].end; + break; + case ts.RefFileKind.ReferenceFile: + (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end); + break; + case ts.RefFileKind.TypeReferenceDirective: + (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end); + break; + default: + return ts.Debug.assertNever(kind); + } + programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args))); + } + else { + programDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); + } + } function verifyProjectReferences() { var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { @@ -92758,7 +93864,7 @@ var ts; } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { - _compilerOptionsObjectLiteralSyntax = null; // tslint:disable-line:no-null-keyword + _compilerOptionsObjectLiteralSyntax = null; // eslint-disable-line no-null/no-null var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); if (jsonObjectLiteral) { for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) { @@ -92914,9 +94020,9 @@ var ts; /*@internal*/ var ts; (function (ts) { - function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers) { + function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit); return { outputFiles: outputFiles, emitSkipped: emitResult.emitSkipped, exportedModulesFromDeclarationEmit: emitResult.exportedModulesFromDeclarationEmit }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); @@ -93162,11 +94268,19 @@ var ts; } } else { - var emitOutput = ts.getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken); - if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { - latestSignature = computeHash(emitOutput.outputFiles[0].text); + var emitOutput_1 = ts.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; + 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(firstDts_1.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { - updateExportedModules(sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache); + updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); } } else { @@ -93372,6 +94486,11 @@ var ts; /*@internal*/ var ts; (function (ts) { + var BuilderFileEmit; + (function (BuilderFileEmit) { + BuilderFileEmit[BuilderFileEmit["DtsOnly"] = 0] = "DtsOnly"; + BuilderFileEmit[BuilderFileEmit["Full"] = 1] = "Full"; + })(BuilderFileEmit = ts.BuilderFileEmit || (ts.BuilderFileEmit = {})); function hasSameKeys(map1, map2) { // Has same size and every key is present in both maps return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); @@ -93409,7 +94528,8 @@ var ts; ts.copyEntries(changedFilesSet, state.changedFilesSet); } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; + state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice(); + state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind); state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; } } @@ -93455,7 +94575,7 @@ var ts; }); if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - addToAffectedFilesPendingEmit(state, newProgram.getSourceFiles().map(function (f) { return f.path; })); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.path, 1 /* Full */); }); ts.Debug.assert(state.seenAffectedFiles === undefined); state.seenAffectedFiles = ts.createMap(); } @@ -93483,7 +94603,7 @@ var ts; } function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); } /** * Releases program and other related not needed properties @@ -93509,7 +94629,8 @@ var ts; newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState); newState.program = state.program; newState.compilerOptions = state.compilerOptions; - newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit; + newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); + newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind); newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles); newState.programEmitComplete = state.programEmitComplete; @@ -93541,7 +94662,6 @@ var ts; handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash); return affectedFile; } - seenAffectedFiles.set(affectedFile.path, true); affectedFilesIndex++; } // Remove the changed file from the change set @@ -93587,13 +94707,18 @@ var ts; var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap()); for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) { var affectedFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]); - if (affectedFile && !seenEmittedFiles.has(affectedFile.path)) { - // emit this file - state.affectedFilesPendingEmitIndex = i; - return affectedFile; + if (affectedFile) { + var seenKind = seenEmittedFiles.get(affectedFile.path); + var emitKind = ts.Debug.assertDefined(ts.Debug.assertDefined(state.affectedFilesPendingEmitKind).get(affectedFile.path)); + if (seenKind === undefined || seenKind < emitKind) { + // emit this file + state.affectedFilesPendingEmitIndex = i; + return { affectedFile: affectedFile, emitKind: emitKind }; + } } } state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; state.affectedFilesPendingEmitIndex = undefined; } return undefined; @@ -93637,7 +94762,7 @@ var ts; ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.assertDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, [path]); + addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); } } } @@ -93731,7 +94856,7 @@ var ts; * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly */ - function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit) { + function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) { if (isBuildInfoEmit) { state.emittedBuildInfo = true; } @@ -93741,6 +94866,9 @@ var ts; } else { state.seenAffectedFiles.set(affected.path, true); + if (emitKind !== undefined) { + (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, emitKind); + } if (isPendingEmit) { state.affectedFilesPendingEmitIndex++; } @@ -93752,8 +94880,15 @@ var ts; /** * Returns the result with affected file */ - function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); + function toAffectedFileResult(state, result, affected) { + doneWithAffectedFile(state, affected); + return { result: result, affected: affected }; + } + /** + * Returns the result with affected file + */ + function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } /** @@ -93878,7 +95013,7 @@ var ts; } function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? relativeToBuildInfo(file.path) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.path) : undefined }); } var BuilderProgramKind; (function (BuilderProgramKind) { @@ -93976,22 +95111,24 @@ var ts; */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var emitKind = 1 /* Full */; var isPendingEmitFile = false; if (!affected) { if (!state.compilerOptions.out && !state.compilerOptions.outFile) { - affected = getNextAffectedFilePendingEmit(state); - if (!affected) { + var pendingAffectedFile = getNextAffectedFilePendingEmit(state); + if (!pendingAffectedFile) { if (state.emittedBuildInfo) { return undefined; } var affected_1 = ts.Debug.assertDefined(state.program); - return toAffectedFileResult(state, + return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } + (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind); isPendingEmitFile = true; } else { @@ -94004,10 +95141,10 @@ var ts; affected = program; } } - return toAffectedFileResult(state, + return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers), affected, isPendingEmitFile); + ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); } /** * Emits the JavaScript and declaration files. @@ -94063,7 +95200,7 @@ var ts; } // Add file to affected file pending emit to handle for later emit time if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - addToAffectedFilesPendingEmit(state, [affected.path]); + addToAffectedFilesPendingEmit(state, affected.path, 1 /* Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -94095,7 +95232,7 @@ var ts; } // When semantic builder asks for diagnostics of the whole program, // ensure that all the affected files are handled - // tslint:disable-next-line no-empty + // eslint-disable-next-line no-empty while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) { } var diagnostics; @@ -94107,8 +95244,14 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; - function addToAffectedFilesPendingEmit(state, affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit); + function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) { + if (!state.affectedFilesPendingEmit) + state.affectedFilesPendingEmit = []; + if (!state.affectedFilesPendingEmitKind) + state.affectedFilesPendingEmitKind = ts.createMap(); + var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit); + state.affectedFilesPendingEmit.push(affectedFilePendingEmit); + state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind); // affectedFilesPendingEmitIndex === undefined // - means the emit state.affectedFilesPendingEmit was undefined before adding current affected files // so start from 0 as array would be affectedFilesPendingEmit @@ -94144,7 +95287,7 @@ var ts; compilerOptions: convertFromReusableCompilerOptions(program.options, toAbsolutePath), referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), - semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return ts.isString(value) ? value : value[0]; }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), + 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]; }), hasReusableDiagnostic: true }; return { @@ -94270,15 +95413,27 @@ var ts; // ignore "/user", "c:/users" or "c:/folderAtRoot" return false; } - if (dirPath.charCodeAt(0) !== 47 /* slash */ && - dirPath.substr(rootLength, nextDirectorySeparator).search(/users/i) === -1) { + var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + if (isNonDirectorySeparatorRoot && + dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths + pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart + nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1); + if (nextDirectorySeparator === -1) { + // ignore "//vda1cs4850/c$/folderAtRoot" + return false; + } + pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1); + } + if (isNonDirectorySeparatorRoot && + pathPartForUserCheck.search(/users\//i) !== 0) { // Paths like c:/folderAtRoot/subFolder are allowed return true; } for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) { searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1; if (searchIndex === 0) { - // Folder isnt at expected minimun levels + // Folder isnt at expected minimum levels return false; } } @@ -94443,8 +95598,8 @@ var ts; !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path : !!redirectedReference; var seenNamesInFile = ts.createMap(); - for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name = names_2[_i]; + for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { + var name = names_3[_i]; var resolution = resolutionsInFile.get(name); // Resolution is valid if it is present and not invalidated if (!seenNamesInFile.has(name) && @@ -94524,7 +95679,7 @@ var ts; if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { // Ensure failed look up is normalized path failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); - ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); // tslint:disable-line + ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); var subDirectoryInRoot = failedLookupLocationPath.indexOf(ts.directorySeparator, rootPath.length + 1); if (subDirectoryInRoot !== -1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution @@ -94920,8 +96075,9 @@ var ts; function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, - ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? + 2 /* JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, oldImportSpecifier) { @@ -94950,7 +96106,7 @@ var ts; return [ambient]; var info = getInfo(importingSourceFile.path, host); var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); - var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.fileName, info.getCanonicalFileName, host, redirectTargetsMap); + var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.originalFileName, info.getCanonicalFileName, host, redirectTargetsMap); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); var global = ts.mapDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }); return global.length ? global : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifier(moduleFileName, info, compilerOptions, preferences); }); @@ -94966,7 +96122,7 @@ var ts; var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; var ending = _b.ending, relativePreference = _b.relativePreference; var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; - var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); if (!baseUrl || relativePreference === 0 /* Relative */) { return relativePath; @@ -95041,7 +96197,7 @@ var ts; */ function getAllModulePaths(files, importingFileName, importedFileName, getCanonicalFileName, host, redirectTargetsMap) { var redirects = redirectTargetsMap.get(importedFileName); - var importedFileNames = redirects ? redirects.concat([importedFileName]) : [importedFileName]; + var importedFileNames = redirects ? __spreadArrays(redirects, [importedFileName]) : [importedFileName]; var cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); var links = discoverProbableSymlinks(files, getCanonicalFileName, cwd); @@ -95092,14 +96248,16 @@ var ts; } } } - function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) { + function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) { var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName); if (normalizedTargetPath === undefined) { return undefined; } var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName); var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath; - return ts.removeFileExtension(relativePath); + return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs + ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) + : ts.removeFileExtension(relativePath); } function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; @@ -95531,7 +96689,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); if (result) { result.version = computeHash.call(host, result.text); } @@ -95545,7 +96703,9 @@ var ts; function createProgramHost(system, createProgram) { var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); }); var host = system; - host; // tslint:disable-line no-unused-expression (TODO: `host` is unused!) + // TODO: `host` is unused! + // eslint-disable-next-line no-unused-expressions + host; return { useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; }, getNewLine: function () { return system.newLine; }, @@ -95579,7 +96739,7 @@ var ts; result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); }); }; return result; } @@ -95721,7 +96881,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - return getVersionedSourceFileByPath.apply(void 0, [fileName, toPath(fileName)].concat(args)); + return getVersionedSourceFileByPath.apply(void 0, __spreadArrays([fileName, toPath(fileName)], args)); }; compilerHost.getSourceFileByPath = getVersionedSourceFileByPath; compilerHost.getNewLine = function () { return newLine; }; @@ -95749,10 +96909,22 @@ var ts; /*logChangesWhenResolvingModule*/ false); // Resolve module using host module resolution strategy if provided otherwise use resolution cache to resolve module names compilerHost.resolveModuleNames = host.resolveModuleNames ? - (function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveModuleNames.apply(host, args); + }) : (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }); compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ? - (function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveTypeReferenceDirectives.apply(host, args); + }) : (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; builderProgram = readBuilderProgram(compilerOptions, compilerHost); @@ -95978,13 +97150,19 @@ var ts; reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); switch (reloadLevel) { case ts.ConfigFileProgramReloadLevel.Partial: - return reloadFileNamesFromConfigFile(); + ts.perfLogger.logStartUpdateProgram("PartialConfigReload"); + reloadFileNamesFromConfigFile(); + break; case ts.ConfigFileProgramReloadLevel.Full: - return reloadConfigFile(); + ts.perfLogger.logStartUpdateProgram("FullConfigReload"); + reloadConfigFile(); + break; default: + ts.perfLogger.logStartUpdateProgram("SynchronizeProgram"); synchronizeProgram(); - return; + break; } + ts.perfLogger.logStopUpdateProgram("Done"); } function reloadFileNamesFromConfigFile() { writeLog("Reloading new file names and options"); @@ -96168,6 +97346,16 @@ var ts; function isDeclarationFile(fileName) { return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */); } + /*@internal*/ + function isCircularBuildOrder(buildOrder) { + return !!buildOrder && !!buildOrder.buildOrder; + } + ts.isCircularBuildOrder = isCircularBuildOrder; + /*@internal*/ + function getBuildOrderFromAnyBuildOrder(anyBuildOrder) { + return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder; + } + ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ @@ -96329,11 +97517,14 @@ var ts; var permanentMarks = ts.createMap(); var circularityReportStack = []; var buildOrder; + var circularDiagnostics; for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { var root = roots_1[_i]; visit(root); } - return buildOrder || ts.emptyArray; + return circularDiagnostics ? + { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } : + buildOrder || ts.emptyArray; function visit(configFileName, inCircularContext) { var projPath = toResolvedConfigFilePath(state, configFileName); // Already visited @@ -96342,8 +97533,7 @@ var ts; // Circular if (temporaryMarks.has(projPath)) { if (!inCircularContext) { - // TODO:: Do we report this as error? - reportStatus(state, ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")); + (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n"))); } return; } @@ -96363,12 +97553,35 @@ var ts; } } function getBuildOrder(state) { - return state.buildOrder || - (state.buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }))); + return state.buildOrder || createStateBuildOrder(state); + } + function createStateBuildOrder(state) { + var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); })); + // Clear all to ResolvedConfigFilePaths cache to start fresh + state.resolvedConfigFilePaths.clear(); + var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); }); + var noopOnDelete = { onDeleteValue: ts.noop }; + // Config file cache + ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete); + // Remove watches for the program no longer in the solution + if (state.watch) { + ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher }); + ts.mutateMapSkippingNewValues(state.allWatchedWildcardDirectories, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcherOf); } }); + ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } }); + } + return state.buildOrder = buildOrder; } function getBuildOrderFor(state, project, onlyReferences) { var resolvedProject = project && resolveProjectName(state, project); var buildOrderFromState = getBuildOrder(state); + if (isCircularBuildOrder(buildOrderFromState)) + return buildOrderFromState; if (resolvedProject) { var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject); var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; }); @@ -96376,6 +97589,7 @@ var ts; return undefined; } var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState; + ts.Debug.assert(!isCircularBuildOrder(buildOrder)); ts.Debug.assert(!onlyReferences || resolvedProject !== undefined); ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject); return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder; @@ -96392,7 +97606,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); }), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, getSourceFileWithCache = _a.getSourceFileWithCache, readFileWithCache = _a.readFileWithCache; state.readFileWithCache = readFileWithCache; compilerHost.getSourceFile = getSourceFileWithCache; @@ -96447,7 +97661,7 @@ var ts; reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode); } enableCache(state); - var buildOrder = getBuildOrder(state); + var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state)); buildOrder.forEach(function (configFileName) { return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None); }); @@ -96619,7 +97833,7 @@ var ts; } function getSyntaxDiagnostics(cancellationToken) { ts.Debug.assertDefined(program); - handleDiagnostics(program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); + handleDiagnostics(__spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); } function getSemanticDiagnostics(cancellationToken) { handleDiagnostics(ts.Debug.assertDefined(program).getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic"); @@ -96787,6 +98001,8 @@ var ts; function getNextInvalidatedProject(state, buildOrder, reportQueue) { if (!state.projectPendingBuild.size) return undefined; + if (isCircularBuildOrder(buildOrder)) + return undefined; if (state.currentInvalidatedProject) { // Only if same buildOrder the currentInvalidated project can be sent again return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ? @@ -96843,8 +98059,11 @@ var ts; if (status.type === ts.UpToDateStatusType.UpstreamBlocked) { reportAndStoreErrors(state, projectPath, config.errors); projectPendingBuild.delete(projectPath); - if (options.verbose) - reportStatus(state, ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + if (options.verbose) { + reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built : + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + } continue; } if (status.type === ts.UpToDateStatusType.ContainerOnly) { @@ -97015,10 +98234,12 @@ var ts; continue; } // An upstream project is blocked - if (refStatus.type === ts.UpToDateStatusType.Unbuildable) { + if (refStatus.type === ts.UpToDateStatusType.Unbuildable || + refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) { return { type: ts.UpToDateStatusType.UpstreamBlocked, - upstreamProjectName: ref.path + upstreamProjectName: ref.path, + upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked }; } // If the upstream project is out of date, then so are we (someone shouldn't have asked, though?) @@ -97242,16 +98463,22 @@ var ts; disableCache(state); reportErrorSummary(state, buildOrder); startWatching(state, buildOrder); - return errorProjects ? - successfulProjects ? - ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : - ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : - ts.ExitStatus.Success; + return isCircularBuildOrder(buildOrder) ? + ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped : + errorProjects ? + successfulProjects ? + ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : + ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : + ts.ExitStatus.Success; } function clean(state, project, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; + if (isCircularBuildOrder(buildOrder)) { + reportErrors(state, buildOrder.circularDiagnostics); + return ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped; + } var options = state.options, host = state.host; var filesToDelete = options.dry ? [] : undefined; for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) { @@ -97394,8 +98621,8 @@ var ts; if (!state.watchAllProjectsPending) return; state.watchAllProjectsPending = false; - for (var _i = 0, buildOrder_2 = buildOrder; _i < buildOrder_2.length; _i++) { - var resolved = buildOrder_2[_i]; + for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) { + var resolved = _a[_i]; var resolvedPath = toResolvedConfigFilePath(state, resolved); // Watch this file watchConfigFile(state, resolved, resolvedPath); @@ -97427,6 +98654,7 @@ var ts; }, invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); }, buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); }, + getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); }, }; } function relName(state, path) { @@ -97437,7 +98665,7 @@ var ts; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } - state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args))); + state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); } function reportWatchStatus(state, message) { var args = []; @@ -97445,7 +98673,7 @@ var ts; args[_i - 2] = arguments[_i]; } if (state.hostWithWatch.onWatchStatusChange) { - state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)), state.host.getNewLine(), state.baseCompilerOptions); + state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)), state.host.getNewLine(), state.baseCompilerOptions); } } function reportErrors(_a, errors) { @@ -97463,23 +98691,33 @@ var ts; reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]); } function reportErrorSummary(state, buildOrder) { - if (!state.needsSummary || (!state.watch && !state.host.reportErrorSummary)) + if (!state.needsSummary) return; state.needsSummary = false; + var canReportSummary = state.watch || !!state.host.reportErrorSummary; var diagnostics = state.diagnostics; - // Report errors from the other projects - buildOrder.forEach(function (project) { - var projectPath = toResolvedConfigFilePath(state, project); - if (!state.projectErrorsReported.has(projectPath)) { - reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); - } - }); var totalErrors = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + if (isCircularBuildOrder(buildOrder)) { + reportBuildQueue(state, buildOrder.buildOrder); + reportErrors(state, buildOrder.circularDiagnostics); + if (canReportSummary) + totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics); + } + else { + // Report errors from the other projects + buildOrder.forEach(function (project) { + var projectPath = toResolvedConfigFilePath(state, project); + if (!state.projectErrorsReported.has(projectPath)) { + reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); + } + }); + if (canReportSummary) + diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + } if (state.watch) { reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors); } - else { + else if (state.host.reportErrorSummary) { state.host.reportErrorSummary(totalErrors); } } @@ -97512,13 +98750,16 @@ var ts; case ts.UpToDateStatusType.UpstreamOutOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.UpstreamBlocked: - return reportStatus(state, ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); + return reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built : + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.Unbuildable: return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason); case ts.UpToDateStatusType.TsVersionOutputOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relName(state, configFileName), status.version, ts.version); case ts.UpToDateStatusType.ContainerOnly: // Don't report status on "solution" projects + // falls through case ts.UpToDateStatusType.ComputingUpstream: // Should never leak from getUptoDateStatusWorker break; @@ -97540,7 +98781,6 @@ var ts; (function (ts) { var server; (function (server) { - // tslint:disable variable-name server.ActionSet = "action::set"; server.ActionInvalidate = "action::invalidate"; server.ActionPackageInstalled = "action::packageInstalled"; @@ -98192,37 +99432,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 275 /* CatchClause */: - case 268 /* JsxAttribute */: + case 153 /* Parameter */: + case 188 /* BindingElement */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 276 /* CatchClause */: + case 269 /* JsxAttribute */: return 1 /* Value */; - case 151 /* TypeParameter */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 169 /* TypeLiteral */: + case 152 /* TypeParameter */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 170 /* TypeLiteral */: return 2 /* Type */; - case 311 /* JSDocTypedefTag */: + case 313 /* 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 279 /* EnumMember */: - case 241 /* ClassDeclaration */: + case 280 /* EnumMember */: + case 242 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -98232,26 +99472,26 @@ var ts; else { return 4 /* Namespace */; } - case 244 /* EnumDeclaration */: - case 253 /* NamedImports */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 245 /* EnumDeclaration */: + case 254 /* NamedImports */: + case 255 /* ImportSpecifier */: + case 250 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: + case 256 /* ExportAssignment */: + case 257 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 285 /* SourceFile */: + case 286 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 255 /* ExportAssignment */ || node.parent.kind === 260 /* ExternalModuleReference */) { + else if (node.parent.kind === 256 /* ExportAssignment */ || node.parent.kind === 261 /* ExternalModuleReference */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -98283,11 +99523,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 149 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 249 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 150 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 250 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 150 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -98299,27 +99539,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 149 /* QualifiedName */) { - while (root.parent && root.parent.kind === 149 /* QualifiedName */) { + if (root.parent.kind === 150 /* QualifiedName */) { + while (root.parent && root.parent.kind === 150 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 165 /* TypeReference */ && !isLastClause; + return root.parent.kind === 166 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 190 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 190 /* PropertyAccessExpression */) { + if (root.parent.kind === 191 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 191 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 212 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 274 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 213 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 275 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 241 /* ClassDeclaration */ && root.parent.parent.token === 110 /* ImplementsKeyword */) || - (decl.kind === 242 /* InterfaceDeclaration */ && root.parent.parent.token === 87 /* ExtendsKeyword */); + return (decl.kind === 242 /* ClassDeclaration */ && root.parent.parent.token === 110 /* ImplementsKeyword */) || + (decl.kind === 243 /* InterfaceDeclaration */ && root.parent.parent.token === 87 /* ExtendsKeyword */); } return false; } @@ -98330,15 +99570,15 @@ var ts; switch (node.kind) { case 101 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 179 /* ThisType */: + case 180 /* ThisType */: return true; } switch (node.parent.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return true; - case 184 /* ImportType */: + case 185 /* ImportType */: return !node.parent.isTypeOf; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -98365,7 +99605,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 234 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 235 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -98397,15 +99637,15 @@ var ts; } ts.isTagName = isTagName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 150 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 191 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 245 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 246 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -98415,22 +99655,22 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 279 /* EnumMember */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 245 /* ModuleDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 277 /* PropertyAssignment */: + case 280 /* EnumMember */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 246 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return true; - case 183 /* LiteralType */: - return node.parent.parent.kind === 181 /* IndexedAccessType */; + case 184 /* LiteralType */: + return node.parent.parent.kind === 182 /* IndexedAccessType */; default: return false; } @@ -98454,17 +99694,17 @@ var ts; return undefined; } switch (node.kind) { - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 286 /* SourceFile */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 246 /* ModuleDeclaration */: return node; } } @@ -98472,48 +99712,53 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return "class" /* classElement */; - case 242 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 243 /* TypeAliasDeclaration */: - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 243 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 244 /* TypeAliasDeclaration */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 244 /* EnumDeclaration */: return "enum" /* enumElement */; - case 238 /* VariableDeclaration */: + case 245 /* EnumDeclaration */: return "enum" /* enumElement */; + case 239 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: return "function" /* functionElement */; - case 159 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 160 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 161 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 277 /* PropertyAssignment */: + var initializer = node.initializer; + return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 278 /* ShorthandPropertyAssignment */: + case 279 /* SpreadAssignment */: return "property" /* memberVariableElement */; - case 163 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 162 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 161 /* CallSignature */: return "call" /* callSignatureElement */; - case 158 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 151 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 279 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 152 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 164 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 163 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 162 /* CallSignature */: return "call" /* callSignatureElement */; + case 159 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 152 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 280 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 153 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 250 /* ImportEqualsDeclaration */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: + case 253 /* NamespaceImport */: return "alias" /* alias */; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { @@ -98561,7 +99806,7 @@ var ts; return true; case 73 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 152 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 153 /* Parameter */; default: return false; } @@ -98626,42 +99871,42 @@ var ts; return false; } switch (n.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 185 /* ObjectBindingPattern */: - case 169 /* TypeLiteral */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 247 /* CaseBlock */: - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 190 /* ObjectLiteralExpression */: + case 186 /* ObjectBindingPattern */: + case 170 /* TypeLiteral */: + case 220 /* Block */: + case 247 /* ModuleBlock */: + case 248 /* CaseBlock */: + case 254 /* NamedImports */: + case 258 /* NamedExports */: return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 193 /* NewExpression */: + case 194 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 192 /* CallExpression */: - case 196 /* ParenthesizedExpression */: - case 178 /* ParenthesizedType */: + case 193 /* CallExpression */: + case 197 /* ParenthesizedExpression */: + case 179 /* ParenthesizedType */: return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 198 /* ArrowFunction */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 163 /* ConstructSignature */: + case 162 /* CallSignature */: + case 199 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -98671,65 +99916,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 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 223 /* IfStatement */: + case 224 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 188 /* ArrayLiteralExpression */: - case 186 /* ArrayBindingPattern */: - case 191 /* ElementAccessExpression */: - case 150 /* ComputedPropertyName */: - case 171 /* TupleType */: + case 189 /* ArrayLiteralExpression */: + case 187 /* ArrayBindingPattern */: + case 192 /* ElementAccessExpression */: + case 151 /* ComputedPropertyName */: + case 172 /* TupleType */: return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 226 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 224 /* DoStatement */: + case 225 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; return hasChildOfKind(n, 108 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 200 /* TypeOfExpression */: - case 199 /* DeleteExpression */: - case 201 /* VoidExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: + case 201 /* TypeOfExpression */: + case 200 /* DeleteExpression */: + case 202 /* VoidExpression */: + case 209 /* YieldExpression */: + case 210 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -98908,7 +100153,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 285 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 286 /* 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. @@ -98978,17 +100223,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 272 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 272 /* JsxExpression */) { return true; } //
|
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 264 /* JsxClosingElement */) { + if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 265 /* JsxClosingElement */) { return true; } return false; @@ -99107,12 +100352,14 @@ var ts; nTypeArguments++; break; case 37 /* EqualsGreaterThanToken */: + // falls through case 73 /* Identifier */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 103 /* TrueKeyword */: case 88 /* FalseKeyword */: + // falls through case 105 /* TypeOfKeyword */: case 87 /* ExtendsKeyword */: case 130 /* KeyOfKeyword */: @@ -99174,10 +100421,10 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 165 /* TypeReference */ || node.kind === 192 /* CallExpression */) { + if (node.kind === 166 /* TypeReference */ || node.kind === 193 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 241 /* ClassDeclaration */ || node.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 242 /* ClassDeclaration */ || node.kind === 243 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -99222,18 +100469,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 188 /* ArrayLiteralExpression */ || - node.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 189 /* ArrayLiteralExpression */ || + node.kind === 190 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 205 /* BinaryExpression */ && + if (node.parent.kind === 206 /* BinaryExpression */ && node.parent.left === node && node.parent.operatorToken.kind === 60 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 228 /* ForOfStatement */ && + if (node.parent.kind === 229 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -99241,7 +100488,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 276 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 277 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -99337,7 +100584,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 150 /* ComputedPropertyName */ + return name.kind === 151 /* 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.getTextOfIdentifierOrLiteral(name); @@ -99502,7 +100749,7 @@ var ts; /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 152 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 153 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -99964,15 +101211,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 193 /* NewExpression */: + case 194 /* NewExpression */: return checker.getContextualType(parent); - case 205 /* BinaryExpression */: { + case 206 /* 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 272 /* CaseClause */: + case 273 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -100014,8 +101261,8 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: + case 208 /* TemplateExpression */: + case 195 /* TaggedTemplateExpression */: return true; default: return false; @@ -100055,19 +101302,19 @@ var ts; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; function syntaxUsuallyHasTrailingSemicolon(kind) { - return kind === 220 /* VariableStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 224 /* DoStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 230 /* BreakStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 155 /* PropertyDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */; + return kind === 221 /* VariableStatement */ + || kind === 223 /* ExpressionStatement */ + || kind === 225 /* DoStatement */ + || kind === 230 /* ContinueStatement */ + || kind === 231 /* BreakStatement */ + || kind === 232 /* ReturnStatement */ + || kind === 236 /* ThrowStatement */ + || kind === 238 /* DebuggerStatement */ + || kind === 156 /* PropertyDeclaration */ + || kind === 244 /* TypeAliasDeclaration */ + || kind === 251 /* ImportDeclaration */ + || kind === 250 /* ImportEqualsDeclaration */ + || kind === 257 /* ExportDeclaration */; } ts.syntaxUsuallyHasTrailingSemicolon = syntaxUsuallyHasTrailingSemicolon; function probablyUsesSemicolons(sourceFile) { @@ -100101,6 +101348,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier() { var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false); function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { @@ -100533,10 +101781,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 241 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -100729,6 +101977,11 @@ var ts; return; } } + else if (kind === 2 /* SingleLineCommentTrivia */) { + if (tryClassifyTripleSlashComment(start, width)) { + return; + } + } // Simple comment. Just add as is. pushCommentRange(start, width); } @@ -100749,18 +102002,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 306 /* JSDocParameterTag */: + case 308 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 309 /* JSDocTypeTag */: + case 311 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 307 /* JSDocReturnTag */: + case 309 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -100789,6 +102042,70 @@ var ts; } } } + function tryClassifyTripleSlashComment(start, width) { + var tripleSlashXMLCommentRegEx = /^(\/\/\/\s*)(<)(?:(\S+)((?:[^/]|\/[^>])*)(\/>)?)?/im; + var attributeRegex = /(\S+)(\s*)(=)(\s*)('[^']+'|"[^"]+")/img; + var text = sourceFile.text.substr(start, width); + var match = tripleSlashXMLCommentRegEx.exec(text); + if (!match) { + return false; + } + // Limiting classification to exactly the elements and attributes + // defined in `ts.commentPragmas` would be excessive, but we can avoid + // some obvious false positives (e.g. in XML-like doc comments) by + // checking the element name. + // eslint-disable-next-line no-in-operator + if (!match[3] || !(match[3] in ts.commentPragmas)) { + return false; + } + var pos = start; + pushCommentRange(pos, match[1].length); // /// + pos += match[1].length; + pushClassification(pos, match[2].length, 10 /* punctuation */); // < + pos += match[2].length; + pushClassification(pos, match[3].length, 21 /* jsxSelfClosingTagName */); // element name + pos += match[3].length; + var attrText = match[4]; + var attrPos = pos; + while (true) { + var attrMatch = attributeRegex.exec(attrText); + if (!attrMatch) { + break; + } + var newAttrPos = pos + attrMatch.index; + if (newAttrPos > attrPos) { + pushCommentRange(attrPos, newAttrPos - attrPos); + attrPos = newAttrPos; + } + pushClassification(attrPos, attrMatch[1].length, 22 /* jsxAttribute */); // attribute name + attrPos += attrMatch[1].length; + if (attrMatch[2].length) { + pushCommentRange(attrPos, attrMatch[2].length); // whitespace + attrPos += attrMatch[2].length; + } + pushClassification(attrPos, attrMatch[3].length, 5 /* operator */); // = + attrPos += attrMatch[3].length; + if (attrMatch[4].length) { + pushCommentRange(attrPos, attrMatch[4].length); // whitespace + attrPos += attrMatch[4].length; + } + pushClassification(attrPos, attrMatch[5].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value + attrPos += attrMatch[5].length; + } + pos += match[4].length; + if (pos > attrPos) { + pushCommentRange(attrPos, pos - attrPos); + } + if (match[5]) { + pushClassification(pos, match[5].length, 10 /* punctuation */); // /> + pos += match[5].length; + } + var end = start + width; + if (pos < end) { + pushCommentRange(pos, end - pos); + } + return true; + } function processJSDocTemplateTag(tag) { for (var _i = 0, _a = tag.getChildren(); _i < _a.length; _i++) { var child = _a[_i]; @@ -100847,22 +102164,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 263 /* JsxOpeningElement */: + case 264 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -100891,17 +102208,17 @@ var ts; var parent = token.parent; if (tokenKind === 60 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 238 /* VariableDeclaration */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 152 /* Parameter */ || - parent.kind === 268 /* JsxAttribute */) { + if (parent.kind === 239 /* VariableDeclaration */ || + parent.kind === 156 /* PropertyDeclaration */ || + parent.kind === 153 /* Parameter */ || + parent.kind === 269 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 205 /* BinaryExpression */ || - parent.kind === 203 /* PrefixUnaryExpression */ || - parent.kind === 204 /* PostfixUnaryExpression */ || - parent.kind === 206 /* ConditionalExpression */) { + if (parent.kind === 206 /* BinaryExpression */ || + parent.kind === 204 /* PrefixUnaryExpression */ || + parent.kind === 205 /* PostfixUnaryExpression */ || + parent.kind === 207 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -100915,7 +102232,7 @@ var ts; } else if (tokenKind === 10 /* StringLiteral */) { // TODO: GH#18217 - return token.parent.kind === 268 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 269 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -100931,32 +102248,32 @@ var ts; else if (tokenKind === 73 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 152 /* Parameter */: + case 153 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -101079,11 +102396,11 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { var parent = node.parent; switch (parent.kind) { - case 183 /* LiteralType */: + case 184 /* LiteralType */: switch (parent.parent.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent)), isNewIdentifier: false }; - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -101091,9 +102408,9 @@ var ts; // } // let x: Foo["/*completion position*/"] return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(parent.parent.objectType)); - case 184 /* ImportType */: + case 185 /* ImportType */: return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 174 /* UnionType */: { + case 175 /* UnionType */: { if (!ts.isTypeReferenceNode(parent.parent.parent)) return undefined; var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(parent.parent, parent); @@ -101103,7 +102420,7 @@ var ts; default: return undefined; } - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -101120,7 +102437,7 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(parent.parent)); } return fromContextualType(); - case 191 /* ElementAccessExpression */: { + case 192 /* ElementAccessExpression */: { var _a = parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { // Get all names of properties on the expression @@ -101133,8 +102450,8 @@ var ts; } return undefined; } - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* 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 @@ -101143,9 +102460,9 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 260 /* ExternalModuleReference */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: + case 261 /* 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*/"); @@ -101189,11 +102506,8 @@ var ts; if (!type) return ts.emptyArray; type = ts.skipConstraint(type); - return type.isUnion() - ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) - : type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) - ? [type] - : ts.emptyArray; + return type.isUnion() ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) : + type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; } function nameAndKind(name, kind, extension) { return { name: name, kind: kind, extension: extension }; @@ -101250,7 +102564,7 @@ var ts; return ts.containsPath(rootDirectory, scriptDirectory, basePath, ignoreCase) ? scriptDirectory.substr(rootDirectory.length) : undefined; }); // TODO: GH#18217 // Now find a path for each potential directory that is to be merged with the one containing the script - return ts.deduplicate(rootDirs.map(function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }).concat([scriptDirectory]), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); + return ts.deduplicate(__spreadArrays(rootDirs.map(function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }), [scriptDirectory]), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptDirectory, extensionOptions, compilerOptions, host, exclude) { var basePath = compilerOptions.project || host.getCurrentDirectory(); @@ -101457,7 +102771,7 @@ var ts; var name = trimPrefixAndSuffix(dir); return name === undefined ? undefined : directoryResult(name); }); - return matches.concat(directories); + return __spreadArrays(matches, directories); function trimPrefixAndSuffix(path) { var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix); return inner === undefined ? undefined : removeLeadingDirectorySeparator(inner); @@ -101658,10 +102972,12 @@ var ts; var SortText; (function (SortText) { SortText["LocationPriority"] = "0"; - SortText["SuggestedClassMembers"] = "1"; - SortText["GlobalsOrKeywords"] = "2"; - SortText["AutoImportSuggestions"] = "3"; - SortText["JavascriptIdentifiers"] = "4"; + SortText["OptionalMember"] = "1"; + SortText["MemberDeclaredBySpreadAssignment"] = "2"; + SortText["SuggestedClassMembers"] = "3"; + SortText["GlobalsOrKeywords"] = "4"; + SortText["AutoImportSuggestions"] = "5"; + SortText["JavascriptIdentifiers"] = "6"; })(SortText = Completions.SortText || (Completions.SortText = {})); var SymbolOriginInfoKind; (function (SymbolOriginInfoKind) { @@ -101669,6 +102985,7 @@ var ts; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 1] = "SymbolMemberNoExport"; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 2] = "SymbolMemberExport"; SymbolOriginInfoKind[SymbolOriginInfoKind["Export"] = 3] = "Export"; + SymbolOriginInfoKind[SymbolOriginInfoKind["Promise"] = 4] = "Promise"; })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {})); function originIsSymbolMember(origin) { return origin.kind === 2 /* SymbolMemberExport */ || origin.kind === 1 /* SymbolMemberNoExport */; @@ -101676,6 +102993,9 @@ var ts; function originIsExport(origin) { return origin.kind === 2 /* SymbolMemberExport */ || origin.kind === 3 /* Export */; } + function originIsPromise(origin) { + return origin.kind === 4 /* Promise */; + } var KeywordCompletionFilters; (function (KeywordCompletionFilters) { KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None"; @@ -101836,6 +103156,13 @@ var ts; replacementSpan = ts.createTextSpanFromNode(isJsxInitializer, sourceFile); } } + if (origin && originIsPromise(origin) && propertyAccessToConvert) { + if (insertText === undefined) + insertText = name; + var awaitText = "(await " + propertyAccessToConvert.expression.getText() + ")"; + insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : awaitText + "." + insertText; + replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); + } if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) { return undefined; } @@ -102066,11 +103393,11 @@ var ts; return ts.getContextualTypeFromParent(previousToken, checker); case 60 /* EqualsToken */: switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; @@ -102080,16 +103407,16 @@ var ts; case 75 /* CaseKeyword */: return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 18 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 261 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 262 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); - return argInfo + return argInfo ? // At `,`, treat this as the next argument after the comma. - ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) - : ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) + checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) : + ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) ? // completion at `x ===/**/` should be for the right side - ? checker.getTypeAtLocation(parent.left) - : checker.getContextualType(previousToken); + checker.getTypeAtLocation(parent.left) : + checker.getContextualType(previousToken); } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { @@ -102099,7 +103426,7 @@ 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 === 285 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 286 /* SourceFile */; }); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { var typeChecker = program.getTypeChecker(); @@ -102150,11 +103477,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 290 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 312 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 314 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -102204,7 +103531,7 @@ var ts; if (contextToken.kind === 24 /* DotToken */) { isRightOfDot = true; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; if (node.end === contextToken.pos && @@ -102216,14 +103543,14 @@ var ts; return undefined; } break; - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: node = parent.left; break; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: node = parent.name; break; - case 184 /* ImportType */: - case 215 /* MetaProperty */: + case 185 /* ImportType */: + case 216 /* MetaProperty */: node = parent; break; default: @@ -102236,7 +103563,7 @@ var ts; // // If the tagname is a property access expression, we will then walk up to the top most of property access expression. // Then, try to get a JSX container and its associated attributes type. - if (parent && parent.kind === 190 /* PropertyAccessExpression */) { + if (parent && parent.kind === 191 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } @@ -102244,38 +103571,38 @@ var ts; if (currentToken.parent === location) { switch (currentToken.kind) { case 30 /* GreaterThanToken */: - if (currentToken.parent.kind === 261 /* JsxElement */ || currentToken.parent.kind === 263 /* JsxOpeningElement */) { + if (currentToken.parent.kind === 262 /* JsxElement */ || currentToken.parent.kind === 264 /* JsxOpeningElement */) { location = currentToken; } break; case 42 /* SlashToken */: - if (currentToken.parent.kind === 262 /* JsxSelfClosingElement */) { + if (currentToken.parent.kind === 263 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: if (contextToken.kind === 42 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: - case 263 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 262 /* JsxElement */: + case 264 /* JsxOpeningElement */: if (contextToken.kind === 28 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: switch (previousToken.kind) { case 60 /* EqualsToken */: isJsxInitializer = true; @@ -102350,11 +103677,11 @@ var ts; }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 311 /* JSDocTypedefTag */: + case 308 /* JSDocParameterTag */: + case 314 /* JSDocPropertyTag */: + case 309 /* JSDocReturnTag */: + case 311 /* JSDocTypeTag */: + case 313 /* JSDocTypedefTag */: return true; default: return false; @@ -102398,8 +103725,8 @@ 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 !== 285 /* SourceFile */ && d.kind !== 245 /* ModuleDeclaration */ && d.kind !== 244 /* EnumDeclaration */; })) { - addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); + symbol.declarations.some(function (d) { return d.kind !== 286 /* SourceFile */ && d.kind !== 246 /* ModuleDeclaration */ && d.kind !== 245 /* EnumDeclaration */; })) { + addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node), !!(node.flags & 16384 /* AwaitContext */)); } return; } @@ -102411,11 +103738,12 @@ var ts; return; } if (!isTypeLocation) { - addTypeProperties(typeChecker.getTypeAtLocation(node)); + addTypeProperties(typeChecker.getTypeAtLocation(node), !!(node.flags & 16384 /* AwaitContext */)); } } - function addTypeProperties(type) { + function addTypeProperties(type, insertAwait) { isNewIdentifierLocation = !!type.getStringIndexType(); + var propertyAccess = node.kind === 185 /* 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 @@ -102427,13 +103755,24 @@ var ts; else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 184 /* ImportType */ ? node : node.parent, type, symbol)) { + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) { addPropertySymbol(symbol); } } } + if (insertAwait && preferences.includeCompletionsWithInsertText) { + var promiseType = typeChecker.getPromisedTypeOfPromise(type); + if (promiseType) { + for (var _b = 0, _c = promiseType.getApparentProperties(); _b < _c.length; _b++) { + var symbol = _c[_b]; + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, promiseType, symbol)) { + addPropertySymbol(symbol, /* insertAwait */ true); + } + } + } + } } - function addPropertySymbol(symbol) { + function addPropertySymbol(symbol, insertAwait) { // For a computed property with an accessible name like `Symbol.iterator`, // we'll add a completion for the *name* `Symbol` instead of for the property. // If this is e.g. [Symbol.iterator], add a completion for `Symbol`. @@ -102450,12 +103789,19 @@ var ts; !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) ? { kind: 1 /* SymbolMemberNoExport */ } : { kind: 2 /* SymbolMemberExport */, moduleSymbol: moduleSymbol, isDefaultExport: false }; } else if (preferences.includeCompletionsWithInsertText) { + addPromiseSymbolOriginInfo(symbol); symbols.push(symbol); } } else { + addPromiseSymbolOriginInfo(symbol); symbols.push(symbol); } + function addPromiseSymbolOriginInfo(symbol) { + if (insertAwait && preferences.includeCompletionsWithInsertText && !symbolToOriginInfoMap[ts.getSymbolId(symbol)]) { + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 4 /* Promise */ }; + } + } } /** Given 'a.b.c', returns 'a'. */ function getLeftMostName(e) { @@ -102488,6 +103834,7 @@ var ts; if (!attrsType) return 0 /* Continue */; symbols = filterJsxAttributes(getPropertiesForObjectExpression(attrsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties); + setSortTextToOptionalMember(); completionKind = 3 /* MemberLike */; isNewIdentifierLocation = false; return 1 /* Success */; @@ -102531,7 +103878,7 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; isInSnippetScope = isSnippetScope(scopeNode); var isTypeOnly = isTypeOnlyCompletion(); - var symbolMeanings = (isTypeOnly ? 0 /* None */ : 67220415 /* Value */) | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; + var symbolMeanings = (isTypeOnly ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { var symbol = symbols_2[_i]; @@ -102541,7 +103888,7 @@ var ts; } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 285 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 286 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType) { for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) { @@ -102575,10 +103922,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 285 /* SourceFile */: - case 207 /* TemplateExpression */: - case 271 /* JsxExpression */: - case 219 /* Block */: + case 286 /* SourceFile */: + case 208 /* TemplateExpression */: + case 272 /* JsxExpression */: + case 220 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -102608,7 +103955,7 @@ var ts; } } // expressions are value space (which includes the value namespaces) - return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 67220415 /* Value */); + return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */); }); } function isTypeAssertion() { @@ -102624,27 +103971,27 @@ var ts; function isContextTokenValueLocation(contextToken) { return contextToken && contextToken.kind === 105 /* TypeOfKeyword */ && - (contextToken.parent.kind === 168 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + (contextToken.parent.kind === 169 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { case 57 /* ColonToken */: - return parentKind === 155 /* PropertyDeclaration */ || - parentKind === 154 /* PropertySignature */ || - parentKind === 152 /* Parameter */ || - parentKind === 238 /* VariableDeclaration */ || + return parentKind === 156 /* PropertyDeclaration */ || + parentKind === 155 /* PropertySignature */ || + parentKind === 153 /* Parameter */ || + parentKind === 239 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); case 60 /* EqualsToken */: - return parentKind === 243 /* TypeAliasDeclaration */; + return parentKind === 244 /* TypeAliasDeclaration */; case 120 /* AsKeyword */: - return parentKind === 213 /* AsExpression */; + return parentKind === 214 /* AsExpression */; case 28 /* LessThanToken */: - return parentKind === 165 /* TypeReference */ || - parentKind === 195 /* TypeAssertionExpression */; + return parentKind === 166 /* TypeReference */ || + parentKind === 196 /* TypeAssertionExpression */; case 87 /* ExtendsKeyword */: - return parentKind === 151 /* TypeParameter */; + return parentKind === 152 /* TypeParameter */; } } return false; @@ -102653,7 +104000,7 @@ var ts; function symbolCanBeReferencedAtTypeLocation(symbol, seenModules) { if (seenModules === void 0) { seenModules = ts.createMap(); } var sym = ts.skipAlias(symbol.exportSymbol || symbol, typeChecker); - return !!(sym.flags & 67897832 /* Type */) || + 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); }); @@ -102674,7 +104021,7 @@ var ts; if (resolvedModuleSymbol !== moduleSymbol && // 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`. - ts.some(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) { + ts.every(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) { symbols.push(resolvedModuleSymbol); symbolToSortTextMap[ts.getSymbolId(resolvedModuleSymbol)] = SortText.AutoImportSuggestions; symbolToOriginInfoMap[ts.getSymbolId(resolvedModuleSymbol)] = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: false }; @@ -102753,11 +104100,11 @@ var ts; return true; } if (contextToken.kind === 30 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 263 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 264 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 264 /* JsxClosingElement */ || contextToken.parent.kind === 262 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 261 /* JsxElement */; + if (contextToken.parent.kind === 265 /* JsxClosingElement */ || contextToken.parent.kind === 263 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 262 /* JsxElement */; } } return false; @@ -102768,40 +104115,40 @@ var ts; // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(previousToken)) { case 27 /* CommaToken */: - return containingNodeKind === 192 /* CallExpression */ // func( a, | - || containingNodeKind === 158 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 193 /* NewExpression */ // new C(a, | - || containingNodeKind === 188 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 205 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 166 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 193 /* CallExpression */ // func( a, | + || containingNodeKind === 159 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 194 /* NewExpression */ // new C(a, | + || containingNodeKind === 189 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 206 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 167 /* FunctionType */; // var x: (s: string, list| case 20 /* OpenParenToken */: - return containingNodeKind === 192 /* CallExpression */ // func( | - || containingNodeKind === 158 /* Constructor */ // constructor( | - || containingNodeKind === 193 /* NewExpression */ // new C(a| - || containingNodeKind === 196 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 178 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 193 /* CallExpression */ // func( | + || containingNodeKind === 159 /* Constructor */ // constructor( | + || containingNodeKind === 194 /* NewExpression */ // new C(a| + || containingNodeKind === 197 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 179 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 22 /* OpenBracketToken */: - return containingNodeKind === 188 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 163 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 150 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + return containingNodeKind === 189 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 164 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 151 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 131 /* ModuleKeyword */: // module | case 132 /* NamespaceKeyword */: // namespace | return true; case 24 /* DotToken */: - return containingNodeKind === 245 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 246 /* ModuleDeclaration */; // module A.| case 18 /* OpenBraceToken */: - return containingNodeKind === 241 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 242 /* ClassDeclaration */; // class A{ | case 60 /* EqualsToken */: - return containingNodeKind === 238 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 205 /* BinaryExpression */; // x = a| + return containingNodeKind === 239 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 206 /* BinaryExpression */; // x = a| case 15 /* TemplateHead */: - return containingNodeKind === 207 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 208 /* TemplateExpression */; // `aa ${| case 16 /* TemplateMiddle */: - return containingNodeKind === 217 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 218 /* TemplateSpan */; // `aa ${10} dd ${| case 116 /* PublicKeyword */: case 114 /* PrivateKeyword */: case 115 /* ProtectedKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 156 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -102828,7 +104175,7 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 189 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 190 /* ObjectLiteralExpression */) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2 /* Fail */; @@ -102837,7 +104184,7 @@ var ts; existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 185 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 186 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -102848,12 +104195,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 === 228 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 152 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 229 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 153 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 157 /* MethodDeclaration */ || rootDeclaration.parent.kind === 160 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 158 /* MethodDeclaration */ || rootDeclaration.parent.kind === 161 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -102870,6 +104217,7 @@ var ts; // Add filtered items to the completion list symbols = filterObjectMembersList(typeMembers, ts.Debug.assertDefined(existingMembers)); } + setSortTextToOptionalMember(); return 1 /* Success */; } /** @@ -102895,7 +104243,7 @@ var ts; return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 253 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 254 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -102923,7 +104271,7 @@ var ts; // If you're in an interface you don't want to repeat things from super-interface. So just stop here. if (!ts.isClassLike(decl)) return 1 /* Success */; - var classElement = contextToken.parent; + var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getModifierFlags(classElement) : 0 /* None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier if (contextToken.kind === 73 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { @@ -103017,11 +104365,11 @@ var ts; case 29 /* LessThanSlashToken */: case 42 /* SlashToken */: case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 269 /* JsxAttributes */: - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 262 /* JsxSelfClosingElement */ || parent.kind === 263 /* JsxOpeningElement */)) { + case 191 /* PropertyAccessExpression */: + case 270 /* JsxAttributes */: + case 269 /* JsxAttribute */: + case 271 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 263 /* JsxSelfClosingElement */ || parent.kind === 264 /* JsxOpeningElement */)) { if (contextToken.kind === 30 /* GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); if (!parent.typeArguments || (precedingToken && precedingToken.kind === 42 /* SlashToken */)) @@ -103029,7 +104377,7 @@ var ts; } return parent; } - else if (parent.kind === 268 /* JsxAttribute */) { + else if (parent.kind === 269 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103041,7 +104389,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 === 268 /* JsxAttribute */) || (parent.kind === 270 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 269 /* JsxAttribute */) || (parent.kind === 271 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103051,8 +104399,8 @@ var ts; break; case 19 /* CloseBraceToken */: if (parent && - parent.kind === 271 /* JsxExpression */ && - parent.parent && parent.parent.kind === 268 /* JsxAttribute */) { + parent.kind === 272 /* JsxExpression */ && + parent.parent && parent.parent.kind === 269 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103060,7 +104408,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 270 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 271 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103080,49 +104428,49 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 27 /* CommaToken */: - return containingNodeKind === 238 /* VariableDeclaration */ || - containingNodeKind === 239 /* VariableDeclarationList */ || - containingNodeKind === 220 /* VariableStatement */ || - containingNodeKind === 244 /* EnumDeclaration */ || // enum a { foo, | + return containingNodeKind === 239 /* VariableDeclaration */ || + containingNodeKind === 240 /* VariableDeclarationList */ || + containingNodeKind === 221 /* VariableStatement */ || + containingNodeKind === 245 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 24 /* DotToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 187 /* ArrayBindingPattern */; // var [.| case 57 /* ColonToken */: - return containingNodeKind === 187 /* BindingElement */; // var {x :html| + return containingNodeKind === 188 /* BindingElement */; // var {x :html| case 22 /* OpenBracketToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 187 /* ArrayBindingPattern */; // var [x| case 20 /* OpenParenToken */: - return containingNodeKind === 275 /* CatchClause */ || + return containingNodeKind === 276 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 18 /* OpenBraceToken */: - return containingNodeKind === 244 /* EnumDeclaration */; // enum a { | + return containingNodeKind === 245 /* EnumDeclaration */; // enum a { | case 28 /* LessThanToken */: - return containingNodeKind === 241 /* ClassDeclaration */ || // class A< | - containingNodeKind === 210 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 243 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 242 /* ClassDeclaration */ || // class A< | + containingNodeKind === 211 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 243 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 244 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); case 117 /* StaticKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + return containingNodeKind === 156 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 25 /* DotDotDotToken */: - return containingNodeKind === 152 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 186 /* ArrayBindingPattern */); // var [...z| + return containingNodeKind === 153 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 187 /* ArrayBindingPattern */); // var [...z| case 116 /* PublicKeyword */: case 114 /* PrivateKeyword */: case 115 /* ProtectedKeyword */: - return containingNodeKind === 152 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + return containingNodeKind === 153 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); case 120 /* AsKeyword */: - return containingNodeKind === 254 /* ImportSpecifier */ || - containingNodeKind === 258 /* ExportSpecifier */ || - containingNodeKind === 252 /* NamespaceImport */; + return containingNodeKind === 255 /* ImportSpecifier */ || + containingNodeKind === 259 /* ExportSpecifier */ || + containingNodeKind === 253 /* NamespaceImport */; case 127 /* GetKeyword */: case 138 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); @@ -103183,7 +104531,7 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 158 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 159 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -103202,16 +104550,18 @@ var ts; if (existingMembers.length === 0) { return contextualMemberSymbols; } + var membersDeclaredBySpreadAssignment = ts.createMap(); var existingMemberNames = ts.createUnderscoreEscapedMap(); 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 !== 276 /* PropertyAssignment */ && - m.kind !== 277 /* ShorthandPropertyAssignment */ && - m.kind !== 187 /* BindingElement */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 277 /* PropertyAssignment */ && + m.kind !== 278 /* ShorthandPropertyAssignment */ && + m.kind !== 188 /* BindingElement */ && + m.kind !== 158 /* MethodDeclaration */ && + m.kind !== 160 /* GetAccessor */ && + m.kind !== 161 /* SetAccessor */ && + m.kind !== 279 /* SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -103219,7 +104569,10 @@ var ts; continue; } var existingName = void 0; - if (ts.isBindingElement(m) && m.propertyName) { + if (ts.isSpreadAssignment(m)) { + setMembersDeclaredBySpreadAssignment(m, membersDeclaredBySpreadAssignment); + } + else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list if (m.propertyName.kind === 73 /* Identifier */) { existingName = m.propertyName.escapedText; @@ -103234,7 +104587,40 @@ var ts; } existingMemberNames.set(existingName, true); // TODO: GH#18217 } - return contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + var filteredSymbols = contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; + } + function setMembersDeclaredBySpreadAssignment(declaration, membersDeclaredBySpreadAssignment) { + var expression = declaration.expression; + var symbol = typeChecker.getSymbolAtLocation(expression); + var type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, expression); + var properties = type && type.properties; + if (properties) { + properties.forEach(function (property) { + membersDeclaredBySpreadAssignment.set(property.name, true); + }); + } + } + // Set SortText to OptionalMember if it is an optinoal member + function setSortTextToOptionalMember() { + symbols.forEach(function (m) { + if (m.flags & 16777216 /* Optional */) { + symbolToSortTextMap[ts.getSymbolId(m)] = symbolToSortTextMap[ts.getSymbolId(m)] || SortText.OptionalMember; + } + }); + } + // Set SortText to MemberDeclaredBySpreadAssignment if it is fulfilled by spread assignment + function setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, contextualMemberSymbols) { + if (membersDeclaredBySpreadAssignment.size === 0) { + return; + } + for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) { + var contextualMemberSymbol = contextualMemberSymbols_1[_i]; + if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) { + symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = SortText.MemberDeclaredBySpreadAssignment; + } + } } /** * Filters out completion suggestions for class elements. @@ -103246,10 +104632,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 !== 155 /* PropertyDeclaration */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 156 /* PropertyDeclaration */ && + m.kind !== 158 /* MethodDeclaration */ && + m.kind !== 160 /* GetAccessor */ && + m.kind !== 161 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -103283,17 +104669,23 @@ var ts; */ function filterJsxAttributes(symbols, attributes) { var seenNames = ts.createUnderscoreEscapedMap(); + var membersDeclaredBySpreadAssignment = ts.createMap(); for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) { var attr = attributes_1[_i]; // If this is the current item we are editing right now, do not filter it out if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 268 /* JsxAttribute */) { + if (attr.kind === 269 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } + else if (ts.isJsxSpreadAttribute(attr)) { + setMembersDeclaredBySpreadAssignment(attr, membersDeclaredBySpreadAssignment); + } } - return symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + var filteredSymbols = symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; } function isCurrentlyEditingNode(node) { return node.getStart(sourceFile) <= position && position <= node.getEnd(); @@ -103333,7 +104725,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 74 /* FirstKeyword */; i <= 148 /* LastKeyword */; i++) { + for (var i = 74 /* FirstKeyword */; i <= 149 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -103467,7 +104859,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 313 /* SyntaxList */: + case 315 /* 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); @@ -103662,7 +105054,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 285 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 286 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -103694,16 +105086,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 233 /* SwitchStatement */: - if (statement.kind === 229 /* ContinueStatement */) { + case 234 /* SwitchStatement */: + if (statement.kind === 230 /* ContinueStatement */) { return false; } // falls through - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 226 /* WhileStatement */: + case 225 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -103719,35 +105111,37 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 219 /* Block */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 247 /* ModuleBlock */: + case 286 /* SourceFile */: + case 220 /* Block */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { - return declaration.members.concat([declaration]); + return __spreadArrays(declaration.members, [declaration]); } else { return container.statements; } - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + return __spreadArrays(container.parameters, (ts.isClassLike(container.parent) ? container.parent.members : [])); + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 170 /* TypeLiteral */: var nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & 28 /* AccessibilityModifier */) { + if (modifierFlag & (28 /* AccessibilityModifier */ | 64 /* Readonly */)) { var constructor = ts.find(container.members, ts.isConstructorDeclaration); if (constructor) { - return nodes.concat(constructor.parameters); + return __spreadArrays(nodes, constructor.parameters); } } else if (modifierFlag & 128 /* Abstract */) { - return nodes.concat([container]); + return __spreadArrays(nodes, [container]); } return nodes; default: @@ -103769,7 +105163,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 90 /* ForKeyword */, 108 /* WhileKeyword */, 83 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 224 /* DoStatement */) { + if (loopNode.kind === 225 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 108 /* WhileKeyword */)) { @@ -103789,13 +105183,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -104162,10 +105556,10 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 238 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 239 /* VariableDeclaration */) { var name = parent.name; if (name.kind === 73 /* Identifier */) { directImports.push(name); @@ -104178,20 +105572,20 @@ var ts; break; case 73 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 253 /* 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 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -104201,7 +105595,7 @@ var ts; directImports.push(direct); } break; - case 184 /* ImportType */: + case 185 /* ImportType */: directImports.push(direct); break; default: @@ -104218,7 +105612,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 285 /* SourceFile */ || sourceFileLike.kind === 245 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 286 /* SourceFile */ || sourceFileLike.kind === 246 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -104273,7 +105667,7 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 249 /* ImportEqualsDeclaration */) { + if (decl.kind === 250 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } @@ -104283,7 +105677,7 @@ var ts; handleNamespaceImportLike(decl); return; } - if (decl.kind === 184 /* ImportType */) { + if (decl.kind === 185 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -104298,17 +105692,17 @@ var ts; if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 256 /* ExportDeclaration */) { + if (decl.kind === 257 /* ExportDeclaration */) { searchForNamedImport(decl.exportClause); return; } var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 253 /* NamedImports */: + case 254 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -104358,7 +105752,7 @@ var ts; } } else { - var localSymbol = element.kind === 258 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 259 /* 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); @@ -104387,7 +105781,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 === 285 /* SourceFile */) { + if (searchSourceFile.kind === 286 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -104435,7 +105829,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 === 285 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 286 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -104450,15 +105844,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: { + case 257 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 249 /* ImportEqualsDeclaration */: { + case 250 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -104472,7 +105866,7 @@ var ts; /** * Given a local reference, we might notice that it's an import/export and recursively search for references of that. * If at an import, look locally for the symbol it imports. - * If an an export, look for all imports of it. + * If at an export, look for all imports of it. * This doesn't handle export specifiers; that is done in `getReferencesAtExportSpecifier`. * @param comingFromExport If we are doing a search for all exports, don't bother looking backwards for the imported symbol, since that's the reason we're here. */ @@ -104482,7 +105876,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 190 /* PropertyAccessExpression */) { + if (parent.kind === 191 /* 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) @@ -104604,10 +105998,10 @@ var ts; // If a reference is a class expression, the exported node would be its parent. // If a reference is a variable declaration, the exported node would be the variable statement. function getExportNode(parent, node) { - if (parent.kind === 238 /* VariableDeclaration */) { - var p = parent; - return p.name !== node ? undefined : - p.parent.kind === 275 /* CatchClause */ ? undefined : p.parent.parent.kind === 220 /* VariableStatement */ ? p.parent.parent : undefined; + var declaration = ts.isVariableDeclaration(parent) ? parent : ts.isBindingElement(parent) ? ts.walkUpBindingElementsAndPatterns(parent) : undefined; + if (declaration) { + return parent.name !== node ? undefined : + ts.isCatchClause(declaration.parent) ? undefined : ts.isVariableStatement(declaration.parent.parent) ? declaration.parent.parent : undefined; } else { return parent; @@ -104616,13 +106010,13 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 254 /* ImportSpecifier */: + case 255 /* 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 251 /* ImportClause */: - case 252 /* NamespaceImport */: + case 252 /* ImportClause */: + case 253 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return true; default: @@ -104655,21 +106049,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 193 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 285 /* SourceFile */) { + if (parent.kind === 286 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 246 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 247 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 246 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 260 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 261 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -104771,7 +106165,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -104779,27 +106173,27 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 187 /* BindingElement */: + case 188 /* BindingElement */: return getContextNode(node.parent.parent); - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return node.parent.parent.parent; - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 259 /* ExportSpecifier */: + case 253 /* NamespaceImport */: return node.parent.parent; - case 251 /* ImportClause */: + case 252 /* ImportClause */: return node.parent; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 228 /* ForInStatement */: return { start: node.initializer, end: node.expression }; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -104843,13 +106237,13 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* 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 === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 278 /* ShorthandPropertyAssignment */) { var result_1 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); return result_1; @@ -104934,16 +106328,16 @@ var ts; return { displayParts: displayParts, kind: symbolKind }; } function toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixText) { - return __assign({}, entryToDocumentSpan(entry), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker))); + return __assign(__assign({}, entryToDocumentSpan(entry)), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker))); } FindAllReferences.toRenameLocation = toRenameLocation; function toReferenceEntry(entry) { var documentSpan = entryToDocumentSpan(entry); if (entry.kind === 0 /* Span */) { - return __assign({}, documentSpan, { isWriteAccess: false, isDefinition: false }); + return __assign(__assign({}, documentSpan), { isWriteAccess: false, isDefinition: false }); } var kind = entry.kind, node = entry.node; - return __assign({}, documentSpan, { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 81 /* DefaultKeyword */ + return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 81 /* DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); } @@ -104987,10 +106381,10 @@ var ts; var documentSpan = entryToDocumentSpan(entry); if (entry.kind !== 0 /* Span */) { var node = entry.node; - return __assign({}, documentSpan, implementationKindDisplayParts(node, checker)); + return __assign(__assign({}, documentSpan), implementationKindDisplayParts(node, checker)); } else { - return __assign({}, documentSpan, { kind: "" /* unknown */, displayParts: [] }); + return __assign(__assign({}, documentSpan), { kind: "" /* unknown */, displayParts: [] }); } } function implementationKindDisplayParts(node, checker) { @@ -104998,13 +106392,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 190 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 210 /* ClassExpression */) { + else if (node.kind === 211 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] @@ -105059,46 +106453,46 @@ var ts; if (!!(decl.flags & 4194304 /* Ambient */)) return true; switch (decl.kind) { - case 205 /* BinaryExpression */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 206 /* BinaryExpression */: + case 188 /* BindingElement */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: case 81 /* DefaultKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 258 /* ExportSpecifier */: - case 251 /* ImportClause */: // default import - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 242 /* InterfaceDeclaration */: - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: - case 268 /* JsxAttribute */: - case 245 /* ModuleDeclaration */: - case 248 /* NamespaceExportDeclaration */: - case 252 /* NamespaceImport */: - case 152 /* Parameter */: - case 277 /* ShorthandPropertyAssignment */: - case 243 /* TypeAliasDeclaration */: - case 151 /* TypeParameter */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 259 /* ExportSpecifier */: + case 252 /* ImportClause */: // default import + case 250 /* ImportEqualsDeclaration */: + case 255 /* ImportSpecifier */: + case 243 /* InterfaceDeclaration */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 269 /* JsxAttribute */: + case 246 /* ModuleDeclaration */: + case 249 /* NamespaceExportDeclaration */: + case 253 /* NamespaceImport */: + case 153 /* Parameter */: + case 278 /* ShorthandPropertyAssignment */: + case 244 /* TypeAliasDeclaration */: + case 152 /* TypeParameter */: return true; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return !!decl.body; - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: + case 239 /* VariableDeclaration */: + case 156 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 156 /* MethodSignature */: - case 154 /* PropertySignature */: - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: + case 157 /* MethodSignature */: + case 155 /* PropertySignature */: + case 314 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -105258,10 +106652,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 285 /* SourceFile */: + case 286 /* 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 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(FindAllReferences.nodeEntry(decl.name)); } @@ -105278,21 +106672,32 @@ var ts; var sourceFile = decl.getSourceFile(); if (sourceFilesSet.has(sourceFile.fileName)) { // At `module.exports = ...`, reference node is `module` - var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) - ? decl.left.expression - : ts.isExportAssignment(decl) - ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 86 /* ExportKeyword */, sourceFile)) - : ts.getNameOfDeclaration(decl) || decl; + var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : + ts.isExportAssignment(decl) ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 86 /* ExportKeyword */, sourceFile)) : + ts.getNameOfDeclaration(decl) || decl; references.push(FindAllReferences.nodeEntry(node)); } } } return references.length ? [{ definition: { type: 0 /* Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; } + /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ + function isReadonlyTypeOperator(node) { + return node.kind === 134 /* ReadonlyKeyword */ + && ts.isTypeOperatorNode(node.parent) + && node.parent.operator === 134 /* ReadonlyKeyword */; + } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { if (ts.isTypeKeyword(node.kind)) { - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + // A modifier readonly (like on a property declaration) is not special; + // a readonly type keyword (like `readonly string[]`) is. + if (node.kind === 134 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + return undefined; + } + // Likewise, when we *are* looking for a special keyword, make sure we + // *don’t* include readonly member modifiers. + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 134 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } // Labels if (ts.isJumpStatementTarget(node)) { @@ -105591,7 +106996,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 === 197 /* FunctionExpression */ || valueDeclaration.kind === 210 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 198 /* FunctionExpression */ || valueDeclaration.kind === 211 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -105601,7 +107006,7 @@ var ts; if (flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.find(declarations, function (d) { return ts.hasModifier(d, 8 /* Private */); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 241 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 242 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -105630,7 +107035,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 286 /* 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; @@ -105651,7 +107056,7 @@ var ts; } Core.isSymbolReferencedInFile = isSymbolReferencedInFile; function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) { - var symbol = ts.isParameterPropertyDeclaration(definition.parent) + var symbol = ts.isParameterPropertyDeclaration(definition.parent, definition.parent.parent) ? ts.first(checker.getSymbolsOfParameterPropertyDeclaration(definition.parent, definition.text)) : checker.getSymbolAtLocation(definition); if (!symbol) @@ -105753,11 +107158,13 @@ var ts; return false; } } - function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { + function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken, filter) { var references = ts.flatMap(sourceFiles, function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, ts.tokenToString(keywordKind), sourceFile), function (referenceLocation) { - return referenceLocation.kind === keywordKind ? FindAllReferences.nodeEntry(referenceLocation) : undefined; + if (referenceLocation.kind === keywordKind && (!filter || filter(referenceLocation))) { + return FindAllReferences.nodeEntry(referenceLocation); + } }); }); return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; @@ -105931,7 +107338,7 @@ var ts; } } function addReference(referenceLocation, relatedSymbol, state) { - var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; + var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator var addRef = state.referenceAdder(symbol); if (state.options.implementations) { addImplementationReferences(referenceLocation, addRef, state); @@ -105994,14 +107401,14 @@ var ts; for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var ctrKeyword = ts.findChildOfKind(decl, 125 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 158 /* Constructor */ && !!ctrKeyword); + ts.Debug.assert(decl.kind === 159 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 157 /* MethodDeclaration */) { + if (decl && decl.kind === 158 /* MethodDeclaration */) { var body = decl.body; if (body) { forEachDescendantOfKind(body, 101 /* ThisKeyword */, function (thisKeyword) { @@ -106025,7 +107432,7 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 158 /* Constructor */); + ts.Debug.assert(decl.kind === 159 /* Constructor */); var body = decl.body; if (body) { forEachDescendantOfKind(body, 99 /* SuperKeyword */, function (node) { @@ -106055,7 +107462,7 @@ var ts; if (refNode.kind !== 73 /* Identifier */) { return; } - if (refNode.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 278 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -106075,7 +107482,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 219 /* Block */) { + if (body.kind === 220 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -106103,13 +107510,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 188 /* ArrayLiteralExpression */: + case 199 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 190 /* ObjectLiteralExpression */: + case 211 /* ClassExpression */: + case 189 /* ArrayLiteralExpression */: return true; default: return false; @@ -106162,13 +107569,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -106189,41 +107596,41 @@ var ts; return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 73 /* Identifier */ && node.parent.kind === 152 /* Parameter */ && node.parent.name === node; + return node.kind === 73 /* Identifier */ && node.parent.kind === 153 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 198 /* 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 === 285 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 286 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -106231,19 +107638,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 242 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 285 /* SourceFile */: - return container.kind === 285 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 286 /* SourceFile */: + return container.kind === 286 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -106320,7 +107727,7 @@ var ts; var res = fromRoot(symbol); if (res) return res; - if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) { // For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property). var paramProps = checker.getSymbolsOfParameterPropertyDeclaration(ts.cast(symbol.valueDeclaration, ts.isParameter), symbol.name); ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] @@ -106362,7 +107769,7 @@ var ts; }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 187 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 188 /* BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -106412,11 +107819,10 @@ var ts; } Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations; function isImplementation(node) { - return !!(node.flags & 4194304 /* Ambient */) - ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) - : (ts.isVariableLike(node) ? ts.hasInitializer(node) - : ts.isFunctionLikeDeclaration(node) ? !!node.body - : ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); + return !!(node.flags & 4194304 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : + (ts.isVariableLike(node) ? ts.hasInitializer(node) : + ts.isFunctionLikeDeclaration(node) ? !!node.body : + ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); } function getReferenceEntriesForShorthandPropertyAssignment(node, checker, addReference) { var refSymbol = checker.getSymbolAtLocation(node); @@ -106719,9 +108125,9 @@ var ts; return [sigInfo]; } else { - var defs = getDefinitionFromSymbol(typeChecker, symbol, node) || ts.emptyArray; + var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 99 /* SuperKeyword */ ? [sigInfo].concat(defs) : defs.concat([sigInfo]); + return node.kind === 99 /* SuperKeyword */ ? __spreadArrays([sigInfo], defs) : __spreadArrays(defs, [sigInfo]); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -106729,7 +108135,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 278 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -106889,28 +108295,32 @@ var ts; return true; } switch (declaration.kind) { - case 251 /* ImportClause */: - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportClause */: + case 250 /* ImportEqualsDeclaration */: return true; - case 254 /* ImportSpecifier */: - return declaration.parent.kind === 253 /* NamedImports */; + case 255 /* ImportSpecifier */: + return declaration.parent.kind === 254 /* NamedImports */; default: return false; } } - function getDefinitionFromSymbol(typeChecker, symbol, node) { - return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(symbol.declarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); + function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) { + // There are cases when you extend a function by adding properties to it afterwards, + // we want to strip those extra properties. + // For deduping purposes, we also want to exclude any declarationNodes if provided. + var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); }) || undefined; + return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); function getConstructSignatureDefinition() { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (symbol.flags & 32 /* Class */ && (ts.isNewExpressionTarget(node) || node.kind === 125 /* ConstructorKeyword */)) { - var cls = ts.find(symbol.declarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); + if (symbol.flags & 32 /* Class */ && !(symbol.flags & 16 /* Function */) && (ts.isNewExpressionTarget(node) || node.kind === 125 /* ConstructorKeyword */)) { + var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } } function getCallSignatureDefinition() { return ts.isCallOrNewExpressionTarget(node) || ts.isNameOfFunctionDeclaration(node) - ? getSignatureDefinition(symbol.declarations, /*selectConstructors*/ false) + ? getSignatureDefinition(filteredDeclarations, /*selectConstructors*/ false) : undefined; } function getSignatureDefinition(signatureDeclarations, selectConstructors) { @@ -106918,8 +108328,12 @@ var ts; return undefined; } var declarations = signatureDeclarations.filter(selectConstructors ? ts.isConstructorDeclaration : ts.isFunctionLike); + var declarationsWithBody = declarations.filter(function (d) { return !!d.body; }); + // declarations defined on the global scope can be defined on multiple files. Get all of them. return declarations.length - ? [createDefinitionInfo(ts.find(declarations, function (d) { return !!d.body; }) || ts.last(declarations), typeChecker, symbol, node)] + ? declarationsWithBody.length !== 0 + ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); }) + : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)] : undefined; } } @@ -106972,9 +108386,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 159 /* Constructor */: + case 168 /* ConstructorType */: + case 163 /* ConstructSignature */: return true; default: return false; @@ -107092,11 +108506,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: + case 314 /* JSDocPropertyTag */: return [declaration]; - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -107117,16 +108531,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 301 /* JSDocAugmentsTag */: + case 303 /* JSDocAugmentsTag */: return withNode(tag.class); - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 309 /* JSDocTypeTag */: + case 311 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 314 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -107313,23 +108727,23 @@ var ts; } function getCommentOwnerInfoWorker(commentOwner) { switch (commentOwner.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 156 /* MethodSignature */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 157 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer); - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 154 /* PropertySignature */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 243 /* TypeAliasDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 155 /* PropertySignature */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 244 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 220 /* VariableStatement */: { + case 221 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -107337,14 +108751,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 285 /* SourceFile */: + case 286 /* SourceFile */: return "quit"; - case 245 /* ModuleDeclaration */: + case 246 /* 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 === 245 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 205 /* BinaryExpression */: { + return commentOwner.parent.kind === 246 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 206 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; @@ -107363,14 +108777,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 196 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 197 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return rightHandSide.parameters; - case 210 /* ClassExpression */: { + case 211 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -107432,9 +108846,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 251 /* ImportClause */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportClause */: + case 255 /* ImportSpecifier */: + case 250 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -107444,7 +108858,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 150 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 151 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -107461,7 +108875,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 === 150 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 151 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -107505,6 +108919,7 @@ var ts; (function (ts) { var NavigationBar; (function (NavigationBar) { + var _a; /** * Matches all whitespace characters in a string. Eg: * @@ -107519,6 +108934,11 @@ var ts; * does not match. */ var whiteSpaceRegex = /\s+/g; + /** + * Maximum amount of characters to return + * The amount was choosen arbitrarily. + */ + var maxLength = 150; // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. var curCancellationToken; var curSourceFile; @@ -107529,13 +108949,15 @@ var ts; */ var parentsStack = []; var parent; + var trackedEs5ClassesStack = []; + var trackedEs5Classes; // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. var emptyChildItemArray = []; function getNavigationBarItems(sourceFile, cancellationToken) { curCancellationToken = cancellationToken; curSourceFile = sourceFile; try { - return ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); + return ts.map(primaryNavBarMenuItems(rootNavigationBarNode(sourceFile)), convertToPrimaryNavBarMenuItem); } finally { reset(); @@ -107561,7 +108983,7 @@ var ts; emptyChildItemArray = []; } function nodeText(node) { - return node.getText(curSourceFile); + return cleanText(node.getText(curSourceFile)); } function navigationBarNodeKind(n) { return n.node.kind; @@ -107586,28 +109008,55 @@ var ts; ts.Debug.assert(!parent && !parentsStack.length); return root; } - function addLeafNode(node) { - pushChild(parent, emptyNavigationBarNode(node)); + function addLeafNode(node, name) { + pushChild(parent, emptyNavigationBarNode(node, name)); } - function emptyNavigationBarNode(node) { + function emptyNavigationBarNode(node, name) { return { node: node, - name: ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined, + name: name || (ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined), additionalNodes: undefined, parent: parent, children: undefined, indent: parent.indent + 1 }; } + function addTrackedEs5Class(name) { + if (!trackedEs5Classes) { + trackedEs5Classes = ts.createMap(); + } + trackedEs5Classes.set(name, true); + } + function endNestedNodes(depth) { + for (var i = 0; i < depth; i++) + endNode(); + } + function startNestedNodes(targetNode, entityName) { + var names = []; + while (!ts.isIdentifier(entityName)) { + var name = entityName.name; + entityName = entityName.expression; + if (name.escapedText === "prototype") + continue; + names.push(name); + } + names.push(entityName); + for (var i = names.length - 1; i > 0; i--) { + var name = names[i]; + startNode(targetNode, name); + } + return [names.length - 1, names[0]]; + } /** * Add a new level of NavigationBarNodes. * This pushes to the stack, so you must call `endNode` when you are done adding to this node. */ - function startNode(node) { - var navNode = emptyNavigationBarNode(node); + function startNode(node, name) { + var navNode = emptyNavigationBarNode(node, name); pushChild(parent, navNode); // Save the old parent parentsStack.push(parent); + trackedEs5ClassesStack.push(trackedEs5Classes); parent = navNode; } /** Call after calling `startNode` and adding children to it. */ @@ -107617,46 +109066,48 @@ var ts; sortChildren(parent.children); } parent = parentsStack.pop(); + trackedEs5Classes = trackedEs5ClassesStack.pop(); } - function addNodeWithRecursiveChild(node, child) { - startNode(node); + function addNodeWithRecursiveChild(node, child, name) { + startNode(node, name); addChildrenRecursively(child); endNode(); } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ function addChildrenRecursively(node) { + var _a; curCancellationToken.throwIfCancellationRequested(); if (!node || ts.isToken(node)) { return; } switch (node.kind) { - case 158 /* Constructor */: + case 159 /* 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); // Parameter properties are children of the class, not the constructor. - for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { - var param = _a[_i]; - if (ts.isParameterPropertyDeclaration(param)) { + for (var _i = 0, _b = ctr.parameters; _i < _b.length; _i++) { + var param = _b[_i]; + if (ts.isParameterPropertyDeclaration(param, ctr)) { addLeafNode(param); } } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 157 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 251 /* ImportClause */: + case 252 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -107668,90 +109119,168 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 253 /* NamespaceImport */) { addLeafNode(namedBindings); } else { - for (var _b = 0, _c = namedBindings.elements; _b < _c.length; _b++) { - var element = _c[_b]; + for (var _c = 0, _d = namedBindings.elements; _c < _d.length; _c++) { + var element = _d[_c]; addLeafNode(element); } } } break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: - var _d = node, name = _d.name, initializer = _d.initializer; + case 278 /* ShorthandPropertyAssignment */: + addNodeWithRecursiveChild(node, node.name); + break; + case 279 /* 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 188 /* BindingElement */: + case 277 /* PropertyAssignment */: + case 239 /* VariableDeclaration */: + var _e = node, name = _e.name, initializer = _e.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); } else if (initializer && isFunctionOrClassExpression(initializer)) { - if (initializer.name) { - // Don't add a node for the VariableDeclaration, just for the initializer. - addChildrenRecursively(initializer); - } - else { - // Add a node for the VariableDeclaration, but not for the initializer. - startNode(node); - ts.forEachChild(initializer, addChildrenRecursively); - endNode(); - } + // Add a node for the VariableDeclaration, but not for the initializer. + startNode(node); + ts.forEachChild(initializer, addChildrenRecursively); + endNode(); } else { addNodeWithRecursiveChild(node, initializer); } break; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + var nameNode = node.name; + // If we see a function declaration track as a possible ES5 class + if (nameNode && ts.isIdentifier(nameNode)) { + addTrackedEs5Class(nameNode.text); + } + addNodeWithRecursiveChild(node, node.body); + break; + case 199 /* ArrowFunction */: + case 198 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: startNode(node); - for (var _e = 0, _f = node.members; _e < _f.length; _e++) { - var member = _f[_e]; + for (var _f = 0, _g = node.members; _f < _g.length; _f++) { + var member = _g[_f]; if (!isComputedProperty(member)) { addLeafNode(member); } } endNode(); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: startNode(node); - for (var _g = 0, _h = node.members; _g < _h.length; _g++) { - var member = _h[_g]; + for (var _h = 0, _j = node.members; _h < _j.length; _h++) { + var member = _j[_h]; addChildrenRecursively(member); } endNode(); break; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 258 /* ExportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 163 /* IndexSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 243 /* TypeAliasDeclaration */: + case 259 /* ExportSpecifier */: + case 250 /* ImportEqualsDeclaration */: + case 164 /* IndexSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 244 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 205 /* BinaryExpression */: { + case 193 /* CallExpression */: + case 206 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: case 2 /* ModuleExports */: - case 3 /* PrototypeProperty */: - case 6 /* Prototype */: addNodeWithRecursiveChild(node, node.right); return; + case 6 /* Prototype */: + case 3 /* PrototypeProperty */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var prototypeAccess = special === 3 /* PrototypeProperty */ ? + assignmentTarget.expression : + assignmentTarget; + var depth = 0; + var className = void 0; + // If we see a prototype assignment, start tracking the target as a class + // This is only done for simple classes not nested assignments. + if (ts.isIdentifier(prototypeAccess.expression)) { + addTrackedEs5Class(prototypeAccess.expression.text); + className = prototypeAccess.expression; + } + else { + _a = startNestedNodes(binaryExpression, prototypeAccess.expression), depth = _a[0], className = _a[1]; + } + if (special === 6 /* Prototype */) { + if (ts.isObjectLiteralExpression(binaryExpression.right)) { + if (binaryExpression.right.properties.length > 0) { + startNode(binaryExpression, className); + ts.forEachChild(binaryExpression.right, addChildrenRecursively); + endNode(); + } + } + } + else if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, className); + } + else { + startNode(binaryExpression, className); + addNodeWithRecursiveChild(node, binaryExpression.right, assignmentTarget.name); + endNode(); + } + endNestedNodes(depth); + return; + } + case 7 /* ObjectDefinePropertyValue */: + case 9 /* ObjectDefinePrototypeProperty */: { + var defineCall = node; + var className = special === 7 /* ObjectDefinePropertyValue */ ? + defineCall.arguments[0] : + defineCall.arguments[0].expression; + var memberName = defineCall.arguments[1]; + var _k = startNestedNodes(node, className), depth = _k[0], classNameIdentifier = _k[1]; + startNode(node, classNameIdentifier); + startNode(node, ts.setTextRange(ts.createIdentifier(memberName.text), memberName)); + addChildrenRecursively(node.arguments[2]); + endNode(); + endNode(); + endNestedNodes(depth); + return; + } + case 5 /* Property */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var targetFunction = assignmentTarget.expression; + if (ts.isIdentifier(targetFunction) && assignmentTarget.name.escapedText !== "prototype" && + trackedEs5Classes && trackedEs5Classes.has(targetFunction.text)) { + if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, targetFunction); + } + else { + startNode(binaryExpression, targetFunction); + addNodeWithRecursiveChild(binaryExpression.left, binaryExpression.right, assignmentTarget.name); + endNode(); + } + return; + } + break; + } case 4 /* ThisProperty */: - case 5 /* Property */: case 0 /* None */: - case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: break; default: ts.Debug.assertNever(special); @@ -107774,8 +109303,8 @@ var ts; /** Merge declarations of the same kind. */ function mergeChildren(children, node) { var nameToItems = ts.createMap(); - ts.filterMutate(children, function (child) { - var declName = ts.getNameOfDeclaration(child.node); + ts.filterMutate(children, function (child, index) { + var declName = child.name || ts.getNameOfDeclaration(child.node); var name = declName && nodeText(declName); if (!name) { // Anonymous items are never merged. @@ -107789,7 +109318,7 @@ var ts; if (itemsWithSameName instanceof Array) { for (var _i = 0, itemsWithSameName_1 = itemsWithSameName; _i < itemsWithSameName_1.length; _i++) { var itemWithSameName = itemsWithSameName_1[_i]; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } } @@ -107798,7 +109327,7 @@ var ts; } else { var itemWithSameName = itemsWithSameName; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } nameToItems.set(name, [itemWithSameName, child]); @@ -107806,7 +109335,100 @@ var ts; } }); } - function tryMerge(a, b, parent) { + var isEs5ClassMember = (_a = {}, + _a[5 /* Property */] = true, + _a[3 /* PrototypeProperty */] = true, + _a[7 /* ObjectDefinePropertyValue */] = true, + _a[9 /* ObjectDefinePrototypeProperty */] = true, + _a[0 /* None */] = false, + _a[1 /* ExportsProperty */] = false, + _a[2 /* ModuleExports */] = false, + _a[8 /* ObjectDefinePropertyExports */] = false, + _a[6 /* Prototype */] = true, + _a[4 /* ThisProperty */] = false, + _a); + function tryMergeEs5Class(a, b, bIndex, parent) { + function isPossibleConstructor(node) { + return ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node) || ts.isVariableDeclaration(node); + } + var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? + ts.getAssignmentDeclarationKind(b.node) : + 0 /* None */; + var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? + ts.getAssignmentDeclarationKind(a.node) : + 0 /* None */; + // We treat this as an es5 class and merge the nodes in in one of several cases + if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements + || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member + || (isPossibleConstructor(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & ctor function + || (ts.isClassDeclaration(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // class (generated) & member + || (ts.isClassDeclaration(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & class (generated) + || (ts.isClassDeclaration(a.node) && isPossibleConstructor(b.node)) // class (generated) & ctor + || (ts.isClassDeclaration(b.node) && isPossibleConstructor(a.node)) // ctor & class (generated) + ) { + var lastANode = a.additionalNodes && ts.lastOrUndefined(a.additionalNodes) || a.node; + if ((!ts.isClassDeclaration(a.node) && !ts.isClassDeclaration(b.node)) // If neither outline node is a class + || isPossibleConstructor(a.node) || isPossibleConstructor(b.node) // If either function is a constructor function + ) { + var ctorFunction = isPossibleConstructor(a.node) ? a.node : + isPossibleConstructor(b.node) ? b.node : + undefined; + if (ctorFunction !== undefined) { + var ctorNode = ts.setTextRange(ts.createConstructor(/* decorators */ undefined, /* modifiers */ undefined, [], /* body */ undefined), ctorFunction); + var ctor = emptyNavigationBarNode(ctorNode); + ctor.indent = a.indent + 1; + ctor.children = a.node === ctorFunction ? a.children : b.children; + a.children = a.node === ctorFunction ? ts.concatenate([ctor], b.children || [b]) : ts.concatenate(a.children || [a], [ctor]); + } + else { + if (a.children || b.children) { + a.children = ts.concatenate(a.children || [a], b.children || [b]); + if (a.children) { + mergeChildren(a.children, a); + sortChildren(a.children); + } + } + } + lastANode = a.node = ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), a.node); + } + else { + a.children = ts.concatenate(a.children, b.children); + if (a.children) { + mergeChildren(a.children, a); + } + } + var bNode = b.node; + // We merge if the outline node previous to b (bIndex - 1) is already part of the current class + // We do this so that statements between class members that do not generate outline nodes do not split up the class outline: + // Ex This should produce one outline node C: + // function C() {}; a = 1; C.prototype.m = function () {} + // Ex This will produce 3 outline nodes: C, a, C + // function C() {}; let a = 1; C.prototype.m = function () {} + if (parent.children[bIndex - 1].node.end === lastANode.end) { + ts.setTextRange(lastANode, { pos: lastANode.pos, end: bNode.end }); + } + else { + if (!a.additionalNodes) + a.additionalNodes = []; + a.additionalNodes.push(ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), b.node)); + } + return true; + } + return bAssignmentDeclarationKind === 0 /* None */ ? false : true; + } + function tryMerge(a, b, bIndex, parent) { + // const v = false as boolean; + if (tryMergeEs5Class(a, b, bIndex, parent)) { + return true; + } if (shouldReallyMerge(a.node, b.node, parent)) { merge(a, b); return true; @@ -107819,12 +109441,12 @@ var ts; return false; } switch (a.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -107840,7 +109462,7 @@ var ts; // 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 !== 245 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 246 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -107870,7 +109492,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 245 /* ModuleDeclaration */) { + if (node.kind === 246 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -107878,35 +109500,35 @@ var ts; return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 } switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 211 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 245 /* ModuleDeclaration */) { - return getModuleName(node); + if (node.kind === 246 /* ModuleDeclaration */) { + return cleanText(getModuleName(node)); } if (name) { - var text = nodeText(name); + var text = ts.isIdentifier(name) ? name.text : nodeText(name); if (text.length > 0) { - return text; + return cleanText(text); } } switch (node.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 199 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -107914,24 +109536,27 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 158 /* Constructor */: + case 159 /* Constructor */: return "constructor"; - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: return "new()"; - case 161 /* CallSignature */: + case 162 /* CallSignature */: return "()"; - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: return "[]"; default: return ""; } } - /** Flattens the NavNode tree to a list, keeping only the top-level items. */ - function topLevelItems(root) { - var topLevel = []; + /** Flattens the NavNode tree to a list of items to appear in the primary navbar menu. */ + function primaryNavBarMenuItems(root) { + // The primary (middle) navbar menu displays the general code navigation hierarchy, similar to the navtree. + // The secondary (right) navbar menu displays the child items of whichever primary item is selected. + // Some less interesting items without their own child navigation items (e.g. a local variable declaration) only show up in the secondary menu. + var primaryNavBarMenuItems = []; function recur(item) { - if (isTopLevel(item)) { - topLevel.push(item); + if (shouldAppearInPrimaryNavBarMenu(item)) { + primaryNavBarMenuItems.push(item); if (item.children) { for (var _i = 0, _a = item.children; _i < _a.length; _i++) { var child = _a[_i]; @@ -107941,28 +109566,28 @@ var ts; } } recur(root); - return topLevel; - function isTopLevel(item) { + return primaryNavBarMenuItems; + /** Determines if a node should appear in the primary navbar menu. */ + function shouldAppearInPrimaryNavBarMenu(item) { + // Items with children should always appear in the primary navbar menu. + if (item.children) { + return true; + } + // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 285 /* SourceFile */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 245 /* EnumDeclaration */: + case 243 /* InterfaceDeclaration */: + case 246 /* ModuleDeclaration */: + case 286 /* SourceFile */: + case 244 /* TypeAliasDeclaration */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: return true; - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 238 /* VariableDeclaration */: - return hasSomeImportantChild(item); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -107972,21 +109597,15 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: + case 247 /* ModuleBlock */: + case 286 /* SourceFile */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: return true; default: - return hasSomeImportantChild(item); + return false; } } - function hasSomeImportantChild(item) { - return ts.some(item.children, function (child) { - var childKind = navigationBarNodeKind(child); - return childKind !== 238 /* VariableDeclaration */ && childKind !== 187 /* BindingElement */; - }); - } } } function convertToTree(n) { @@ -107999,18 +109618,18 @@ var ts; childItems: ts.map(n.children, convertToTree) }; } - function convertToTopLevelItem(n) { + function convertToPrimaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), kindModifiers: getModifiers(n.node), spans: getSpans(n), - childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, + childItems: ts.map(n.children, convertToSecondaryNavBarMenuItem) || emptyChildItemArray, indent: n.indent, bolded: false, grayed: false }; - function convertToChildItem(n) { + function convertToSecondaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), @@ -108041,7 +109660,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 246 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -108055,13 +109674,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 150 /* ComputedPropertyName */; + return !member.name || member.name.kind === 151 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 285 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 286 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 238 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 239 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -108069,11 +109688,11 @@ var ts; function getFunctionOrClassName(node) { var parent = node.parent; if (node.name && ts.getFullWidth(node.name) > 0) { - return ts.declarationNameToString(node.name); + return cleanText(ts.declarationNameToString(node.name)); } // See if it is a var initializer. If so, use the var name. else if (ts.isVariableDeclaration(parent)) { - return ts.declarationNameToString(parent.name); + return cleanText(ts.declarationNameToString(parent.name)); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 60 /* EqualsToken */) { @@ -108093,7 +109712,11 @@ var ts; else if (ts.isCallExpression(parent)) { var name = getCalledExpressionName(parent.expression); if (name !== undefined) { - var args = ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", "); + name = cleanText(name); + if (name.length > maxLength) { + return name + " callback"; + } + var args = cleanText(ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", ")); return name + "(" + args + ") callback"; } } @@ -108114,14 +109737,24 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: + case 199 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 211 /* ClassExpression */: return true; default: return false; } } + function cleanText(text) { + // Truncate to maximum amount of characters as we don't want to do a big replace operation. + text = text.length > maxLength ? text.substring(0, maxLength) + "..." : text; + // Replaces ECMAScript line terminators and removes the trailing `\` from each line: + // \n - Line Feed + // \r - Carriage Return + // \u2028 - Line separator + // \u2029 - Paragraph separator + return text.replace(/\\?(\r?\n|\r|\u2028|\u2029)/g, ""); + } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); /* @internal */ @@ -108581,7 +110214,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 219 /* Block */: + case 220 /* Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -108589,16 +110222,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 224 /* DoStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 275 /* CatchClause */: + case 225 /* DoStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 227 /* ForStatement */: + case 224 /* IfStatement */: + case 226 /* WhileStatement */: + case 233 /* WithStatement */: + case 276 /* CatchClause */: return spanForNode(n.parent); - case 236 /* TryStatement */: + case 237 /* TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { @@ -108613,24 +110246,24 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return spanForNode(n.parent); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 247 /* CaseBlock */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 248 /* CaseBlock */: return spanForNode(n); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 261 /* JsxElement */: + case 262 /* JsxElement */: return spanForJSXElement(n); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return spanForJSXFragment(n); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); } function spanForJSXElement(node) { @@ -108672,7 +110305,7 @@ var ts; ? ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) : ts.findChildOfKind(body, 18 /* OpenBraceToken */, sourceFile); var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 198 /* ArrowFunction */); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 199 /* ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } @@ -109516,7 +111149,7 @@ var ts; return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 150 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 151 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -109605,7 +111238,7 @@ var ts; if (node.getStart(sourceFile) > pos) { break outer; } - if (positionShouldSnapToNode(pos, node, nextNode)) { + 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 // of things that should be considered independently. @@ -109614,7 +111247,7 @@ var ts; // // Dive in without pushing a selection range. if (ts.isBlock(node) - || ts.isTemplateSpan(node) || ts.isTemplateHead(node) + || ts.isTemplateSpan(node) || ts.isTemplateHead(node) || ts.isTemplateTail(node) || prevNode && ts.isTemplateHead(prevNode) || ts.isVariableDeclarationList(node) && ts.isVariableStatement(parentNode) || ts.isSyntaxList(node) && ts.isVariableDeclarationList(parentNode) @@ -109677,12 +111310,11 @@ var ts; * count too, unless that position belongs to the next node. In effect, makes * selections able to snap to preceding tokens when the cursor is on the tail * end of them with only whitespace ahead. + * @param sourceFile The source file containing the nodes. * @param pos The position to check. * @param node The candidate node to snap to. - * @param nextNode The next sibling node in the tree. - * @param sourceFile The source file containing the nodes. */ - function positionShouldSnapToNode(pos, node, nextNode) { + function positionShouldSnapToNode(sourceFile, pos, node) { // Can’t use 'ts.positionBelongsToNode()' here because it cleverly accounts // for missing nodes, which can’t really be considered when deciding what // to select. @@ -109691,9 +111323,8 @@ var ts; return true; } var nodeEnd = node.getEnd(); - var nextNodeStart = nextNode && nextNode.getStart(); if (nodeEnd === pos) { - return pos !== nextNodeStart; + return ts.getTouchingPropertyName(sourceFile, pos).pos < node.end; } return false; } @@ -109735,7 +111366,7 @@ var ts; var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; return kind === 22 /* OpenBracketToken */ || - kind === 151 /* TypeParameter */ || + kind === 152 /* TypeParameter */ || kind === 23 /* CloseBracketToken */; }); return [ @@ -109842,7 +111473,7 @@ var ts; } function createSyntaxList(children) { ts.Debug.assertGreaterThanOrEqual(children.length, 1); - var syntaxList = ts.createNode(313 /* SyntaxList */, children[0].pos, ts.last(children).end); + var syntaxList = ts.createNode(315 /* SyntaxList */, children[0].pos, ts.last(children).end); syntaxList._children = children; return syntaxList; } @@ -109851,14 +111482,14 @@ var ts; return kind === 18 /* OpenBraceToken */ || kind === 22 /* OpenBracketToken */ || kind === 20 /* OpenParenToken */ - || kind === 263 /* JsxOpeningElement */; + || kind === 264 /* JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; return kind === 19 /* CloseBraceToken */ || kind === 23 /* CloseBracketToken */ || kind === 21 /* CloseParenToken */ - || kind === 264 /* JsxClosingElement */; + || kind === 265 /* JsxClosingElement */; } })(SmartSelectionRange = ts.SmartSelectionRange || (ts.SmartSelectionRange = {})); })(ts || (ts = {})); @@ -110063,10 +111694,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 194 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 195 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 207 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 208 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -110133,17 +111764,17 @@ var ts; return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 197 /* ParenthesizedExpression */: + case 158 /* MethodDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* 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 205 /* BinaryExpression */: { + case 206 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; @@ -110214,11 +111845,11 @@ var ts; // not enough to put us in the substitution expression; we should consider ourselves part of // the *next* span's expression by offsetting the index (argIndex = (spanIndex + 1) + 1). // - // tslint:disable no-double-space + /* eslint-disable no-double-space */ // Example: f `# abcd $#{# 1 + 1# }# efghi ${ #"#hello"# } # ` // ^ ^ ^ ^ ^ ^ ^ ^ ^ // Case: 1 1 3 2 1 3 2 2 1 - // tslint:enable no-double-space + /* eslint-enable no-double-space */ ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); if (ts.isTemplateLiteralToken(node)) { if (ts.isInsideTemplateLiteral(node, position, sourceFile)) { @@ -110267,7 +111898,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 === 207 /* TemplateExpression */) { + if (template.kind === 208 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -110332,14 +111963,14 @@ var ts; var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); var tags = symbol.getJsDocTags(); - var prefixDisplayParts = typeSymbolDisplay.concat([ts.punctuationPart(28 /* LessThanToken */)]); + var prefixDisplayParts = __spreadArrays(typeSymbolDisplay, [ts.punctuationPart(28 /* LessThanToken */)]); return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(30 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]; function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) { var _a = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile), isVariadic = _a.isVariadic, parameters = _a.parameters, prefix = _a.prefix, suffix = _a.suffix; - var prefixDisplayParts = callTargetDisplayParts.concat(prefix); - var suffixDisplayParts = suffix.concat(returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker)); + var prefixDisplayParts = __spreadArrays(callTargetDisplayParts, prefix); + var suffixDisplayParts = __spreadArrays(suffix, returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker)); var documentation = candidateSignature.getDocumentationComment(checker); var tags = candidateSignature.getJsDocTags(); return { isVariadic: isVariadic, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; @@ -110363,10 +111994,10 @@ var ts; var parameters = (typeParameters || ts.emptyArray).map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var parameterParts = ts.mapToDisplayParts(function (writer) { var thisParameter = candidateSignature.thisParameter ? [checker.symbolToParameterDeclaration(candidateSignature.thisParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags)] : []; - var params = ts.createNodeArray(thisParameter.concat(checker.getExpandedParameters(candidateSignature).map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); + var params = ts.createNodeArray(__spreadArrays(thisParameter, checker.getExpandedParameters(candidateSignature).map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(28 /* LessThanToken */)], suffix: [ts.punctuationPart(30 /* GreaterThanToken */)].concat(parameterParts) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(28 /* LessThanToken */)], suffix: __spreadArrays([ts.punctuationPart(30 /* GreaterThanToken */)], parameterParts) }; } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { var isVariadic = checker.hasEffectiveRestParameter(candidateSignature); @@ -110378,7 +112009,7 @@ var ts; } }); var parameters = checker.getExpandedParameters(candidateSignature).map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }); - return { isVariadic: isVariadic, parameters: parameters, prefix: typeParameterParts.concat([ts.punctuationPart(20 /* OpenParenToken */)]), suffix: [ts.punctuationPart(21 /* CloseParenToken */)] }; + return { isVariadic: isVariadic, parameters: parameters, prefix: __spreadArrays(typeParameterParts, [ts.punctuationPart(20 /* OpenParenToken */)]), suffix: [ts.punctuationPart(21 /* CloseParenToken */)] }; } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { @@ -110579,7 +112210,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: var decl = ts.getDeclarationOfExpando(node); if (decl) { var symbol_1 = decl.symbol; @@ -110589,7 +112220,7 @@ var ts; } } // falls through if no diagnostic was created - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: var symbol = node.symbol; if (symbol.members && (symbol.members.size > 0)) { diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); @@ -110622,11 +112253,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 222 /* ExpressionStatement */: { + case 223 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -110643,12 +112274,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 252 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 253 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -110706,11 +112337,11 @@ var ts; // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg) { switch (arg.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); - /* falls through */ + // falls through case 97 /* NullKeyword */: case 73 /* Identifier */: // identifier includes undefined return true; @@ -110735,7 +112366,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 211 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -110823,11 +112454,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 263 /* JsxOpeningElement */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: return location.kind === 73 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -110870,7 +112501,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 190 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 191 /* 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)) { @@ -110890,7 +112521,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 193 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 99 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 194 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 99 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -110945,7 +112576,7 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 125 /* ConstructorKeyword */ && location.parent.kind === 158 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 125 /* ConstructorKeyword */ && location.parent.kind === 159 /* 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 @@ -110953,21 +112584,21 @@ var ts; return declaration === (location.kind === 125 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 158 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 159 /* 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 === 158 /* Constructor */) { + if (functionDeclaration_1.kind === 159 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 161 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 162 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -110977,7 +112608,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 211 /* 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 @@ -111021,7 +112652,7 @@ var ts; } if (symbolFlags & 1536 /* Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 245 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 246 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 73 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 132 /* NamespaceKeyword */ : 131 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -111042,7 +112673,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 151 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 152 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -111050,16 +112681,16 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 162 /* ConstructSignature */) { + if (declaration.kind === 163 /* ConstructSignature */) { displayParts.push(ts.keywordPart(96 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 161 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 162 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 243 /* TypeAliasDeclaration */) { + else if (declaration.kind === 244 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path @@ -111076,7 +112707,7 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 279 /* EnumMember */) { + if (declaration.kind === 280 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -111106,17 +112737,17 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(132 /* NamespaceKeyword */)); break; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 60 /* EqualsToken */ : 81 /* DefaultKeyword */)); break; - case 258 /* ExportSpecifier */: + case 259 /* ExportSpecifier */: displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); break; default: @@ -111125,7 +112756,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 249 /* ImportEqualsDeclaration */) { + if (declaration.kind === 250 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -111203,10 +112834,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 === 285 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 286 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 205 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 206 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -111319,16 +112950,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 197 /* FunctionExpression */) { + if (declaration.kind === 198 /* FunctionExpression */) { return true; } - if (declaration.kind !== 238 /* VariableDeclaration */ && declaration.kind !== 240 /* FunctionDeclaration */) { + if (declaration.kind !== 239 /* VariableDeclaration */ && declaration.kind !== 241 /* 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 === 285 /* SourceFile */ || parent.kind === 246 /* ModuleBlock */) { + if (parent.kind === 286 /* SourceFile */ || parent.kind === 247 /* ModuleBlock */) { return false; } } @@ -111351,32 +112982,24 @@ var ts; */ function transpileModule(input, transpileOptions) { var diagnostics = []; - var options = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : ts.getDefaultCompilerOptions(); - options.isolatedModules = true; + var options = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : {}; + // mix in default options + var defaultOptions = ts.getDefaultCompilerOptions(); + for (var key in defaultOptions) { + if (ts.hasProperty(defaultOptions, key) && options[key] === undefined) { + options[key] = defaultOptions[key]; + } + } + for (var _i = 0, transpileOptionValueCompilerOptions_1 = ts.transpileOptionValueCompilerOptions; _i < transpileOptionValueCompilerOptions_1.length; _i++) { + var option = transpileOptionValueCompilerOptions_1[_i]; + options[option.name] = option.transpileOptionValue; + } // transpileModule does not write anything to disk so there is no need to verify that there are no conflicts between input and output paths. options.suppressOutputPathCheck = true; // Filename can be non-ts file. options.allowNonTsExtensions = true; - // We are not returning a sourceFile for lib file when asked by the program, - // so pass --noLib to avoid reporting a file not found error. - options.noLib = true; - // Clear out other settings that would not be used in transpiling this module - options.lib = undefined; - options.types = undefined; - options.noEmit = undefined; - options.noEmitOnError = undefined; - options.paths = undefined; - options.rootDirs = undefined; - options.declaration = undefined; - options.composite = undefined; - options.declarationDir = undefined; - options.out = undefined; - options.outFile = undefined; - // We are not doing a full typecheck, we are not resolving the whole context, - // so pass --noResolve to avoid reporting missing file errors. - options.noResolve = true; // if jsx is specified then treat file as .tsx - var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); + var inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts"); var sourceFile = ts.createSourceFile(inputFileName, input, options.target); // TODO: GH#18217 if (transpileOptions.moduleName) { sourceFile.moduleName = transpileOptions.moduleName; @@ -111633,10 +113256,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 268 /* JsxAttribute */: - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 269 /* JsxAttribute */: + case 264 /* JsxOpeningElement */: + case 265 /* JsxClosingElement */: + case 263 /* 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 === 73 /* Identifier */; } @@ -111660,17 +113283,12 @@ var ts; ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) - ? 1 /* RescanGreaterThanToken */ - : shouldRescanSlashToken(n) - ? 2 /* RescanSlashToken */ - : shouldRescanTemplateToken(n) - ? 3 /* RescanTemplateToken */ - : shouldRescanJsxIdentifier(n) - ? 4 /* RescanJsxIdentifier */ - : shouldRescanJsxText(n) - ? 5 /* RescanJsxText */ - : 0 /* Scan */; + var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : + shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : + shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : + shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : + shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : + 0 /* Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -111813,7 +113431,7 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 148 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 149 /* LastToken */; token++) { allTokens.push(token); } function anyTokenExcept() { @@ -111824,10 +113442,10 @@ var ts; return { tokens: allTokens.filter(function (t) { return !tokens.some(function (t2) { return t2 === t; }); }), isSpecific: false }; } var anyToken = { tokens: allTokens, isSpecific: false }; - var anyTokenIncludingMultilineComments = tokenRangeFrom(allTokens.concat([3 /* MultiLineCommentTrivia */])); - var keywords = tokenRangeFromRange(74 /* FirstKeyword */, 148 /* LastKeyword */); + var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArrays(allTokens, [3 /* MultiLineCommentTrivia */])); + var keywords = tokenRangeFromRange(74 /* FirstKeyword */, 149 /* LastKeyword */); var binaryOperators = tokenRangeFromRange(28 /* FirstBinaryOperator */, 72 /* LastBinaryOperator */); - var binaryKeywordOperators = [94 /* InKeyword */, 95 /* InstanceOfKeyword */, 148 /* OfKeyword */, 120 /* AsKeyword */, 129 /* IsKeyword */]; + var binaryKeywordOperators = [94 /* InKeyword */, 95 /* InstanceOfKeyword */, 149 /* OfKeyword */, 120 /* AsKeyword */, 129 /* IsKeyword */]; var unaryPrefixOperators = [44 /* PlusPlusToken */, 45 /* MinusMinusToken */, 53 /* TildeToken */, 52 /* ExclamationToken */]; var unaryPrefixExpressions = [ 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 73 /* Identifier */, 20 /* OpenParenToken */, @@ -111838,7 +113456,7 @@ var ts; var unaryPredecrementExpressions = [73 /* Identifier */, 20 /* OpenParenToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */]; var unaryPostdecrementExpressions = [73 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 96 /* NewKeyword */]; var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = [73 /* Identifier */].concat(ts.typeKeywords); + var typeNames = __spreadArrays([73 /* Identifier */], ts.typeKeywords); // Place a space before open brace in a function declaration // TypeScript: Function can have return types, which can be made of tons of different token kinds var functionOpenBraceLeftTokenRange = anyTokenIncludingMultilineComments; @@ -112076,7 +113694,7 @@ var ts; // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. rule("SpaceAfterTryFinally", [104 /* TryKeyword */, 89 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), ]; - return highPriorityCommonRules.concat(userConfigurableRules, lowPriorityCommonRules); + return __spreadArrays(highPriorityCommonRules, userConfigurableRules, lowPriorityCommonRules); } formatting.getAllRules = getAllRules; /** @@ -112130,45 +113748,50 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 226 /* ForStatement */; + return context.contextNode.kind === 227 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 176 /* ConditionalType */: - case 213 /* AsExpression */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 164 /* TypePredicate */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 206 /* BinaryExpression */: + case 207 /* ConditionalExpression */: + case 177 /* ConditionalType */: + case 214 /* AsExpression */: + case 259 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 165 /* TypePredicate */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 187 /* BindingElement */: + case 188 /* BindingElement */: // equals in type X = ... - case 243 /* TypeAliasDeclaration */: + // falls through + case 244 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 249 /* ImportEqualsDeclaration */: - // equal in let a = 0; - case 238 /* VariableDeclaration */: - // equal in p = 0; - case 152 /* Parameter */: - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + // falls through + case 250 /* ImportEqualsDeclaration */: + // equal in let a = 0 + // falls through + case 239 /* VariableDeclaration */: + // equal in p = 0 + // falls through + case 153 /* Parameter */: + case 280 /* EnumMember */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 151 /* TypeParameter */: + // falls through + case 152 /* TypeParameter */: return context.currentTokenSpan.kind === 94 /* InKeyword */ || context.nextTokenSpan.kind === 94 /* InKeyword */ || context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 228 /* ForOfStatement */: - return context.currentTokenSpan.kind === 148 /* OfKeyword */ || context.nextTokenSpan.kind === 148 /* OfKeyword */; + case 229 /* ForOfStatement */: + return context.currentTokenSpan.kind === 149 /* OfKeyword */ || context.nextTokenSpan.kind === 149 /* OfKeyword */; } return false; } @@ -112180,22 +113803,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 155 /* PropertyDeclaration */ || - contextKind === 154 /* PropertySignature */ || - contextKind === 152 /* Parameter */ || - contextKind === 238 /* VariableDeclaration */ || + return contextKind === 156 /* PropertyDeclaration */ || + contextKind === 155 /* PropertySignature */ || + contextKind === 153 /* Parameter */ || + contextKind === 239 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 206 /* ConditionalExpression */ || - context.contextNode.kind === 176 /* ConditionalType */; + return context.contextNode.kind === 207 /* ConditionalExpression */ || + context.contextNode.kind === 177 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 185 /* ObjectBindingPattern */ || - context.contextNode.kind === 182 /* MappedType */ || + return context.contextNode.kind === 186 /* ObjectBindingPattern */ || + context.contextNode.kind === 183 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -112221,31 +113844,34 @@ var ts; return true; } switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 189 /* ObjectLiteralExpression */: - case 246 /* ModuleBlock */: + case 220 /* Block */: + case 248 /* CaseBlock */: + case 190 /* ObjectLiteralExpression */: + case 247 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + // falls through + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 161 /* CallSignature */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 198 /* ArrowFunction */: + // falls through + case 162 /* CallSignature */: + case 198 /* FunctionExpression */: + case 159 /* Constructor */: + case 199 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 242 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + // falls through + case 243 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -112254,40 +113880,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 240 /* FunctionDeclaration */ || context.contextNode.kind === 197 /* FunctionExpression */; + return context.contextNode.kind === 241 /* FunctionDeclaration */ || context.contextNode.kind === 198 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 169 /* TypeLiteral */: - case 245 /* ModuleDeclaration */: - case 256 /* ExportDeclaration */: - case 257 /* NamedExports */: - case 250 /* ImportDeclaration */: - case 253 /* NamedImports */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 170 /* TypeLiteral */: + case 246 /* ModuleDeclaration */: + case 257 /* ExportDeclaration */: + case 258 /* NamedExports */: + case 251 /* ImportDeclaration */: + case 254 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 275 /* CatchClause */: - case 246 /* ModuleBlock */: - case 233 /* SwitchStatement */: + case 242 /* ClassDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 276 /* CatchClause */: + case 247 /* ModuleBlock */: + case 234 /* SwitchStatement */: return true; - case 219 /* Block */: { + case 220 /* 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 !== 198 /* ArrowFunction */ && blockParent.kind !== 197 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 199 /* ArrowFunction */ && blockParent.kind !== 198 /* FunctionExpression */) { return true; } } @@ -112296,31 +113922,32 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 232 /* WithStatement */: + case 224 /* IfStatement */: + case 234 /* SwitchStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 226 /* WhileStatement */: + case 237 /* TryStatement */: + case 225 /* DoStatement */: + case 233 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 275 /* CatchClause */: + // falls through + case 276 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 189 /* ObjectLiteralExpression */; + return context.contextNode.kind === 190 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 192 /* CallExpression */; + return context.contextNode.kind === 193 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 193 /* NewExpression */; + return context.contextNode.kind === 194 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -112332,28 +113959,28 @@ var ts; return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 198 /* ArrowFunction */; + return context.contextNode.kind === 199 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 184 /* ImportType */; + return context.contextNode.kind === 185 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 261 /* JsxElement */ && context.contextNode.kind !== 265 /* JsxFragment */; + return context.contextNode.kind !== 262 /* JsxElement */ && context.contextNode.kind !== 266 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 271 /* JsxExpression */ || context.contextNode.kind === 270 /* JsxSpreadAttribute */; + return context.contextNode.kind === 272 /* JsxExpression */ || context.contextNode.kind === 271 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 268 /* JsxAttribute */; + return context.nextTokenParent.kind === 269 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 268 /* JsxAttribute */; + return context.contextNode.kind === 269 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 262 /* JsxSelfClosingElement */; + return context.contextNode.kind === 263 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -112368,45 +113995,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 153 /* Decorator */; + return node.kind === 154 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 239 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 240 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 245 /* ModuleDeclaration */; + return context.contextNode.kind === 246 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 169 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 170 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 162 /* ConstructSignature */; + return context.contextNode.kind === 163 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { if (token.kind !== 28 /* LessThanToken */ && token.kind !== 30 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 165 /* TypeReference */: - case 195 /* TypeAssertionExpression */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: + case 166 /* TypeReference */: + case 196 /* TypeAssertionExpression */: + case 244 /* TypeAliasDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 213 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -112417,16 +114044,16 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 195 /* TypeAssertionExpression */; + return context.contextNode.kind === 196 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 107 /* VoidKeyword */ && context.currentTokenParent.kind === 201 /* VoidExpression */; + return context.currentTokenSpan.kind === 107 /* VoidKeyword */ && context.currentTokenParent.kind === 202 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 208 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 209 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 214 /* NonNullExpression */; + return context.contextNode.kind === 215 /* NonNullExpression */; } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -112477,12 +114104,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 148 /* LastKeyword */ && column <= 148 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 149 /* LastKeyword */ && column <= 149 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 148 /* LastToken */ + 1; + var mapRowLength = 149 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; @@ -112508,11 +114135,11 @@ var ts; // In order to insert a rule to the end of sub-bucket (3), we get the index by adding // the values in the bitmap segments 3rd, 2nd, and 1st. function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) { - var position = rule.action === 1 /* Ignore */ - ? specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny - : rule.context !== formatting.anyContext - ? specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny - : specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; + var position = rule.action === 1 /* Ignore */ ? + specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny : + rule.context !== formatting.anyContext ? + specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny : + specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; var state = constructionState[rulesBucketIndex] || 0; rules.splice(getInsertionIndex(state, position), 0, rule); constructionState[rulesBucketIndex] = increaseInsertionIndex(state, position); @@ -112660,17 +114287,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 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 246 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 285 /* SourceFile */: - case 219 /* Block */: - case 246 /* ModuleBlock */: + return !!body && body.kind === 247 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 286 /* SourceFile */: + case 220 /* Block */: + case 247 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -112895,19 +114522,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 241 /* ClassDeclaration */: return 77 /* ClassKeyword */; - case 242 /* InterfaceDeclaration */: return 111 /* InterfaceKeyword */; - case 240 /* FunctionDeclaration */: return 91 /* FunctionKeyword */; - case 244 /* EnumDeclaration */: return 244 /* EnumDeclaration */; - case 159 /* GetAccessor */: return 127 /* GetKeyword */; - case 160 /* SetAccessor */: return 138 /* SetKeyword */; - case 157 /* MethodDeclaration */: + case 242 /* ClassDeclaration */: return 77 /* ClassKeyword */; + case 243 /* InterfaceDeclaration */: return 111 /* InterfaceKeyword */; + case 241 /* FunctionDeclaration */: return 91 /* FunctionKeyword */; + case 245 /* EnumDeclaration */: return 245 /* EnumDeclaration */; + case 160 /* GetAccessor */: return 127 /* GetKeyword */; + case 161 /* SetAccessor */: return 138 /* SetKeyword */; + case 158 /* MethodDeclaration */: if (node.asteriskToken) { return 40 /* AsteriskToken */; } // falls through - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 153 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -112964,15 +114591,15 @@ var ts; case 42 /* SlashToken */: case 30 /* GreaterThanToken */: switch (container.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 265 /* JsxClosingElement */: + case 263 /* JsxSelfClosingElement */: return false; } break; case 22 /* OpenBracketToken */: case 23 /* CloseBracketToken */: - if (container.kind !== 182 /* MappedType */) { + if (container.kind !== 183 /* MappedType */) { return false; } break; @@ -113064,7 +114691,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 153 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 154 /* 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 */) { @@ -113072,7 +114699,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 188 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 189 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -113455,8 +115082,7 @@ var ts; /** * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. */ - function getRangeOfEnclosingComment(sourceFile, position, precedingToken, // tslint:disable-line:no-null-keyword - tokenAtPosition) { + function getRangeOfEnclosingComment(sourceFile, position, precedingToken, tokenAtPosition) { if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position); } var jsdoc = ts.findAncestor(tokenAtPosition, ts.isJSDoc); if (jsdoc) @@ -113465,6 +115091,7 @@ var ts; if (tokenStart <= position && position < tokenAtPosition.getEnd()) { return undefined; } + // eslint-disable-next-line no-null/no-null precedingToken = precedingToken === null ? undefined : precedingToken === undefined ? ts.findPrecedingToken(position, sourceFile) : precedingToken; // Between two consecutive tokens, all comments are either trailing on the former // or leading on the latter (and none are in both lists). @@ -113490,12 +115117,12 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 198 /* ArrowFunction */: + case 159 /* Constructor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 199 /* ArrowFunction */: if (node.typeParameters === list) { return 28 /* LessThanToken */; } @@ -113503,8 +115130,8 @@ var ts; return 20 /* OpenParenToken */; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: if (node.typeArguments === list) { return 28 /* LessThanToken */; } @@ -113512,12 +115139,12 @@ var ts; return 20 /* OpenParenToken */; } break; - case 165 /* TypeReference */: + case 166 /* TypeReference */: if (node.typeArguments === list) { return 28 /* LessThanToken */; } break; - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return 18 /* OpenBraceToken */; } return 0 /* Unknown */; @@ -113615,7 +115242,8 @@ var ts; return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); - var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); // tslint:disable-line:no-null-keyword + // eslint-disable-next-line no-null/no-null + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } @@ -113634,7 +115262,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 205 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 206 /* 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 */) { @@ -113788,7 +115416,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 === 285 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 286 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -113836,7 +115464,7 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 223 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 224 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 84 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -113871,40 +115499,40 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return getList(node.typeArguments); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return getList(node.properties); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return getList(node.elements); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return getList(node.members); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 159 /* Constructor */: + case 168 /* ConstructorType */: + case 163 /* ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 312 /* JSDocTemplateTag */: return getList(node.typeParameters); - case 193 /* NewExpression */: - case 192 /* CallExpression */: + case 194 /* NewExpression */: + case 193 /* CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return getList(node.declarations); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 254 /* NamedImports */: + case 258 /* NamedExports */: return getList(node.elements); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -113927,7 +115555,7 @@ var ts; return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 239 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 240 /* VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens return -1 /* Unknown */; } @@ -114000,83 +115628,87 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 222 /* ExpressionStatement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 188 /* ArrayLiteralExpression */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 182 /* MappedType */: - case 171 /* TupleType */: - case 247 /* CaseBlock */: - case 273 /* DefaultClause */: - case 272 /* CaseClause */: - case 196 /* ParenthesizedExpression */: - case 190 /* PropertyAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 220 /* VariableStatement */: - case 255 /* ExportAssignment */: - case 231 /* ReturnStatement */: - case 206 /* ConditionalExpression */: - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: - case 262 /* JsxSelfClosingElement */: - case 271 /* JsxExpression */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 152 /* Parameter */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 178 /* ParenthesizedType */: - case 194 /* TaggedTemplateExpression */: - case 202 /* AwaitExpression */: - case 257 /* NamedExports */: - case 253 /* NamedImports */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 155 /* PropertyDeclaration */: + case 223 /* ExpressionStatement */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 189 /* ArrayLiteralExpression */: + case 220 /* Block */: + case 247 /* ModuleBlock */: + case 190 /* ObjectLiteralExpression */: + case 170 /* TypeLiteral */: + case 183 /* MappedType */: + case 172 /* TupleType */: + case 248 /* CaseBlock */: + case 274 /* DefaultClause */: + case 273 /* CaseClause */: + case 197 /* ParenthesizedExpression */: + case 191 /* PropertyAccessExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 221 /* VariableStatement */: + case 256 /* ExportAssignment */: + case 232 /* ReturnStatement */: + case 207 /* ConditionalExpression */: + case 187 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 264 /* JsxOpeningElement */: + case 267 /* JsxOpeningFragment */: + case 263 /* JsxSelfClosingElement */: + case 272 /* JsxExpression */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 153 /* Parameter */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 179 /* ParenthesizedType */: + case 195 /* TaggedTemplateExpression */: + case 203 /* AwaitExpression */: + case 258 /* NamedExports */: + case 254 /* NamedImports */: + case 259 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 156 /* PropertyDeclaration */: return true; - case 238 /* VariableDeclaration */: - case 276 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 189 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 239 /* VariableDeclaration */: + case 277 /* PropertyAssignment */: + case 206 /* BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 190 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - return true; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return childKind !== 219 /* Block */; - case 256 /* ExportDeclaration */: - return childKind !== 257 /* NamedExports */; - case 250 /* ImportDeclaration */: - return childKind !== 251 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 253 /* NamedImports */); - case 261 /* JsxElement */: - return childKind !== 264 /* JsxClosingElement */; - case 265 /* JsxFragment */: - return childKind !== 267 /* JsxClosingFragment */; - case 175 /* IntersectionType */: - case 174 /* UnionType */: - if (childKind === 169 /* TypeLiteral */) { + if (parent.kind !== 206 /* BinaryExpression */) { + return true; + } + break; + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 227 /* ForStatement */: + case 224 /* IfStatement */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 199 /* ArrowFunction */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + return childKind !== 220 /* Block */; + case 257 /* ExportDeclaration */: + return childKind !== 258 /* NamedExports */; + case 251 /* ImportDeclaration */: + return childKind !== 252 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 254 /* NamedImports */); + case 262 /* JsxElement */: + return childKind !== 265 /* JsxClosingElement */; + case 266 /* JsxFragment */: + return childKind !== 268 /* JsxClosingFragment */; + case 176 /* IntersectionType */: + case 175 /* UnionType */: + if (childKind === 170 /* TypeLiteral */) { return false; } // falls through @@ -114087,11 +115719,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: - return parent.kind !== 219 /* Block */; + case 232 /* ReturnStatement */: + case 236 /* ThrowStatement */: + case 230 /* ContinueStatement */: + case 231 /* BreakStatement */: + return parent.kind !== 220 /* Block */; default: return false; } @@ -114233,7 +115865,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 === 189 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 190 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -114398,7 +116030,7 @@ var ts; } } else { - endNode = node.kind !== 238 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 239 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; @@ -114430,7 +116062,7 @@ var ts; ChangeTracker.prototype.insertNodeAtConstructorStart = function (sourceFile, ctr, newStatement) { var firstStatement = ts.firstOrUndefined(ctr.body.statements); if (!firstStatement || !ctr.body.multiLine) { - this.replaceConstructorBody(sourceFile, ctr, [newStatement].concat(ctr.body.statements)); + this.replaceConstructorBody(sourceFile, ctr, __spreadArrays([newStatement], ctr.body.statements)); } else { this.insertNodeBefore(sourceFile, firstStatement, newStatement); @@ -114439,7 +116071,7 @@ var ts; ChangeTracker.prototype.insertNodeAtConstructorEnd = function (sourceFile, ctr, newStatement) { var lastStatement = ts.lastOrUndefined(ctr.body.statements); if (!lastStatement || !ctr.body.multiLine) { - this.replaceConstructorBody(sourceFile, ctr, ctr.body.statements.concat([newStatement])); + this.replaceConstructorBody(sourceFile, ctr, __spreadArrays(ctr.body.statements, [newStatement])); } else { this.insertNodeAfter(sourceFile, lastStatement, newStatement); @@ -114472,7 +116104,7 @@ var ts; if (getMembersOrProperties(cls).length === 0) { if (ts.addToSeen(this.classesWithNodesInsertedAtStart, ts.getNodeId(cls), { node: cls, sourceFile: sourceFile })) { // For `class C {\n}`, don't add the trailing "\n" - var shouldSuffix = ts.positionsAreOnSameLine.apply(void 0, getClassOrObjectBraceEnds(cls, sourceFile).concat([sourceFile])); // TODO: GH#4130 remove 'as any' + var shouldSuffix = ts.positionsAreOnSameLine.apply(void 0, __spreadArrays(getClassOrObjectBraceEnds(cls, sourceFile), [sourceFile])); // TODO: GH#4130 remove 'as any' return { prefix: this.newLineCharacter, suffix: comma + (shouldSuffix ? this.newLineCharacter : "") }; } else { @@ -114511,22 +116143,22 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptions = function (sourceFile, after) { var options = this.getInsertNodeAfterOptionsWorker(after); - return __assign({}, options, { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); + return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 246 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: case 10 /* StringLiteral */: case 73 /* Identifier */: return { prefix: ", " }; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; case 86 /* ExportKeyword */: return { prefix: " " }; - case 152 /* Parameter */: + case 153 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -114535,7 +116167,7 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 198 /* ArrowFunction */) { + if (node.kind === 199 /* ArrowFunction */) { var arrow = ts.findChildOfKind(node, 37 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { @@ -114549,14 +116181,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 219 /* Block */) { + if (node.body.kind !== 220 /* Block */) { // `() => 0` => `function f() { return 0; }` this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(98 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(26 /* SemicolonToken */), ts.createToken(19 /* CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 197 /* FunctionExpression */ ? 91 /* FunctionKeyword */ : 77 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 198 /* FunctionExpression */ ? 91 /* FunctionKeyword */ : 77 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -114829,7 +116461,7 @@ var ts; var omitTrailingSemicolon = !!sourceFile && !ts.probablyUsesSemicolons(sourceFile); var writer = createWriter(newLineCharacter, omitTrailingSemicolon); var newLine = newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; - ts.createPrinter({ newLine: newLine, neverAsciiEscape: true, omitTrailingSemicolon: omitTrailingSemicolon }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + ts.createPrinter({ newLine: newLine, neverAsciiEscape: true }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -115081,14 +116713,14 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 150 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 151 /* 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 152 /* Parameter */: { + case 153 /* Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && @@ -115103,14 +116735,14 @@ var ts; } break; } - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: deleteNode(changes, sourceFile, node, // For first import, leave header comment in place node === sourceFile.imports[0].parent ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined); break; - case 187 /* BindingElement */: + case 188 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 186 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 187 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -115118,13 +116750,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -115133,7 +116765,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; default: @@ -115180,13 +116812,13 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 250 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 251 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 275 /* CatchClause */) { + if (parent.kind === 276 /* 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; @@ -115197,14 +116829,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 228 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); break; - case 226 /* ForStatement */: + case 227 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: deleteNode(changes, sourceFile, gp); break; default: @@ -115365,7 +116997,7 @@ var ts; }); function makeChange(changeTracker, sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); })); + var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); }), "Expected to find an assertion expression"); var replacement = ts.isAsExpression(assertion) ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(144 /* UnknownKeyword */)) : ts.createTypeAssertion(ts.createKeywordTypeNode(144 /* UnknownKeyword */), assertion.expression); @@ -115384,7 +117016,7 @@ var ts; ts.Diagnostics.This_expression_is_not_callable.code, ts.Diagnostics.This_expression_is_not_constructable.code, ]; - var errorCodes = [ + var errorCodes = __spreadArrays([ ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type.code, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type.code, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type.code, @@ -115400,13 +117032,13 @@ var ts; ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator.code, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code, propertyAccessCode - ].concat(callableConstructableErrorCodes); + ], callableConstructableErrorCodes); codefix.registerCodeFix({ fixIds: [fixId], errorCodes: errorCodes, getCodeActions: function (context) { var sourceFile = context.sourceFile, errorCode = context.errorCode, span = context.span, cancellationToken = context.cancellationToken, program = context.program; - var expression = getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program); if (!expression) { return; } @@ -115420,27 +117052,38 @@ var ts; getAllCodeActions: function (context) { var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; var checker = context.program.getTypeChecker(); + var fixedDeclarations = ts.createMap(); return codefix.codeFixAll(context, errorCodes, function (t, diagnostic) { - var expression = getAwaitableExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); if (!expression) { return; } var trackChanges = function (cb) { return (cb(t), []); }; - return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges) - || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges); + return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations) + || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations); }); }, }); - function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges) { - var sourceFile = context.sourceFile; - var awaitableInitializer = findAwaitableInitializer(expression, sourceFile, checker); - if (awaitableInitializer) { - var initializerChanges = trackChanges(function (t) { return makeChange(t, errorCode, sourceFile, checker, awaitableInitializer); }); - return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, [ts.Diagnostics.Add_await_to_initializer_for_0, expression.getText(sourceFile)]); + function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; + var awaitableInitializers = findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker); + if (awaitableInitializers) { + var initializerChanges = trackChanges(function (t) { + ts.forEach(awaitableInitializers.initializers, function (_a) { + var expression = _a.expression; + return makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + }); + if (fixedDeclarations && awaitableInitializers.needsSecondPassForFixAll) { + makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + } + }); + return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, awaitableInitializers.initializers.length === 1 + ? [ts.Diagnostics.Add_await_to_initializer_for_0, awaitableInitializers.initializers[0].declarationSymbol.name] + : ts.Diagnostics.Add_await_to_initializers); } } - function getUseSiteFix(context, expression, errorCode, checker, trackChanges) { - var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression); }); + function getUseSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression, fixedDeclarations); }); return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_await, fixId, ts.Diagnostics.Fix_all_expressions_possibly_missing_await); } function isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) { @@ -115454,7 +117097,7 @@ var ts; ts.some(relatedInformation, function (related) { return related.code === ts.Diagnostics.Did_you_forget_to_use_await.code; }); }); } - function getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program) { + function getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program) { var token = ts.getTokenAtPosition(sourceFile, span.start); // Checker has already done work to determine that await might be possible, and has attached // related info to the node, so start by finding the expression that exactly matches up @@ -115467,64 +117110,146 @@ var ts; }); return expression && isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) - && isInsideAwaitableBody(expression) - ? expression - : undefined; + && isInsideAwaitableBody(expression) ? expression : undefined; } - function findAwaitableInitializer(expression, sourceFile, checker) { - if (!ts.isIdentifier(expression)) { + function findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker) { + var identifiers = getIdentifiersFromErrorSpanExpression(expression, checker); + if (!identifiers) { return; } - var symbol = checker.getSymbolAtLocation(expression); - if (!symbol) { - return; + var isCompleteFix = identifiers.isCompleteFix; + var initializers; + var _loop_11 = 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, 221 /* VariableStatement */); + if (!declaration || !variableStatement || + declaration.type || + !declaration.initializer || + variableStatement.getSourceFile() !== sourceFile || + ts.hasModifier(variableStatement, 1 /* Export */) || + !variableName || + !isInsideAwaitableBody(declaration.initializer)) { + isCompleteFix = false; + return "continue"; + } + var diagnostics = program.getSemanticDiagnostics(sourceFile, cancellationToken); + var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (reference) { + return identifier !== reference && !symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker); + }); + if (isUsedElsewhere) { + isCompleteFix = false; + return "continue"; + } + (initializers || (initializers = [])).push({ + expression: declaration.initializer, + declarationSymbol: symbol, + }); + }; + for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { + var identifier = _a[_i]; + _loop_11(identifier); } - var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); - var variableName = ts.tryCast(declaration && declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 220 /* VariableStatement */); - if (!declaration || !variableStatement || - declaration.type || - !declaration.initializer || - variableStatement.getSourceFile() !== sourceFile || - ts.hasModifier(variableStatement, 1 /* Export */) || - !variableName || - !isInsideAwaitableBody(declaration.initializer)) { - return; + return initializers && { + initializers: initializers, + needsSecondPassForFixAll: !isCompleteFix, + }; + } + function getIdentifiersFromErrorSpanExpression(expression, checker) { + if (ts.isPropertyAccessExpression(expression.parent) && ts.isIdentifier(expression.parent.expression)) { + return { identifiers: [expression.parent.expression], isCompleteFix: true }; + } + if (ts.isIdentifier(expression)) { + return { identifiers: [expression], isCompleteFix: true }; + } + if (ts.isBinaryExpression(expression)) { + var sides = void 0; + var isCompleteFix = true; + for (var _i = 0, _a = [expression.left, expression.right]; _i < _a.length; _i++) { + var side = _a[_i]; + var type = checker.getTypeAtLocation(side); + if (checker.getPromisedTypeOfPromise(type)) { + if (!ts.isIdentifier(side)) { + isCompleteFix = false; + continue; + } + (sides || (sides = [])).push(side); + } + } + return sides && { identifiers: sides, isCompleteFix: isCompleteFix }; } - var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (identifier) { - return identifier !== expression; + } + function symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker) { + var errorNode = ts.isPropertyAccessExpression(reference.parent) ? reference.parent.name : + ts.isBinaryExpression(reference.parent) ? reference.parent : + reference; + var diagnostic = ts.find(diagnostics, function (diagnostic) { + return diagnostic.start === errorNode.getStart(sourceFile) && + diagnostic.start + diagnostic.length === errorNode.getEnd(); }); - if (isUsedElsewhere) { - return; - } - return declaration.initializer; + return diagnostic && ts.contains(errorCodes, diagnostic.code) || + // A Promise is usually not correct in a binary expression (it’s not valid + // in an arithmetic expression and an equality comparison seems unusual), + // but if the other side of the binary expression has an error, the side + // is typed `any` which will squash the error that would identify this + // Promise as an invalid operand. So if the whole binary expression is + // typed `any` as a result, there is a strong likelihood that this Promise + // is accidentally missing `await`. + checker.getTypeAtLocation(errorNode).flags & 1 /* Any */; } function isInsideAwaitableBody(node) { return node.kind & 16384 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 240 /* FunctionDeclaration */ || - ancestor.parent.kind === 197 /* FunctionExpression */ || - ancestor.parent.kind === 198 /* ArrowFunction */ || - ancestor.parent.kind === 157 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 241 /* FunctionDeclaration */ || + ancestor.parent.kind === 198 /* FunctionExpression */ || + ancestor.parent.kind === 199 /* ArrowFunction */ || + ancestor.parent.kind === 158 /* MethodDeclaration */); }); } - function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite) { + function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { if (ts.isBinaryExpression(insertionSite)) { - var left = insertionSite.left, right = insertionSite.right; - var leftType = checker.getTypeAtLocation(left); - var rightType = checker.getTypeAtLocation(right); - var newLeft = checker.getPromisedTypeOfPromise(leftType) ? ts.createAwait(left) : left; - var newRight = checker.getPromisedTypeOfPromise(rightType) ? ts.createAwait(right) : right; - changeTracker.replaceNode(sourceFile, left, newLeft); - changeTracker.replaceNode(sourceFile, right, newRight); + for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) { + var side = _a[_i]; + if (fixedDeclarations && ts.isIdentifier(side)) { + var symbol = checker.getSymbolAtLocation(side); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + continue; + } + } + var type = checker.getTypeAtLocation(side); + var newNode = checker.getPromisedTypeOfPromise(type) ? ts.createAwait(side) : side; + changeTracker.replaceNode(sourceFile, side, newNode); + } } else if (errorCode === propertyAccessCode && ts.isPropertyAccessExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite.parent.expression)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.expression); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite.parent.expression, ts.createParen(ts.createAwait(insertionSite.parent.expression))); } else if (ts.contains(callableConstructableErrorCodes, errorCode) && ts.isCallOrNewExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite)) { + var symbol = checker.getSymbolAtLocation(insertionSite); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createParen(ts.createAwait(insertionSite))); } else { + if (fixedDeclarations && ts.isVariableDeclaration(insertionSite.parent) && ts.isIdentifier(insertionSite.parent.name)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.name); + if (symbol && !ts.addToSeen(fixedDeclarations, ts.getSymbolId(symbol))) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createAwait(insertionSite)); } } @@ -115593,10 +117318,10 @@ var ts; function isPossiblyPartOfDestructuring(node) { switch (node.kind) { case 73 /* Identifier */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return true; default: return false; @@ -115611,7 +117336,7 @@ var ts; function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { case 73 /* Identifier */: - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: case 27 /* CommaToken */: return true; default: @@ -115752,33 +117477,33 @@ var ts; } } else { - var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl)); // If not defined, shouldn't have been an error to fix - ts.Debug.assert(!decl.type); // If defined, shouldn't have been an error to fix. + var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl), "A JSDocType for this declaration should exist"); // If not defined, shouldn't have been an error to fix + ts.Debug.assert(!decl.type, "The JSDocType decl should have a type"); // If defined, shouldn't have been an error to fix. changes.tryInsertTypeAnnotation(sourceFile, decl, transformJSDocType(jsdocType)); } } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 238 /* VariableDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 239 /* VariableDeclaration */ || + node.kind === 155 /* PropertySignature */ || + node.kind === 156 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 291 /* JSDocAllType */: + case 292 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 294 /* JSDocOptionalType */: + case 295 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 293 /* JSDocNonNullableType */: + case 294 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 292 /* JSDocNullableType */: + case 293 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 296 /* JSDocVariadicType */: + case 297 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); // TODO: GH#18217 @@ -115800,7 +117525,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 296 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 297 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); var dotdotdot = isRest ? ts.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -116032,13 +117757,8 @@ var ts; if (!ts.isIdentifier(parameterDeclaration.name)) { return; } - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - var parameterInferences = InferFromReference.inferTypeForParametersFromReferences(references, containingFunction, program, cancellationToken) || - containingFunction.parameters.map(function (p) { return ({ - declaration: p, - type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() - }); }); - ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length); + var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken); + ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length, "Parameter count and inference count should match"); if (ts.isInJSFile(containingFunction)) { annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } @@ -116057,14 +117777,11 @@ var ts; } } function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - if (!references) { - return; - } - var thisInference = InferFromReference.inferTypeForThisFromReferences(references, program, cancellationToken); - if (!thisInference) { + var references = getFunctionReferences(containingFunction, sourceFile, program, cancellationToken); + if (!references || !references.length) { return; } + var thisInference = inferTypeFromReferences(program, references, cancellationToken).thisParameter(); var typeNode = ts.getTypeNodeIfAccessible(thisInference, containingFunction, program, host); if (!typeNode) { return; @@ -116099,7 +117816,7 @@ var ts; function annotate(changes, sourceFile, declaration, type, program, host) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 154 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 155 /* PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -116139,14 +117856,14 @@ var ts; oldTags[i] = merged; return !!merged; }); }); - var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray((oldTags || ts.emptyArray).concat(unmergedNewTags))); - var jsDocNode = parent.kind === 198 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; + var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray(__spreadArrays((oldTags || ts.emptyArray), unmergedNewTags))); + var jsDocNode = parent.kind === 199 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; jsDocNode.jsDoc = parent.jsDoc; jsDocNode.jsDocCache = parent.jsDocCache; changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag); } function getJsDocNodeForArrowFunction(signature) { - if (signature.parent.kind === 155 /* PropertyDeclaration */) { + if (signature.parent.kind === 156 /* PropertyDeclaration */) { return signature.parent; } return signature.parent.parent; @@ -116156,14 +117873,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 306 /* JSDocParameterTag */: { + case 308 /* JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.createJSDocParamTag(newParam.name, newParam.isBracketed, newParam.typeExpression, oldParam.comment) : undefined; } - case 307 /* JSDocReturnTag */: + case 309 /* JSDocReturnTag */: return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); } } @@ -116175,25 +117892,31 @@ var ts; } function inferTypeForVariableFromUsage(token, program, cancellationToken) { var references = getReferences(token, program, cancellationToken); - var checker = program.getTypeChecker(); - var types = InferFromReference.inferTypesFromReferences(references, checker, cancellationToken); - return InferFromReference.unifyFromContext(types, checker); + return inferTypeFromReferences(program, references, cancellationToken).single(); } - function inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken) { + function inferTypeForParametersFromUsage(func, sourceFile, program, cancellationToken) { + var references = getFunctionReferences(func, sourceFile, program, cancellationToken); + return references && inferTypeFromReferences(program, references, cancellationToken).parameters(func) || + func.parameters.map(function (p) { return ({ + declaration: p, + type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() + }); }); + } + function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: searchToken = ts.findChildOfKind(containingFunction, 125 /* ConstructorKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 198 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: searchToken = containingFunction.name; break; } @@ -116202,54 +117925,51 @@ var ts; } return getReferences(searchToken, program, cancellationToken); } - var InferFromReference; - (function (InferFromReference) { - function inferTypesFromReferences(references, checker, cancellationToken) { - var usageContext = {}; - for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { - var reference = references_2[_i]; - cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); - } - return inferFromContext(usageContext, checker); + function inferTypeFromReferences(program, references, cancellationToken) { + var checker = program.getTypeChecker(); + return { + single: single, + parameters: parameters, + thisParameter: thisParameter, + }; + function single() { + return unifyFromUsage(inferTypesFromReferencesSingle(references)); } - InferFromReference.inferTypesFromReferences = inferTypesFromReferences; - function inferTypeForParametersFromReferences(references, declaration, program, cancellationToken) { - if (references === undefined || references.length === 0 || !declaration.parameters) { + function parameters(declaration) { + if (references.length === 0 || !declaration.parameters) { return undefined; } - var checker = program.getTypeChecker(); - var usageContext = {}; - for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { - var reference = references_3[_i]; + var usage = {}; + for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { + var reference = references_2[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - var callContexts = (usageContext.constructContexts || []).concat(usageContext.callContexts || []); + var calls = __spreadArrays(usage.constructs || [], usage.calls || []); return declaration.parameters.map(function (parameter, parameterIndex) { var types = []; var isRest = ts.isRestParameter(parameter); var isOptional = false; - for (var _i = 0, callContexts_1 = callContexts; _i < callContexts_1.length; _i++) { - var callContext = callContexts_1[_i]; - if (callContext.argumentTypes.length <= parameterIndex) { + for (var _i = 0, calls_1 = calls; _i < calls_1.length; _i++) { + var call = calls_1[_i]; + if (call.argumentTypes.length <= parameterIndex) { isOptional = ts.isInJSFile(declaration); types.push(checker.getUndefinedType()); } else if (isRest) { - for (var i = parameterIndex; i < callContext.argumentTypes.length; i++) { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + for (var i = parameterIndex; i < call.argumentTypes.length; i++) { + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[i])); } } else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex])); } } if (ts.isIdentifier(parameter.name)) { - var inferred = inferTypesFromReferences(getReferences(parameter.name, program, cancellationToken), checker, cancellationToken); + var inferred = inferTypesFromReferencesSingle(getReferences(parameter.name, program, cancellationToken)); types.push.apply(types, (isRest ? ts.mapDefined(inferred, checker.getElementTypeOfArrayType) : inferred)); } - var type = unifyFromContext(types, checker); + var type = unifyFromUsage(types); return { type: isRest ? checker.createArrayType(type) : type, isOptional: isOptional && !isRest, @@ -116257,112 +117977,119 @@ var ts; }; }); } - InferFromReference.inferTypeForParametersFromReferences = inferTypeForParametersFromReferences; - function inferTypeForThisFromReferences(references, program, cancellationToken) { - if (references.length === 0) { - return undefined; + function thisParameter() { + var usage = {}; + for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { + var reference = references_3[_i]; + cancellationToken.throwIfCancellationRequested(); + calculateUsageOfNode(reference, usage); } - var checker = program.getTypeChecker(); - var usageContext = {}; + return unifyFromUsage(usage.candidateThisTypes || ts.emptyArray); + } + function inferTypesFromReferencesSingle(references) { + var usage = {}; for (var _i = 0, references_4 = references; _i < references_4.length; _i++) { var reference = references_4[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - return unifyFromContext(usageContext.candidateThisTypes || ts.emptyArray, checker); + return inferFromUsage(usage); } - InferFromReference.inferTypeForThisFromReferences = inferTypeForThisFromReferences; - function inferTypeFromContext(node, checker, usageContext) { + function calculateUsageOfNode(node, usage) { while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } switch (node.parent.kind) { - case 204 /* PostfixUnaryExpression */: - usageContext.isNumber = true; + case 205 /* PostfixUnaryExpression */: + usage.isNumber = true; break; - case 203 /* PrefixUnaryExpression */: - inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); + case 204 /* PrefixUnaryExpression */: + inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 205 /* BinaryExpression */: - inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); + case 206 /* BinaryExpression */: + inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); + case 273 /* CaseClause */: + case 274 /* DefaultClause */: + inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: if (node.parent.expression === node) { - inferTypeFromCallExpressionContext(node.parent, checker, usageContext); + inferTypeFromCallExpression(node.parent, usage); } else { - inferTypeFromContextualType(node, checker, usageContext); + inferTypeFromContextualType(node, usage); } break; - case 190 /* PropertyAccessExpression */: - inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); + case 191 /* PropertyAccessExpression */: + inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 191 /* ElementAccessExpression */: - inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); + case 192 /* ElementAccessExpression */: + inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - inferTypeFromPropertyAssignment(node.parent, checker, usageContext); + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: + inferTypeFromPropertyAssignment(node.parent, usage); break; - case 155 /* PropertyDeclaration */: - inferTypeFromPropertyDeclaration(node.parent, checker, usageContext); + case 156 /* PropertyDeclaration */: + inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 238 /* VariableDeclaration */: { + case 239 /* 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. - addCandidateType(usageContext, checker.getTypeAtLocation(initializer)); + addCandidateType(usage, checker.getTypeAtLocation(initializer)); } break; } } // falls through default: - return inferTypeFromContextualType(node, checker, usageContext); + return inferTypeFromContextualType(node, usage); } } - function inferTypeFromContextualType(node, checker, usageContext) { + function inferTypeFromContextualType(node, usage) { if (ts.isExpressionNode(node)) { - addCandidateType(usageContext, checker.getContextualType(node)); + addCandidateType(usage, checker.getContextualType(node)); } } - function inferTypeFromPrefixUnaryExpressionContext(node, usageContext) { + function inferTypeFromPrefixUnaryExpression(node, usage) { switch (node.operator) { case 44 /* PlusPlusToken */: case 45 /* MinusMinusToken */: case 39 /* MinusToken */: case 53 /* TildeToken */: - usageContext.isNumber = true; + usage.isNumber = true; break; case 38 /* PlusToken */: - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; break; // case SyntaxKind.ExclamationToken: // no inferences here; } } - function inferTypeFromBinaryExpressionContext(node, parent, checker, usageContext) { + function inferTypeFromBinaryExpression(node, parent, usage) { switch (parent.operatorToken.kind) { // ExponentiationOperator case 41 /* AsteriskAsteriskToken */: // MultiplicativeOperator + // falls through case 40 /* AsteriskToken */: case 42 /* SlashToken */: case 43 /* PercentToken */: // ShiftOperator + // falls through case 46 /* LessThanLessThanToken */: case 47 /* GreaterThanGreaterThanToken */: case 48 /* GreaterThanGreaterThanGreaterThanToken */: // BitwiseOperator + // falls through case 49 /* AmpersandToken */: case 50 /* BarToken */: case 51 /* CaretToken */: // CompoundAssignmentOperator + // falls through case 62 /* MinusEqualsToken */: case 64 /* AsteriskAsteriskEqualsToken */: case 63 /* AsteriskEqualsToken */: @@ -116375,34 +118102,36 @@ var ts; case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: case 68 /* GreaterThanGreaterThanEqualsToken */: // AdditiveOperator + // falls through case 39 /* MinusToken */: // RelationalOperator + // falls through case 28 /* LessThanToken */: case 31 /* LessThanEqualsToken */: case 30 /* GreaterThanToken */: case 32 /* GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (operandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, operandType); + addCandidateType(usage, operandType); } else { - usageContext.isNumber = true; + usage.isNumber = true; } break; case 61 /* PlusEqualsToken */: case 38 /* PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (otherOperandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, otherOperandType); + addCandidateType(usage, otherOperandType); } else if (otherOperandType.flags & 296 /* NumberLike */) { - usageContext.isNumber = true; + usage.isNumber = true; } else if (otherOperandType.flags & 132 /* StringLike */) { - usageContext.isString = true; + usage.isString = true; } else { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; } break; // AssignmentOperators @@ -116411,20 +118140,20 @@ var ts; case 35 /* EqualsEqualsEqualsToken */: case 36 /* ExclamationEqualsEqualsToken */: case 34 /* ExclamationEqualsToken */: - addCandidateType(usageContext, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); + addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; case 94 /* InKeyword */: if (node === parent.left) { - usageContext.isString = true; + usage.isString = true; } break; // LogicalOperator case 55 /* BarBarToken */: if (node === parent.left && - (node.parent.parent.kind === 238 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 239 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType - addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); + addCandidateType(usage, checker.getTypeAtLocation(parent.right)); } break; case 54 /* AmpersandAmpersandToken */: @@ -116434,65 +118163,62 @@ var ts; break; } } - function inferTypeFromSwitchStatementLabelContext(parent, checker, usageContext) { - addCandidateType(usageContext, checker.getTypeAtLocation(parent.parent.parent.expression)); + function inferTypeFromSwitchStatementLabel(parent, usage) { + addCandidateType(usage, checker.getTypeAtLocation(parent.parent.parent.expression)); } - function inferTypeFromCallExpressionContext(parent, checker, usageContext) { - var callContext = { + function inferTypeFromCallExpression(parent, usage) { + var call = { argumentTypes: [], returnType: {} }; if (parent.arguments) { for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { var argument = _a[_i]; - callContext.argumentTypes.push(checker.getTypeAtLocation(argument)); + call.argumentTypes.push(checker.getTypeAtLocation(argument)); } } - inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 192 /* CallExpression */) { - (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); + calculateUsageOfNode(parent, call.returnType); + if (parent.kind === 193 /* CallExpression */) { + (usage.calls || (usage.calls = [])).push(call); } else { - (usageContext.constructContexts || (usageContext.constructContexts = [])).push(callContext); + (usage.constructs || (usage.constructs = [])).push(call); } } - function inferTypeFromPropertyAccessExpressionContext(parent, checker, usageContext) { + function inferTypeFromPropertyAccessExpression(parent, usage) { var name = ts.escapeLeadingUnderscores(parent.name.text); - if (!usageContext.properties) { - usageContext.properties = ts.createUnderscoreEscapedMap(); + if (!usage.properties) { + usage.properties = ts.createUnderscoreEscapedMap(); } - var propertyUsageContext = usageContext.properties.get(name) || {}; - inferTypeFromContext(parent, checker, propertyUsageContext); - usageContext.properties.set(name, propertyUsageContext); + var propertyUsage = usage.properties.get(name) || {}; + calculateUsageOfNode(parent, propertyUsage); + usage.properties.set(name, propertyUsage); } - function inferTypeFromPropertyElementExpressionContext(parent, node, checker, usageContext) { + function inferTypeFromPropertyElementExpression(parent, node, usage) { if (node === parent.argumentExpression) { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; return; } else { var indexType = checker.getTypeAtLocation(parent.argumentExpression); - var indexUsageContext = {}; - inferTypeFromContext(parent, checker, indexUsageContext); + var indexUsage = {}; + calculateUsageOfNode(parent, indexUsage); if (indexType.flags & 296 /* NumberLike */) { - usageContext.numberIndexContext = indexUsageContext; + usage.numberIndex = indexUsage; } else { - usageContext.stringIndexContext = indexUsageContext; + usage.stringIndex = indexUsage; } } } - function inferTypeFromPropertyAssignment(assignment, checker, usageContext) { - var objectLiteral = ts.isShorthandPropertyAssignment(assignment) ? - assignment.parent : - assignment.parent.parent; - var nodeWithRealType = ts.isVariableDeclaration(objectLiteral.parent) ? - objectLiteral.parent : - objectLiteral; - addCandidateThisType(usageContext, checker.getTypeAtLocation(nodeWithRealType)); + function inferTypeFromPropertyAssignment(assignment, usage) { + var nodeWithRealType = ts.isVariableDeclaration(assignment.parent.parent) ? + assignment.parent.parent : + assignment.parent; + addCandidateThisType(usage, checker.getTypeAtLocation(nodeWithRealType)); } - function inferTypeFromPropertyDeclaration(declaration, checker, usageContext) { - addCandidateThisType(usageContext, checker.getTypeAtLocation(declaration.parent)); + function inferTypeFromPropertyDeclaration(declaration, usage) { + addCandidateThisType(usage, checker.getTypeAtLocation(declaration.parent)); } function removeLowPriorityInferences(inferences, priorities) { var toRemove = []; @@ -116501,14 +118227,14 @@ var ts; for (var _a = 0, priorities_1 = priorities; _a < priorities_1.length; _a++) { var _b = priorities_1[_a], high = _b.high, low = _b.low; if (high(i)) { - ts.Debug.assert(!low(i)); + ts.Debug.assert(!low(i), "Priority can't have both low and high"); toRemove.push(low); } } } return inferences.filter(function (i) { return toRemove.every(function (f) { return !f(i); }); }); } - function unifyFromContext(inferences, checker, fallback) { + function unifyFromUsage(inferences, fallback) { if (fallback === void 0) { fallback = checker.getAnyType(); } if (!inferences.length) return fallback; @@ -116534,12 +118260,11 @@ var ts; var anons = good.filter(function (i) { return checker.getObjectFlags(i) & 16 /* Anonymous */; }); if (anons.length) { good = good.filter(function (i) { return !(checker.getObjectFlags(i) & 16 /* Anonymous */); }); - good.push(unifyAnonymousTypes(anons, checker)); + good.push(unifyAnonymousTypes(anons)); } return checker.getWidenedType(checker.getUnionType(good)); } - InferFromReference.unifyFromContext = unifyFromContext; - function unifyAnonymousTypes(anons, checker) { + function unifyAnonymousTypes(anons) { if (anons.length === 1) { return anons[0]; } @@ -116575,74 +118300,74 @@ var ts; }); return checker.createAnonymousType(anons[0].symbol, members, calls, constructs, stringIndices.length ? checker.createIndexInfo(checker.getUnionType(stringIndices), stringIndexReadonly) : undefined, numberIndices.length ? checker.createIndexInfo(checker.getUnionType(numberIndices), numberIndexReadonly) : undefined); } - function inferFromContext(usageContext, checker) { + function inferFromUsage(usage) { var types = []; - if (usageContext.isNumber) { + if (usage.isNumber) { types.push(checker.getNumberType()); } - if (usageContext.isString) { + if (usage.isString) { types.push(checker.getStringType()); } - if (usageContext.isNumberOrString) { + if (usage.isNumberOrString) { types.push(checker.getUnionType([checker.getStringType(), checker.getNumberType()])); } - types.push.apply(types, (usageContext.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); - if (usageContext.properties && hasCallContext(usageContext.properties.get("then"))) { - var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); // TODO: GH#18217 - var types_1 = paramType.getCallSignatures().map(function (c) { return c.getReturnType(); }); + types.push.apply(types, (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); + if (usage.properties && hasCalls(usage.properties.get("then"))) { + var paramType = getParameterTypeFromCalls(0, usage.properties.get("then").calls, /*isRestParameter*/ false); // TODO: GH#18217 + var types_1 = paramType.getCallSignatures().map(function (sig) { return sig.getReturnType(); }); types_1.push(checker.createPromiseType(types_1.length ? checker.getUnionType(types_1, 2 /* Subtype */) : checker.getAnyType())); } - else if (usageContext.properties && hasCallContext(usageContext.properties.get("push"))) { - types.push(checker.createArrayType(getParameterTypeFromCallContexts(0, usageContext.properties.get("push").callContexts, /*isRestParameter*/ false, checker))); + else if (usage.properties && hasCalls(usage.properties.get("push"))) { + types.push(checker.createArrayType(getParameterTypeFromCalls(0, usage.properties.get("push").calls, /*isRestParameter*/ false))); } - if (usageContext.numberIndexContext) { - types.push(checker.createArrayType(recur(usageContext.numberIndexContext))); + if (usage.numberIndex) { + types.push(checker.createArrayType(recur(usage.numberIndex))); } - else if (usageContext.properties || usageContext.callContexts || usageContext.constructContexts || usageContext.stringIndexContext) { + else if (usage.properties || usage.calls || usage.constructs || usage.stringIndex) { var members_1 = ts.createUnderscoreEscapedMap(); var callSignatures = []; var constructSignatures = []; var stringIndexInfo = void 0; - if (usageContext.properties) { - usageContext.properties.forEach(function (context, name) { + if (usage.properties) { + usage.properties.forEach(function (u, name) { var symbol = checker.createSymbol(4 /* Property */, name); - symbol.type = recur(context); + symbol.type = recur(u); members_1.set(name, symbol); }); } - if (usageContext.callContexts) { - for (var _i = 0, _a = usageContext.callContexts; _i < _a.length; _i++) { - var callContext = _a[_i]; - callSignatures.push(getSignatureFromCallContext(callContext, checker)); + if (usage.calls) { + for (var _i = 0, _a = usage.calls; _i < _a.length; _i++) { + var call = _a[_i]; + callSignatures.push(getSignatureFromCall(call)); } } - if (usageContext.constructContexts) { - for (var _b = 0, _c = usageContext.constructContexts; _b < _c.length; _b++) { - var constructContext = _c[_b]; - constructSignatures.push(getSignatureFromCallContext(constructContext, checker)); + if (usage.constructs) { + for (var _b = 0, _c = usage.constructs; _b < _c.length; _b++) { + var construct = _c[_b]; + constructSignatures.push(getSignatureFromCall(construct)); } } - if (usageContext.stringIndexContext) { - stringIndexInfo = checker.createIndexInfo(recur(usageContext.stringIndexContext), /*isReadonly*/ false); + if (usage.stringIndex) { + stringIndexInfo = checker.createIndexInfo(recur(usage.stringIndex), /*isReadonly*/ false); } types.push(checker.createAnonymousType(/*symbol*/ undefined, members_1, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined)); // TODO: GH#18217 } return types; - function recur(innerContext) { - return unifyFromContext(inferFromContext(innerContext, checker), checker); + function recur(innerUsage) { + return unifyFromUsage(inferFromUsage(innerUsage)); } } - function getParameterTypeFromCallContexts(parameterIndex, callContexts, isRestParameter, checker) { + function getParameterTypeFromCalls(parameterIndex, calls, isRestParameter) { var types = []; - if (callContexts) { - for (var _i = 0, callContexts_2 = callContexts; _i < callContexts_2.length; _i++) { - var callContext = callContexts_2[_i]; - if (callContext.argumentTypes.length > parameterIndex) { + if (calls) { + for (var _i = 0, calls_2 = calls; _i < calls_2.length; _i++) { + var call = calls_2[_i]; + if (call.argumentTypes.length > parameterIndex) { if (isRestParameter) { - types = ts.concatenate(types, ts.map(callContext.argumentTypes.slice(parameterIndex), function (a) { return checker.getBaseTypeOfLiteralType(a); })); + types = ts.concatenate(types, ts.map(call.argumentTypes.slice(parameterIndex), function (a) { return checker.getBaseTypeOfLiteralType(a); })); } else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex])); } } } @@ -116653,31 +118378,31 @@ var ts; } return undefined; } - function getSignatureFromCallContext(callContext, checker) { + function getSignatureFromCall(call) { var parameters = []; - for (var i = 0; i < callContext.argumentTypes.length; i++) { + for (var i = 0; i < call.argumentTypes.length; i++) { var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); - symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(call.argumentTypes[i])); parameters.push(symbol); } - var returnType = unifyFromContext(inferFromContext(callContext.returnType, checker), checker, checker.getVoidType()); + var returnType = unifyFromUsage(inferFromUsage(call.returnType), checker.getVoidType()); // TODO: GH#18217 - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, call.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); } - function addCandidateType(context, type) { + function addCandidateType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateTypes || (context.candidateTypes = [])).push(type); + (usage.candidateTypes || (usage.candidateTypes = [])).push(type); } } - function addCandidateThisType(context, type) { + function addCandidateThisType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateThisTypes || (context.candidateThisTypes = [])).push(type); + (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); } } - function hasCallContext(usageContext) { - return !!usageContext && !!usageContext.callContexts; + function hasCalls(usage) { + return !!usage && !!usage.calls; } - })(InferFromReference || (InferFromReference = {})); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -116706,12 +118431,12 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: precedingNode = ctorDeclaration; changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { @@ -116766,7 +118491,7 @@ var ts; return; } // 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 === 222 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 223 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { @@ -116774,7 +118499,7 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 197 /* FunctionExpression */: { + case 198 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 122 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, @@ -116782,12 +118507,12 @@ var ts; ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 198 /* ArrowFunction */: { + case 199 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 219 /* Block */) { + if (arrowFunctionBody.kind === 220 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] @@ -116815,7 +118540,7 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 197 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 198 /* FunctionExpression */) { return undefined; } if (node.name.kind !== 73 /* Identifier */) { @@ -116904,7 +118629,7 @@ var ts; var newNodes = transformExpression(node, transformer, node); changes.replaceNodeWithNodes(sourceFile, nodeToReplace, newNodes); } - var _loop_11 = function (statement) { + var _loop_12 = function (statement) { ts.forEachChild(statement, function visit(node) { if (ts.isCallExpression(node)) { startTransformation(node, statement); @@ -116916,7 +118641,7 @@ var ts; }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var statement = returnStatements_1[_i]; - _loop_11(statement); + _loop_12(statement); } } function getReturnStatementsWithPromiseHandlers(body) { @@ -117235,8 +118960,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: { var funcBody = func.body; // Arrow functions with block bodies { } will enter this control flow if (ts.isBlock(funcBody)) { @@ -117348,6 +119073,7 @@ var ts; name = getMapEntryOrDefault(funcNode); } // return undefined argName when arg is null or undefined + // eslint-disable-next-line no-in-operator if (!name || "identifier" in name && name.identifier.text === "undefined") { return undefined; } @@ -117439,10 +119165,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -117468,7 +119194,7 @@ var ts; forEachExportReference(sourceFile, function (node) { var _a = node.name, text = _a.text, originalKeywordKind = _a.originalKeywordKind; if (!res.has(text) && (originalKeywordKind !== undefined && ts.isNonContextualKeyword(originalKeywordKind) - || checker.resolveName(node.name.text, node, 67220415 /* Value */, /*excludeGlobals*/ true))) { + || checker.resolveName(node.name.text, node, 111551 /* Value */, /*excludeGlobals*/ true))) { // Unconditionally add an underscore in case `text` is a keyword. res.set(text, makeUniqueName("_" + text, identifiers)); } @@ -117495,20 +119221,20 @@ var ts; } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 222 /* ExpressionStatement */: { + case 223 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 192 /* CallExpression */: { + case 193 /* 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 205 /* BinaryExpression */: { + case 206 /* BinaryExpression */: { var operatorToken = expression.operatorToken; return operatorToken.kind === 60 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } @@ -117550,8 +119276,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: { + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -117563,7 +119289,7 @@ var ts; // `const a = require("b").c` --> `import { c as a } from "./b"; return [makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]; default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid syntax form " + name.kind); } } function convertAssignment(sourceFile, checker, assignment, changes, exports) { @@ -117602,18 +119328,19 @@ var ts; function tryChangeModuleExportsObject(object) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 277 /* ShorthandPropertyAssignment */: - case 278 /* SpreadAssignment */: + // falls through + case 278 /* ShorthandPropertyAssignment */: + case 279 /* SpreadAssignment */: return undefined; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(86 /* ExportKeyword */)], prop); default: - ts.Debug.assertNever(prop); + ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); } }); return statements && [statements, false]; @@ -117642,12 +119369,10 @@ var ts; var moduleSpecifier = reExported.text; var moduleSymbol = checker.getSymbolAtLocation(reExported); var exports = moduleSymbol ? moduleSymbol.exports : ts.emptyUnderscoreEscapedMap; - return exports.has("export=") - ? [[reExportDefault(moduleSpecifier)], true] - : !exports.has("default") - ? [[reExportStar(moduleSpecifier)], false] + return exports.has("export=") ? [[reExportDefault(moduleSpecifier)], true] : + !exports.has("default") ? [[reExportStar(moduleSpecifier)], false] : // If there's some non-default export, must include both `export *` and `export default`. - : exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; + exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; } function reExportStar(moduleSpecifier) { return makeExportDeclaration(/*exportClause*/ undefined, moduleSpecifier); @@ -117676,7 +119401,7 @@ var ts; function convertExportsDotXEquals_replaceNode(name, exported) { var modifiers = [ts.createToken(86 /* ExportKeyword */)]; switch (exported.kind) { - case 197 /* FunctionExpression */: { + case 198 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -117684,10 +119409,10 @@ var ts; } } // falls through - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -117705,18 +119430,20 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: { + case 186 /* 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 + // (TODO: GH#18217) + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion : makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text); - }); // tslint:disable-line no-unnecessary-type-assertion (TODO: GH#18217) + }); if (importSpecifiers) { return [ts.makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, quotePreference)]; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 186 /* ArrayBindingPattern */: { + case 187 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -117730,7 +119457,7 @@ var ts; case 73 /* Identifier */: return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, quotePreference); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid name kind " + name.kind); } } /** @@ -117752,7 +119479,7 @@ var ts; var parent = use.parent; if (ts.isPropertyAccessExpression(parent)) { var expression = parent.expression, propertyName = parent.name.text; - ts.Debug.assert(expression === use); // Else shouldn't have been in `collectIdentifiers` + 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); @@ -117799,11 +119526,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return parent.name !== node; - case 187 /* BindingElement */: + case 188 /* BindingElement */: return parent.propertyName !== node; - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -117878,8 +119605,10 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var errorCodes = [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, - ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code]; + var errorCodes = [ + ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, + ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code + ]; var fixId = "fixClassIncorrectlyImplementsInterface"; // TODO: share a group with fixClassDoesntImplementInheritedAbstractMember? codefix.registerCodeFix({ errorCodes: errorCodes, @@ -117906,7 +119635,7 @@ var ts; }, }); function getClass(sourceFile, pos) { - return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos))); + return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); @@ -118004,7 +119733,7 @@ var ts; ts.pushIfUnique(entry.namedImports, symbolName); } else { - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add to Existing) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; } break; @@ -118017,7 +119746,7 @@ var ts; } switch (importKind) { case 1 /* Default */: - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add new) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; break; case 0 /* Named */: @@ -118025,14 +119754,14 @@ var ts; break; case 3 /* Equals */: case 2 /* Namespace */: - ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName); + ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); entry.namespaceLikeImport = { importKind: importKind, name: symbolName }; break; } break; } default: - ts.Debug.assertNever(fix); + ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); } }); return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { @@ -118069,10 +119798,11 @@ var ts; ImportKind[ImportKind["Default"] = 1] = "Default"; ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; ImportKind[ImportKind["Equals"] = 3] = "Equals"; + ImportKind[ImportKind["ConstEquals"] = 4] = "ConstEquals"; })(ImportKind || (ImportKind = {})); function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) { - var exportInfos = getAllReExportingModules(exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles()); - ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; })); + var exportInfos = getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles()); + 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 for completions. var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, position, exportInfos, host, preferences)).moduleSpecifier; var fix = ts.first(getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences)); @@ -118083,14 +119813,14 @@ var ts; var description = _a.description, changes = _a.changes, commands = _a.commands; return { description: description, changes: changes, commands: commands }; } - function getAllReExportingModules(exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, compilerOptions, checker, allSourceFiles) { + function getAllReExportingModules(importingFile, exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, compilerOptions, checker, allSourceFiles) { var result = []; forEachExternalModule(checker, allSourceFiles, function (moduleSymbol, moduleFile) { // Don't import from a re-export when looking "up" like to `./index` or `../index`. if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(sourceFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) { return; } - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + var defaultInfo = getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions); if (defaultInfo && defaultInfo.name === symbolName && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol) { result.push({ moduleSymbol: moduleSymbol, importKind: defaultInfo.kind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker) }); } @@ -118104,7 +119834,7 @@ var ts; return result; } function isTypeOnlySymbol(s, checker) { - return !(ts.skipAlias(s, checker).flags & 67220415 /* Value */); + return !(ts.skipAlias(s, checker).flags & 111551 /* Value */); } function getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences) { var checker = program.getTypeChecker(); @@ -118113,7 +119843,7 @@ var ts; var addToExisting = tryAddToExistingImport(existingImports); // Don't bother providing an action to add a new import if we can add to an existing one. var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences); - return (useNamespace ? [useNamespace] : ts.emptyArray).concat(addImport); + return __spreadArrays((useNamespace ? [useNamespace] : ts.emptyArray), addImport); } function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) { // It is possible that multiple import statements with the same specifier exist in the file. @@ -118142,21 +119872,21 @@ var ts; function tryAddToExistingImport(existingImports) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind !== 250 /* ImportDeclaration */) + if (declaration.kind !== 251 /* ImportDeclaration */) return undefined; var importClause = declaration.importClause; if (!importClause) return undefined; var name = importClause.name, namedBindings = importClause.namedBindings; - return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 253 /* NamedImports */) + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 254 /* NamedImports */) ? { kind: 2 /* AddToExisting */, importClause: importClause, importKind: importKind } : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 250 /* ImportDeclaration */) { + if (declaration.kind === 251 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 252 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 253 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -118167,7 +119897,7 @@ var ts; // Can't use an es6 import for a type in JS. return exportedSymbolIsTypeOnly && ts.isSourceFileJS(sourceFile) ? ts.emptyArray : ts.mapDefined(sourceFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 250 /* ImportDeclaration */ || i.kind === 249 /* ImportEqualsDeclaration */) + return (i.kind === 251 /* ImportDeclaration */ || i.kind === 250 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } @@ -118178,7 +119908,7 @@ var ts; return ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences, program.redirectTargetsMap) .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.assertDefined(position) } : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; + return exportedSymbolIsTypeOnly && isJs ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position, "position should be defined") } : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; }); }); // Sort to keep the shortest paths first @@ -118190,9 +119920,9 @@ var ts; } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 250 /* ImportDeclaration */ + var expression = declaration.kind === 251 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 260 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 261 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; return expression && ts.isStringLiteral(expression) ? { kind: 3 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; @@ -118202,7 +119932,7 @@ 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) : undefined; - return info && __assign({}, info, { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); + return info && __assign(__assign({}, info), { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); } function getFixesInfoForUMDImport(_a, token) { var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences; @@ -118212,7 +119942,7 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; + var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(sourceFile, program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; var fixes = getFixForImport(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, program, sourceFile, host, preferences); return { fixes: fixes, symbolName: symbolName }; } @@ -118224,10 +119954,10 @@ var ts; // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. var parent = token.parent; return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) - ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 67220415 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } - function getUmdImportKind(compilerOptions) { + function getUmdImportKind(importingFile, compilerOptions) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { return 1 /* Default */; @@ -118238,6 +119968,9 @@ var ts; case ts.ModuleKind.AMD: case ts.ModuleKind.CommonJS: case ts.ModuleKind.UMD: + if (ts.isInJSFile(importingFile)) { + return ts.isExternalModule(importingFile) ? 2 /* Namespace */ : 4 /* ConstEquals */; + } return 3 /* Equals */; case ts.ModuleKind.System: case ts.ModuleKind.ES2015: @@ -118246,7 +119979,7 @@ var ts; // Fall back to the `import * as ns` style import. return 2 /* Namespace */; default: - return ts.Debug.assertNever(moduleKind); + return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind); } } function getFixesInfoForNonUMDImport(_a, symbolToken) { @@ -118259,7 +119992,7 @@ var ts; ? checker.getJsxNamespace(sourceFile) : symbolToken.text; // "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 */); + ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here"); var fixes = ts.arrayFrom(ts.flatMapIterator(getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), program, sourceFile, host, preferences); @@ -118276,7 +120009,7 @@ var ts; } forEachExternalModuleToImportFrom(checker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { cancellationToken.throwIfCancellationRequested(); - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, program.getCompilerOptions()); + var defaultInfo = getDefaultLikeExportInfo(sourceFile, moduleSymbol, checker, program.getCompilerOptions()); if (defaultInfo && defaultInfo.name === symbolName && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { addSymbol(moduleSymbol, defaultInfo.symbol, defaultInfo.kind); } @@ -118288,20 +120021,41 @@ var ts; }); return originalSymbolToExportInfos; } - function getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions) { - var exported = getDefaultLikeExportWorker(moduleSymbol, checker); + function getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions) { + var exported = getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions); if (!exported) return undefined; var symbol = exported.symbol, kind = exported.kind; var info = getDefaultExportInfoWorker(symbol, moduleSymbol, checker, compilerOptions); return info && __assign({ symbol: symbol, kind: kind }, info); } - function getDefaultLikeExportWorker(moduleSymbol, checker) { + function getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions) { 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: 3 /* Equals */ }; + return exportEquals === moduleSymbol ? undefined : { symbol: exportEquals, kind: getExportEqualsImportKind(importingFile, compilerOptions, checker) }; + } + function getExportEqualsImportKind(importingFile, compilerOptions, checker) { + if (ts.getAllowSyntheticDefaultImports(compilerOptions) && ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { + return 1 /* Default */; + } + if (ts.isInJSFile(importingFile)) { + return ts.isExternalModule(importingFile) ? 1 /* Default */ : 4 /* ConstEquals */; + } + for (var _i = 0, _a = importingFile.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (ts.isImportEqualsDeclaration(statement)) { + return 3 /* Equals */; + } + if (ts.isImportDeclaration(statement) && statement.importClause && statement.importClause.name) { + var moduleSymbol = checker.getImmediateAliasedSymbol(statement.importClause.symbol); + if (moduleSymbol && moduleSymbol.name !== "default" /* Default */) { + return 1 /* Default */; + } + } + } + return 3 /* Equals */; } function getDefaultExportInfoWorker(defaultExport, moduleSymbol, checker, compilerOptions) { var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); @@ -118312,7 +120066,7 @@ var ts; return { symbolForMeaning: defaultExport, name: name }; if (defaultExport.flags & 2097152 /* Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); - return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent), checker, compilerOptions); + return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent, "Alias targets of default exports must have a parent"), checker, compilerOptions); } if (defaultExport.escapedName !== "default" /* Default */ && defaultExport.escapedName !== "export=" /* ExportEquals */) { @@ -118328,7 +120082,7 @@ var ts; } } else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.text === "default" /* Default */); + ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); return declaration.propertyName && declaration.propertyName.text; } }); @@ -118362,12 +120116,12 @@ var ts; return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; } default: - return ts.Debug.assertNever(fix); + return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind); } } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports) { if (defaultImport) { - ts.Debug.assert(!clause.name); + ts.Debug.assert(!clause.name, "Default imports can't have names"); changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), ts.createIdentifier(defaultImport), { suffix: ", " }); } if (namedImports.length) { @@ -118385,7 +120139,7 @@ var ts; changes.replaceNode(sourceFile, clause.namedBindings, namedImports_1); } else { - changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name), namedImports_1); + changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name, "Named import specifiers must have names"), namedImports_1); } } } @@ -118410,11 +120164,17 @@ var ts; ts.insertImport(changes, sourceFile, ts.makeImport(defaultImport === undefined ? undefined : ts.createIdentifier(defaultImport), namedImports.map(function (n) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(n)); }), moduleSpecifier, quotePreference)); } if (namespaceLikeImport) { - ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ - ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) - : ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); + ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) : + namespaceLikeImport.importKind === 4 /* ConstEquals */ ? createConstEqualsRequireDeclaration(namespaceLikeImport.name, quotedModuleSpecifier) : + ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); } } + function createConstEqualsRequireDeclaration(name, quotedModuleSpecifier) { + return ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.createIdentifier(name), + /*type*/ undefined, ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, [quotedModuleSpecifier])) + ], 2 /* Const */)); + } function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); @@ -118522,12 +120282,12 @@ var ts; var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 73 /* Identifier */); + ts.Debug.assert(node.kind === 73 /* Identifier */, "Expected an identifier for spelling (property access)"); var containingType = checker.getTypeAtLocation(node.parent.expression); suggestion = checker.getSuggestionForNonexistentProperty(node, containingType); } else if (ts.isImportSpecifier(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 73 /* Identifier */); + ts.Debug.assert(node.kind === 73 /* Identifier */, "Expected an identifier for spelling (import)"); var importDeclaration = ts.findAncestor(node, ts.isImportDeclaration); var resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration); if (resolvedSourceFile && resolvedSourceFile.symbol) { @@ -118556,10 +120316,10 @@ var ts; flags |= 1920 /* Namespace */; } if (meaning & 2 /* Type */) { - flags |= 67897832 /* Type */; + flags |= 788968 /* Type */; } if (meaning & 1 /* Value */) { - flags |= 67220415 /* Value */; + flags |= 111551 /* Value */; } return flags; } @@ -118630,7 +120390,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, classDeclaration) { var supers = getAllSupers(classDeclaration, checker); - var _loop_12 = function (info) { + var _loop_13 = function (info) { // If some superclass added this property, don't add it again. if (supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -118657,7 +120417,7 @@ var ts; }; for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { var info = infos_1[_i]; - _loop_12(info); + _loop_13(info); } }); })); @@ -118718,7 +120478,7 @@ var ts; } function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 210 /* ClassExpression */) { + if (classDeclaration.kind === 211 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -118744,7 +120504,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 205 /* BinaryExpression */) { + if (token.parent.parent.kind === 206 /* 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))); @@ -118807,7 +120567,7 @@ var ts; } function addMethodDeclaration(context, changeTracker, declSourceFile, typeDecl, token, callExpression, makeStatic, inJs, preferences) { var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences, typeDecl); - var containingMethodDeclaration = ts.getAncestor(callExpression, 157 /* MethodDeclaration */); + var containingMethodDeclaration = ts.getAncestor(callExpression, 158 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === typeDecl) { changeTracker.insertNodeAfter(declSourceFile, containingMethodDeclaration, methodDeclaration); } @@ -119054,7 +120814,7 @@ var ts; }); function getNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 125 /* ConstructorKeyword */); + ts.Debug.assert(token.kind === 125 /* ConstructorKeyword */, "token should be at the constructor keyword"); return token.parent; } function doChange(changes, sourceFile, ctr) { @@ -119098,6 +120858,43 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixID = "fixEnableJsxFlag"; + var errorCodes = [ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) { + return doChange(changeTracker, configFile); + }); + return [ + codefix.createCodeFixActionNoFixId(fixID, changes, ts.Diagnostics.Enable_the_jsx_flag_in_your_configuration_file) + ]; + }, + fixIds: [fixID], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + doChange(changes, configFile); + }); + } + }); + function doChange(changeTracker, configFile) { + codefix.setJsonCompilerOptionValue(changeTracker, configFile, "jsx", ts.createStringLiteral("react")); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -119307,7 +121104,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); } function deleteTypeParameters(changes, sourceFile, token) { - changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters)); + changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. function tryGetFullImport(token) { @@ -119317,7 +121114,7 @@ var ts; if (token.kind !== 18 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; var decl = token.parent.parent; - if (decl.kind === 152 /* Parameter */) { + if (decl.kind === 153 /* Parameter */) { tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); } else { @@ -119328,7 +121125,7 @@ var ts; function tryDeleteFullVariableStatement(sourceFile, token, changes) { var declarationList = ts.tryCast(token.parent, ts.isVariableDeclarationList); if (declarationList && declarationList.getChildren(sourceFile)[0] === token) { - changes.delete(sourceFile, declarationList.parent.kind === 220 /* VariableStatement */ ? declarationList.parent : declarationList); + changes.delete(sourceFile, declarationList.parent.kind === 221 /* VariableStatement */ ? declarationList.parent : declarationList); return true; } return false; @@ -119346,14 +121143,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 152 /* Parameter */: - case 151 /* TypeParameter */: + case 153 /* Parameter */: + case 152 /* TypeParameter */: return true; - case 238 /* VariableDeclaration */: { + case 239 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 228 /* ForInStatement */: return true; } } @@ -119400,26 +121197,26 @@ var ts; function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: // Don't remove a parameter if this overrides something. var symbol = checker.getSymbolAtLocation(parent.name); if (ts.isMemberSymbolInBaseType(symbol, checker)) return false; // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: + case 159 /* Constructor */: + case 241 /* FunctionDeclaration */: return true; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 198 /* FunctionExpression */: + case 199 /* 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. var parameters = parent.parameters; var index = parameters.indexOf(p); - ts.Debug.assert(index !== -1); + ts.Debug.assert(index !== -1, "The parameter should already be in the list"); return isFixAll ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 73 /* Identifier */ && !p.symbol.isReferenced; }) : index === parameters.length - 1; } - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -119455,11 +121252,11 @@ var ts; function doChange(changes, sourceFile, start, length) { var token = ts.getTokenAtPosition(sourceFile, start); var statement = ts.findAncestor(token, ts.isStatement); - ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); + ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile), "token and statement should start at the same point"); 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 223 /* IfStatement */: + case 224 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -119470,15 +121267,15 @@ var ts; return; } // falls through - case 225 /* WhileStatement */: - case 226 /* ForStatement */: + case 226 /* WhileStatement */: + case 227 /* ForStatement */: changes.delete(sourceFile, container); return; } } if (ts.isBlock(statement.parent)) { var end_3 = start + length; - var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; })); + var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; }), "Some statement should be last"); changes.deleteNodeRange(sourceFile, statement, lastStatement); } else { @@ -119544,7 +121341,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 === 292 /* JSDocNullableType */) { + if (typeNode.kind === 293 /* 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)); @@ -119564,7 +121361,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 292 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 293 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -119581,22 +121378,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 213 /* AsExpression */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 240 /* FunctionDeclaration */: - case 159 /* GetAccessor */: - case 163 /* IndexSignature */: - case 182 /* MappedType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 195 /* TypeAssertionExpression */: - case 238 /* VariableDeclaration */: + case 214 /* AsExpression */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 241 /* FunctionDeclaration */: + case 160 /* GetAccessor */: + case 164 /* IndexSignature */: + case 183 /* MappedType */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 153 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 161 /* SetAccessor */: + case 244 /* TypeAliasDeclaration */: + case 196 /* TypeAssertionExpression */: + case 239 /* VariableDeclaration */: return true; default: return false; @@ -119625,12 +121422,15 @@ var ts; return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_async_modifier_to_containing_function, fixId, ts.Diagnostics.Add_all_missing_async_modifiers)]; }, fixIds: [fixId], - getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var nodes = getNodes(diag.file, diag.start); - if (!nodes) - return; - doChange(changes, context.sourceFile, nodes); - }); }, + getAllCodeActions: function (context) { + var seen = ts.createMap(); + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var nodes = getNodes(diag.file, diag.start); + if (!nodes || !ts.addToSeen(seen, ts.getNodeId(nodes.insertBefore))) + return; + doChange(changes, context.sourceFile, nodes); + }); + }, }); function getReturnType(expr) { if (expr.type) { @@ -119650,14 +121450,14 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: insertBefore = ts.findChildOfKind(containingFunction, 91 /* FunctionKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -119784,18 +121584,40 @@ var ts; var modifiers = visibilityModifier ? ts.createNodeArray([visibilityModifier]) : undefined; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var optional = !!(symbol.flags & 16777216 /* Optional */); + var ambient = !!(enclosingDeclaration.flags & 4194304 /* Ambient */); switch (declaration.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 154 /* PropertySignature */: - case 155 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 156 /* PropertyDeclaration */: var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); out(ts.createProperty( /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 156 /* MethodSignature */: - case 157 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: { + var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); + var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); + var orderedAccessors = allAccessors.secondAccessor + ? [allAccessors.firstAccessor, allAccessors.secondAccessor] + : [allAccessors.firstAccessor]; + for (var _i = 0, orderedAccessors_1 = orderedAccessors; _i < orderedAccessors_1.length; _i++) { + var accessor = orderedAccessors_1[_i]; + if (ts.isGetAccessorDeclaration(accessor)) { + out(ts.createGetAccessor( + /*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : createStubbedMethodBody(preferences))); + } + else { + ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter"); + var parameter = ts.getSetAccessorValueParameter(accessor); + var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined; + out(ts.createSetAccessor( + /*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : createStubbedMethodBody(preferences))); + } + } + break; + } + case 157 /* MethodSignature */: + case 158 /* 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 @@ -119808,23 +121630,25 @@ var ts; break; } if (declarations.length === 1) { - ts.Debug.assert(signatures.length === 1); + ts.Debug.assert(signatures.length === 1, "One declaration implies one signature"); var signature = signatures[0]; - outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); + outputMethod(signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(preferences)); break; } - for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { - var signature = signatures_1[_i]; + for (var _a = 0, signatures_1 = signatures; _a < signatures_1.length; _a++) { + var signature = signatures_1[_a]; // Need to ensure nodes are fresh each time so they can have different positions. outputMethod(signature, ts.getSynthesizedDeepClones(modifiers, /*includeTrivia*/ false), ts.getSynthesizedDeepClone(name, /*includeTrivia*/ false)); } - if (declarations.length > signatures.length) { - var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); - outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); - } - else { - ts.Debug.assert(declarations.length === signatures.length); - out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); + if (!ambient) { + if (declarations.length > signatures.length) { + var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); + outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); + } + else { + ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); + out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); + } } break; } @@ -119836,7 +121660,7 @@ var ts; } function signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body) { var program = context.program; - var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 157 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); + var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 158 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } @@ -119857,8 +121681,7 @@ var ts; return checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, /*flags*/ undefined, tracker); }); var names = ts.map(args, function (arg) { - return ts.isIdentifier(arg) ? arg.text : - ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; + return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; }); var contextualType = checker.getContextualType(call); var returnType = (inJs || !contextualType) ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); @@ -120012,7 +121835,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 192 /* CallExpression */ : 193 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 193 /* CallExpression */ : 194 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -120252,6 +122075,39 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "useBigintLiteral"; + var errorCodes = [ + ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span); }); + if (changes.length > 0) { + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_to_a_bigint_numeric_literal, fixId, ts.Diagnostics.Convert_all_to_bigint_numeric_literals)]; + } + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag); }); + }, + }); + function makeChange(changeTracker, sourceFile, span) { + var numericLiteral = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), ts.isNumericLiteral); + if (!numericLiteral) { + return; + } + // We use .getText to overcome parser inaccuracies: https://github.com/microsoft/TypeScript/issues/33298 + var newText = numericLiteral.getText(sourceFile) + "n"; + changeTracker.replaceNode(sourceFile, numericLiteral, ts.createBigIntLiteral(newText)); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -120273,8 +122129,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 93 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 184 /* ImportType */); + ts.Debug.assert(token.kind === 93 /* ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 185 /* ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -120327,7 +122183,7 @@ var ts; var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(134 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); - var intersectionType = ts.createIntersectionTypeNode(ts.getAllSuperTypeNodes(container).concat([ + var intersectionType = ts.createIntersectionTypeNode(__spreadArrays(ts.getAllSuperTypeNodes(container), [ mappedIntersectionType ], (otherMembers.length ? [ts.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); changes.replaceNode(sourceFile, container, createTypeAliasFromInterface(container, intersectionType)); @@ -120379,6 +122235,40 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "fixConvertConstToLet"; + var errorCodes = [ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, span = context.span, program = context.program; + var variableStatement = getVariableStatement(sourceFile, span.start, program); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, variableStatement); }); + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_const_to_let, fixId, ts.Diagnostics.Convert_const_to_let)]; + }, + fixIds: [fixId] + }); + function getVariableStatement(sourceFile, pos, program) { + var token = ts.getTokenAtPosition(sourceFile, pos); + var checker = program.getTypeChecker(); + var symbol = checker.getSymbolAtLocation(token); + if (symbol) { + return symbol.valueDeclaration.parent.parent; + } + } + function doChange(changes, sourceFile, variableStatement) { + if (!variableStatement) { + return; + } + var start = variableStatement.getStart(); + changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 5 }, "let"); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var refactor; (function (refactor) { @@ -120395,8 +122285,8 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context)), t, context.cancellationToken); }); + ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context), "context must have info"), t, context.cancellationToken); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; }, }); @@ -120416,16 +122306,16 @@ var ts; return undefined; } switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: { + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 246 /* ModuleDeclaration */: { var node = exportNode; return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } - case 220 /* VariableStatement */: { + case 221 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -120434,7 +122324,7 @@ var ts; var decl = ts.first(vs.declarationList.declarations); if (!decl.initializer) return undefined; - ts.Debug.assert(!wasDefault); + 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; } default: @@ -120448,40 +122338,40 @@ 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.assertDefined(ts.findModifier(exportNode, 81 /* DefaultKeyword */))); + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 81 /* DefaultKeyword */), "Should find a default keyword in modifier list")); } else { - var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 86 /* ExportKeyword */)); + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 86 /* ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(81 /* DefaultKeyword */)); break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: // If 'x' isn't used in this file, `export const x = 0;` --> `export default 0;` if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile)) { // We checked in `getInfo` that an initializer exists. - changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer))); + changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer, "Initializer was previously known to be present"))); break; } // falls through - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 246 /* ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.createExportDefault(ts.createIdentifier(exportName.text))); break; default: - ts.Debug.assertNever(exportNode); + ts.Debug.assertNever(exportNode, "Unexpected exportNode kind " + exportNode.kind); } } } function changeImports(program, _a, changes, cancellationToken) { var wasDefault = _a.wasDefault, exportName = _a.exportName, exportingModuleSymbol = _a.exportingModuleSymbol; var checker = program.getTypeChecker(); - var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName)); + var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName), "Export name should resolve to a symbol"); ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) { var importingSourceFile = ref.getSourceFile(); if (wasDefault) { @@ -120495,27 +122385,27 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: { + case 255 /* ImportSpecifier */: + case 259 /* 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 251 /* ImportClause */: { + case 252 /* ImportClause */: { var clause = parent; - ts.Debug.assert(clause.name === ref); + ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); var namedBindings = clause.namedBindings; if (!namedBindings) { // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); } - else if (namedBindings.kind === 252 /* NamespaceImport */) { + else if (namedBindings.kind === 253 /* 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 */; @@ -120536,11 +122426,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); break; - case 254 /* ImportSpecifier */: { + case 255 /* ImportSpecifier */: { // `import { foo } from "./a";` --> `import foo from "./a";` // `import { foo as bar } from "./a";` --> `import bar from "./a";` var defaultImport = ts.createIdentifier(parent.name.text); @@ -120553,7 +122443,7 @@ var ts; } break; } - case 258 /* ExportSpecifier */: { + case 259 /* 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";` @@ -120562,7 +122452,7 @@ var ts; break; } default: - ts.Debug.assertNever(parent); + ts.Debug.assertNever(parent, "Unexpected parent kind " + parent.kind); } } function makeImportSpecifier(propertyName, name) { @@ -120586,13 +122476,13 @@ var ts; var i = getImportToConvert(context); if (!i) return ts.emptyArray; - var description = i.kind === 252 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; - var actionName = i.kind === 252 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + var description = i.kind === 253 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 253 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); + ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context), "Context must provide an import to convert")); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; } }); @@ -120609,7 +122499,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 252 /* NamespaceImport */) { + if (toConvert.kind === 253 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -120630,7 +122520,7 @@ var ts; if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { conflictingNames.set(exportName, true); } - ts.Debug.assert(parent.expression === id); + ts.Debug.assert(parent.expression === id, "Parent expression should match id"); nodesToReplace.push(parent); } }); @@ -120669,7 +122559,7 @@ var ts; }); var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; var neededNamedImports = []; - var _loop_13 = function (element) { + var _loop_14 = function (element) { var propertyName = (element.propertyName || element.name).text; ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); @@ -120688,7 +122578,7 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_13(element); + _loop_14(element); } changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); if (neededNamedImports.length) { @@ -120809,6 +122699,7 @@ var ts; Messages.cannotExtractRange = createMessage("Cannot extract range."); Messages.cannotExtractImport = createMessage("Cannot extract import statement."); Messages.cannotExtractSuper = createMessage("Cannot extract super call."); + Messages.cannotExtractJSDoc = createMessage("Cannot extract JSDoc."); Messages.cannotExtractEmpty = createMessage("Cannot extract empty range."); Messages.expressionExpected = createMessage("expression expected."); Messages.uselessConstantType = createMessage("No reason to extract constant of type."); @@ -120900,6 +122791,9 @@ 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)] }; @@ -120952,20 +122846,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 155 /* PropertyDeclaration */) { + if (current.kind === 156 /* PropertyDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 152 /* Parameter */) { + else if (current.kind === 153 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 158 /* Constructor */) { + if (ctorOrMethod.kind === 159 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 157 /* MethodDeclaration */) { + else if (current.kind === 158 /* MethodDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -120983,9 +122877,9 @@ var ts; PermittedJumps[PermittedJumps["Return"] = 4] = "Return"; })(PermittedJumps || (PermittedJumps = {})); // We believe it's true because the node is from the (unmodified) tree. - ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (1)"); // For understanding how skipTrivia functioned: - ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (2)"); if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck))) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)]; } @@ -121008,7 +122902,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 238 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 239 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasModifier(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`! @@ -121020,13 +122914,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; case 99 /* 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 === 192 /* CallExpression */) { + if (node.parent.kind === 193 /* 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)) { @@ -121041,8 +122935,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -121054,20 +122948,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 223 /* IfStatement */: + case 224 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 236 /* TryStatement */: + case 237 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 219 /* Block */: - if (node.parent && node.parent.kind === 236 /* TryStatement */ && node.parent.finallyBlock === node) { + case 220 /* Block */: + if (node.parent && node.parent.kind === 237 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 272 /* CaseClause */: + case 273 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -121079,19 +122973,19 @@ var ts; break; } switch (node.kind) { - case 179 /* ThisType */: + case 180 /* ThisType */: case 101 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 234 /* LabeledStatement */: { + case 235 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: { + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -121100,20 +122994,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 230 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 231 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -121167,7 +123061,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 === 152 /* Parameter */) { + if (current.kind === 153 /* 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; } @@ -121178,7 +123072,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 285 /* SourceFile */) { + if (current.kind === 286 /* SourceFile */) { return scopes; } } @@ -121268,32 +123162,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: return "constructor"; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return "arrow function"; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return "method '" + scope.name.getText() + "'"; - case 159 /* GetAccessor */: + case 160 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: - throw ts.Debug.assertNever(scope); + throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 241 /* ClassDeclaration */ + return scope.kind === 242 /* 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 === 246 /* ModuleBlock */ + return scope.kind === 247 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -121397,8 +123291,8 @@ var ts; if (exposedVariableDeclarations.length && !writes) { // No need to mix declarations and writes. // How could any variables be exposed if there's a return statement? - ts.Debug.assert(!returnValueProperty); - ts.Debug.assert(!(range.facts & RangeFacts.HasReturn)); + ts.Debug.assert(!returnValueProperty, "Expected no returnValueProperty"); + ts.Debug.assert(!(range.facts & RangeFacts.HasReturn), "Expected RangeFacts.HasReturn flag to be unset"); if (exposedVariableDeclarations.length === 1) { // Declaring exactly one variable: let x = newFunction(); var variableDeclaration = exposedVariableDeclarations[0]; @@ -121466,7 +123360,7 @@ var ts; if (assignments.length === 1) { // We would only have introduced a return value property if there had been // other assignments to make. - ts.Debug.assert(!returnValueProperty); + ts.Debug.assert(!returnValueProperty, "Shouldn't have returnValueProperty here"); newNodes.push(ts.createStatement(ts.createAssignment(assignments[0].name, call))); if (range.facts & RangeFacts.HasReturn) { newNodes.push(ts.createReturn()); @@ -121523,6 +123417,7 @@ var ts; * Stores either a list of changes that should be applied to extract a range or a list of errors */ function extractConstantInScope(node, scope, _a, rangeFacts, context) { + var _b; var substitutions = _a.substitutions; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable @@ -121533,10 +123428,11 @@ var ts; ? undefined : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(node, substitutions); + (_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer); ts.suppressLeadingAndTrailingTrivia(initializer); var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); if (ts.isClassLike(scope)) { - ts.Debug.assert(!isJS); // See CannotExtractToJSClass + ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass var modifiers = []; modifiers.push(ts.createToken(114 /* PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { @@ -121571,7 +123467,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 222 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 223 /* 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.createVariableStatement( @@ -121590,7 +123486,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 222 /* ExpressionStatement */) { + if (node.parent.kind === 223 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -121604,6 +123500,63 @@ var ts; var renameFilename = node.getSourceFile().fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, localNameText, /*isDeclaredBeforeUse*/ true); return { renameFilename: renameFilename, renameLocation: renameLocation, edits: edits }; + function transformFunctionInitializerAndType(variableType, initializer) { + // If no contextual type exists there is nothing to transfer to the function signature + if (variableType === undefined) + return { variableType: variableType, initializer: initializer }; + // Only do this for function expressions and arrow functions that are not generic + if (!ts.isFunctionExpression(initializer) && !ts.isArrowFunction(initializer) || !!initializer.typeParameters) + return { variableType: variableType, initializer: initializer }; + var functionType = checker.getTypeAtLocation(node); + var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* Call */)); + // If no function signature, maybe there was an error, do nothing + if (!functionSignature) + return { variableType: variableType, initializer: initializer }; + // If the function signature has generic type parameters we don't attempt to move the parameters + if (!!functionSignature.getTypeParameters()) + return { variableType: variableType, initializer: initializer }; + // We add parameter types if needed + var parameters = []; + var hasAny = false; + for (var _i = 0, _a = initializer.parameters; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.type) { + parameters.push(p); + } + else { + var paramType = checker.getTypeAtLocation(p); + if (paramType === checker.getAnyType()) + hasAny = true; + parameters.push(ts.updateParameter(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NoTruncation */), p.initializer)); + } + } + // If a parameter was inferred as any we skip adding function parameters at all. + // Turning an implicit any (which under common settings is a error) to an explicit + // is probably actually a worse refactor outcome. + if (hasAny) + return { variableType: variableType, initializer: initializer }; + variableType = undefined; + if (ts.isArrowFunction(initializer)) { + initializer = ts.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); + } + else { + if (functionSignature && !!functionSignature.thisParameter) { + var firstParameter = ts.firstOrUndefined(parameters); + // If the function signature has a this parameter and if the first defined parameter is not the this parameter, we must add it + // Note: If this parameter was already there, it would have been previously updated with the type if not type was present + if ((!firstParameter || (ts.isIdentifier(firstParameter.name) && firstParameter.name.escapedText !== "this"))) { + var thisType = checker.getTypeOfSymbolAtLocation(functionSignature.thisParameter, node); + parameters.splice(0, 0, ts.createParameter( + /* decorators */ undefined, + /* modifiers */ undefined, + /* dotDotDotToken */ undefined, "this", + /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NoTruncation */))); + } + } + initializer = ts.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.body); + } + return { variableType: variableType, initializer: initializer }; + } } function getContainingVariableDeclarationIfInList(node, scope) { var prevNode; @@ -121677,7 +123630,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 231 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 232 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -121740,7 +123693,7 @@ var ts; } function getNodeToInsertPropertyBefore(maxPos, scope) { var members = scope.members; - ts.Debug.assert(members.length > 0); // There must be at least one child, since we extracted from one. + ts.Debug.assert(members.length > 0, "Found no members"); // There must be at least one child, since we extracted from one. var prevMember; var allProperties = true; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { @@ -121782,11 +123735,11 @@ var ts; } if (!prevStatement && ts.isCaseClause(curr)) { // We must have been in the expression of the case clause. - ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent)); + ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent), "Grandparent isn't a switch statement"); return curr.parent.parent; } // There must be at least one statement since we started in one. - return ts.Debug.assertDefined(prevStatement); + return ts.Debug.assertDefined(prevStatement, "prevStatement failed to get set"); } ts.Debug.assert(curr !== scope, "Didn't encounter a block-like before encountering scope"); } @@ -121855,7 +123808,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 240 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 241 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -121908,7 +123861,7 @@ var ts; // If we didn't get through all the scopes, then there were some that weren't in our // parent chain (impossible at time of writing). A conservative solution would be to // copy allTypeParameterUsages into all remaining scopes. - ts.Debug.assert(i_1 === scopes.length); + ts.Debug.assert(i_1 === scopes.length, "Should have iterated all scopes"); } // If there are any declarations in the extracted block that are used in the same enclosing // lexical scope, we can't move the extraction "up" as those declarations will become unreachable @@ -121918,7 +123871,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_14 = function (i) { + var _loop_15 = 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 @@ -121940,7 +123893,7 @@ var ts; } }); // If an expression was extracted, then there shouldn't have been any variable declarations. - ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0); + ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0, "No variable declarations expected if something was extracted"); if (hasWrite && !isReadonlyArray(targetRange.range)) { var diag = ts.createDiagnosticForNode(targetRange.range, Messages.cannotWriteInExpression); functionErrorsPerScope[i].push(diag); @@ -121958,7 +123911,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_14(i); + _loop_15(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -122171,30 +124124,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 279 /* EnumMember */: + case 280 /* EnumMember */: return false; } switch (node.kind) { case 10 /* StringLiteral */: - return parent.kind !== 250 /* ImportDeclaration */ && - parent.kind !== 254 /* ImportSpecifier */; - case 209 /* SpreadElement */: - case 185 /* ObjectBindingPattern */: - case 187 /* BindingElement */: + return parent.kind !== 251 /* ImportDeclaration */ && + parent.kind !== 255 /* ImportSpecifier */; + case 210 /* SpreadElement */: + case 186 /* ObjectBindingPattern */: + case 188 /* BindingElement */: return false; case 73 /* Identifier */: - return parent.kind !== 187 /* BindingElement */ && - parent.kind !== 254 /* ImportSpecifier */ && - parent.kind !== 258 /* ExportSpecifier */; + return parent.kind !== 188 /* BindingElement */ && + parent.kind !== 255 /* ImportSpecifier */ && + parent.kind !== 259 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 219 /* Block */: - case 285 /* SourceFile */: - case 246 /* ModuleBlock */: - case 272 /* CaseClause */: + case 220 /* Block */: + case 286 /* SourceFile */: + case 247 /* ModuleBlock */: + case 273 /* CaseClause */: return true; default: return false; @@ -122210,6 +124163,7 @@ var ts; (function (refactor) { var refactorName = "Extract type"; var extractToTypeAlias = "Extract to type alias"; + var extractToInterface = "Extract to interface"; var extractToTypeDef = "Extract to typedef"; refactor.registerRefactor(refactorName, { getAvailableActions: function (context) { @@ -122219,22 +124173,34 @@ var ts; return [{ name: refactorName, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_type), - actions: [info.isJS ? { + actions: info.isJS ? [{ name: extractToTypeDef, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_typedef) - } : { + }] : ts.append([{ name: extractToTypeAlias, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_type_alias) - }] + }], info.typeElements && { + name: extractToInterface, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_interface) + }) }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === extractToTypeAlias || actionName === extractToTypeDef); var file = context.file; - var info = ts.Debug.assertDefined(getRangeToExtract(context)); - ts.Debug.assert(actionName === extractToTypeAlias && !info.isJS || actionName === extractToTypeDef && info.isJS); + var info = ts.Debug.assertDefined(getRangeToExtract(context), "Expected to find a range to extract"); var name = ts.getUniqueName("NewType", file); - var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { return info.isJS ? - doTypedefChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters) : - doTypeAliasChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters); }); + var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { + switch (actionName) { + case extractToTypeAlias: + ts.Debug.assert(!info.isJS, "Invalid actionName/JS combo"); + return doTypeAliasChange(changes, file, name, info); + case extractToTypeDef: + ts.Debug.assert(info.isJS, "Invalid actionName/JS combo"); + return doTypedefChange(changes, file, name, info); + case extractToInterface: + ts.Debug.assert(!info.isJS && !!info.typeElements, "Invalid actionName/JS combo"); + return doInterfaceChange(changes, file, name, info); + default: + ts.Debug.fail("Unexpected action name"); + } + }); var renameFilename = file.fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, name, /*preferLastLocation*/ false); return { edits: edits, renameFilename: renameFilename, renameLocation: renameLocation }; @@ -122249,11 +124215,36 @@ var ts; if (!selection || !ts.isTypeNode(selection)) return undefined; var checker = context.program.getTypeChecker(); - var firstStatement = ts.Debug.assertDefined(isJS ? ts.findAncestor(selection, isStatementAndHasJSDoc) : ts.findAncestor(selection, ts.isStatement)); + var firstStatement = ts.Debug.assertDefined(isJS ? ts.findAncestor(selection, isStatementAndHasJSDoc) : ts.findAncestor(selection, ts.isStatement), "Should find a statement"); var typeParameters = collectTypeParameters(checker, selection, firstStatement, file); if (!typeParameters) return undefined; - return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters }; + var typeElements = flattenTypeLiteralNodeReference(checker, selection); + return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters, typeElements: typeElements }; + } + function flattenTypeLiteralNodeReference(checker, node) { + if (!node) + return undefined; + if (ts.isIntersectionTypeNode(node)) { + var result = []; + var seen_1 = ts.createMap(); + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var type = _a[_i]; + var flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type); + if (!flattenedTypeMembers || !flattenedTypeMembers.every(function (type) { return type.name && ts.addToSeen(seen_1, ts.getNameFromPropertyName(type.name)); })) { + return undefined; + } + ts.addRange(result, flattenedTypeMembers); + } + return result; + } + else if (ts.isParenthesizedTypeNode(node)) { + return flattenTypeLiteralNodeReference(checker, node.type); + } + else if (ts.isTypeLiteralNode(node)) { + return node.members; + } + return undefined; } function isStatementAndHasJSDoc(n) { return ts.isStatement(n) && ts.hasJSDocNodes(n); @@ -122290,7 +124281,7 @@ var ts; } else if (ts.isTypeQueryNode(node)) { if (ts.isIdentifier(node.exprName)) { - var symbol = checker.resolveName(node.exprName.text, node.exprName, 67220415 /* Value */, /* excludeGlobals */ false); + 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)) { return true; } @@ -122304,15 +124295,26 @@ var ts; return ts.forEachChild(node, visitor); } } - function doTypeAliasChange(changes, file, name, firstStatement, selection, typeParameters) { + function doTypeAliasChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; var newTypeNode = ts.createTypeAliasDeclaration( /* decorators */ undefined, /* modifiers */ undefined, name, typeParameters.map(function (id) { return ts.updateTypeParameterDeclaration(id, id.name, id.constraint, /* defaultType */ undefined); }), selection); changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); } - function doTypedefChange(changes, file, name, firstStatement, selection, typeParameters) { - var node = ts.createNode(311 /* JSDocTypedefTag */); + function doInterfaceChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters, typeElements = info.typeElements; + var newTypeNode = ts.createInterfaceDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, name, typeParameters, + /* heritageClauses */ undefined, typeElements); + changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); + changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); + } + function doTypedefChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; + var node = ts.createNode(313 /* JSDocTypedefTag */); node.tagName = ts.createIdentifier("typedef"); // TODO: jsdoc factory https://github.com/Microsoft/TypeScript/pull/29539 node.fullName = ts.createIdentifier(name); node.name = node.fullName; @@ -122320,10 +124322,10 @@ var ts; var templates = []; ts.forEach(typeParameters, function (typeParameter) { var constraint = ts.getEffectiveConstraintOfTypeParameter(typeParameter); - var template = ts.createNode(310 /* JSDocTemplateTag */); + var template = ts.createNode(312 /* JSDocTemplateTag */); template.tagName = ts.createIdentifier("template"); template.constraint = constraint && ts.cast(constraint, ts.isJSDocTypeExpression); - var parameter = ts.createNode(151 /* TypeParameter */); + var parameter = ts.createNode(152 /* TypeParameter */); parameter.name = typeParameter.name; template.typeParameters = ts.createNodeArray([parameter]); templates.push(template); @@ -122404,7 +124406,7 @@ var ts; return ts.isIdentifier(name) || ts.isStringLiteral(name); } function isAcceptedDeclaration(node) { - return ts.isParameterPropertyDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); + return ts.isParameterPropertyDeclaration(node, node.parent) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); } function createPropertyName(name, originalName) { return ts.isIdentifier(originalName) ? ts.createIdentifier(name) : ts.createLiteral(name); @@ -122437,7 +124439,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasReadonlyModifier(declaration), type: ts.getTypeAnnotationNode(declaration), - container: declaration.kind === 152 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 153 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -122483,11 +124485,9 @@ var ts; } } function insertAccessor(changeTracker, file, accessor, declaration, container) { - ts.isParameterPropertyDeclaration(declaration) - ? changeTracker.insertNodeAtClassStart(file, container, accessor) - : ts.isPropertyAssignment(declaration) - ? changeTracker.insertNodeAfterComma(file, declaration, accessor) - : changeTracker.insertNodeAfter(file, declaration, accessor); + ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.insertNodeAtClassStart(file, container, accessor) : + ts.isPropertyAssignment(declaration) ? changeTracker.insertNodeAfterComma(file, declaration, accessor) : + changeTracker.insertNodeAfter(file, declaration, accessor); } function updateReadonlyPropertyInitializerStatementConstructor(changeTracker, file, constructor, fieldName, originalName) { if (!constructor.body) @@ -122525,7 +124525,7 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Wrong refactor invoked"); var statements = ts.Debug.assertDefined(getStatementsToMove(context)); var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; @@ -122582,11 +124582,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return true; - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -122621,7 +124621,7 @@ var ts; deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker); deleteMovedStatements(oldFile, toMove.ranges, changes); updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName); - return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference).concat(addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); + return __spreadArrays(getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference), addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); } function deleteMovedStatements(sourceFile, moved, changes) { for (var _i = 0, moved_1 = moved; _i < moved_1.length; _i++) { @@ -122639,10 +124639,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_15 = function (sourceFile) { + var _loop_16 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_16 = function (statement) { + var _loop_17 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -122664,25 +124664,25 @@ var ts; }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_16(statement); + _loop_17(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_15(sourceFile); + _loop_16(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 252 /* NamespaceImport */ ? + case 251 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 253 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return node.name; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { @@ -122710,20 +124710,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function moduleSpecifierFromImport(i) { - return (i.kind === 250 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 249 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 251 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 250 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -122765,7 +124765,7 @@ var ts; return ts.makeImportIfNecessary(defaultImport, specifiers, path, quotePreference); } else { - ts.Debug.assert(!defaultImport); // If there's a default export, it should have been an es6 module. + ts.Debug.assert(!defaultImport, "No default import should exist"); // If there's a default export, it should have been an es6 module. var bindingElements = imports.map(function (i) { return ts.createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, i); }); return bindingElements.length ? makeVariableStatement(ts.createObjectBindingPattern(bindingElements), /*type*/ undefined, createRequireCall(ts.createLiteral(path))) @@ -122793,19 +124793,19 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: - ts.Debug.assertNever(importDecl); + ts.Debug.assertNever(importDecl, "Unexpected import decl kind " + importDecl.kind); } } function deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused) { @@ -122814,7 +124814,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 252 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 253 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -122824,9 +124824,9 @@ var ts; } if (namedBindings) { if (namedBindingsUnused) { - changes.delete(sourceFile, namedBindings); + changes.replaceNode(sourceFile, importDecl.importClause, ts.updateImportClause(importDecl.importClause, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 253 /* NamedImports */) { + else if (namedBindings.kind === 254 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -122844,9 +124844,9 @@ var ts; changes.delete(sourceFile, name); } break; - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: break; - case 185 /* ObjectBindingPattern */: + case 186 /* 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); } @@ -122920,7 +124920,7 @@ var ts; for (var _i = 0, toMove_1 = toMove; _i < toMove_1.length; _i++) { var statement = toMove_1[_i]; forEachTopLevelDeclaration(statement, function (decl) { - movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol)); + movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol, "Need a symbol here")); }); } for (var _a = 0, toMove_2 = toMove; _a < toMove_2.length; _a++) { @@ -122973,13 +124973,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: + case 250 /* ImportEqualsDeclaration */: + case 255 /* ImportSpecifier */: + case 252 /* ImportClause */: return true; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -122991,7 +124991,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 250 /* ImportDeclaration */: { + case 251 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -123001,18 +125001,18 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 238 /* VariableDeclaration */: { + case 239 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } default: - return ts.Debug.assertNever(i); + return ts.Debug.assertNever(i, "Unexpected import kind " + i.kind); } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 253 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -123024,9 +125024,9 @@ var ts; switch (name.kind) { case 73 /* Identifier */: return keep(name) ? name : undefined; - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: return name; - case 185 /* ObjectBindingPattern */: { + case 186 /* 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.createObjectBindingPattern(newElements) : undefined; @@ -123078,18 +125078,18 @@ var ts; return ts.isVariableDeclaration(node) ? node.parent.parent.parent : node.parent; } function isTopLevelDeclarationStatement(node) { - ts.Debug.assert(ts.isSourceFile(node.parent)); + ts.Debug.assert(ts.isSourceFile(node.parent), "Node parent should be a SourceFile"); return isNonVariableTopLevelDeclaration(node) || ts.isVariableStatement(node); } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 250 /* ImportEqualsDeclaration */: return true; default: return false; @@ -123097,17 +125097,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 250 /* ImportEqualsDeclaration */: return cb(statement); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 222 /* ExpressionStatement */: { + case 223 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -123119,11 +125119,11 @@ var ts; switch (name.kind) { case 73 /* Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); } } function nameOfTopLevelDeclaration(d) { @@ -123131,9 +125131,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return d.parent.parent; - case 187 /* BindingElement */: + case 188 /* BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -123166,48 +125166,48 @@ var ts; function addEs6Export(d) { var modifiers = ts.concatenate([ts.createModifier(86 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(d); + return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); } } function addCommonjsExport(decl) { - return [decl].concat(getNamesToExportInCommonJS(decl).map(createExportAssignment)); + return __spreadArrays([decl], getNamesToExportInCommonJS(decl).map(createExportAssignment)); } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 250 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 222 /* ExpressionStatement */: - return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` + case 223 /* 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); + return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); } } /** Creates `exports.x = x;` */ @@ -123335,7 +125335,7 @@ var ts; }]; } function getEditsForAction(context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Unexpected action name"); var file = context.file, startPosition = context.startPosition, program = context.program, cancellationToken = context.cancellationToken, host = context.host; var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker()); if (!functionDeclaration || !cancellationToken) @@ -123367,7 +125367,7 @@ var ts; function getGroupedReferences(functionDeclaration, program, cancellationToken) { var functionNames = getFunctionNames(functionDeclaration); var classNames = ts.isConstructorDeclaration(functionDeclaration) ? getClassNames(functionDeclaration) : []; - var names = ts.deduplicate(functionNames.concat(classNames), ts.equateValues); + var names = ts.deduplicate(__spreadArrays(functionNames, classNames), ts.equateValues); var checker = program.getTypeChecker(); var references = ts.flatMap(names, /*mapfn*/ function (/*mapfn*/ name) { return ts.FindAllReferences.getReferenceEntriesForNode(-1, name, program, program.getSourceFiles(), cancellationToken); }); var groupedReferences = groupReferences(references); @@ -123474,15 +125474,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -123492,7 +125492,7 @@ var ts; } break; // x["foo"](...) - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -123511,14 +125511,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -123560,11 +125560,11 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return isSingleImplementation(functionDeclaration, checker); - case 158 /* Constructor */: + case 159 /* Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -123572,8 +125572,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -123744,7 +125744,7 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; @@ -123752,7 +125752,7 @@ var ts; // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 81 /* DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -123763,30 +125763,30 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* 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.assertDefined(ts.findModifier(functionDeclaration, 81 /* DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return [functionDeclaration.name]; - case 158 /* Constructor */: + case 159 /* Constructor */: var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 125 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 210 /* ClassExpression */) { + if (functionDeclaration.parent.kind === 211 /* ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return [functionDeclaration.parent.name]; - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; default: - return ts.Debug.assertNever(functionDeclaration); + return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind " + functionDeclaration.kind); } } })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); @@ -123815,7 +125815,7 @@ var ts; this.kind = kind; } NodeObject.prototype.assertHasRealPosition = function (message) { - // tslint:disable-next-line:debug-assert + // eslint-disable-next-line debug-assert ts.Debug.assert(!ts.positionIsSynthesized(this.pos) && !ts.positionIsSynthesized(this.end), message || "Node must have a real position for this operation"); }; NodeObject.prototype.getSourceFile = function () { @@ -123872,8 +125872,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 289 /* FirstJSDocNode */ || kid.kind > 312 /* LastJSDocNode */; }); - return child.kind < 149 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 290 /* FirstJSDocNode */ || kid.kind > 314 /* LastJSDocNode */; }); + return child.kind < 150 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -123884,7 +125884,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 149 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 150 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -123942,7 +125942,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(313 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(315 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { @@ -124277,10 +126277,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -124300,31 +126300,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 169 /* TypeLiteral */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 245 /* EnumDeclaration */: + case 246 /* ModuleDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 259 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 252 /* ImportClause */: + case 253 /* NamespaceImport */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 170 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 152 /* Parameter */: + case 153 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // falls through - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: { + case 239 /* VariableDeclaration */: + case 188 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -124335,19 +126335,19 @@ var ts; } } // falls through - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 280 /* EnumMember */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: addDeclaration(node); break; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -124359,7 +126359,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 253 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -124368,7 +126368,7 @@ var ts; } } break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -124565,7 +126565,7 @@ var ts; return sourceFile; } ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; - ts.disableIncrementalParsing = false; + ts.disableIncrementalParsing = false; // eslint-disable-line prefer-const function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { // If we were given a text change range, and our version or open-ness changed, then // incrementally parse this file. @@ -124694,7 +126694,11 @@ var ts; function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { - throw new Error("Could not find sourceFile: '" + fileName + "' in " + (program && JSON.stringify(program.getSourceFiles().map(function (f) { return f.fileName; }))) + "."); + var error = new Error("Could not find source file: '" + fileName + "'."); + // We've been having trouble debugging this, so attach sidecar data for the tsserver log. + // See https://github.com/microsoft/TypeScript/issues/30180. + error.ProgramFiles = program.getSourceFiles().map(function (f) { return f.fileName; }); + throw error; } return sourceFile; } @@ -124763,11 +126767,21 @@ var ts; compilerHost.trace = function (message) { return host.trace(message); }; } if (host.resolveModuleNames) { - compilerHost.resolveModuleNames = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }; + compilerHost.resolveModuleNames = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveModuleNames.apply(host, args); + }; } if (host.resolveTypeReferenceDirectives) { - compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { - return host.resolveTypeReferenceDirectives(typeReferenceDirectiveNames, containingFile, redirectedReference); + compilerHost.resolveTypeReferenceDirectives = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveTypeReferenceDirectives.apply(host, args); }; } var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); @@ -124905,7 +126919,7 @@ var ts; } // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); - return semanticDiagnostics.concat(declarationDiagnostics); + return __spreadArrays(semanticDiagnostics, declarationDiagnostics); } function getSuggestionDiagnostics(fileName) { synchronizeHostData(); @@ -124913,12 +126927,12 @@ var ts; } function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); + return __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken)); } function getCompletionsAtPosition(fileName, position, options) { if (options === void 0) { options = ts.emptyOptions; } // Convert from deprecated options names to new names - var fullPreferences = __assign({}, ts.identity(options), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); + var fullPreferences = __assign(__assign({}, ts.identity(options)), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); synchronizeHostData(); return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter); } @@ -124976,12 +126990,12 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node); - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 191 /* PropertyAccessExpression */: + case 150 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); case 101 /* ThisKeyword */: - case 179 /* ThisType */: + case 180 /* ThisType */: case 99 /* SuperKeyword */: return true; default: @@ -125008,13 +127022,13 @@ var ts; } /// References and Occurrences function getOccurrencesAtPosition(fileName, position) { - return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */, isDefinition: false }, highlightSpan.isInString && { isInString: true }, highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); + return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */, isDefinition: false }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); } function getDocumentHighlights(fileName, position, filesToSearch) { var normalizedFileName = ts.normalizePath(fileName); ts.Debug.assert(filesToSearch.some(function (f) { return ts.normalizePath(f) === normalizedFileName; })); synchronizeHostData(); - var sourceFilesToSearch = filesToSearch.map(getValidSourceFile); + var sourceFilesToSearch = ts.mapDefined(filesToSearch, function (fileName) { return program.getSourceFile(fileName); }); var sourceFile = getValidSourceFile(fileName); return ts.DocumentHighlights.getDocumentHighlights(program, cancellationToken, sourceFile, position, sourceFilesToSearch); } @@ -125084,15 +127098,15 @@ var ts; return undefined; } switch (node.kind) { - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 191 /* PropertyAccessExpression */: + case 150 /* QualifiedName */: case 10 /* StringLiteral */: case 88 /* FalseKeyword */: case 103 /* TrueKeyword */: case 97 /* NullKeyword */: case 99 /* SuperKeyword */: case 101 /* ThisKeyword */: - case 179 /* ThisType */: + case 180 /* ThisType */: case 73 /* Identifier */: break; // Cant create the text span @@ -125109,7 +127123,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 === 245 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 246 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -125561,7 +127575,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 260 /* ExternalModuleReference */ || + node.parent.kind === 261 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -125578,13 +127592,13 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 150 /* ComputedPropertyName */) { + if (node.parent.kind === 151 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through case 73 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 189 /* ObjectLiteralExpression */ || node.parent.parent.kind === 269 /* JsxAttributes */) && + (node.parent.parent.kind === 190 /* ObjectLiteralExpression */ || node.parent.parent.kind === 270 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -125626,7 +127640,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 191 /* ElementAccessExpression */ && + node.parent.kind === 192 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -125706,114 +127720,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 239 /* VariableDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return spanInVariableDeclaration(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return spanInParameterDeclaration(node); - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 159 /* Constructor */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 219 /* Block */: + case 220 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return spanInBlock(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return spanInBlock(node.block); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 224 /* DoStatement */: + case 225 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 237 /* DebuggerStatement */: + case 238 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 223 /* IfStatement */: + case 224 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return spanInForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 236 /* TryStatement */: + case 237 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 187 /* BindingElement */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 188 /* BindingElement */: // span on complete node return textSpan(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 153 /* Decorator */: + case 154 /* Decorator */: return spanInNodeArray(parent.decorators); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: return undefined; // Tokens: case 26 /* SemicolonToken */: @@ -125843,7 +127857,7 @@ var ts; case 76 /* CatchKeyword */: case 89 /* FinallyKeyword */: return spanInNextNode(node); - case 148 /* OfKeyword */: + case 149 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -125856,13 +127870,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 === 73 /* Identifier */ || - node.kind === 209 /* SpreadElement */ || - node.kind === 276 /* PropertyAssignment */ || - node.kind === 277 /* ShorthandPropertyAssignment */) && + node.kind === 210 /* SpreadElement */ || + node.kind === 277 /* PropertyAssignment */ || + node.kind === 278 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 205 /* BinaryExpression */) { + if (node.kind === 206 /* 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 @@ -125884,22 +127898,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 224 /* DoStatement */: + case 225 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 153 /* Decorator */: + case 154 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 227 /* ForStatement */: + case 229 /* ForOfStatement */: return textSpan(node); - case 205 /* BinaryExpression */: + case 206 /* 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 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -125908,21 +127922,21 @@ var ts; } } switch (node.parent.kind) { - case 276 /* PropertyAssignment */: + case 277 /* 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 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: { + case 239 /* VariableDeclaration */: + case 153 /* 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)) { @@ -125930,7 +127944,7 @@ var ts; } break; } - case 205 /* BinaryExpression */: { + case 206 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -125960,7 +127974,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 227 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 228 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -125972,7 +127986,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 228 /* ForOfStatement */) { + parent.parent.kind === 229 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -126013,7 +128027,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 241 /* ClassDeclaration */ && functionDeclaration.kind !== 158 /* Constructor */); + (functionDeclaration.parent.kind === 242 /* ClassDeclaration */ && functionDeclaration.kind !== 159 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -126036,26 +128050,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } - // falls through // Set on parent if on same line otherwise on first statement - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 227 /* ForInStatement */: + // falls through + case 226 /* WhileStatement */: + case 224 /* IfStatement */: + case 228 /* 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 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 227 /* ForStatement */: + case 229 /* 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 === 239 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 240 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -126080,21 +128094,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 212 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 187 /* BindingElement */) { + if (bindingPattern.parent.kind === 188 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 186 /* ArrayBindingPattern */ && node.kind !== 185 /* ObjectBindingPattern */); - var elements = node.kind === 188 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 187 /* ArrayBindingPattern */ && node.kind !== 186 /* ObjectBindingPattern */); + var elements = node.kind === 189 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 212 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -126102,18 +128116,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 === 205 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 206 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -126121,25 +128135,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 246 /* ModuleBlock */: + case 247 /* 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 244 /* EnumDeclaration */: - case 241 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 242 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 219 /* Block */: + case 220 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 275 /* CatchClause */: + case 276 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -126147,7 +128161,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 185 /* ObjectBindingPattern */: + case 186 /* 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); @@ -126163,7 +128177,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 186 /* ArrayBindingPattern */: + case 187 /* 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); @@ -126178,12 +128192,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 224 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 192 /* CallExpression */ || - node.parent.kind === 193 /* NewExpression */) { + if (node.parent.kind === 225 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 193 /* CallExpression */ || + node.parent.kind === 194 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 196 /* ParenthesizedExpression */) { + if (node.parent.kind === 197 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -126192,21 +128206,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 196 /* ParenthesizedExpression */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 159 /* Constructor */: + case 226 /* WhileStatement */: + case 225 /* DoStatement */: + case 227 /* ForStatement */: + case 229 /* ForOfStatement */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 197 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -126216,20 +128230,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ || - node.parent.kind === 152 /* Parameter */) { + node.parent.kind === 277 /* PropertyAssignment */ || + node.parent.kind === 153 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 195 /* TypeAssertionExpression */) { + if (node.parent.kind === 196 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 224 /* DoStatement */) { + if (node.parent.kind === 225 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -126237,7 +128251,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.kind === 229 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -126282,10 +128296,9 @@ var ts; // limitations under the License. // /* @internal */ -var debugObjectHost = (function () { return this; })(); +var debugObjectHost = (function () { return this; })(); // eslint-disable-line prefer-const // We need to use 'null' to interface with the managed side. -/* tslint:disable:no-null-keyword */ -/* tslint:disable:no-in-operator */ +/* eslint-disable no-in-operator */ /* @internal */ var ts; (function (ts) { @@ -126307,9 +128320,11 @@ var ts; ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + /* eslint-disable no-null/no-null */ if (encoded === null) { return null; // TODO: GH#18217 } + /* eslint-enable no-null/no-null */ var decoded = JSON.parse(encoded); // TODO: GH#18217 return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); }; @@ -126380,6 +128395,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); + // eslint-disable-next-line no-null/no-null if (settingsJson === null || settingsJson === "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } @@ -126408,6 +128424,7 @@ var ts; return this.shimHost.getScriptVersion(fileName); }; LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { + /* eslint-disable no-null/no-null */ var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); if (diagnosticMessagesJson === null || diagnosticMessagesJson === "") { return null; @@ -126419,6 +128436,7 @@ var ts; this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); return null; } + /* eslint-enable no-null/no-null */ }; LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { var hostCancellationToken = this.shimHost.getCancellationToken(); @@ -126562,13 +128580,13 @@ var ts; LanguageServiceShimObject.prototype.dispose = function (dummy) { this.logger.log("dispose()"); this.languageService.dispose(); - this.languageService = null; + this.languageService = null; // eslint-disable-line no-null/no-null // force a GC if (debugObjectHost && debugObjectHost.CollectGarbage) { debugObjectHost.CollectGarbage(); this.logger.log("CollectGarbage()"); } - this.logger = null; + this.logger = null; // eslint-disable-line no-null/no-null _super.prototype.dispose.call(this, dummy); }; /// REFRESH @@ -126576,13 +128594,14 @@ var ts; * Update the list of scripts known to the compiler */ LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); + this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; } // eslint-disable-line no-null/no-null + ); }; LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { var _this = this; this.forwardJSONCall("cleanupSemanticCache()", function () { _this.languageService.cleanupSemanticCache(); - return null; + return null; // eslint-disable-line no-null/no-null }); }; LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { @@ -126953,7 +128972,7 @@ var ts; typeAcquisition: configFile.typeAcquisition, files: configFile.fileNames, raw: configFile.raw, - errors: realizeDiagnostics(result.parseDiagnostics.concat(configFile.errors), "\r\n") + errors: realizeDiagnostics(__spreadArrays(result.parseDiagnostics, configFile.errors), "\r\n") }; }); }; @@ -127040,8 +129059,7 @@ var ts; module.exports = ts; } })(ts || (ts = {})); -/* tslint:enable:no-in-operator */ -/* tslint:enable:no-null */ +/* eslint-enable no-in-operator */ /// TODO: this is used by VS, clean this up on both sides of the interface /* @internal */ var TypeScript; diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index d13ea15429262..d469dd1d749b0 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -15,6 +15,13 @@ and limitations under the License. "use strict"; +var __spreadArrays = (this && this.__spreadArrays) || function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +}; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { @@ -74,7 +81,7 @@ var ts; (function (ts) { // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configureNightly` too. - ts.versionMajorMinor = "3.6"; + ts.versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ ts.version = ts.versionMajorMinor + ".0-dev"; })(ts || (ts = {})); @@ -92,7 +99,7 @@ var ts; ts.emptyArray = []; /** Create a MapLike with good performance. */ function createDictionaryObject() { - var map = Object.create(/*prototype*/ null); // tslint:disable-line:no-null-keyword + var map = Object.create(/*prototype*/ null); // eslint-disable-line no-null/no-null // Using 'delete' on an object causes V8 to put the object in dictionary mode. // This disables creation of hidden classes, which are expensive when an object is // constantly changing shape. @@ -127,7 +134,7 @@ var ts; } ts.createMapFromTemplate = createMapFromTemplate; // Internet Explorer's Map doesn't support iteration, so don't use it. - // tslint:disable-next-line no-in-operator variable-name + // eslint-disable-next-line no-in-operator ts.MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); // Keep the class inside a function so it doesn't get compiled if it's not used. function shimMap() { @@ -191,7 +198,7 @@ var ts; return this; }; class_1.prototype.has = function (key) { - // tslint:disable-next-line:no-in-operator + // eslint-disable-next-line no-in-operator return key in this.data; }; class_1.prototype.delete = function (key) { @@ -784,7 +791,7 @@ var ts; return array1; if (!some(array1)) return array2; - return array1.concat(array2); + return __spreadArrays(array1, array2); } ts.concatenate = concatenate; function deduplicateRelational(array, equalityComparer, comparer) { @@ -841,6 +848,7 @@ var ts; // equality comparison case true: // relational comparison + // falls through case 0 /* EqualTo */: continue; case -1 /* LessThan */: @@ -1231,6 +1239,18 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; + function getAllKeys(obj) { + var result = []; + do { + var names = Object.getOwnPropertyNames(obj); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name = names_1[_i]; + pushIfUnique(result, name); + } + } while (obj = Object.getPrototypeOf(obj)); + return result; + } + ts.getAllKeys = getAllKeys; function getOwnValues(sparseArray) { var values = []; for (var key in sparseArray) { @@ -1428,7 +1448,7 @@ var ts; } ts.cast = cast; /** Does nothing. */ - function noop(_) { } // tslint:disable-line no-empty + function noop(_) { } ts.noop = noop; /** Do nothing and return false */ function returnFalse() { return false; } @@ -1940,7 +1960,7 @@ var ts; return function (arg) { return f(arg) || g(arg); }; } ts.or = or; - function assertType(_) { } // tslint:disable-line no-empty + function assertType(_) { } ts.assertType = assertType; function singleElementArray(t) { return t === undefined ? undefined : [t]; @@ -2017,8 +2037,10 @@ var ts; (function (ts) { var Debug; (function (Debug) { + /* eslint-disable prefer-const */ Debug.currentAssertionLevel = 0 /* None */; Debug.isDebugging = false; + /* eslint-enable prefer-const */ function shouldAssert(level) { return Debug.currentAssertionLevel >= level; } @@ -2067,6 +2089,7 @@ var ts; } Debug.fail = fail; function assertDefined(value, message) { + // eslint-disable-next-line no-null/no-null if (value === undefined || value === null) return fail(message); return value; @@ -2082,7 +2105,7 @@ var ts; Debug.assertEachDefined = assertEachDefined; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } - var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); + var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); return fail(message + " " + detail, stackCrawlMark || assertNever); } Debug.assertNever = assertNever; @@ -2370,6 +2393,47 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var nullLogger = { + logEvent: ts.noop, + logErrEvent: ts.noop, + logPerfEvent: ts.noop, + logInfoEvent: ts.noop, + logStartCommand: ts.noop, + logStopCommand: ts.noop, + logStartUpdateProgram: ts.noop, + logStopUpdateProgram: ts.noop, + logStartUpdateGraph: ts.noop, + logStopUpdateGraph: ts.noop, + logStartResolveModule: ts.noop, + logStopResolveModule: ts.noop, + logStartParseSourceFile: ts.noop, + logStopParseSourceFile: ts.noop, + logStartReadFile: ts.noop, + logStopReadFile: ts.noop, + logStartBindFile: ts.noop, + logStopBindFile: ts.noop, + logStartScheduledOperation: ts.noop, + logStopScheduledOperation: ts.noop, + }; + // Load optional module to enable Event Tracing for Windows + // See https://github.com/microsoft/typescript-etw for more information + var etwModule; + try { + // require() will throw an exception if the module is not installed + // It may also return undefined if not installed properly + etwModule = require("@microsoft/typescript-etw"); + } + catch (e) { + etwModule = undefined; + } + /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ + ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; + var args = typeof process === "undefined" ? [] : process.argv; + ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify(args)); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { // https://semver.org/#spec-item-2 // > A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative @@ -2894,200 +2958,203 @@ var ts; SyntaxKind[SyntaxKind["FromKeyword"] = 145] = "FromKeyword"; SyntaxKind[SyntaxKind["GlobalKeyword"] = 146] = "GlobalKeyword"; SyntaxKind[SyntaxKind["BigIntKeyword"] = 147] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 148] = "OfKeyword"; + SyntaxKind[SyntaxKind["TagKeyword"] = 148] = "TagKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 149] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 149] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 150] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 150] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 151] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 151] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 152] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 153] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 152] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 153] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 154] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 154] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 155] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 156] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 157] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 158] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 159] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 160] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 161] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 162] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 163] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 155] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 156] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 157] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 158] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 159] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 160] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 161] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 162] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 163] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 164] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 164] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 165] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 166] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 167] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 168] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 169] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 170] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 171] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 172] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 173] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 174] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 175] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 176] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 177] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 178] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 179] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 180] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 181] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 182] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 183] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 184] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 165] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 166] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 167] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 168] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 169] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 170] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 171] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 172] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 173] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 174] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 175] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 176] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 177] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 178] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 179] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 180] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 181] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 182] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 183] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 184] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 185] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 185] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 186] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 187] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 186] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 187] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 188] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 188] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 189] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 190] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 191] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 192] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 193] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 194] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 195] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 196] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 197] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 198] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 199] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 200] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 201] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 202] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 203] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 204] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 205] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 206] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 207] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 208] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 209] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 210] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 211] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 212] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 213] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 214] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 215] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 216] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 189] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 190] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 191] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 192] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 193] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 194] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 195] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 196] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 197] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 198] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 199] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 200] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 201] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 202] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 203] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 204] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 205] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 206] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 207] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 208] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 209] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 210] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 211] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 212] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 213] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 214] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 215] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 216] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 217] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 217] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 218] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 218] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 219] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 219] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 220] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 221] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 222] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 223] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 224] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 225] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 226] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 227] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 228] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 229] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 230] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 231] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 232] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 233] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 234] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 235] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 236] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 237] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 238] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 239] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 240] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 241] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 242] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 243] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 244] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 245] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 246] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 247] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 248] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 249] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 250] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 251] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 252] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 253] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 254] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 255] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 256] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 257] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 258] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 259] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 220] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 221] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 222] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 223] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 224] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 225] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 226] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 227] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 228] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 229] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 230] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 231] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 232] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 233] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 234] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 235] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 236] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 237] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 238] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 239] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 240] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 241] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 242] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 243] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 244] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 245] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 246] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 247] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 248] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 249] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 250] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 251] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 252] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 253] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 254] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 255] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 256] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 257] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 258] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 259] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 260] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 260] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 261] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 261] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 262] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 263] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 264] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 265] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 266] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 267] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 268] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 269] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 270] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 271] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 262] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 263] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 264] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 265] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 266] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 267] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 268] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 269] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 270] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 271] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 272] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 272] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 273] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 274] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 275] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 273] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 274] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 275] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 276] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 276] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 277] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 278] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 277] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 278] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 279] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 279] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 280] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 280] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 281] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 282] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 283] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 284] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 281] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 282] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 283] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 284] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 285] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 285] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 286] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 287] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 288] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 286] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 287] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 288] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 289] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 289] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 290] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 290] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 291] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 291] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 292] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 293] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 294] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 295] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 296] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 297] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 298] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 299] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 300] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 301] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 302] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 303] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 304] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 305] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 306] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 307] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 308] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 309] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 310] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 311] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 312] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 292] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 293] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 294] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 295] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 296] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 297] = "JSDocVariadicType"; + // https://jsdoc.app/about-namepaths.html + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 298] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 299] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 300] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 301] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 302] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 303] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 304] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 305] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 306] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 307] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 308] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 309] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 310] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 311] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 312] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 313] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 314] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 313] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 315] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 314] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 315] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 316] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 317] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 318] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 316] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 317] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 318] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 319] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 320] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 319] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 321] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 60] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 72] = "LastAssignment"; @@ -3096,15 +3163,15 @@ var ts; SyntaxKind[SyntaxKind["FirstReservedWord"] = 74] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 109] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 74] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 148] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 149] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 110] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 118] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 164] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 184] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 165] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 185] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 72] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 148] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 149] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -3113,13 +3180,13 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 72] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 149] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 289] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 312] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 300] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 312] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 150] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 290] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 314] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 302] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 314] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 119] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 148] = "LastContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 149] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -3243,6 +3310,8 @@ var ts; /* @internal */ TokenFlags[TokenFlags["ContainsSeparator"] = 512] = "ContainsSeparator"; /* @internal */ + TokenFlags[TokenFlags["UnicodeEscape"] = 1024] = "UnicodeEscape"; + /* @internal */ TokenFlags[TokenFlags["BinaryOrOctalSpecifier"] = 384] = "BinaryOrOctalSpecifier"; /* @internal */ TokenFlags[TokenFlags["NumericLiteralFlags"] = 1008] = "NumericLiteralFlags"; @@ -3273,6 +3342,13 @@ var ts; return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + /*@internal*/ + var RefFileKind; + (function (RefFileKind) { + RefFileKind[RefFileKind["Import"] = 0] = "Import"; + RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile"; + RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective"; + })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {})); /* @internal */ var StructureIsReused; (function (StructureIsReused) { @@ -3293,6 +3369,8 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; // When build skipped because passed in project is invalid ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped"; + // When build is skipped because project references form cycle + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); /* @internal */ var UnionReduction; @@ -3358,7 +3436,6 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 4096] = "UseTypeOfFunction"; TypeFormatFlags[TypeFormatFlags["OmitParameterModifiers"] = 8192] = "OmitParameterModifiers"; TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; - // even though `T` can't be accessed in the current scope. // Error Handling TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; // TypeFormatFlags exclusive @@ -3413,22 +3490,33 @@ var ts; /* @internal */ var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { + // The TypeReferenceNode could not be resolved. + // The type name should be emitted using a safe fallback. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; - // should be emitted using a safe fallback. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a type with a constructor // function that can be reached at runtime (e.g. a `class` // declaration or a `var` declaration for the static side // of a type, such as the global `Promise` type in lib.d.ts). + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a Void-like, Nullable, or Never type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType"; + // The TypeReferenceNode resolves to a Number-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + // The TypeReferenceNode resolves to a BigInt-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType"; + // The TypeReferenceNode resolves to a String-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType"; + // The TypeReferenceNode resolves to a Boolean-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType"; + // The TypeReferenceNode resolves to an Array-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType"; + // The TypeReferenceNode resolves to the ESSymbol type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType"; + // The TypeReferenceNode resolved to the global Promise constructor symbol. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise"; + // The TypeReferenceNode resolves to a Function type or a type with call signatures. TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature"; - // with call signatures. + // The TypeReferenceNode resolves to any other type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var SymbolFlags; @@ -3466,32 +3554,32 @@ var ts; SymbolFlags[SymbolFlags["All"] = 67108863] = "All"; SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; - SymbolFlags[SymbolFlags["Value"] = 67220415] = "Value"; - SymbolFlags[SymbolFlags["Type"] = 67897832] = "Type"; + SymbolFlags[SymbolFlags["Value"] = 111551] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 788968] = "Type"; SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; // Variables can be redeclared, but can not redeclare a block-scoped declaration with the // same name, or any other value that is not a variable, e.g. ValueModule or Class - SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 67220414] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 111550] = "FunctionScopedVariableExcludes"; // Block-scoped declarations are not allowed to be re-declared // they can not merge with anything in the value space - SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 67220415] = "BlockScopedVariableExcludes"; - SymbolFlags[SymbolFlags["ParameterExcludes"] = 67220415] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 111551] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 111551] = "ParameterExcludes"; SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; - SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 68008959] = "EnumMemberExcludes"; - SymbolFlags[SymbolFlags["FunctionExcludes"] = 67219887] = "FunctionExcludes"; - SymbolFlags[SymbolFlags["ClassExcludes"] = 68008383] = "ClassExcludes"; - SymbolFlags[SymbolFlags["InterfaceExcludes"] = 67897736] = "InterfaceExcludes"; - SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 68008191] = "RegularEnumExcludes"; - SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 68008831] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 110991] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899503] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 788872] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 110735] = "ValueModuleExcludes"; SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; - SymbolFlags[SymbolFlags["MethodExcludes"] = 67212223] = "MethodExcludes"; - SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 67154879] = "GetAccessorExcludes"; - SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 67187647] = "SetAccessorExcludes"; - SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 67635688] = "TypeParameterExcludes"; - SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 67897832] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 103359] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 46015] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 78783] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 526824] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 788968] = "TypeAliasExcludes"; SymbolFlags[SymbolFlags["AliasExcludes"] = 2097152] = "AliasExcludes"; SymbolFlags[SymbolFlags["ModuleMember"] = 2623475] = "ModuleMember"; SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; @@ -3610,6 +3698,7 @@ var ts; TypeFlags[TypeFlags["Conditional"] = 16777216] = "Conditional"; TypeFlags[TypeFlags["Substitution"] = 33554432] = "Substitution"; TypeFlags[TypeFlags["NonPrimitive"] = 67108864] = "NonPrimitive"; + TypeFlags[TypeFlags["StructuralTag"] = 134217728] = "StructuralTag"; /* @internal */ TypeFlags[TypeFlags["AnyOrUnknown"] = 3] = "AnyOrUnknown"; /* @internal */ @@ -3636,22 +3725,22 @@ var ts; /* @internal */ TypeFlags[TypeFlags["DisjointDomains"] = 67238908] = "DisjointDomains"; TypeFlags[TypeFlags["UnionOrIntersection"] = 3145728] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 3670016] = "StructuredType"; + TypeFlags[TypeFlags["StructuredType"] = 137887744] = "StructuredType"; TypeFlags[TypeFlags["TypeVariable"] = 8650752] = "TypeVariable"; TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 58982400] = "InstantiableNonPrimitive"; TypeFlags[TypeFlags["InstantiablePrimitive"] = 4194304] = "InstantiablePrimitive"; TypeFlags[TypeFlags["Instantiable"] = 63176704] = "Instantiable"; - TypeFlags[TypeFlags["StructuredOrInstantiable"] = 66846720] = "StructuredOrInstantiable"; + TypeFlags[TypeFlags["StructuredOrInstantiable"] = 201064448] = "StructuredOrInstantiable"; /* @internal */ TypeFlags[TypeFlags["ObjectFlagsType"] = 3899392] = "ObjectFlagsType"; /* @internal */ TypeFlags[TypeFlags["Simplifiable"] = 25165824] = "Simplifiable"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - TypeFlags[TypeFlags["Narrowable"] = 133970943] = "Narrowable"; + TypeFlags[TypeFlags["Narrowable"] = 268188671] = "Narrowable"; TypeFlags[TypeFlags["NotUnionOrUnit"] = 67637251] = "NotUnionOrUnit"; /* @internal */ - TypeFlags[TypeFlags["NotPrimitiveUnion"] = 66994211] = "NotPrimitiveUnion"; + TypeFlags[TypeFlags["NotPrimitiveUnion"] = 201211939] = "NotPrimitiveUnion"; // The following flags are aggregated during union and intersection type construction /* @internal */ TypeFlags[TypeFlags["IncludesMask"] = 68943871] = "IncludesMask"; @@ -3741,7 +3830,9 @@ var ts; InferencePriority[InferencePriority["LiteralKeyof"] = 32] = "LiteralKeyof"; InferencePriority[InferencePriority["NoConstraints"] = 64] = "NoConstraints"; InferencePriority[InferencePriority["AlwaysStrict"] = 128] = "AlwaysStrict"; + InferencePriority[InferencePriority["MaxValue"] = 256] = "MaxValue"; InferencePriority[InferencePriority["PriorityImpliesCombination"] = 56] = "PriorityImpliesCombination"; + InferencePriority[InferencePriority["Circularity"] = -1] = "Circularity"; })(InferencePriority = ts.InferencePriority || (ts.InferencePriority = {})); /* @internal */ var InferenceFlags; @@ -3819,6 +3910,9 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; + // NOTE: ES module kinds should be contiguous to more easily check whether a module kind is *any* ES module kind. + // Non-ES module kinds should not come between ES2015 (the earliest ES module kind) and ESNext (the last ES + // module kind). ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); @@ -4403,7 +4497,7 @@ var ts; function getCustomPollingBasedLevels(baseVariable, defaultLevels) { var customLevels = getCustomLevels(baseVariable); return (pollingIntervalChanged || customLevels) && - createPollingIntervalBasedLevels(customLevels ? __assign({}, defaultLevels, customLevels) : defaultLevels); + createPollingIntervalBasedLevels(customLevels ? __assign(__assign({}, defaultLevels), customLevels) : defaultLevels); } } ts.setCustomPollingValues = setCustomPollingValues; @@ -4557,6 +4651,38 @@ var ts; } } ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile; + /* @internal */ + function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) { + var cache = ts.createMap(); + var callbacksCache = ts.createMultiMap(); + var toCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); + return function (fileName, callback, pollingInterval) { + var path = toCanonicalFileName(fileName); + var existing = cache.get(path); + if (existing) { + existing.refCount++; + } + else { + cache.set(path, { + watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval), + refCount: 1 + }); + } + callbacksCache.add(path, callback); + return { + close: function () { + var watcher = ts.Debug.assertDefined(cache.get(path)); + callbacksCache.remove(path, callback); + watcher.refCount--; + if (watcher.refCount) + return; + cache.delete(path); + ts.closeFileWatcherOf(watcher); + } + }; + }; + } + ts.createSingleFileWatcherPerName = createSingleFileWatcherPerName; /** * Returns true if file status changed */ @@ -4583,6 +4709,8 @@ var ts; ts.getFileWatcherEventKind = getFileWatcherEventKind; /*@internal*/ ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"]; + /*@internal*/ + ts.sysLog = ts.noop; // eslint-disable-line prefer-const /** * Watch the directory recursively using host provided method to watch child directories * that means if this is recursive watcher, watch the children directories as well @@ -4703,6 +4831,7 @@ var ts; } ts.getNodeMajorVersion = getNodeMajorVersion; // TODO: GH#18217 this is used as if it's certainly defined in many places. + // eslint-disable-next-line prefer-const ts.sys = (function () { // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual // byte order mark from the specified encoding. Using any other byte order mark does @@ -4723,6 +4852,7 @@ var ts; 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 FileSystemEntryKind; @@ -4733,6 +4863,7 @@ var ts; var useNonPollingWatchers = process.env.TSC_NONPOLLING_WATCHER; var tscWatchFile = process.env.TSC_WATCHFILE; var tscWatchDirectory = process.env.TSC_WATCHDIRECTORY; + var fsWatchFile = createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames); var dynamicPollingWatchFile; var nodeSystem = { args: process.argv.slice(2), @@ -4869,7 +5000,7 @@ var ts; return useNonPollingWatchers ? createNonPollingWatchFile() : // Default to do not use polling interval as it is before this experiment branch - function (fileName, callback) { return fsWatchFile(fileName, callback); }; + function (fileName, callback) { return fsWatchFile(fileName, callback, /*pollingInterval*/ undefined); }; } function getWatchDirectory() { // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows @@ -4943,7 +5074,7 @@ var ts; return watcher; } } - function fsWatchFile(fileName, callback, pollingInterval) { + function fsWatchFileWorker(fileName, callback, pollingInterval) { _fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged); var eventKind; return { @@ -5001,6 +5132,12 @@ var ts; } function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingWatchFile, pollingInterval) { var options; + var lastDirectoryPartWithDirectorySeparator; + var lastDirectoryPart; + if (isLinuxOrMacOs) { + lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator)); + lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length); + } /** Watcher for the file system entry depending on whether it is missing or present */ var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry() : @@ -5017,6 +5154,7 @@ var ts; * @param createWatcher */ function invokeCallbackAndUpdateWatcher(createWatcher) { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); // Call the callback for current directory callback("rename", ""); // If watcher is not closed, update it @@ -5041,7 +5179,9 @@ var ts; } } try { - var presentWatcher = _fs.watch(fileOrDirectory, options, callback); + var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ? + callbackChangingToMissingFileSystemEntry : + callback); // Watch the missing file or directory or error presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); }); return presentWatcher; @@ -5053,11 +5193,23 @@ var ts; return watchPresentFileSystemEntryWithFsWatchFile(); } } + function callbackChangingToMissingFileSystemEntry(event, relativeName) { + // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations + // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path + return event === "rename" && + (!relativeName || + relativeName === lastDirectoryPart || + relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) && + !fileSystemEntryExists(fileOrDirectory, entryKind) ? + invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) : + callback(event, relativeName); + } /** * Watch the file or directory using fs.watchFile since fs.watch threw exception * Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point */ function watchPresentFileSystemEntryWithFsWatchFile() { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile"); return fallbackPollingWatchFile(fileOrDirectory, createFileWatcherCallback(callback), pollingInterval); } /** @@ -5090,7 +5242,7 @@ var ts; function createWatchDirectoryUsing(fsWatchFile) { return function (directoryName, callback) { return fsWatchFile(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium); }; } - function readFile(fileName, _encoding) { + function readFileWorker(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -5118,7 +5270,14 @@ var ts; // Default is UTF-8 with no byte order mark return buffer.toString("utf8"); } + function readFile(fileName, _encoding) { + ts.perfLogger.logStartReadFile(fileName); + var file = readFileWorker(fileName, _encoding); + ts.perfLogger.logStopReadFile(); + return file; + } function writeFile(fileName, data, writeByteOrderMark) { + ts.perfLogger.logEvent("WriteFile: " + fileName); // If a BOM is required, emit one if (writeByteOrderMark) { data = byteOrderMarkIndicator + data; @@ -5135,6 +5294,7 @@ var ts; } } function getAccessibleFileSystemEntries(path) { + ts.perfLogger.logEvent("ReadDir: " + (path || ".")); try { var entries = _fs.readdirSync(path || ".").sort(); var files = []; @@ -5190,6 +5350,7 @@ var ts; return fileSystemEntryExists(path, 1 /* Directory */); } function getDirectories(path) { + ts.perfLogger.logEvent("ReadDir: " + path); return ts.filter(_fs.readdirSync(path), function (dir) { return fileSystemEntryExists(ts.combinePaths(path, dir), 1 /* Directory */); }); } function realpath(path) { @@ -5317,7 +5478,6 @@ var ts; function diag(code, category, key, message, reportsUnnecessary) { return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary }; } - // tslint:disable-next-line variable-name ts.Diagnostics = { Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), @@ -5380,7 +5540,6 @@ var ts; A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), - An_accessor_cannot_be_declared_in_an_ambient_context: diag(1086, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_declared_in_an_ambient_context_1086", "An accessor cannot be declared in an ambient context."), _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), @@ -5435,7 +5594,6 @@ var ts; Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: diag(1150, ts.DiagnosticCategory.Error, "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", "'new T[]' cannot be used to create an array. Use 'new Array()' instead."), const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), @@ -5533,6 +5691,7 @@ var ts; 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."), Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), 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."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -5565,7 +5724,7 @@ var ts; Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), - The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), @@ -5579,6 +5738,7 @@ var ts; readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), + An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), @@ -6359,6 +6519,8 @@ var ts; Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2: diag(6381, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381", "Project '{0}' is out of date because output for it was generated with version '{1}' that differs with current version '{2}'"), + Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), + Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), 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."), @@ -6474,6 +6636,7 @@ var ts; require_call_may_be_converted_to_an_import: diag(80005, ts.DiagnosticCategory.Suggestion, "require_call_may_be_converted_to_an_import_80005", "'require' call may be converted to an import."), This_may_be_converted_to_an_async_function: diag(80006, ts.DiagnosticCategory.Suggestion, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."), await_has_no_effect_on_the_type_of_this_expression: diag(80007, ts.DiagnosticCategory.Suggestion, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."), + Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, ts.DiagnosticCategory.Suggestion, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."), Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"), Make_super_call_the_first_statement_in_the_constructor: diag(90002, ts.DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"), Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"), @@ -6591,6 +6754,12 @@ var ts; Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"), Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"), Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"), + Enable_the_jsx_flag_in_your_configuration_file: diag(95088, ts.DiagnosticCategory.Message, "Enable_the_jsx_flag_in_your_configuration_file_95088", "Enable the '--jsx' flag in your configuration file"), + Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"), + Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"), + Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"), + Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"), + Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"), 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?"), @@ -6685,10 +6854,11 @@ var ts; _a.yield = 118 /* YieldKeyword */, _a.async = 122 /* AsyncKeyword */, _a.await = 123 /* AwaitKeyword */, - _a.of = 148 /* OfKeyword */, + _a.of = 149 /* OfKeyword */, + _a.tag = 148 /* TagKeyword */, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 28 /* LessThanToken */, ">": 30 /* GreaterThanToken */, "<=": 31 /* LessThanEqualsToken */, ">=": 32 /* GreaterThanEqualsToken */, "==": 33 /* EqualsEqualsToken */, "!=": 34 /* ExclamationEqualsToken */, "===": 35 /* EqualsEqualsEqualsToken */, "!==": 36 /* ExclamationEqualsEqualsToken */, "=>": 37 /* EqualsGreaterThanToken */, "+": 38 /* PlusToken */, "-": 39 /* MinusToken */, "**": 41 /* AsteriskAsteriskToken */, "*": 40 /* AsteriskToken */, "/": 42 /* SlashToken */, "%": 43 /* PercentToken */, "++": 44 /* PlusPlusToken */, "--": 45 /* MinusMinusToken */, "<<": 46 /* LessThanLessThanToken */, ">": 47 /* GreaterThanGreaterThanToken */, ">>>": 48 /* GreaterThanGreaterThanGreaterThanToken */, "&": 49 /* AmpersandToken */, "|": 50 /* BarToken */, "^": 51 /* CaretToken */, "!": 52 /* ExclamationToken */, "~": 53 /* TildeToken */, "&&": 54 /* AmpersandAmpersandToken */, "||": 55 /* BarBarToken */, "?": 56 /* QuestionToken */, ":": 57 /* ColonToken */, "=": 60 /* EqualsToken */, "+=": 61 /* PlusEqualsToken */, "-=": 62 /* MinusEqualsToken */, "*=": 63 /* AsteriskEqualsToken */, "**=": 64 /* AsteriskAsteriskEqualsToken */, "/=": 65 /* SlashEqualsToken */, "%=": 66 /* PercentEqualsToken */, "<<=": 67 /* LessThanLessThanEqualsToken */, ">>=": 68 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 70 /* AmpersandEqualsToken */, "|=": 71 /* BarEqualsToken */, "^=": 72 /* CaretEqualsToken */, "@": 58 /* AtToken */, "`": 59 /* BacktickToken */ })); + var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 28 /* LessThanToken */, ">": 30 /* GreaterThanToken */, "<=": 31 /* LessThanEqualsToken */, ">=": 32 /* GreaterThanEqualsToken */, "==": 33 /* EqualsEqualsToken */, "!=": 34 /* ExclamationEqualsToken */, "===": 35 /* EqualsEqualsEqualsToken */, "!==": 36 /* ExclamationEqualsEqualsToken */, "=>": 37 /* EqualsGreaterThanToken */, "+": 38 /* PlusToken */, "-": 39 /* MinusToken */, "**": 41 /* AsteriskAsteriskToken */, "*": 40 /* AsteriskToken */, "/": 42 /* SlashToken */, "%": 43 /* PercentToken */, "++": 44 /* PlusPlusToken */, "--": 45 /* MinusMinusToken */, "<<": 46 /* LessThanLessThanToken */, ">": 47 /* GreaterThanGreaterThanToken */, ">>>": 48 /* GreaterThanGreaterThanGreaterThanToken */, "&": 49 /* AmpersandToken */, "|": 50 /* BarToken */, "^": 51 /* CaretToken */, "!": 52 /* ExclamationToken */, "~": 53 /* TildeToken */, "&&": 54 /* AmpersandAmpersandToken */, "||": 55 /* BarBarToken */, "?": 56 /* QuestionToken */, ":": 57 /* ColonToken */, "=": 60 /* EqualsToken */, "+=": 61 /* PlusEqualsToken */, "-=": 62 /* MinusEqualsToken */, "*=": 63 /* AsteriskEqualsToken */, "**=": 64 /* AsteriskAsteriskEqualsToken */, "/=": 65 /* SlashEqualsToken */, "%=": 66 /* PercentEqualsToken */, "<<=": 67 /* LessThanLessThanEqualsToken */, ">>=": 68 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 70 /* AmpersandEqualsToken */, "|=": 71 /* BarEqualsToken */, "^=": 72 /* CaretEqualsToken */, "@": 58 /* AtToken */, "`": 59 /* BacktickToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -6735,6 +6905,14 @@ var ts; */ var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + /** + * Generated by scripts/regenerate-unicode-identifier-parts.js on node v12.4.0 with unicode 12.1 + * based on http://www.unicode.org/reports/tr31/ and https://www.ecma-international.org/ecma-262/6.0/#sec-names-and-keywords + * unicodeESNextIdentifierStart corresponds to the ID_Start and Other_ID_Start property, and + * unicodeESNextIdentifierPart corresponds to ID_Continue, Other_ID_Continue, plus ID_Start and Other_ID_Start + */ + var unicodeESNextIdentifierStart = [65, 90, 97, 122, 170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2809, 2809, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101]; + var unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2208, 2228, 2230, 2237, 2259, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3328, 3331, 3333, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7673, 7675, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43047, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69376, 69404, 69415, 69415, 69424, 69456, 69600, 69622, 69632, 69702, 69734, 69743, 69759, 69818, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69958, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70096, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70206, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70751, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71680, 71738, 71840, 71913, 71935, 71935, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123584, 123641, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101, 917760, 917999]; function lookupInUnicodeMap(code, map) { // Bail out quickly if it couldn't possibly be in the map. if (code < map[0]) { @@ -6761,15 +6939,17 @@ var ts; return false; } /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierStart) : - lookupInUnicodeMap(code, unicodeES3IdentifierStart); + return languageVersion >= 2 /* ES2015 */ ? + lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : + languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierPart) : - lookupInUnicodeMap(code, unicodeES3IdentifierPart); + return languageVersion >= 2 /* ES2015 */ ? + lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : + languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { var result = []; @@ -6942,6 +7122,7 @@ var ts; case 32 /* space */: case 47 /* slash */: // starts of normal trivia + // falls through case 60 /* lessThan */: case 124 /* bar */: case 61 /* equals */: @@ -7265,11 +7446,12 @@ var ts; ts.isIdentifierPart = isIdentifierPart; /* @internal */ function isIdentifierText(name, languageVersion) { - if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { + var ch = codePointAt(name, 0); + if (!isIdentifierStart(ch, languageVersion)) { return false; } - for (var i = 1; i < name.length; i++) { - if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { + for (var i = charSize(ch); i < name.length; i += charSize(ch)) { + if (!isIdentifierPart(ch = codePointAt(name, i), languageVersion)) { return false; } } @@ -7293,13 +7475,14 @@ var ts; var tokenFlags; var inJSDocType = 0; setText(text, start, length); - return { + var scanner = { getStartPos: function () { return startPos; }, getTextPos: function () { return pos; }, getToken: function () { return token; }, getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, isIdentifier: function () { return token === 73 /* Identifier */ || token > 109 /* LastReservedWord */; }, @@ -7327,6 +7510,15 @@ var ts; lookAhead: lookAhead, scanRange: scanRange, }; + if (ts.Debug.isDebugging) { + Object.defineProperty(scanner, "__debugShowCurrentPositionInText", { + get: function () { + var text = scanner.getText(); + return text.slice(0, scanner.getStartPos()) + "║" + text.slice(scanner.getStartPos()); + }, + }); + } + return scanner; function error(message, errPos, length) { if (errPos === void 0) { errPos = pos; } if (onError) { @@ -7426,7 +7618,7 @@ var ts; } } function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) { - if (!isIdentifierStart(text.charCodeAt(pos), languageVersion)) { + if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) { return; } var identifierStart = pos; @@ -7634,6 +7826,7 @@ var ts; pos++; return scanExtendedUnicodeEscape(); } + tokenFlags |= 1024 /* UnicodeEscape */; // '\uDDDD' return scanHexadecimalEscape(/*numDigits*/ 4); case 120 /* x */: @@ -7716,21 +7909,41 @@ var ts; } return -1; } + function peekExtendedUnicodeEscape() { + if (languageVersion >= 2 /* ES2015 */ && codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) { + var start_2 = pos; + pos += 3; + var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); + var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; + pos = start_2; + return escapedValue; + } + return -1; + } function scanIdentifierParts() { var result = ""; var start = pos; while (pos < end) { - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); if (isIdentifierPart(ch, languageVersion)) { - pos++; + pos += charSize(ch); } else if (ch === 92 /* backslash */) { + ch = peekExtendedUnicodeEscape(); + if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + result += scanExtendedUnicodeEscape(); + start = pos; + continue; + } ch = peekUnicodeEscape(); if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } + tokenFlags |= 1024 /* UnicodeEscape */; result += text.substring(start, pos); - result += String.fromCharCode(ch); + result += utf16EncodeAsString(ch); // Valid Unicode escape is always six characters pos += 6; start = pos; @@ -7818,14 +8031,14 @@ var ts; function scan() { var _a; startPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; var asteriskSeen = false; while (true) { tokenPos = pos; if (pos >= end) { return token = 1 /* EndOfFileToken */; } - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); // Special handling for shebang if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); @@ -8190,9 +8403,17 @@ var ts; pos++; return token = 58 /* AtToken */; case 92 /* backslash */: + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; + tokenFlags |= 1024 /* UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } @@ -8201,9 +8422,9 @@ var ts; return token = 0 /* Unknown */; default: if (isIdentifierStart(ch, languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; + pos += charSize(ch); + while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) + pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); if (ch === 92 /* backslash */) { tokenValue += scanIdentifierParts(); @@ -8211,16 +8432,16 @@ var ts; return token = getIdentifierToken(); } else if (isWhiteSpaceSingleLine(ch)) { - pos++; + pos += charSize(ch); continue; } else if (isLineBreak(ch)) { tokenFlags |= 1 /* PrecedingLineBreak */; - pos++; + pos += charSize(ch); continue; } error(ts.Diagnostics.Invalid_character); - pos++; + pos += charSize(ch); return token = 0 /* Unknown */; } } @@ -8337,7 +8558,7 @@ var ts; // First non-whitespace character on this line. var firstNonWhitespace = 0; // These initial values are special because the first line is: - // firstNonWhitespace = 0 to indicate that we want leading whitspace, + // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { char = text.charCodeAt(pos); if (char === 123 /* openBrace */) { @@ -8371,17 +8592,22 @@ var ts; // they allow dashes function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { - var firstCharPosition = pos; + // An identifier or keyword has already been parsed - check for a `-` and then append it and everything after it to the token + // Do note that this means that `scanJsxIdentifier` effectively _mutates_ the visible token without advancing to a new token + // Any caller should be expecting this behavior and should only read the pos or token value after calling it. while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { + if (ch === 45 /* minus */) { + tokenValue += "-"; pos++; + continue; } - else { + var oldPos = pos; + tokenValue += scanIdentifierParts(); // reuse `scanIdentifierParts` so unicode escapes are handled + if (pos === oldPos) { break; } } - tokenValue += text.substring(firstCharPosition, pos); } return token; } @@ -8399,12 +8625,12 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; if (pos >= end) { return token = 1 /* EndOfFileToken */; } - var ch = text.charCodeAt(pos); - pos++; + var ch = codePointAt(text, pos); + pos += charSize(ch); switch (ch) { case 9 /* tab */: case 11 /* verticalTab */: @@ -8442,12 +8668,33 @@ var ts; return token = 24 /* DotToken */; case 96 /* backtick */: return token = 59 /* BacktickToken */; - } - if (isIdentifierStart(ch, 99 /* Latest */)) { - while (isIdentifierPart(text.charCodeAt(pos), 99 /* Latest */) && pos < end) { + case 92 /* backslash */: + pos--; + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } + var cookedChar = peekUnicodeEscape(); + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + pos += 6; + tokenFlags |= 1024 /* UnicodeEscape */; + tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); + return token = getIdentifierToken(); + } pos++; - } + return token = 0 /* Unknown */; + } + if (isIdentifierStart(ch, languageVersion)) { + var char = ch; + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) + pos += charSize(char); tokenValue = text.substring(tokenPos, pos); + if (char === 92 /* backslash */) { + tokenValue += scanIdentifierParts(); + } return token = getIdentifierToken(); } else { @@ -8523,13 +8770,40 @@ var ts; tokenPos = textPos; token = 0 /* Unknown */; tokenValue = undefined; - tokenFlags = 0; + tokenFlags = 0 /* None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; } } ts.createScanner = createScanner; + /* @internal */ + var codePointAt = String.prototype.codePointAt ? function (s, i) { return s.codePointAt(i); } : function codePointAt(str, i) { + // from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt + var size = str.length; + // Account for out-of-bounds indices: + if (i < 0 || i >= size) { + return undefined; // String.codePointAt returns `undefined` for OOB indexes + } + // Get the first code unit + var first = str.charCodeAt(i); + // check if it’s the start of a surrogate pair + if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) { // high surrogate and there is a next code unit + var second = str.charCodeAt(i + 1); + if (second >= 0xDC00 && second <= 0xDFFF) { // low surrogate + // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + } + } + return first; + }; + /* @internal */ + function charSize(ch) { + if (ch >= 0x10000) { + return 2; + } + return 1; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -8696,7 +8970,7 @@ var ts; } ts.copyEntries = copyEntries; function arrayToSet(array, makeKey) { - return ts.arrayToMap(array, makeKey || (function (s) { return s; }), function () { return true; }); + return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue); } ts.arrayToSet = arrayToSet; function cloneMap(map) { @@ -8805,7 +9079,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 285 /* SourceFile */) { + while (node && node.kind !== 286 /* SourceFile */) { node = node.parent; } return node; @@ -8813,11 +9087,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 220 /* Block */: + case 248 /* CaseBlock */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: return true; } return false; @@ -8902,7 +9176,7 @@ var ts; break; } } - to.splice.apply(to, [statementIndex, 0].concat(from)); + to.splice.apply(to, __spreadArrays([statementIndex, 0], from)); return to; } function insertStatementAfterPrologue(to, statement, isPrologueDirective) { @@ -8985,7 +9259,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 313 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 315 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -9004,7 +9278,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 289 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 290 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -9050,6 +9324,8 @@ var ts; ts.isBigIntLiteral(node))) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } + // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text + // had to include a backslash: `not \${a} substitution`. var escapeText = neverAsciiEscape || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; // If we can't reach the original source text, use the canonical form if it's a number, // or a (possibly escaped) quoted form of the original text if it's string-like. @@ -9062,15 +9338,21 @@ var ts; return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; } case 14 /* NoSubstitutionTemplateLiteral */: - return "`" + escapeText(node.text, 96 /* backtick */) + "`"; case 15 /* TemplateHead */: - // tslint:disable-next-line no-invalid-template-strings - return "`" + escapeText(node.text, 96 /* backtick */) + "${"; case 16 /* TemplateMiddle */: - // tslint:disable-next-line no-invalid-template-strings - return "}" + escapeText(node.text, 96 /* backtick */) + "${"; case 17 /* TemplateTail */: - return "}" + escapeText(node.text, 96 /* backtick */) + "`"; + var rawText = node.rawText || escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); + switch (node.kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + return "`" + rawText + "`"; + case 15 /* TemplateHead */: + return "`" + rawText + "${"; + case 16 /* TemplateMiddle */: + return "}" + rawText + "${"; + case 17 /* TemplateTail */: + return "}" + rawText + "`"; + } + break; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 13 /* RegularExpressionLiteral */: @@ -9096,7 +9378,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 238 /* VariableDeclaration */ && node.parent.kind === 275 /* CatchClause */; + return node.kind === 239 /* VariableDeclaration */ && node.parent.kind === 276 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -9128,11 +9410,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 === 245 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 246 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 285 /* SourceFile */ || - node.kind === 245 /* ModuleDeclaration */ || + return node.kind === 286 /* SourceFile */ || + node.kind === 246 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -9149,9 +9431,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: return ts.isExternalModule(node.parent); - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -9165,24 +9447,61 @@ var ts; return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS) && !!node.commonJsModuleIndicator); } ts.isEffectiveExternalModule = isEffectiveExternalModule; + /** + * Returns whether the source file will be treated as if it were in strict mode at runtime. + */ + function isEffectiveStrictModeSourceFile(node, compilerOptions) { + // We can only verify strict mode for JS/TS files + switch (node.scriptKind) { + case 1 /* JS */: + case 3 /* TS */: + case 2 /* JSX */: + case 4 /* TSX */: + break; + default: + return false; + } + // Strict mode does not matter for declaration files. + if (node.isDeclarationFile) { + return false; + } + // If `alwaysStrict` is set, then treat the file as strict. + if (ts.getStrictOptionValue(compilerOptions, "alwaysStrict")) { + return true; + } + // Starting with a "use strict" directive indicates the file is strict. + if (ts.startsWithUseStrict(node.statements)) { + return true; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + // ECMAScript Modules are always strict. + if (ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { + return true; + } + // Other modules are strict unless otherwise specified. + return !compilerOptions.noImplicitUseStrict; + } + return false; + } + ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 275 /* CatchClause */: - case 245 /* ModuleDeclaration */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 286 /* SourceFile */: + case 248 /* CaseBlock */: + case 276 /* CatchClause */: + case 246 /* ModuleDeclaration */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return true; - case 219 /* Block */: + case 220 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -9192,9 +9511,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: - case 299 /* JSDocSignature */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 301 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -9204,25 +9523,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 157 /* MethodSignature */: + case 164 /* IndexSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 296 /* JSDocFunctionType */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 312 /* JSDocTemplateTag */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -9232,8 +9551,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: return true; default: return false; @@ -9242,15 +9561,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 220 /* VariableStatement */: - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 221 /* VariableStatement */: + case 242 /* ClassDeclaration */: + case 241 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: return true; default: return false; @@ -9286,7 +9605,7 @@ var ts; case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 151 /* 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"); @@ -9299,9 +9618,9 @@ var ts; switch (name.kind) { case 73 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -9346,7 +9665,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 219 /* Block */) { + if (node.body && node.body.kind === 220 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -9360,7 +9679,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 285 /* SourceFile */: + case 286 /* 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 @@ -9369,25 +9688,25 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 239 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 244 /* TypeAliasDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: errorNode = node.name; break; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -9395,6 +9714,7 @@ var ts; // construct. return getSpanOfTokenAtPosition(sourceFile, node.pos); } + ts.Debug.assert(!ts.isJSDoc(errorNode)); var isMissing = nodeIsMissing(errorNode); var pos = isMissing || ts.isJsxText(node) ? errorNode.pos @@ -9424,7 +9744,7 @@ var ts; } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { @@ -9436,19 +9756,25 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 99 /* SuperKeyword */; + return n.kind === 193 /* CallExpression */ && n.expression.kind === 99 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 93 /* ImportKeyword */; + return n.kind === 193 /* CallExpression */ && n.expression.kind === 93 /* ImportKeyword */; } ts.isImportCall = isImportCall; + function isImportMeta(n) { + return ts.isMetaProperty(n) + && n.keywordToken === 93 /* ImportKeyword */ + && n.name.escapedText === "meta"; + } + ts.isImportMeta = isImportMeta; function isLiteralImportTypeNode(n) { return ts.isImportTypeNode(n) && ts.isLiteralTypeNode(n.argument) && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 222 /* ExpressionStatement */ + return node.kind === 223 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -9457,11 +9783,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 152 /* Parameter */ || - node.kind === 151 /* TypeParameter */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 198 /* ArrowFunction */ || - node.kind === 196 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 153 /* Parameter */ || + node.kind === 152 /* TypeParameter */ || + node.kind === 198 /* FunctionExpression */ || + node.kind === 199 /* ArrowFunction */ || + node.kind === 197 /* ParenthesizedExpression */) ? 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 '/**/' @@ -9477,7 +9803,7 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (164 /* FirstTypeNode */ <= node.kind && node.kind <= 184 /* LastTypeNode */) { + if (165 /* FirstTypeNode */ <= node.kind && node.kind <= 185 /* LastTypeNode */) { return true; } switch (node.kind) { @@ -9493,32 +9819,32 @@ var ts; case 133 /* NeverKeyword */: return true; case 107 /* VoidKeyword */: - return node.parent.kind !== 201 /* VoidExpression */; - case 212 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 202 /* VoidExpression */; + case 213 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 151 /* TypeParameter */: - return node.parent.kind === 182 /* MappedType */ || node.parent.kind === 177 /* InferType */; + case 152 /* TypeParameter */: + return node.parent.kind === 183 /* MappedType */ || node.parent.kind === 178 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 73 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 150 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 191 /* 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 === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */ || node.kind === 190 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 73 /* Identifier */ || node.kind === 150 /* QualifiedName */ || node.kind === 191 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 149 /* QualifiedName */: - case 190 /* PropertyAccessExpression */: + case 150 /* QualifiedName */: + case 191 /* PropertyAccessExpression */: case 101 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 168 /* TypeQuery */) { + if (parent.kind === 169 /* TypeQuery */) { return false; } - if (parent.kind === 184 /* ImportType */) { + if (parent.kind === 185 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -9527,40 +9853,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 (164 /* FirstTypeNode */ <= parent.kind && parent.kind <= 184 /* LastTypeNode */) { + if (165 /* FirstTypeNode */ <= parent.kind && parent.kind <= 185 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return node === parent.constraint; - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return node === parent.constraint; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 153 /* Parameter */: + case 239 /* VariableDeclaration */: return node === parent.type; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return node === parent.type; - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: return node === parent.type; - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: return node === parent.type; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -9585,23 +9911,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitor(node); - case 247 /* CaseBlock */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 248 /* CaseBlock */: + case 220 /* Block */: + case 224 /* IfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 233 /* WithStatement */: + case 234 /* SwitchStatement */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: + case 235 /* LabeledStatement */: + case 237 /* TryStatement */: + case 276 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -9611,26 +9937,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 245 /* EnumDeclaration */: + case 243 /* InterfaceDeclaration */: + case 246 /* ModuleDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 151 /* 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); @@ -9653,10 +9979,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 170 /* ArrayType */) { + if (node && node.kind === 171 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 165 /* TypeReference */) { + else if (node && node.kind === 166 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9666,12 +9992,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 169 /* TypeLiteral */: + case 243 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 170 /* TypeLiteral */: return node.members; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return node.properties; } } @@ -9679,14 +10005,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 187 /* BindingElement */: - case 279 /* EnumMember */: - case 152 /* Parameter */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 277 /* ShorthandPropertyAssignment */: - case 238 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 280 /* EnumMember */: + case 153 /* Parameter */: + case 277 /* PropertyAssignment */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 278 /* ShorthandPropertyAssignment */: + case 239 /* VariableDeclaration */: return true; } } @@ -9698,8 +10024,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 239 /* VariableDeclarationList */ - && node.parent.parent.kind === 220 /* VariableStatement */; + return node.parent.kind === 240 /* VariableDeclarationList */ + && node.parent.parent.kind === 221 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -9710,13 +10036,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: return true; } return false; @@ -9727,7 +10053,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 234 /* LabeledStatement */) { + if (node.statement.kind !== 235 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -9735,17 +10061,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 219 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 220 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 157 /* MethodDeclaration */ && node.parent.kind === 189 /* ObjectLiteralExpression */; + return node && node.kind === 158 /* MethodDeclaration */ && node.parent.kind === 190 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 157 /* MethodDeclaration */ && - (node.parent.kind === 189 /* ObjectLiteralExpression */ || - node.parent.kind === 210 /* ClassExpression */); + return node.kind === 158 /* MethodDeclaration */ && + (node.parent.kind === 190 /* ObjectLiteralExpression */ || + node.parent.kind === 211 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -9758,7 +10084,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 276 /* PropertyAssignment */) { + if (property.kind === 277 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -9799,14 +10125,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 285 /* SourceFile */); + ts.Debug.assert(node.kind !== 286 /* 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 150 /* ComputedPropertyName */: + case 151 /* 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 @@ -9821,9 +10147,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 153 /* Decorator */: + case 154 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 153 /* 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; @@ -9834,26 +10160,26 @@ var ts; node = node.parent; } break; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 245 /* ModuleDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 244 /* EnumDeclaration */: - case 285 /* SourceFile */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 246 /* ModuleDeclaration */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 245 /* EnumDeclaration */: + case 286 /* SourceFile */: return node; } } @@ -9863,9 +10189,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 159 /* Constructor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: return container; } } @@ -9887,27 +10213,27 @@ var ts; return node; } switch (node.kind) { - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: node = node.parent; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return node; - case 153 /* Decorator */: + case 154 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 153 /* 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; @@ -9923,14 +10249,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 197 /* FunctionExpression */ || func.kind === 198 /* ArrowFunction */) { + if (func.kind === 198 /* FunctionExpression */ || func.kind === 199 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 196 /* ParenthesizedExpression */) { + while (parent.kind === 197 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 192 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 193 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -9946,7 +10272,7 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) + return (kind === 191 /* PropertyAccessExpression */ || kind === 192 /* ElementAccessExpression */) && node.expression.kind === 99 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; @@ -9955,20 +10281,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) + return (kind === 191 /* PropertyAccessExpression */ || kind === 192 /* ElementAccessExpression */) && node.expression.kind === 101 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return node; } return undefined; @@ -9976,10 +10302,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return node.tag; - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -9988,25 +10314,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: // classes are valid targets return true; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 241 /* ClassDeclaration */; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + return parent.kind === 242 /* ClassDeclaration */; + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 158 /* 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 === 241 /* ClassDeclaration */; - case 152 /* Parameter */: + && parent.kind === 242 /* ClassDeclaration */; + case 153 /* 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 === 158 /* Constructor */ - || parent.kind === 157 /* MethodDeclaration */ - || parent.kind === 160 /* SetAccessor */) - && grandparent.kind === 241 /* ClassDeclaration */; + && (parent.kind === 159 /* Constructor */ + || parent.kind === 158 /* MethodDeclaration */ + || parent.kind === 161 /* SetAccessor */) + && grandparent.kind === 242 /* ClassDeclaration */; } return false; } @@ -10022,10 +10348,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 161 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -10034,9 +10360,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 263 /* JsxOpeningElement */ || - parent.kind === 262 /* JsxSelfClosingElement */ || - parent.kind === 264 /* JsxClosingElement */) { + if (parent.kind === 264 /* JsxOpeningElement */ || + parent.kind === 263 /* JsxSelfClosingElement */ || + parent.kind === 265 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -10049,45 +10375,45 @@ var ts; case 103 /* TrueKeyword */: case 88 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 213 /* AsExpression */: - case 195 /* TypeAssertionExpression */: - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 209 /* SpreadElement */: - case 207 /* TemplateExpression */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 195 /* TaggedTemplateExpression */: + case 214 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 215 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: + case 198 /* FunctionExpression */: + case 211 /* ClassExpression */: + case 199 /* ArrowFunction */: + case 202 /* VoidExpression */: + case 200 /* DeleteExpression */: + case 201 /* TypeOfExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: + case 206 /* BinaryExpression */: + case 207 /* ConditionalExpression */: + case 210 /* SpreadElement */: + case 208 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: - case 211 /* OmittedExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 208 /* YieldExpression */: - case 202 /* AwaitExpression */: - case 215 /* MetaProperty */: + case 212 /* OmittedExpression */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 266 /* JsxFragment */: + case 209 /* YieldExpression */: + case 203 /* AwaitExpression */: + case 216 /* MetaProperty */: return true; - case 149 /* QualifiedName */: - while (node.parent.kind === 149 /* QualifiedName */) { + case 150 /* QualifiedName */: + while (node.parent.kind === 150 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node); + return node.parent.kind === 169 /* TypeQuery */ || isJSXTagName(node); case 73 /* Identifier */: - if (node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node)) { + if (node.parent.kind === 169 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through @@ -10104,49 +10430,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 187 /* BindingElement */: + case 239 /* VariableDeclaration */: + case 153 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 280 /* EnumMember */: + case 277 /* PropertyAssignment */: + case 188 /* BindingElement */: return parent.initializer === node; - case 222 /* ExpressionStatement */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 231 /* ReturnStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 235 /* ThrowStatement */: + case 223 /* ExpressionStatement */: + case 224 /* IfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 232 /* ReturnStatement */: + case 233 /* WithStatement */: + case 234 /* SwitchStatement */: + case 273 /* CaseClause */: + case 236 /* ThrowStatement */: return parent.expression === node; - case 226 /* ForStatement */: + case 227 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 240 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 240 /* VariableDeclarationList */) || forInStatement.expression === node; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: return node === parent.expression; - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return node === parent.expression; - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return node === parent.expression; - case 153 /* Decorator */: - case 271 /* JsxExpression */: - case 270 /* JsxSpreadAttribute */: - case 278 /* SpreadAssignment */: + case 154 /* Decorator */: + case 272 /* JsxExpression */: + case 271 /* JsxSpreadAttribute */: + case 279 /* SpreadAssignment */: return true; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -10154,7 +10480,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */; + return node.kind === 250 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 261 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -10163,7 +10489,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 260 /* ExternalModuleReference */; + return node.kind === 250 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 261 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -10195,7 +10521,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 192 /* CallExpression */) { + if (callExpression.kind !== 193 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -10307,11 +10633,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 197 /* FunctionExpression */ || e.kind === 198 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 198 /* FunctionExpression */ || e.kind === 199 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 197 /* FunctionExpression */ || - initializer.kind === 210 /* ClassExpression */ || - initializer.kind === 198 /* ArrowFunction */) { + if (initializer.kind === 198 /* FunctionExpression */ || + initializer.kind === 211 /* ClassExpression */ || + initializer.kind === 199 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -10479,7 +10805,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 222 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 223 /* ExpressionStatement */ && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -10488,7 +10814,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 240 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 241 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -10497,14 +10823,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: return node.parent; - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: return node.parent.parent; - case 192 /* CallExpression */: + case 193 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 183 /* LiteralType */: + case 184 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -10514,12 +10840,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: return node.moduleSpecifier; - case 249 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 260 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 184 /* ImportType */: + case 250 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 261 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 185 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -10528,11 +10854,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return node; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -10540,19 +10866,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 250 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 251 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 152 /* Parameter */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 277 /* ShorthandPropertyAssignment */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 153 /* Parameter */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 278 /* ShorthandPropertyAssignment */: + case 277 /* PropertyAssignment */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -10566,7 +10892,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 311 /* JSDocTypedefTag */ || node.kind === 304 /* JSDocCallbackTag */; + return node.kind === 313 /* JSDocTypedefTag */ || node.kind === 306 /* JSDocCallbackTag */ || node.kind === 307 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10591,12 +10917,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return node.initializer; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return node.initializer; } } @@ -10607,7 +10933,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 245 /* ModuleDeclaration */ + node.body.kind === 246 /* ModuleDeclaration */ ? node.body : undefined; } @@ -10622,11 +10948,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 152 /* Parameter */) { + if (node.kind === 153 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 151 /* TypeParameter */) { + if (node.kind === 152 /* TypeParameter */) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -10637,10 +10963,10 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 276 /* PropertyAssignment */ || - parent.kind === 255 /* ExportAssignment */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 222 /* ExpressionStatement */ && node.kind === 190 /* PropertyAccessExpression */ || + if (parent.kind === 277 /* PropertyAssignment */ || + parent.kind === 256 /* ExportAssignment */ || + parent.kind === 156 /* PropertyDeclaration */ || + parent.kind === 223 /* ExpressionStatement */ && node.kind === 191 /* PropertyAccessExpression */ || getNestedModuleDeclaration(parent) || ts.isBinaryExpression(node) && node.operatorToken.kind === 60 /* EqualsToken */) { return parent; @@ -10701,7 +11027,7 @@ var ts; function getTypeParameterFromJsDoc(node) { var name = node.name.escapedText; var typeParameters = node.parent.parent.parent.typeParameters; - return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); + return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { @@ -10711,7 +11037,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 === 296 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 297 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10724,31 +11050,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 60 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 44 /* PlusPlusToken */ || unaryOperator === 45 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 196 /* ParenthesizedExpression */: - case 188 /* ArrayLiteralExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: + case 189 /* ArrayLiteralExpression */: + case 210 /* SpreadElement */: + case 215 /* NonNullExpression */: node = parent; break; - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -10775,22 +11101,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 219 /* Block */: - case 220 /* VariableStatement */: - case 232 /* WithStatement */: - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 220 /* Block */: + case 221 /* VariableStatement */: + case 233 /* WithStatement */: + case 224 /* IfStatement */: + case 234 /* SwitchStatement */: + case 248 /* CaseBlock */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: + case 235 /* LabeledStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 237 /* TryStatement */: + case 276 /* CatchClause */: return true; } return false; @@ -10807,33 +11133,33 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 178 /* ParenthesizedType */); + return walkUp(node, 179 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 196 /* ParenthesizedExpression */); + return walkUp(node, 197 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 197 /* ParenthesizedExpression */) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 197 /* 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 !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 191 /* PropertyAccessExpression */ && node.kind !== 192 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 199 /* DeleteExpression */; + return node && node.kind === 200 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -10883,7 +11209,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 10 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 150 /* ComputedPropertyName */ && + node.parent.kind === 151 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -10891,32 +11217,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 190 /* PropertyAccessExpression */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 280 /* EnumMember */: + case 277 /* PropertyAssignment */: + case 191 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 149 /* QualifiedName */) { + while (parent.kind === 150 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 168 /* TypeQuery */ || parent.kind === 165 /* TypeReference */; + return parent.kind === 169 /* TypeQuery */ || parent.kind === 166 /* TypeReference */; } return false; - case 187 /* BindingElement */: - case 254 /* ImportSpecifier */: + case 188 /* BindingElement */: + case 255 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 258 /* ExportSpecifier */: - case 268 /* JsxAttribute */: + case 259 /* ExportSpecifier */: + case 269 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -10933,13 +11259,13 @@ var ts; // export default // module.exports = function isAliasSymbolDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 248 /* NamespaceExportDeclaration */ || - node.kind === 251 /* ImportClause */ && !!node.name || - node.kind === 252 /* NamespaceImport */ || - node.kind === 254 /* ImportSpecifier */ || - node.kind === 258 /* ExportSpecifier */ || - node.kind === 255 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + return node.kind === 250 /* ImportEqualsDeclaration */ || + node.kind === 249 /* NamespaceExportDeclaration */ || + node.kind === 252 /* ImportClause */ && !!node.name || + node.kind === 253 /* NamespaceImport */ || + node.kind === 255 /* ImportSpecifier */ || + node.kind === 259 /* ExportSpecifier */ || + node.kind === 256 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -10972,9 +11298,9 @@ var ts; ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { - return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray - : ts.emptyArray; + return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray : + ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : + ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { @@ -11005,17 +11331,21 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 74 /* FirstKeyword */ <= token && token <= 148 /* LastKeyword */; + return 74 /* FirstKeyword */ <= token && token <= 149 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 119 /* FirstContextualKeyword */ <= token && token <= 148 /* LastContextualKeyword */; + return 119 /* FirstContextualKeyword */ <= token && token <= 149 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { return isKeyword(token) && !isContextualKeyword(token); } ts.isNonContextualKeyword = isNonContextualKeyword; + function isFutureReservedKeyword(token) { + return 110 /* FirstFutureReservedWord */ <= token && token <= 118 /* LastFutureReservedWord */; + } + ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { var token = ts.stringToToken(name); return token !== undefined && isNonContextualKeyword(token); @@ -11044,14 +11374,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 158 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -11065,10 +11395,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -11101,7 +11431,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 150 /* ComputedPropertyName */ && + return name.kind === 151 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression) && !isSignedNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); @@ -11123,7 +11453,7 @@ var ts; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -11178,11 +11508,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 152 /* Parameter */; + return root.kind === 153 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 187 /* BindingElement */) { + while (node.kind === 188 /* BindingElement */) { node = node.parent.parent; } return node; @@ -11190,15 +11520,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 197 /* FunctionExpression */ - || kind === 240 /* FunctionDeclaration */ - || kind === 198 /* ArrowFunction */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 245 /* ModuleDeclaration */ - || kind === 285 /* SourceFile */; + return kind === 159 /* Constructor */ + || kind === 198 /* FunctionExpression */ + || kind === 241 /* FunctionDeclaration */ + || kind === 199 /* ArrowFunction */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */ + || kind === 246 /* ModuleDeclaration */ + || kind === 286 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -11217,23 +11547,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 194 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 193 /* NewExpression */: + case 194 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: + case 204 /* PrefixUnaryExpression */: + case 201 /* TypeOfExpression */: + case 202 /* VoidExpression */: + case 200 /* DeleteExpression */: + case 203 /* AwaitExpression */: + case 207 /* ConditionalExpression */: + case 209 /* YieldExpression */: return 1 /* Right */; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (operator) { case 41 /* AsteriskAsteriskToken */: case 60 /* EqualsToken */: @@ -11257,15 +11587,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 194 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 205 /* BinaryExpression */) { + if (expression.kind === 206 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 203 /* PrefixUnaryExpression */ || expression.kind === 204 /* PostfixUnaryExpression */) { + else if (expression.kind === 204 /* PrefixUnaryExpression */ || expression.kind === 205 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -11275,15 +11605,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: return 0; - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return 1; - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return 2; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return 4; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0; @@ -11304,21 +11634,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: + case 204 /* PrefixUnaryExpression */: + case 201 /* TypeOfExpression */: + case 202 /* VoidExpression */: + case 200 /* DeleteExpression */: + case 203 /* AwaitExpression */: return 16; - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return 17; - case 192 /* CallExpression */: + case 193 /* CallExpression */: return 18; - case 193 /* NewExpression */: + case 194 /* NewExpression */: return hasArguments ? 19 : 18; - case 194 /* TaggedTemplateExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 195 /* TaggedTemplateExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return 19; case 101 /* ThisKeyword */: case 99 /* SuperKeyword */: @@ -11329,19 +11659,19 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 211 /* ClassExpression */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 266 /* JsxFragment */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 196 /* ParenthesizedExpression */: - case 211 /* OmittedExpression */: + case 208 /* TemplateExpression */: + case 197 /* ParenthesizedExpression */: + case 212 /* OmittedExpression */: return 20; default: return -1; @@ -11461,6 +11791,10 @@ var ts; } } ts.createDiagnosticCollection = createDiagnosticCollection; + var templateSubstitutionRegExp = /\$\{/g; + function escapeTemplateSubstitution(str) { + return str.replace(templateSubstitutionRegExp, "\\${"); + } // This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, // paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in // the language service. These characters should be escaped when printing, and if any characters are added, @@ -11468,7 +11802,8 @@ var ts; // There is no reason for this other than that JSON.stringify does not handle it either. var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var backtickQuoteEscapedCharsRegExp = /[\\\`\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + // Template strings should be preserved as much as possible + var backtickQuoteEscapedCharsRegExp = /[\\\`]/g; var escapedCharsMap = ts.createMapFromTemplate({ "\t": "\\t", "\v": "\\v", @@ -11646,7 +11981,7 @@ var ts; }; } ts.createTextWriter = createTextWriter; - function getTrailingSemicolonOmittingWriter(writer) { + function getTrailingSemicolonDeferringWriter(writer) { var pendingTrailingSemicolon = false; function commitPendingTrailingSemicolon() { if (pendingTrailingSemicolon) { @@ -11654,7 +11989,7 @@ var ts; pendingTrailingSemicolon = false; } } - return __assign({}, writer, { writeTrailingSemicolon: function () { + return __assign(__assign({}, writer), { writeTrailingSemicolon: function () { pendingTrailingSemicolon = true; }, writeLiteral: function (s) { @@ -11708,6 +12043,17 @@ var ts; decreaseIndent: function () { commitPendingTrailingSemicolon(); writer.decreaseIndent(); + }, + resetPendingTrailingSemicolon: function () { + pendingTrailingSemicolon = false; + } }); + } + ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter; + function getTrailingSemicolonOmittingWriter(writer) { + var deferringWriter = getTrailingSemicolonDeferringWriter(writer); + return __assign(__assign({}, deferringWriter), { writeLine: function () { + deferringWriter.resetPendingTrailingSemicolon(); + writer.writeLine(); } }); } ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; @@ -11829,6 +12175,7 @@ var ts; return accessor.parameters[hasThis ? 1 : 0]; } } + ts.getSetAccessorValueParameter = getSetAccessorValueParameter; /** Get the type annotation for the value parameter. */ function getSetAccessorTypeAnnotationNode(accessor) { var parameter = getSetAccessorValueParameter(accessor); @@ -11865,10 +12212,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 160 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 160 /* SetAccessor */) { + else if (accessor.kind === 161 /* SetAccessor */) { setAccessor = accessor; } else { @@ -11888,10 +12235,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 159 /* GetAccessor */ && !getAccessor) { + if (member.kind === 160 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 160 /* SetAccessor */ && !setAccessor) { + if (member.kind === 161 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -11937,7 +12284,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 === 297 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 299 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -12235,8 +12582,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 189 /* ObjectLiteralExpression */ - || kind === 188 /* ArrayLiteralExpression */; + return kind === 190 /* ObjectLiteralExpression */ + || kind === 189 /* ArrayLiteralExpression */; } return false; } @@ -12268,17 +12615,17 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 150 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 191 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 189 /* ObjectLiteralExpression */ && + return expression.kind === 190 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 188 /* ArrayLiteralExpression */ && + return expression.kind === 189 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -12576,8 +12923,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: + case 246 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -12654,35 +13001,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return accessKind(parent); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 44 /* PlusPlusToken */ || operator === 45 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? operatorToken.kind === 60 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 276 /* PropertyAssignment */: { + case 277 /* 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 277 /* ShorthandPropertyAssignment */: + case 278 /* 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 188 /* ArrayLiteralExpression */: + case 189 /* 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 === 222 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 223 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -12728,8 +13075,8 @@ var ts; /** * Mutates the map with newMap such that keys in map will be same as newMap. */ - function mutateMap(map, newMap, options) { - var createNewValue = options.createNewValue, onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; + function mutateMapSkippingNewValues(map, newMap, options) { + var onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; // Needs update map.forEach(function (existingValue, key) { var valueInNewMap = newMap.get(key); @@ -12743,6 +13090,15 @@ var ts; onExistingValue(existingValue, valueInNewMap, key); } }); + } + ts.mutateMapSkippingNewValues = mutateMapSkippingNewValues; + /** + * Mutates the map with newMap such that keys in map will be same as newMap. + */ + function mutateMap(map, newMap, options) { + // Needs update + mutateMapSkippingNewValues(map, newMap, options); + var createNewValue = options.createNewValue; // Add new values that are not already present newMap.forEach(function (valueInNewMap, key) { if (!map.has(key)) { @@ -12837,7 +13193,7 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) + return (kind >= 165 /* FirstTypeNode */ && kind <= 185 /* LastTypeNode */) || kind === 121 /* AnyKeyword */ || kind === 144 /* UnknownKeyword */ || kind === 136 /* NumberKeyword */ @@ -12851,18 +13207,18 @@ var ts; || kind === 142 /* UndefinedKeyword */ || kind === 97 /* NullKeyword */ || kind === 133 /* NeverKeyword */ - || kind === 212 /* ExpressionWithTypeArguments */ - || kind === 290 /* JSDocAllType */ - || kind === 291 /* JSDocUnknownType */ - || kind === 292 /* JSDocNullableType */ - || kind === 293 /* JSDocNonNullableType */ - || kind === 294 /* JSDocOptionalType */ - || kind === 295 /* JSDocFunctionType */ - || kind === 296 /* JSDocVariadicType */; + || kind === 213 /* ExpressionWithTypeArguments */ + || kind === 291 /* JSDocAllType */ + || kind === 292 /* JSDocUnknownType */ + || kind === 293 /* JSDocNullableType */ + || kind === 294 /* JSDocNonNullableType */ + || kind === 295 /* JSDocOptionalType */ + || kind === 296 /* JSDocFunctionType */ + || kind === 297 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */ || node.kind === 191 /* ElementAccessExpression */; + return node.kind === 191 /* PropertyAccessExpression */ || node.kind === 192 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function isBundleFileTextLike(section) { @@ -12982,7 +13338,7 @@ var ts; return { span: span, newLength: newLength }; } ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); // eslint-disable-line prefer-const /** * Called to merge all the changes that occurred across several versions of a script snapshot * into a single change. i.e. if a user keeps making successive edits to a script we will @@ -13099,17 +13455,17 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 151 /* TypeParameter */) { + if (d && d.kind === 152 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 243 /* InterfaceDeclaration */) { return current; } } } } ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 158 /* Constructor */; + function isParameterPropertyDeclaration(node, parent) { + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 159 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -13139,14 +13495,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 238 /* VariableDeclaration */) { + if (node.kind === 239 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 239 /* VariableDeclarationList */) { + if (node && node.kind === 240 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 220 /* VariableStatement */) { + if (node && node.kind === 221 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -13210,7 +13566,8 @@ var ts; return false; } try { - // tslint:disable-next-line no-unnecessary-qualifier (making clear this is a global mutation!) + // making clear this is a global mutation! + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier ts.localizedDiagnosticMessages = JSON.parse(fileContents); } catch (_a) { @@ -13292,27 +13649,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: var expr = hostNode.expression; + if (expr.kind === 206 /* BinaryExpression */ && expr.operatorToken.kind === 60 /* EqualsToken */) { + expr = expr.left; + } switch (expr.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return expr.name; - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 196 /* ParenthesizedExpression */: { + case 197 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 234 /* LabeledStatement */: { + case 235 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -13338,16 +13698,16 @@ var ts; switch (declaration.kind) { case 73 /* Identifier */: return declaration; - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: { + case 314 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 149 /* QualifiedName */) { + if (name.kind === 150 /* QualifiedName */) { return name.right; } break; } - case 192 /* CallExpression */: - case 205 /* BinaryExpression */: { + case 193 /* CallExpression */: + case 206 /* BinaryExpression */: { var expr = declaration; switch (ts.getAssignmentDeclarationKind(expr)) { case 1 /* ExportsProperty */: @@ -13363,9 +13723,11 @@ var ts; return undefined; } } - case 311 /* JSDocTypedefTag */: + case 313 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 255 /* ExportAssignment */: { + case 307 /* JSDocEnumTag */: + return nameForNamelessJSDocTypedef(declaration); + case 256 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } @@ -13570,7 +13932,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 297 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 299 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13590,10 +13952,9 @@ var ts; } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getEffectiveConstraintOfTypeParameter(node) { - return node.constraint ? node.constraint - : ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] - ? node.parent.constraint - : undefined; + return node.constraint ? node.constraint : + ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint : + undefined; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; })(ts || (ts = {})); @@ -13643,193 +14004,193 @@ var ts; ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 149 /* QualifiedName */; + return node.kind === 150 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 150 /* ComputedPropertyName */; + return node.kind === 151 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 151 /* TypeParameter */; + return node.kind === 152 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 152 /* Parameter */; + return node.kind === 153 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 153 /* Decorator */; + return node.kind === 154 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 154 /* PropertySignature */; + return node.kind === 155 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 155 /* PropertyDeclaration */; + return node.kind === 156 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 156 /* MethodSignature */; + return node.kind === 157 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 158 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 158 /* Constructor */; + return node.kind === 159 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 160 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 161 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 161 /* CallSignature */; + return node.kind === 162 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 162 /* ConstructSignature */; + return node.kind === 163 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 163 /* IndexSignature */; + return node.kind === 164 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */ || node.kind === 159 /* GetAccessor */; + return node.kind === 161 /* SetAccessor */ || node.kind === 160 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 164 /* TypePredicate */; + return node.kind === 165 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 165 /* TypeReference */; + return node.kind === 166 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 166 /* FunctionType */; + return node.kind === 167 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 167 /* ConstructorType */; + return node.kind === 168 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 168 /* TypeQuery */; + return node.kind === 169 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 169 /* TypeLiteral */; + return node.kind === 170 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 170 /* ArrayType */; + return node.kind === 171 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 171 /* TupleType */; + return node.kind === 172 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 174 /* UnionType */; + return node.kind === 175 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 175 /* IntersectionType */; + return node.kind === 176 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 176 /* ConditionalType */; + return node.kind === 177 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 177 /* InferType */; + return node.kind === 178 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 178 /* ParenthesizedType */; + return node.kind === 179 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 179 /* ThisType */; + return node.kind === 180 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 180 /* TypeOperator */; + return node.kind === 181 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 181 /* IndexedAccessType */; + return node.kind === 182 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 182 /* MappedType */; + return node.kind === 183 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 183 /* LiteralType */; + return node.kind === 184 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 184 /* ImportType */; + return node.kind === 185 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 185 /* ObjectBindingPattern */; + return node.kind === 186 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 186 /* ArrayBindingPattern */; + return node.kind === 187 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 187 /* BindingElement */; + return node.kind === 188 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 188 /* ArrayLiteralExpression */; + return node.kind === 189 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 189 /* ObjectLiteralExpression */; + return node.kind === 190 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */; + return node.kind === 191 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 191 /* ElementAccessExpression */; + return node.kind === 192 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 192 /* CallExpression */; + return node.kind === 193 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 193 /* NewExpression */; + return node.kind === 194 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 194 /* TaggedTemplateExpression */; + return node.kind === 195 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 195 /* TypeAssertionExpression */; + return node.kind === 196 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isConstTypeReference(node) { @@ -13838,376 +14199,376 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function isParenthesizedExpression(node) { - return node.kind === 196 /* ParenthesizedExpression */; + return node.kind === 197 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 315 /* PartiallyEmittedExpression */) { + while (node.kind === 317 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 197 /* FunctionExpression */; + return node.kind === 198 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 198 /* ArrowFunction */; + return node.kind === 199 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 199 /* DeleteExpression */; + return node.kind === 200 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 200 /* TypeOfExpression */; + return node.kind === 201 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 201 /* VoidExpression */; + return node.kind === 202 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 202 /* AwaitExpression */; + return node.kind === 203 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 203 /* PrefixUnaryExpression */; + return node.kind === 204 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 204 /* PostfixUnaryExpression */; + return node.kind === 205 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 205 /* BinaryExpression */; + return node.kind === 206 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 206 /* ConditionalExpression */; + return node.kind === 207 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 207 /* TemplateExpression */; + return node.kind === 208 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 208 /* YieldExpression */; + return node.kind === 209 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 209 /* SpreadElement */; + return node.kind === 210 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 210 /* ClassExpression */; + return node.kind === 211 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 211 /* OmittedExpression */; + return node.kind === 212 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 213 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 213 /* AsExpression */; + return node.kind === 214 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 214 /* NonNullExpression */; + return node.kind === 215 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 215 /* MetaProperty */; + return node.kind === 216 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 217 /* TemplateSpan */; + return node.kind === 218 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 218 /* SemicolonClassElement */; + return node.kind === 219 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 219 /* Block */; + return node.kind === 220 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 220 /* VariableStatement */; + return node.kind === 221 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 221 /* EmptyStatement */; + return node.kind === 222 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 222 /* ExpressionStatement */; + return node.kind === 223 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 223 /* IfStatement */; + return node.kind === 224 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 224 /* DoStatement */; + return node.kind === 225 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 225 /* WhileStatement */; + return node.kind === 226 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 226 /* ForStatement */; + return node.kind === 227 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 227 /* ForInStatement */; + return node.kind === 228 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 228 /* ForOfStatement */; + return node.kind === 229 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 229 /* ContinueStatement */; + return node.kind === 230 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 230 /* BreakStatement */; + return node.kind === 231 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 230 /* BreakStatement */ || node.kind === 229 /* ContinueStatement */; + return node.kind === 231 /* BreakStatement */ || node.kind === 230 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 231 /* ReturnStatement */; + return node.kind === 232 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 232 /* WithStatement */; + return node.kind === 233 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 233 /* SwitchStatement */; + return node.kind === 234 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 234 /* LabeledStatement */; + return node.kind === 235 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 235 /* ThrowStatement */; + return node.kind === 236 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 236 /* TryStatement */; + return node.kind === 237 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 237 /* DebuggerStatement */; + return node.kind === 238 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 238 /* VariableDeclaration */; + return node.kind === 239 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 239 /* VariableDeclarationList */; + return node.kind === 240 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 240 /* FunctionDeclaration */; + return node.kind === 241 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 241 /* ClassDeclaration */; + return node.kind === 242 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 242 /* InterfaceDeclaration */; + return node.kind === 243 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 243 /* TypeAliasDeclaration */; + return node.kind === 244 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 244 /* EnumDeclaration */; + return node.kind === 245 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */; + return node.kind === 246 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 246 /* ModuleBlock */; + return node.kind === 247 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 247 /* CaseBlock */; + return node.kind === 248 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 248 /* NamespaceExportDeclaration */; + return node.kind === 249 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */; + return node.kind === 250 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 250 /* ImportDeclaration */; + return node.kind === 251 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 251 /* ImportClause */; + return node.kind === 252 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 252 /* NamespaceImport */; + return node.kind === 253 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 253 /* NamedImports */; + return node.kind === 254 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 254 /* ImportSpecifier */; + return node.kind === 255 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 255 /* ExportAssignment */; + return node.kind === 256 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 256 /* ExportDeclaration */; + return node.kind === 257 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 257 /* NamedExports */; + return node.kind === 258 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 258 /* ExportSpecifier */; + return node.kind === 259 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 259 /* MissingDeclaration */; + return node.kind === 260 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 260 /* ExternalModuleReference */; + return node.kind === 261 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 261 /* JsxElement */; + return node.kind === 262 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 262 /* JsxSelfClosingElement */; + return node.kind === 263 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 263 /* JsxOpeningElement */; + return node.kind === 264 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 264 /* JsxClosingElement */; + return node.kind === 265 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 265 /* JsxFragment */; + return node.kind === 266 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 266 /* JsxOpeningFragment */; + return node.kind === 267 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 267 /* JsxClosingFragment */; + return node.kind === 268 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 268 /* JsxAttribute */; + return node.kind === 269 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 269 /* JsxAttributes */; + return node.kind === 270 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 270 /* JsxSpreadAttribute */; + return node.kind === 271 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 271 /* JsxExpression */; + return node.kind === 272 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 272 /* CaseClause */; + return node.kind === 273 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 273 /* DefaultClause */; + return node.kind === 274 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 274 /* HeritageClause */; + return node.kind === 275 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 275 /* CatchClause */; + return node.kind === 276 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 276 /* PropertyAssignment */; + return node.kind === 277 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 277 /* ShorthandPropertyAssignment */; + return node.kind === 278 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 278 /* SpreadAssignment */; + return node.kind === 279 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 280 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 285 /* SourceFile */; + return node.kind === 286 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 286 /* Bundle */; + return node.kind === 287 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 287 /* UnparsedSource */; + return node.kind === 288 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; function isUnparsedPrepend(node) { - return node.kind === 281 /* UnparsedPrepend */; + return node.kind === 282 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; function isUnparsedTextLike(node) { switch (node.kind) { - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 283 /* UnparsedText */: + case 284 /* UnparsedInternalText */: return true; default: return false; @@ -14216,105 +14577,105 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 280 /* UnparsedPrologue */ || - node.kind === 284 /* UnparsedSyntheticReference */; + node.kind === 281 /* UnparsedPrologue */ || + node.kind === 285 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 289 /* JSDocTypeExpression */; + return node.kind === 290 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 290 /* JSDocAllType */; + return node.kind === 291 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 291 /* JSDocUnknownType */; + return node.kind === 292 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 292 /* JSDocNullableType */; + return node.kind === 293 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 293 /* JSDocNonNullableType */; + return node.kind === 294 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 294 /* JSDocOptionalType */; + return node.kind === 295 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 295 /* JSDocFunctionType */; + return node.kind === 296 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 296 /* JSDocVariadicType */; + return node.kind === 297 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 297 /* JSDocComment */; + return node.kind === 299 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAuthorTag(node) { - return node.kind === 302 /* JSDocAuthorTag */; + return node.kind === 304 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocAugmentsTag(node) { - return node.kind === 301 /* JSDocAugmentsTag */; + return node.kind === 303 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 303 /* JSDocClassTag */; + return node.kind === 305 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 305 /* JSDocEnumTag */; + return node.kind === 307 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 308 /* JSDocThisTag */; + return node.kind === 310 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 306 /* JSDocParameterTag */; + return node.kind === 308 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 307 /* JSDocReturnTag */; + return node.kind === 309 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 309 /* JSDocTypeTag */; + return node.kind === 311 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 310 /* JSDocTemplateTag */; + return node.kind === 312 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 311 /* JSDocTypedefTag */; + return node.kind === 313 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 312 /* JSDocPropertyTag */; + return node.kind === 314 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 312 /* JSDocPropertyTag */ || node.kind === 306 /* JSDocParameterTag */; + return node.kind === 314 /* JSDocPropertyTag */ || node.kind === 308 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 298 /* JSDocTypeLiteral */; + return node.kind === 300 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 304 /* JSDocCallbackTag */; + return node.kind === 306 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 299 /* JSDocSignature */; + return node.kind === 301 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -14325,7 +14686,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 313 /* SyntaxList */; + return n.kind === 315 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -14335,7 +14696,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 149 /* FirstNode */; + return kind >= 150 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -14344,7 +14705,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 148 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 149 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -14429,7 +14790,7 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 149 /* QualifiedName */ + return kind === 150 /* QualifiedName */ || kind === 73 /* Identifier */; } ts.isEntityName = isEntityName; @@ -14438,14 +14799,14 @@ var ts; return kind === 73 /* Identifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 150 /* ComputedPropertyName */; + || kind === 151 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; return kind === 73 /* Identifier */ - || kind === 185 /* ObjectBindingPattern */ - || kind === 186 /* ArrayBindingPattern */; + || kind === 186 /* ObjectBindingPattern */ + || kind === 187 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -14460,13 +14821,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return true; default: return false; @@ -14475,14 +14836,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 167 /* ConstructorType */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 301 /* JSDocSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 167 /* FunctionType */: + case 296 /* JSDocFunctionType */: + case 168 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -14497,29 +14858,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 155 /* PropertyDeclaration */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 163 /* IndexSignature */ - || kind === 218 /* SemicolonClassElement */; + return kind === 159 /* Constructor */ + || kind === 156 /* PropertyDeclaration */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */ + || kind === 164 /* IndexSignature */ + || kind === 219 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */); + return node && (node.kind === 242 /* ClassDeclaration */ || node.kind === 211 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */); + return node && (node.kind === 160 /* GetAccessor */ || node.kind === 161 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return true; default: return false; @@ -14529,11 +14890,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 162 /* ConstructSignature */ - || kind === 161 /* CallSignature */ - || kind === 154 /* PropertySignature */ - || kind === 156 /* MethodSignature */ - || kind === 163 /* IndexSignature */; + return kind === 163 /* ConstructSignature */ + || kind === 162 /* CallSignature */ + || kind === 155 /* PropertySignature */ + || kind === 157 /* MethodSignature */ + || kind === 164 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -14542,12 +14903,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 276 /* PropertyAssignment */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 278 /* SpreadAssignment */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 277 /* PropertyAssignment */ + || kind === 278 /* ShorthandPropertyAssignment */ + || kind === 279 /* SpreadAssignment */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -14562,8 +14923,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: return true; } return false; @@ -14574,8 +14935,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 186 /* ArrayBindingPattern */ - || kind === 185 /* ObjectBindingPattern */; + return kind === 187 /* ArrayBindingPattern */ + || kind === 186 /* ObjectBindingPattern */; } return false; } @@ -14583,15 +14944,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 188 /* ArrayLiteralExpression */ - || kind === 189 /* ObjectLiteralExpression */; + return kind === 189 /* ArrayLiteralExpression */ + || kind === 190 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 187 /* BindingElement */ - || kind === 211 /* OmittedExpression */; + return kind === 188 /* BindingElement */ + || kind === 212 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -14600,9 +14961,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 239 /* VariableDeclaration */: + case 153 /* Parameter */: + case 188 /* BindingElement */: return true; } return false; @@ -14623,8 +14984,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 186 /* ObjectBindingPattern */: + case 190 /* ObjectLiteralExpression */: return true; } return false; @@ -14636,8 +14997,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 187 /* ArrayBindingPattern */: + case 189 /* ArrayLiteralExpression */: return true; } return false; @@ -14646,26 +15007,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */ - || kind === 184 /* ImportType */; + return kind === 191 /* PropertyAccessExpression */ + || kind === 150 /* QualifiedName */ + || kind === 185 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */; + return kind === 191 /* PropertyAccessExpression */ + || kind === 150 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 153 /* Decorator */: + case 264 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 195 /* TaggedTemplateExpression */: + case 154 /* Decorator */: return true; default: return false; @@ -14673,12 +15034,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 192 /* CallExpression */ || node.kind === 193 /* NewExpression */; + return node.kind === 193 /* CallExpression */ || node.kind === 194 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 207 /* TemplateExpression */ + return kind === 208 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -14689,33 +15050,33 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 193 /* NewExpression */: - case 192 /* CallExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 194 /* TaggedTemplateExpression */: - case 188 /* ArrayLiteralExpression */: - case 196 /* ParenthesizedExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: + case 194 /* NewExpression */: + case 193 /* CallExpression */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 266 /* JsxFragment */: + case 195 /* TaggedTemplateExpression */: + case 189 /* ArrayLiteralExpression */: + case 197 /* ParenthesizedExpression */: + case 190 /* ObjectLiteralExpression */: + case 211 /* ClassExpression */: + case 198 /* FunctionExpression */: case 73 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: case 88 /* FalseKeyword */: case 97 /* NullKeyword */: case 101 /* ThisKeyword */: case 103 /* TrueKeyword */: case 99 /* SuperKeyword */: - case 214 /* NonNullExpression */: - case 215 /* MetaProperty */: + case 215 /* NonNullExpression */: + case 216 /* MetaProperty */: case 93 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: @@ -14729,13 +15090,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 195 /* TypeAssertionExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: + case 200 /* DeleteExpression */: + case 201 /* TypeOfExpression */: + case 202 /* VoidExpression */: + case 203 /* AwaitExpression */: + case 196 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -14744,9 +15105,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return true; - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; default: @@ -14765,15 +15126,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: - case 198 /* ArrowFunction */: - case 205 /* BinaryExpression */: - case 209 /* SpreadElement */: - case 213 /* AsExpression */: - case 211 /* OmittedExpression */: - case 316 /* CommaListExpression */: - case 315 /* PartiallyEmittedExpression */: + case 207 /* ConditionalExpression */: + case 209 /* YieldExpression */: + case 199 /* ArrowFunction */: + case 206 /* BinaryExpression */: + case 210 /* SpreadElement */: + case 214 /* AsExpression */: + case 212 /* OmittedExpression */: + case 318 /* CommaListExpression */: + case 317 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -14781,18 +15142,18 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 195 /* TypeAssertionExpression */ - || kind === 213 /* AsExpression */; + return kind === 196 /* TypeAssertionExpression */ + || kind === 214 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 315 /* PartiallyEmittedExpression */; + return node.kind === 317 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 314 /* NotEmittedStatement */; + return node.kind === 316 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -14803,13 +15164,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: return true; - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -14817,7 +15178,7 @@ var ts; ts.isIterationStatement = isIterationStatement; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 227 /* ForInStatement */ || node.kind === 228 /* ForOfStatement */; + return node.kind === 228 /* ForInStatement */ || node.kind === 229 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -14841,113 +15202,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */ + return kind === 247 /* ModuleBlock */ + || kind === 246 /* ModuleDeclaration */ || kind === 73 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */; + return kind === 247 /* ModuleBlock */ + || kind === 246 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 73 /* Identifier */ - || kind === 245 /* ModuleDeclaration */; + || kind === 246 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 253 /* NamedImports */ - || kind === 252 /* NamespaceImport */; + return kind === 254 /* NamedImports */ + || kind === 253 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ || node.kind === 244 /* EnumDeclaration */; + return node.kind === 246 /* ModuleDeclaration */ || node.kind === 245 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 198 /* ArrowFunction */ - || kind === 187 /* BindingElement */ - || kind === 241 /* ClassDeclaration */ - || kind === 210 /* ClassExpression */ - || kind === 158 /* Constructor */ - || kind === 244 /* EnumDeclaration */ - || kind === 279 /* EnumMember */ - || kind === 258 /* ExportSpecifier */ - || kind === 240 /* FunctionDeclaration */ - || kind === 197 /* FunctionExpression */ - || kind === 159 /* GetAccessor */ - || kind === 251 /* ImportClause */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 254 /* ImportSpecifier */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 268 /* JsxAttribute */ - || kind === 157 /* MethodDeclaration */ - || kind === 156 /* MethodSignature */ - || kind === 245 /* ModuleDeclaration */ - || kind === 248 /* NamespaceExportDeclaration */ - || kind === 252 /* NamespaceImport */ - || kind === 152 /* Parameter */ - || kind === 276 /* PropertyAssignment */ - || kind === 155 /* PropertyDeclaration */ - || kind === 154 /* PropertySignature */ - || kind === 160 /* SetAccessor */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 151 /* TypeParameter */ - || kind === 238 /* VariableDeclaration */ - || kind === 311 /* JSDocTypedefTag */ - || kind === 304 /* JSDocCallbackTag */ - || kind === 312 /* JSDocPropertyTag */; + return kind === 199 /* ArrowFunction */ + || kind === 188 /* BindingElement */ + || kind === 242 /* ClassDeclaration */ + || kind === 211 /* ClassExpression */ + || kind === 159 /* Constructor */ + || kind === 245 /* EnumDeclaration */ + || kind === 280 /* EnumMember */ + || kind === 259 /* ExportSpecifier */ + || kind === 241 /* FunctionDeclaration */ + || kind === 198 /* FunctionExpression */ + || kind === 160 /* GetAccessor */ + || kind === 252 /* ImportClause */ + || kind === 250 /* ImportEqualsDeclaration */ + || kind === 255 /* ImportSpecifier */ + || kind === 243 /* InterfaceDeclaration */ + || kind === 269 /* JsxAttribute */ + || kind === 158 /* MethodDeclaration */ + || kind === 157 /* MethodSignature */ + || kind === 246 /* ModuleDeclaration */ + || kind === 249 /* NamespaceExportDeclaration */ + || kind === 253 /* NamespaceImport */ + || kind === 153 /* Parameter */ + || kind === 277 /* PropertyAssignment */ + || kind === 156 /* PropertyDeclaration */ + || kind === 155 /* PropertySignature */ + || kind === 161 /* SetAccessor */ + || kind === 278 /* ShorthandPropertyAssignment */ + || kind === 244 /* TypeAliasDeclaration */ + || kind === 152 /* TypeParameter */ + || kind === 239 /* VariableDeclaration */ + || kind === 313 /* JSDocTypedefTag */ + || kind === 306 /* JSDocCallbackTag */ + || kind === 314 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 240 /* FunctionDeclaration */ - || kind === 259 /* MissingDeclaration */ - || kind === 241 /* ClassDeclaration */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 244 /* EnumDeclaration */ - || kind === 245 /* ModuleDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */ - || kind === 255 /* ExportAssignment */ - || kind === 248 /* NamespaceExportDeclaration */; + return kind === 241 /* FunctionDeclaration */ + || kind === 260 /* MissingDeclaration */ + || kind === 242 /* ClassDeclaration */ + || kind === 243 /* InterfaceDeclaration */ + || kind === 244 /* TypeAliasDeclaration */ + || kind === 245 /* EnumDeclaration */ + || kind === 246 /* ModuleDeclaration */ + || kind === 251 /* ImportDeclaration */ + || kind === 250 /* ImportEqualsDeclaration */ + || kind === 257 /* ExportDeclaration */ + || kind === 256 /* ExportAssignment */ + || kind === 249 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 230 /* BreakStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 224 /* DoStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 221 /* EmptyStatement */ - || kind === 227 /* ForInStatement */ - || kind === 228 /* ForOfStatement */ - || kind === 226 /* ForStatement */ - || kind === 223 /* IfStatement */ - || kind === 234 /* LabeledStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 233 /* SwitchStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 236 /* TryStatement */ - || kind === 220 /* VariableStatement */ - || kind === 225 /* WhileStatement */ - || kind === 232 /* WithStatement */ - || kind === 314 /* NotEmittedStatement */ - || kind === 318 /* EndOfDeclarationMarker */ - || kind === 317 /* MergeDeclarationMarker */; + return kind === 231 /* BreakStatement */ + || kind === 230 /* ContinueStatement */ + || kind === 238 /* DebuggerStatement */ + || kind === 225 /* DoStatement */ + || kind === 223 /* ExpressionStatement */ + || kind === 222 /* EmptyStatement */ + || kind === 228 /* ForInStatement */ + || kind === 229 /* ForOfStatement */ + || kind === 227 /* ForStatement */ + || kind === 224 /* IfStatement */ + || kind === 235 /* LabeledStatement */ + || kind === 232 /* ReturnStatement */ + || kind === 234 /* SwitchStatement */ + || kind === 236 /* ThrowStatement */ + || kind === 237 /* TryStatement */ + || kind === 221 /* VariableStatement */ + || kind === 226 /* WhileStatement */ + || kind === 233 /* WithStatement */ + || kind === 316 /* NotEmittedStatement */ + || kind === 320 /* EndOfDeclarationMarker */ + || kind === 319 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 151 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 310 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 152 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 312 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14974,10 +15335,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 219 /* Block */) + if (node.kind !== 220 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 236 /* TryStatement */ || node.parent.kind === 275 /* CatchClause */) { + if (node.parent.kind === 237 /* TryStatement */ || node.parent.kind === 276 /* CatchClause */) { return false; } } @@ -14987,8 +15348,8 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 260 /* ExternalModuleReference */ - || kind === 149 /* QualifiedName */ + return kind === 261 /* ExternalModuleReference */ + || kind === 150 /* QualifiedName */ || kind === 73 /* Identifier */; } ts.isModuleReference = isModuleReference; @@ -14998,70 +15359,70 @@ var ts; var kind = node.kind; return kind === 101 /* ThisKeyword */ || kind === 73 /* Identifier */ - || kind === 190 /* PropertyAccessExpression */; + || kind === 191 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 261 /* JsxElement */ - || kind === 271 /* JsxExpression */ - || kind === 262 /* JsxSelfClosingElement */ + return kind === 262 /* JsxElement */ + || kind === 272 /* JsxExpression */ + || kind === 263 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 265 /* JsxFragment */; + || kind === 266 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 268 /* JsxAttribute */ - || kind === 270 /* JsxSpreadAttribute */; + return kind === 269 /* JsxAttribute */ + || kind === 271 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 271 /* JsxExpression */; + || kind === 272 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 263 /* JsxOpeningElement */ - || kind === 262 /* JsxSelfClosingElement */; + return kind === 264 /* JsxOpeningElement */ + || kind === 263 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 272 /* CaseClause */ - || kind === 273 /* DefaultClause */; + return kind === 273 /* CaseClause */ + || kind === 274 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 289 /* FirstJSDocNode */ && node.kind <= 312 /* LastJSDocNode */; + return node.kind >= 290 /* FirstJSDocNode */ && node.kind <= 314 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 297 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 299 /* JSDocComment */ || 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 >= 300 /* FirstJSDocTagNode */ && node.kind <= 312 /* LastJSDocTagNode */; + return node.kind >= 302 /* FirstJSDocTagNode */ && node.kind <= 314 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 161 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 160 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -15091,12 +15452,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 268 /* JsxAttribute */ || node.kind === 270 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 269 /* JsxAttribute */ || node.kind === 271 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 165 /* TypeReference */ || node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 166 /* TypeReference */ || node.kind === 213 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -15132,7 +15493,7 @@ var ts; /* @internal */ (function (ts) { function isNamedImportsOrExports(node) { - return node.kind === 253 /* NamedImports */ || node.kind === 257 /* NamedExports */; + return node.kind === 254 /* NamedImports */ || node.kind === 258 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -15150,7 +15511,7 @@ var ts; this.checker = checker; } } - function Signature() { } // tslint:disable-line no-empty + function Signature() { } function Node(kind, pos, end) { this.pos = pos; this.end = end; @@ -15167,6 +15528,7 @@ var ts; this.text = text; this.skipTrivia = skipTrivia || (function (pos) { return pos; }); } + // eslint-disable-next-line prefer-const ts.objectAllocator = { getNodeConstructor: function () { return Node; }, getTokenConstructor: function () { return Node; }, @@ -15613,7 +15975,7 @@ var ts; var rest = path.substring(rootLength).split(ts.directorySeparator); if (rest.length && !ts.lastOrUndefined(rest)) rest.pop(); - return [root].concat(rest); + return __spreadArrays([root], rest); } /** * Parse a path into an array containing a root component (at index 0) and zero or more path @@ -15713,7 +16075,7 @@ var ts; for (; start < fromComponents.length; start++) { relative.push(".."); } - return [""].concat(relative, components); + return __spreadArrays([""], relative, components); } ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; function getRelativePathFromFile(from, to, getCanonicalFileName) { @@ -15794,7 +16156,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { paths[_i - 1] = arguments[_i]; } - var combined = ts.some(paths) ? combinePaths.apply(void 0, [path].concat(paths)) : ts.normalizeSlashes(path); + var combined = ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : ts.normalizeSlashes(path); var normalized = ts.getPathFromPathComponents(ts.reducePathComponents(ts.getPathComponents(combined))); return normalized && hasTrailingDirectorySeparator(combined) ? ensureTrailingDirectorySeparator(normalized) : normalized; } @@ -16233,14 +16595,14 @@ var ts; ts.supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */]; ts.supportedJSExtensions = [".js" /* Js */, ".jsx" /* Jsx */]; ts.supportedJSAndJsonExtensions = [".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */]; - var allSupportedExtensions = ts.supportedTSExtensions.concat(ts.supportedJSExtensions); - var allSupportedExtensionsWithJson = ts.supportedTSExtensions.concat(ts.supportedJSExtensions, [".json" /* Json */]); + var allSupportedExtensions = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions); + var allSupportedExtensionsWithJson = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions, [".json" /* Json */]); function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && options.allowJs; if (!extraFileExtensions || extraFileExtensions.length === 0) { return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; } - var extensions = (needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions).concat(ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); + var extensions = __spreadArrays(needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions, ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); return ts.deduplicate(extensions, ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } ts.getSupportedExtensions = getSupportedExtensions; @@ -16254,7 +16616,7 @@ var ts; if (supportedExtensions === ts.supportedTSExtensions) { return ts.supportedTSExtensionsWithJson; } - return supportedExtensions.concat([".json" /* Json */]); + return __spreadArrays(supportedExtensions, [".json" /* Json */]); } ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { @@ -16574,6 +16936,7 @@ var ts; } ts.skipTypeChecking = skipTypeChecking; function isJsonEqual(a, b) { + // eslint-disable-next-line no-null/no-null return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && ts.equalOwnProperties(a, b, isJsonEqual); } ts.isJsonEqual = isJsonEqual; @@ -16677,14 +17040,12 @@ var ts; SignatureFlags[SignatureFlags["IgnoreMissingOpenBrace"] = 16] = "IgnoreMissingOpenBrace"; SignatureFlags[SignatureFlags["JSDoc"] = 32] = "JSDoc"; })(SignatureFlags || (SignatureFlags = {})); - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 285 /* SourceFile */) { + if (kind === 286 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 73 /* Identifier */) { @@ -16736,19 +17097,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 <= 148 /* LastToken */) { + if (!node || node.kind <= 149 /* LastToken */) { return; } switch (node.kind) { - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -16756,9 +17117,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 152 /* Parameter */: + case 153 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -16766,7 +17127,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -16774,51 +17135,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 154 /* PropertySignature */: + case 155 /* 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 276 /* PropertyAssignment */: + case 277 /* 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 238 /* VariableDeclaration */: + case 239 /* 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 187 /* BindingElement */: + case 188 /* 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 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -16830,345 +17191,345 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 171 /* TupleType */: + case 172 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 177 /* InferType */: + case 178 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 184 /* ImportType */: + case 185 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 178 /* ParenthesizedType */: - case 180 /* TypeOperator */: + case 179 /* ParenthesizedType */: + case 181 /* TypeOperator */: return visitNode(cbNode, node.type); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 182 /* MappedType */: + case 183 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 183 /* LiteralType */: + case 184 /* LiteralType */: return visitNode(cbNode, node.literal); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 213 /* AsExpression */: + case 214 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return visitNode(cbNode, node.name); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 220 /* Block */: + case 247 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 285 /* SourceFile */: + case 286 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 230 /* ContinueStatement */: + case 231 /* BreakStatement */: return visitNode(cbNode, node.label); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 272 /* CaseClause */: + case 273 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 153 /* Decorator */: + case 154 /* Decorator */: return visitNode(cbNode, node.expression); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* 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 242 /* InterfaceDeclaration */: + case 243 /* 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 243 /* TypeAliasDeclaration */: + case 244 /* 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 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 279 /* EnumMember */: + case 280 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 254 /* NamedImports */: + case 258 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 259 /* MissingDeclaration */: + case 260 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 261 /* JsxElement */: + case 262 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 172 /* OptionalType */: - case 173 /* RestType */: - case 289 /* JSDocTypeExpression */: - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 294 /* JSDocOptionalType */: - case 296 /* JSDocVariadicType */: + case 173 /* OptionalType */: + case 174 /* RestType */: + case 290 /* JSDocTypeExpression */: + case 294 /* JSDocNonNullableType */: + case 293 /* JSDocNullableType */: + case 295 /* JSDocOptionalType */: + case 297 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 297 /* JSDocComment */: + case 299 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: + case 314 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 302 /* JSDocAuthorTag */: + case 304 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName); - case 301 /* JSDocAugmentsTag */: + case 303 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 311 /* JSDocTypedefTag */: + case 313 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 289 /* JSDocTypeExpression */ + node.typeExpression.kind === 290 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 304 /* JSDocCallbackTag */: + case 306 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 308 /* JSDocThisTag */: - case 305 /* JSDocEnumTag */: + case 309 /* JSDocReturnTag */: + case 311 /* JSDocTypeTag */: + case 310 /* JSDocThisTag */: + case 307 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 299 /* JSDocSignature */: + case 301 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 298 /* JSDocTypeLiteral */: + case 300 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 300 /* JSDocTag */: - case 303 /* JSDocClassTag */: + case 302 /* JSDocTag */: + case 305 /* JSDocClassTag */: return visitNode(cbNode, node.tagName); - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -17177,12 +17538,14 @@ var ts; if (setParentNodes === void 0) { setParentNodes = false; } ts.performance.mark("beforeParse"); var result; + ts.perfLogger.logStartParseSourceFile(fileName); if (languageVersion === 100 /* JSON */) { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */); } else { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind); } + ts.perfLogger.logStopParseSourceFile(); ts.performance.mark("afterParse"); ts.performance.measure("Parse", "beforeParse", "afterParse"); return result; @@ -17251,12 +17614,10 @@ var ts; var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); var disallowInAndDecoratorContext = 2048 /* DisallowInContext */ | 8192 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name var sourceFile; var parseDiagnostics; var syntaxCursor; @@ -17266,6 +17627,7 @@ var ts; var identifiers; var identifierCount; var parsingContext; + var notParenthesizedArrow; // Flags that dictate what parsing context we're in. For example: // Whether or not we are in strict parsing mode. All that changes in strict parsing mode is // that some tokens that would be considered identifiers may be considered keywords. @@ -17386,7 +17748,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(222 /* ExpressionStatement */); + var statement = createNode(223 /* ExpressionStatement */); switch (token()) { case 22 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); @@ -17422,6 +17784,9 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; sourceFile.parseDiagnostics = parseDiagnostics; var result = sourceFile; clearState(); @@ -17473,6 +17838,7 @@ var ts; identifiers = undefined; syntaxCursor = undefined; sourceText = undefined; + notParenthesizedArrow = undefined; } function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { var isDeclarationFile = isDeclarationFileName(fileName); @@ -17542,7 +17908,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(285 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(286 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -17682,9 +18048,17 @@ var ts; function token() { return currentToken; } - function nextToken() { + function nextTokenWithoutCheck() { return currentToken = scanner.scan(); } + function nextToken() { + // if the keyword had an escape + if (ts.isKeyword(currentToken) && (scanner.hasUnicodeEscape() || scanner.hasExtendedUnicodeEscape())) { + // issue a parse error for the escape + parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), ts.Diagnostics.Keywords_cannot_contain_escape_characters); + } + return nextTokenWithoutCheck(); + } function nextTokenJSDoc() { return currentToken = scanner.scanJsDocToken(); } @@ -17923,7 +18297,7 @@ var ts; node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); - nextToken(); + nextTokenWithoutCheck(); return finishNode(node); } // Only for end of file because the error gets reported incorrectly on embedded script tags. @@ -17959,7 +18333,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(150 /* ComputedPropertyName */); + var node = createNode(151 /* ComputedPropertyName */); parseExpected(22 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -18393,14 +18767,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 158 /* Constructor */: - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 218 /* SemicolonClassElement */: + case 159 /* Constructor */: + case 164 /* IndexSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 219 /* SemicolonClassElement */: return true; - case 157 /* MethodDeclaration */: + case 158 /* 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. @@ -18415,8 +18789,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: return true; } } @@ -18425,58 +18799,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 220 /* VariableStatement */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 222 /* ExpressionStatement */: - case 235 /* ThrowStatement */: - case 231 /* ReturnStatement */: - case 233 /* SwitchStatement */: - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 221 /* EmptyStatement */: - case 236 /* TryStatement */: - case 234 /* LabeledStatement */: - case 224 /* DoStatement */: - case 237 /* DebuggerStatement */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 241 /* FunctionDeclaration */: + case 221 /* VariableStatement */: + case 220 /* Block */: + case 224 /* IfStatement */: + case 223 /* ExpressionStatement */: + case 236 /* ThrowStatement */: + case 232 /* ReturnStatement */: + case 234 /* SwitchStatement */: + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 227 /* ForStatement */: + case 226 /* WhileStatement */: + case 233 /* WithStatement */: + case 222 /* EmptyStatement */: + case 237 /* TryStatement */: + case 235 /* LabeledStatement */: + case 225 /* DoStatement */: + case 238 /* DebuggerStatement */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 257 /* ExportDeclaration */: + case 256 /* ExportAssignment */: + case 246 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 280 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 154 /* PropertySignature */: - case 161 /* CallSignature */: + case 163 /* ConstructSignature */: + case 157 /* MethodSignature */: + case 164 /* IndexSignature */: + case 155 /* PropertySignature */: + case 162 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 238 /* VariableDeclaration */) { + if (node.kind !== 239 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -18497,7 +18871,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 152 /* Parameter */) { + if (node.kind !== 153 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -18564,7 +18938,7 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */); + parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use @@ -18602,6 +18976,9 @@ var ts; } return result; } + function getExpectedCommaDiagnostic(kind) { + return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + } function createMissingList() { var list = createNodeArray([], getNodePos()); list.isMissingList = true; @@ -18633,7 +19010,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(149 /* QualifiedName */, entity.pos); + var node = createNode(150 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -18670,7 +19047,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(207 /* TemplateExpression */); + var template = createNode(208 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -18682,7 +19059,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(217 /* TemplateSpan */); + var span = createNode(218 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 19 /* CloseBraceToken */) { @@ -18711,6 +19088,16 @@ var ts; function parseLiteralLikeNode(kind) { var node = createNode(kind); node.text = scanner.getTokenValue(); + switch (kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + var isLast = kind === 14 /* NoSubstitutionTemplateLiteral */ || kind === 17 /* TemplateTail */; + var tokenText = scanner.getTokenText(); + node.rawText = tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); + break; + } if (scanner.hasExtendedUnicodeEscape()) { node.hasExtendedUnicodeEscape = true; } @@ -18732,7 +19119,7 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(165 /* TypeReference */); + var node = createNode(166 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); @@ -18742,14 +19129,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: { + case 167 /* FunctionType */: + case 168 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -18757,20 +19144,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(164 /* TypePredicate */, lhs.pos); + var node = createNode(165 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(179 /* ThisType */); + var node = createNode(180 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(290 /* JSDocAllType */); + var result = createNode(291 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(294 /* JSDocOptionalType */, result); + return createPostfixType(295 /* JSDocOptionalType */, result); } else { nextToken(); @@ -18778,7 +19165,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(293 /* JSDocNonNullableType */); + var result = createNode(294 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -18802,28 +19189,28 @@ var ts; token() === 30 /* GreaterThanToken */ || token() === 60 /* EqualsToken */ || token() === 50 /* BarToken */) { - var result = createNode(291 /* JSDocUnknownType */, pos); + var result = createNode(292 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(292 /* JSDocNullableType */, pos); + var result = createNode(293 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(295 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(296 /* JSDocFunctionType */); nextToken(); fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(165 /* TypeReference */); + var node = createNode(166 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(152 /* Parameter */); + var parameter = createNode(153 /* Parameter */); if (token() === 101 /* ThisKeyword */ || token() === 96 /* NewKeyword */) { parameter.name = parseIdentifierName(); parseExpected(57 /* ColonToken */); @@ -18833,27 +19220,44 @@ var ts; } function parseJSDocType() { scanner.setInJSDocType(true); + var moduleSpecifier = parseOptionalToken(131 /* ModuleKeyword */); + if (moduleSpecifier) { + var moduleTag = createNode(298 /* JSDocNamepathType */, moduleSpecifier.pos); + terminate: while (true) { + switch (token()) { + case 19 /* CloseBraceToken */: + case 1 /* EndOfFileToken */: + case 27 /* CommaToken */: + case 5 /* WhitespaceTrivia */: + break terminate; + default: + nextTokenJSDoc(); + } + } + scanner.setInJSDocType(false); + return finishNode(moduleTag); + } var dotdotdot = parseOptionalToken(25 /* DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(296 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(297 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 60 /* EqualsToken */) { - return createPostfixType(294 /* JSDocOptionalType */, type); + return createPostfixType(295 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(168 /* TypeQuery */); + var node = createNode(169 /* TypeQuery */); parseExpected(105 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(152 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(87 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -18898,7 +19302,7 @@ var ts; isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(152 /* Parameter */); + var node = createNodeWithJSDoc(153 /* Parameter */); if (token() === 101 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); @@ -18999,7 +19403,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 162 /* ConstructSignature */) { + if (kind === 163 /* ConstructSignature */) { parseExpected(96 /* NewKeyword */); } fillSignature(57 /* ColonToken */, 4 /* Type */, node); @@ -19060,7 +19464,7 @@ var ts; return token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 163 /* IndexSignature */; + node.kind = 164 /* IndexSignature */; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -19070,13 +19474,13 @@ var ts; node.name = parsePropertyName(); node.questionToken = parseOptionalToken(56 /* QuestionToken */); if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - node.kind = 156 /* MethodSignature */; + node.kind = 157 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] fillSignature(57 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 154 /* PropertySignature */; + node.kind = 155 /* PropertySignature */; node.type = parseTypeAnnotation(); if (token() === 60 /* EqualsToken */) { // Although type literal properties cannot not have initializers, we attempt @@ -19122,10 +19526,10 @@ var ts; } function parseTypeMember() { if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - return parseSignatureMember(161 /* CallSignature */); + return parseSignatureMember(162 /* CallSignature */); } if (token() === 96 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(162 /* ConstructSignature */); + return parseSignatureMember(163 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -19151,7 +19555,7 @@ var ts; return false; } function parseTypeLiteral() { - var node = createNode(169 /* TypeLiteral */); + var node = createNode(170 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -19177,14 +19581,14 @@ var ts; return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 94 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(152 /* TypeParameter */); node.name = parseIdentifier(); parseExpected(94 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(182 /* MappedType */); + var node = createNode(183 /* MappedType */); parseExpected(18 /* OpenBraceToken */); if (token() === 134 /* ReadonlyKeyword */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { node.readonlyToken = parseTokenNode(); @@ -19209,23 +19613,23 @@ var ts; function parseTupleElementType() { var pos = getNodePos(); if (parseOptional(25 /* DotDotDotToken */)) { - var node = createNode(173 /* RestType */, pos); + var node = createNode(174 /* RestType */, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 292 /* JSDocNullableType */ && type.pos === type.type.pos) { - type.kind = 172 /* OptionalType */; + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 293 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 173 /* OptionalType */; } return type; } function parseTupleType() { - var node = createNode(171 /* TupleType */); + var node = createNode(172 /* TupleType */); node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(178 /* ParenthesizedType */); + var node = createNode(179 /* ParenthesizedType */); parseExpected(20 /* OpenParenToken */); node.type = parseType(); parseExpected(21 /* CloseParenToken */); @@ -19233,7 +19637,7 @@ var ts; } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(96 /* NewKeyword */) ? 167 /* ConstructorType */ : 166 /* FunctionType */; + var kind = parseOptional(96 /* NewKeyword */) ? 168 /* ConstructorType */ : 167 /* FunctionType */; var node = createNodeWithJSDoc(kind, pos); fillSignature(37 /* EqualsGreaterThanToken */, 4 /* Type */, node); return finishNode(node); @@ -19243,10 +19647,10 @@ var ts; return token() === 24 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(183 /* LiteralType */); + var node = createNode(184 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(203 /* PrefixUnaryExpression */); + unaryMinusExpression = createNode(204 /* PrefixUnaryExpression */); unaryMinusExpression.operator = 39 /* MinusToken */; nextToken(); } @@ -19267,7 +19671,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(184 /* ImportType */); + var node = createNode(185 /* ImportType */); if (parseOptional(105 /* TypeOfKeyword */)) { node.isTypeOf = true; } @@ -19357,6 +19761,7 @@ var ts; case 134 /* ReadonlyKeyword */: case 140 /* SymbolKeyword */: case 143 /* UniqueKeyword */: + case 148 /* TagKeyword */: case 107 /* VoidKeyword */: case 142 /* UndefinedKeyword */: case 97 /* NullKeyword */: @@ -19403,26 +19808,26 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 52 /* ExclamationToken */: - type = createPostfixType(293 /* JSDocNonNullableType */, type); + type = createPostfixType(294 /* JSDocNonNullableType */, type); break; case 56 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(292 /* JSDocNullableType */, type); + type = createPostfixType(293 /* JSDocNullableType */, type); break; case 22 /* OpenBracketToken */: parseExpected(22 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(181 /* IndexedAccessType */, type.pos); + var node = createNode(182 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(170 /* ArrayType */, type.pos); + var node = createNode(171 /* ArrayType */, type.pos); node.elementType = type; parseExpected(23 /* CloseBracketToken */); type = finishNode(node); @@ -19441,16 +19846,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(180 /* TypeOperator */); + var node = createNode(181 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(177 /* InferType */); + var node = createNode(178 /* InferType */); parseExpected(128 /* InferKeyword */); - var typeParameter = createNode(151 /* TypeParameter */); + var typeParameter = createNode(152 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -19461,6 +19866,7 @@ var ts; case 130 /* KeyOfKeyword */: case 143 /* UniqueKeyword */: case 134 /* ReadonlyKeyword */: + case 148 /* TagKeyword */: return parseTypeOperator(operator); case 128 /* InferKeyword */: return parseInferType(); @@ -19483,10 +19889,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(175 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); + return parseUnionOrIntersectionType(176 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(174 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); + return parseUnionOrIntersectionType(175 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); } function isStartOfFunctionType() { if (token() === 28 /* LessThanToken */) { @@ -19543,7 +19949,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(164 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(165 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -19570,7 +19976,7 @@ var ts; } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(87 /* ExtendsKeyword */)) { - var node = createNode(176 /* ConditionalType */, type.pos); + var node = createNode(177 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); @@ -19764,7 +20170,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(208 /* YieldExpression */); + var node = createNode(209 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -19786,13 +20192,13 @@ var ts; ts.Debug.assert(token() === 37 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(198 /* ArrowFunction */, asyncModifier.pos); + node = createNode(199 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(198 /* ArrowFunction */, identifier.pos); + node = createNode(199 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(152 /* Parameter */, identifier.pos); + var parameter = createNode(153 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); @@ -19956,7 +20362,15 @@ var ts; } } function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + var tokenPos = scanner.getTokenPos(); + if (notParenthesizedArrow && notParenthesizedArrow.has(tokenPos.toString())) { + return undefined; + } + var result = parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + if (!result) { + (notParenthesizedArrow || (notParenthesizedArrow = ts.createMap())).set(tokenPos.toString(), true); + } + return result; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" @@ -19989,7 +20403,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(198 /* ArrowFunction */); + var node = createNodeWithJSDoc(199 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -20055,7 +20469,7 @@ var ts; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(206 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(207 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -20070,7 +20484,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 94 /* InKeyword */ || t === 148 /* OfKeyword */; + return t === 94 /* InKeyword */ || t === 149 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -20135,39 +20549,39 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(205 /* BinaryExpression */, left.pos); + var node = createNode(206 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(213 /* AsExpression */, left.pos); + var node = createNode(214 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(203 /* PrefixUnaryExpression */); + var node = createNode(204 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(199 /* DeleteExpression */); + var node = createNode(200 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(200 /* TypeOfExpression */); + var node = createNode(201 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(201 /* VoidExpression */); + var node = createNode(202 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -20183,7 +20597,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(202 /* AwaitExpression */); + var node = createNode(203 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -20227,7 +20641,7 @@ var ts; if (token() === 41 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 195 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 196 /* 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 { @@ -20324,7 +20738,7 @@ var ts; */ function parseUpdateExpression() { if (token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) { - var node = createNode(203 /* PrefixUnaryExpression */); + var node = createNode(204 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -20337,7 +20751,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(204 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(205 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -20393,7 +20807,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(215 /* MetaProperty */, fullStart); + var node = createNode(216 /* MetaProperty */, fullStart); node.keywordToken = 93 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); @@ -20475,7 +20889,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(190 /* PropertyAccessExpression */, expression.pos); + var node = createNode(191 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -20484,8 +20898,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 263 /* JsxOpeningElement */) { - var node = createNode(261 /* JsxElement */, opening.pos); + if (opening.kind === 264 /* JsxOpeningElement */) { + var node = createNode(262 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -20494,15 +20908,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 266 /* JsxOpeningFragment */) { - var node = createNode(265 /* JsxFragment */, opening.pos); + else if (opening.kind === 267 /* JsxOpeningFragment */) { + var node = createNode(266 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 262 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 263 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -20517,7 +20931,7 @@ var ts; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(205 /* BinaryExpression */, result.pos); + var badNode = createNode(206 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -20576,7 +20990,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(269 /* JsxAttributes */); + var jsxAttributes = createNode(270 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -20585,7 +20999,7 @@ var ts; parseExpected(28 /* LessThanToken */); if (token() === 30 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(266 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(267 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -20597,7 +21011,7 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(263 /* JsxOpeningElement */, fullStart); + node = createNode(264 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -20609,7 +21023,7 @@ var ts; parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(262 /* JsxSelfClosingElement */, fullStart); + node = createNode(263 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -20626,7 +21040,7 @@ var ts; var expression = token() === 101 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(191 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -20634,7 +21048,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(271 /* JsxExpression */); + var node = createNode(272 /* JsxExpression */); if (!parseExpected(18 /* OpenBraceToken */)) { return undefined; } @@ -20660,7 +21074,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(268 /* JsxAttribute */); + var node = createNode(269 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 60 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -20675,7 +21089,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(270 /* JsxSpreadAttribute */); + var node = createNode(271 /* JsxSpreadAttribute */); parseExpected(18 /* OpenBraceToken */); parseExpected(25 /* DotDotDotToken */); node.expression = parseExpression(); @@ -20683,7 +21097,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(264 /* JsxClosingElement */); + var node = createNode(265 /* JsxClosingElement */); parseExpected(29 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -20696,7 +21110,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(267 /* JsxClosingFragment */); + var node = createNode(268 /* JsxClosingFragment */); parseExpected(29 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -20711,7 +21125,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(195 /* TypeAssertionExpression */); + var node = createNode(196 /* TypeAssertionExpression */); parseExpected(28 /* LessThanToken */); node.type = parseType(); parseExpected(30 /* GreaterThanToken */); @@ -20722,7 +21136,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(24 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(191 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -20730,14 +21144,14 @@ var ts; } if (token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(214 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(215 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(22 /* OpenBracketToken */)) { - var indexedAccess = createNode(191 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(192 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; if (token() === 23 /* CloseBracketToken */) { indexedAccess.argumentExpression = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); @@ -20764,7 +21178,7 @@ var ts; return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(194 /* TaggedTemplateExpression */, tag.pos); + var tagExpression = createNode(195 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 14 /* NoSubstitutionTemplateLiteral */ @@ -20789,7 +21203,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(192 /* CallExpression */, expression.pos); + var callExpr = createNode(193 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -20797,7 +21211,7 @@ var ts; continue; } else if (token() === 20 /* OpenParenToken */) { - var callExpr = createNode(192 /* CallExpression */, expression.pos); + var callExpr = createNode(193 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -20835,6 +21249,7 @@ var ts; case 15 /* TemplateHead */: // foo `...${100}...` // these are the only tokens can legally follow a type argument // list. So we definitely want to treat them as type arg lists. + // falls through case 24 /* DotToken */: // foo. case 21 /* CloseParenToken */: // foo) case 23 /* CloseBracketToken */: // foo] @@ -20861,6 +21276,7 @@ var ts; // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. + // falls through default: // Anything else treat as an expression. return false; @@ -20911,28 +21327,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(196 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(197 /* ParenthesizedExpression */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(209 /* SpreadElement */); + var node = createNode(210 /* SpreadElement */); parseExpected(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? createNode(211 /* OmittedExpression */) : + token() === 27 /* CommaToken */ ? createNode(212 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(188 /* ArrayLiteralExpression */); + var node = createNode(189 /* ArrayLiteralExpression */); parseExpected(22 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -20944,17 +21360,17 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(25 /* DotDotDotToken */)) { - node.kind = 278 /* SpreadAssignment */; + node.kind = 279 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + return parseAccessorDeclaration(node, 160 /* GetAccessor */); } if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + return parseAccessorDeclaration(node, 161 /* SetAccessor */); } var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); @@ -20972,7 +21388,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 57 /* ColonToken */); if (isShorthandPropertyAssignment) { - node.kind = 277 /* ShorthandPropertyAssignment */; + node.kind = 278 /* ShorthandPropertyAssignment */; var equalsToken = parseOptionalToken(60 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; @@ -20980,14 +21396,14 @@ var ts; } } else { - node.kind = 276 /* PropertyAssignment */; + node.kind = 277 /* PropertyAssignment */; parseExpected(57 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(189 /* ObjectLiteralExpression */); + var node = createNode(190 /* ObjectLiteralExpression */); parseExpected(18 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21006,7 +21422,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(197 /* FunctionExpression */); + var node = createNodeWithJSDoc(198 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(91 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); @@ -21031,7 +21447,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(96 /* NewKeyword */); if (parseOptional(24 /* DotToken */)) { - var node_2 = createNode(215 /* MetaProperty */, fullStart); + var node_2 = createNode(216 /* MetaProperty */, fullStart); node_2.keywordToken = 96 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -21048,7 +21464,7 @@ var ts; } break; } - var node = createNode(193 /* NewExpression */, fullStart); + var node = createNode(194 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 20 /* OpenParenToken */) { @@ -21058,7 +21474,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(219 /* Block */); + var node = createNode(220 /* Block */); if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21091,12 +21507,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(221 /* EmptyStatement */); + var node = createNode(222 /* EmptyStatement */); parseExpected(26 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(223 /* IfStatement */); + var node = createNode(224 /* IfStatement */); parseExpected(92 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -21106,7 +21522,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(224 /* DoStatement */); + var node = createNode(225 /* DoStatement */); parseExpected(83 /* DoKeyword */); node.statement = parseStatement(); parseExpected(108 /* WhileKeyword */); @@ -21121,7 +21537,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(225 /* WhileStatement */); + var node = createNode(226 /* WhileStatement */); parseExpected(108 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -21144,8 +21560,8 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(148 /* OfKeyword */) : parseOptional(148 /* OfKeyword */)) { - var forOfStatement = createNode(228 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(149 /* OfKeyword */) : parseOptional(149 /* OfKeyword */)) { + var forOfStatement = createNode(229 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -21153,14 +21569,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(94 /* InKeyword */)) { - var forInStatement = createNode(227 /* ForInStatement */, pos); + var forInStatement = createNode(228 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(226 /* ForStatement */, pos); + var forStatement = createNode(227 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(26 /* SemicolonToken */); if (token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */) { @@ -21178,7 +21594,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 230 /* BreakStatement */ ? 74 /* BreakKeyword */ : 79 /* ContinueKeyword */); + parseExpected(kind === 231 /* BreakStatement */ ? 74 /* BreakKeyword */ : 79 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -21186,7 +21602,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(231 /* ReturnStatement */); + var node = createNode(232 /* ReturnStatement */); parseExpected(98 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -21195,7 +21611,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(232 /* WithStatement */); + var node = createNode(233 /* WithStatement */); parseExpected(109 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -21204,7 +21620,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(272 /* CaseClause */); + var node = createNode(273 /* CaseClause */); parseExpected(75 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(57 /* ColonToken */); @@ -21212,7 +21628,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(273 /* DefaultClause */); + var node = createNode(274 /* DefaultClause */); parseExpected(81 /* DefaultKeyword */); parseExpected(57 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -21222,12 +21638,12 @@ var ts; return token() === 75 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(233 /* SwitchStatement */); + var node = createNode(234 /* SwitchStatement */); parseExpected(100 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - var caseBlock = createNode(247 /* CaseBlock */); + var caseBlock = createNode(248 /* CaseBlock */); parseExpected(18 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(19 /* CloseBraceToken */); @@ -21242,7 +21658,7 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(235 /* ThrowStatement */); + var node = createNode(236 /* ThrowStatement */); parseExpected(102 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -21250,7 +21666,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(236 /* TryStatement */); + var node = createNode(237 /* TryStatement */); parseExpected(104 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 76 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -21263,7 +21679,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(275 /* CatchClause */); + var result = createNode(276 /* CatchClause */); parseExpected(76 /* CatchKeyword */); if (parseOptional(20 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -21277,7 +21693,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(237 /* DebuggerStatement */); + var node = createNode(238 /* DebuggerStatement */); parseExpected(80 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -21289,12 +21705,12 @@ var ts; var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); if (expression.kind === 73 /* Identifier */ && parseOptional(57 /* ColonToken */)) { - node.kind = 234 /* LabeledStatement */; + node.kind = 235 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 222 /* ExpressionStatement */; + node.kind = 223 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -21416,6 +21832,7 @@ var ts; case 80 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. + // falls through case 76 /* CatchKeyword */: case 89 /* FinallyKeyword */: return true; @@ -21461,16 +21878,16 @@ var ts; case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); case 106 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(239 /* VariableDeclaration */)); case 112 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(239 /* VariableDeclaration */)); } break; case 91 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(240 /* FunctionDeclaration */)); + return parseFunctionDeclaration(createNodeWithJSDoc(241 /* FunctionDeclaration */)); case 77 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(241 /* ClassDeclaration */)); + return parseClassDeclaration(createNodeWithJSDoc(242 /* ClassDeclaration */)); case 92 /* IfKeyword */: return parseIfStatement(); case 83 /* DoKeyword */: @@ -21480,9 +21897,9 @@ var ts; case 90 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 79 /* ContinueKeyword */: - return parseBreakOrContinueStatement(229 /* ContinueStatement */); + return parseBreakOrContinueStatement(230 /* ContinueStatement */); case 74 /* BreakKeyword */: - return parseBreakOrContinueStatement(230 /* BreakStatement */); + return parseBreakOrContinueStatement(231 /* BreakStatement */); case 98 /* ReturnKeyword */: return parseReturnStatement(); case 109 /* WithKeyword */: @@ -21493,6 +21910,7 @@ var ts; return parseThrowStatement(); case 104 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. + // falls through case 76 /* CatchKeyword */: case 89 /* FinallyKeyword */: return parseTryStatement(); @@ -21528,10 +21946,21 @@ var ts; return modifier.kind === 126 /* DeclareKeyword */; } function parseDeclaration() { + var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); }); + // `parseListElement` attempted to get the reused node at this position, + // but the ambient context flag was not yet set, so the node appeared + // not reusable in that context. + var isAmbient = ts.some(modifiers, isDeclareModifier); + if (isAmbient) { + var node_3 = tryReuseAmbientDeclaration(); + if (node_3) { + return node_3; + } + } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (ts.some(node.modifiers, isDeclareModifier)) { + if (isAmbient) { for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var m = _a[_i]; m.flags |= 4194304 /* Ambient */; @@ -21542,6 +21971,14 @@ var ts; return parseDeclarationWorker(node); } } + function tryReuseAmbientDeclaration() { + return doInsideOfContext(4194304 /* Ambient */, function () { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + }); + } function parseDeclarationWorker(node) { switch (token()) { case 106 /* VarKeyword */: @@ -21579,7 +22016,7 @@ var ts; if (node.decorators || node.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(259 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(260 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -21602,16 +22039,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 27 /* CommaToken */) { - return createNode(211 /* OmittedExpression */); + return createNode(212 /* OmittedExpression */); } - var node = createNode(187 /* BindingElement */); + var node = createNode(188 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(187 /* BindingElement */); + var node = createNode(188 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -21627,14 +22064,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(185 /* ObjectBindingPattern */); + var node = createNode(186 /* ObjectBindingPattern */); parseExpected(18 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(186 /* ArrayBindingPattern */); + var node = createNode(187 /* ArrayBindingPattern */); parseExpected(22 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(23 /* CloseBracketToken */); @@ -21656,7 +22093,7 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(238 /* VariableDeclaration */); + var node = createNode(239 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 73 /* Identifier */ && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { @@ -21669,7 +22106,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(239 /* VariableDeclarationList */); + var node = createNode(240 /* VariableDeclarationList */); switch (token()) { case 106 /* VarKeyword */: break; @@ -21692,7 +22129,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 148 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 149 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -21707,13 +22144,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 220 /* VariableStatement */; + node.kind = 221 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 240 /* FunctionDeclaration */; + node.kind = 241 /* FunctionDeclaration */; parseExpected(91 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); @@ -21737,7 +22174,7 @@ var ts; function tryParseConstructorDeclaration(node) { return tryParse(function () { if (parseConstructorName()) { - node.kind = 158 /* Constructor */; + node.kind = 159 /* Constructor */; fillSignature(57 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); @@ -21745,7 +22182,7 @@ var ts; }); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 157 /* MethodDeclaration */; + node.kind = 158 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; @@ -21754,7 +22191,7 @@ var ts; return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 155 /* PropertyDeclaration */; + node.kind = 156 /* PropertyDeclaration */; if (!node.questionToken && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } @@ -21859,7 +22296,7 @@ var ts; if (!parseOptional(58 /* AtToken */)) { break; } - var decorator = createNode(153 /* Decorator */, decoratorStart); + var decorator = createNode(154 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -21909,7 +22346,7 @@ var ts; } function parseClassElement() { if (token() === 26 /* SemicolonToken */) { - var result = createNode(218 /* SemicolonClassElement */); + var result = createNode(219 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -21917,10 +22354,10 @@ var ts; node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + return parseAccessorDeclaration(node, 160 /* GetAccessor */); } if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + return parseAccessorDeclaration(node, 161 /* SetAccessor */); } if (token() === 125 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(node); @@ -21949,10 +22386,10 @@ var ts; return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 210 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 211 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 241 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 242 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -21995,22 +22432,21 @@ var ts; function parseHeritageClause() { var tok = token(); ts.Debug.assert(tok === 87 /* ExtendsKeyword */ || tok === 110 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(274 /* HeritageClause */); + var node = createNode(275 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(213 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 28 /* LessThanToken */ - ? parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) - : undefined; + return token() === 28 /* LessThanToken */ ? + parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) : undefined; } function isHeritageClause() { return token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; @@ -22019,7 +22455,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 242 /* InterfaceDeclaration */; + node.kind = 243 /* InterfaceDeclaration */; parseExpected(111 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -22028,7 +22464,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 243 /* TypeAliasDeclaration */; + node.kind = 244 /* TypeAliasDeclaration */; parseExpected(141 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -22042,13 +22478,13 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNodeWithJSDoc(279 /* EnumMember */); + var node = createNodeWithJSDoc(280 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 244 /* EnumDeclaration */; + node.kind = 245 /* EnumDeclaration */; parseExpected(85 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(18 /* OpenBraceToken */)) { @@ -22061,7 +22497,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(246 /* ModuleBlock */); + var node = createNode(247 /* ModuleBlock */); if (parseExpected(18 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(19 /* CloseBraceToken */); @@ -22072,7 +22508,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 245 /* ModuleDeclaration */; + node.kind = 246 /* ModuleDeclaration */; // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -22084,7 +22520,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 245 /* ModuleDeclaration */; + node.kind = 246 /* ModuleDeclaration */; if (token() === 146 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); @@ -22130,7 +22566,7 @@ var ts; return nextToken() === 42 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 248 /* NamespaceExportDeclaration */; + node.kind = 249 /* NamespaceExportDeclaration */; parseExpected(120 /* AsKeyword */); parseExpected(132 /* NamespaceKeyword */); node.name = parseIdentifier(); @@ -22148,7 +22584,7 @@ var ts; } } // Import statement - node.kind = 250 /* ImportDeclaration */; + node.kind = 251 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; @@ -22163,7 +22599,7 @@ var ts; return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 249 /* ImportEqualsDeclaration */; + node.kind = 250 /* ImportEqualsDeclaration */; node.name = identifier; parseExpected(60 /* EqualsToken */); node.moduleReference = parseModuleReference(); @@ -22177,7 +22613,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(251 /* ImportClause */, fullStart); + var importClause = createNode(252 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -22187,7 +22623,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(27 /* CommaToken */)) { - importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(253 /* NamedImports */); + importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(254 /* NamedImports */); } return finishNode(importClause); } @@ -22197,7 +22633,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(260 /* ExternalModuleReference */); + var node = createNode(261 /* ExternalModuleReference */); parseExpected(135 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -22220,7 +22656,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(252 /* NamespaceImport */); + var namespaceImport = createNode(253 /* NamespaceImport */); parseExpected(40 /* AsteriskToken */); parseExpected(120 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -22235,14 +22671,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 253 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); + node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 254 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(258 /* ExportSpecifier */); + return parseImportOrExportSpecifier(259 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(254 /* ImportSpecifier */); + return parseImportOrExportSpecifier(255 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -22267,19 +22703,19 @@ var ts; else { node.name = identifierName; } - if (kind === 254 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 255 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 256 /* ExportDeclaration */; + node.kind = 257 /* ExportDeclaration */; if (parseOptional(40 /* AsteriskToken */)) { parseExpected(145 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(257 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(258 /* 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. @@ -22292,7 +22728,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 255 /* ExportAssignment */; + node.kind = 256 /* ExportAssignment */; if (parseOptional(60 /* EqualsToken */)) { node.isExportEquals = true; } @@ -22312,12 +22748,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */ - || node.kind === 250 /* ImportDeclaration */ - || node.kind === 255 /* ExportAssignment */ - || node.kind === 256 /* ExportDeclaration */ - ? node - : undefined; + || node.kind === 250 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 261 /* ExternalModuleReference */ + || node.kind === 251 /* ImportDeclaration */ + || node.kind === 256 /* ExportAssignment */ + || node.kind === 257 /* ExportDeclaration */ ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { return sourceFile.flags & 1048576 /* PossiblyContainsImportMeta */ ? @@ -22379,7 +22813,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(289 /* JSDocTypeExpression */); + var result = createNode(290 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -22391,8 +22825,8 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseIsolatedJSDocComment(content, start, length) { initializeState(content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = { languageVariant: 0 /* Standard */, text: content }; // tslint:disable-line no-object-literal-type-assertion - var jsDoc = parseJSDocCommentWorker(start, length); + sourceFile = { languageVariant: 0 /* Standard */, text: content }; + var jsDoc = doInsideOfContext(2097152 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); var diagnostics = parseDiagnostics; clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -22403,7 +22837,7 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = parseJSDocCommentWorker(start, length); + var comment = doInsideOfContext(2097152 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); if (comment) { comment.parent = parent; } @@ -22542,7 +22976,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(297 /* JSDocComment */, start); + var result = createNode(299 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -22742,7 +23176,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(300 /* JSDocTag */, start); + var result = createNode(302 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -22789,7 +23223,7 @@ var ts; switch (node.kind) { case 137 /* ObjectKeyword */: return true; - case 170 /* ArrayType */: + case 171 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -22805,8 +23239,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(312 /* JSDocPropertyTag */, start) : - createNode(306 /* JSDocParameterTag */, start); + createNode(314 /* JSDocPropertyTag */, start) : + createNode(308 /* JSDocParameterTag */, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -22823,20 +23257,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(289 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(290 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; - var start_2 = scanner.getStartPos(); + var start_3 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 306 /* JSDocParameterTag */ || child.kind === 312 /* JSDocPropertyTag */) { + if (child.kind === 308 /* JSDocParameterTag */ || child.kind === 314 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(298 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(300 /* JSDocTypeLiteral */, start_3); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression.type.kind === 171 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -22848,7 +23282,7 @@ var ts; if (ts.some(tags, ts.isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(307 /* JSDocReturnTag */, start); + var result = createNode(309 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); @@ -22857,13 +23291,13 @@ var ts; if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(309 /* JSDocTypeTag */, start); + var result = createNode(311 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAuthorTag(start, tagName, indent) { - var result = createNode(302 /* JSDocAuthorTag */, start); + var result = createNode(304 /* JSDocAuthorTag */, start); result.tagName = tagName; var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); }); if (!authorInfoWithEmail) { @@ -22917,14 +23351,14 @@ var ts; } } function parseAugmentsTag(start, tagName) { - var result = createNode(301 /* JSDocAugmentsTag */, start); + var result = createNode(303 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18 /* OpenBraceToken */); - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(213 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -22936,7 +23370,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var prop = createNode(190 /* PropertyAccessExpression */, node.pos); + var prop = createNode(191 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -22944,19 +23378,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(303 /* JSDocClassTag */, start); + var tag = createNode(305 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(308 /* JSDocThisTag */, start); + var tag = createNode(310 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(305 /* JSDocEnumTag */, start); + var tag = createNode(307 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); @@ -22965,7 +23399,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(311 /* JSDocTypedefTag */, start); + var typedefTag = createNode(313 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -22979,9 +23413,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(298 /* JSDocTypeLiteral */, start); + jsdocTypeLiteral = createNode(300 /* JSDocTypeLiteral */, start); } - if (child.kind === 309 /* JSDocTypeTag */) { + if (child.kind === 311 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -22994,7 +23428,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 171 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -23013,7 +23447,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(24 /* DotToken */)) { - var jsDocNamespaceNode = createNode(245 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(246 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -23027,14 +23461,14 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(304 /* JSDocCallbackTag */, start); + var callbackTag = createNode(306 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(299 /* JSDocSignature */, start); + var jsdocSignature = createNode(301 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -23042,7 +23476,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(58 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 307 /* JSDocReturnTag */) { + if (tag && tag.kind === 309 /* JSDocReturnTag */) { return tag; } } @@ -23087,7 +23521,7 @@ var ts; case 58 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 306 /* JSDocParameterTag */ || child.kind === 312 /* JSDocPropertyTag */) && + if (child && (child.kind === 308 /* JSDocParameterTag */ || child.kind === 314 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -23151,13 +23585,13 @@ var ts; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(151 /* TypeParameter */); + var typeParameter = createNode(152 /* TypeParameter */); typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); finishNode(typeParameter); skipWhitespace(); typeParameters.push(typeParameter); } while (parseOptionalJsdoc(27 /* CommaToken */)); - var result = createNode(310 /* JSDocTemplateTag */, start); + var result = createNode(312 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -23192,16 +23626,19 @@ var ts; if (!ts.tokenIsIdentifierOrKeyword(token())) { return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } + identifierCount++; var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); var result = createNode(73 /* Identifier */, pos); - result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); + if (token() !== 73 /* Identifier */) { + result.originalKeywordKind = token(); + } + result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); finishNode(result, end); nextTokenJSDoc(); return result; } } - JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {})); })(Parser || (Parser = {})); var IncrementalParser; @@ -24047,6 +24484,7 @@ var ts; type: "boolean", category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_incremental_compilation, + transpileOptionValue: undefined }, { name: "locale", @@ -24056,7 +24494,7 @@ var ts; }, ]; /* @internal */ - ts.optionDeclarations = ts.commonOptionsWithBuild.concat([ + ts.optionDeclarations = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "all", type: "boolean", @@ -24158,7 +24596,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation + description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation, + transpileOptionValue: undefined }, { name: "allowJs", @@ -24195,6 +24634,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "declarationMap", @@ -24203,6 +24643,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "emitDeclarationOnly", @@ -24210,6 +24651,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Only_emit_d_ts_declaration_files, + transpileOptionValue: undefined }, { name: "sourceMap", @@ -24228,6 +24670,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "outDir", @@ -24255,6 +24698,7 @@ var ts; isTSConfigOnly: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_project_compilation, + transpileOptionValue: undefined }, { name: "tsBuildInfoFile", @@ -24264,6 +24708,7 @@ var ts; paramType: ts.Diagnostics.FILE, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, + transpileOptionValue: undefined }, { name: "removeComments", @@ -24280,6 +24725,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Do_not_emit_outputs, + transpileOptionValue: undefined }, { name: "importHelpers", @@ -24299,7 +24745,8 @@ var ts; name: "isolatedModules", type: "boolean", category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule + description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule, + transpileOptionValue: true }, // Strict Type Checks { @@ -24433,7 +24880,8 @@ var ts; affectsModuleResolution: true, isTSConfigOnly: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl + description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl, + transpileOptionValue: undefined }, { // this option can only be specified in tsconfig.json @@ -24448,7 +24896,8 @@ var ts; }, affectsModuleResolution: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime + description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime, + transpileOptionValue: undefined }, { name: "typeRoots", @@ -24472,7 +24921,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation, + transpileOptionValue: undefined }, { name: "allowSyntheticDefaultImports", @@ -24569,6 +25019,7 @@ var ts; category: ts.Diagnostics.Advanced_Options, paramType: ts.Diagnostics.FILE, description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "reactNamespace", @@ -24618,14 +25069,20 @@ var ts; type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts + description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts, + // We are not returning a sourceFile for lib file when asked by the program, + // so pass --noLib to avoid reporting a file not found error. + transpileOptionValue: true }, { name: "noResolve", type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files + description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files, + // We are not doing a full typecheck, we are not resolving the whole context, + // so pass --noResolve to avoid reporting missing file errors. + transpileOptionValue: true }, { name: "stripInternal", @@ -24661,6 +25118,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + transpileOptionValue: undefined }, { name: "preserveConstEnums", @@ -24676,7 +25134,8 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Output_directory_for_generated_declaration_files + description: ts.Diagnostics.Output_directory_for_generated_declaration_files, + transpileOptionValue: undefined }, { name: "skipLibCheck", @@ -24763,7 +25222,11 @@ var ts; return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics; }); /* @internal */ - ts.buildOpts = ts.commonOptionsWithBuild.concat([ + ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) { + return ts.hasProperty(option, "transpileOptionValue"); + }); + /* @internal */ + ts.buildOpts = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "verbose", shortName: "v", @@ -25327,7 +25790,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 276 /* PropertyAssignment */) { + if (element.kind !== 277 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -25391,7 +25854,7 @@ var ts; return false; case 97 /* NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for - return null; // tslint:disable-line:no-null-keyword + return null; // eslint-disable-line no-null/no-null case 10 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); @@ -25409,13 +25872,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: if (valueExpression.operator !== 39 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -25432,7 +25895,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25483,13 +25946,13 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName); }); var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames }); - var config = __assign({ compilerOptions: __assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { + var config = __assign(__assign({ compilerOptions: __assign(__assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { var _a; - return (__assign({}, prev, (_a = {}, _a[cur[0]] = cur[1], _a))); - }, {}), { showConfig: undefined, configFile: undefined, configFilePath: undefined, help: undefined, init: undefined, listFiles: undefined, listEmittedFiles: undefined, project: undefined, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign({}, r, { path: r.originalPath, originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { + return (__assign(__assign({}, prev), (_a = {}, _a[cur[0]] = cur[1], _a))); + }, {})), { showConfig: undefined, configFile: undefined, configFilePath: undefined, help: undefined, init: undefined, listFiles: undefined, listEmittedFiles: undefined, project: undefined, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign(__assign({}, r), { path: r.originalPath ? r.originalPath : "", originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs), exclude: configParseResult.configFileSpecs.validatedExcludeSpecs - } : {}), { compilerOnSave: !!configParseResult.compileOnSave ? true : undefined }); + } : {})), { compileOnSave: !!configParseResult.compileOnSave ? true : undefined }); return config; } ts.convertToTSConfig = convertToTSConfig; @@ -25714,8 +26177,7 @@ var ts; } ts.setConfigFileInOptions = setConfigFileInOptions; function isNullOrUndefined(x) { - // tslint:disable-next-line:no-null-keyword - return x === undefined || x === null; + return x === undefined || x === null; // eslint-disable-line no-null/no-null } function directoryOfCombinedPath(fileName, basePath) { // Use the `getNormalizedAbsolutePath` function to avoid canonicalizing the path, as it must remain noncanonical @@ -25881,7 +26343,7 @@ var ts; basePath = ts.normalizeSlashes(basePath); var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath); if (resolutionStack.indexOf(resolvedPath) >= 0) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))); + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, __spreadArrays(resolutionStack, [resolvedPath]).join(" -> "))); return { raw: json || convertToObject(sourceFile, errors) }; } var ownConfig = json ? @@ -26570,8 +27032,9 @@ var ts; return; } var value = jsonContent[fieldName]; - if (typeof value !== typeOfTag || value === null) { + if (typeof value !== typeOfTag || value === null) { // eslint-disable-line no-null/no-null if (state.traceEnabled) { + // eslint-disable-next-line no-null/no-null trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, fieldName, typeOfTag, value === null ? "null" : typeof value); } return; @@ -26830,7 +27293,7 @@ var ts; var packageJsonPath = ts.combinePaths(root, normalized, "package.json"); // `types-publisher` sometimes creates packages with `"typings": null` for packages that don't provide their own types. // See `createNotNeededPackageJSON` in the types-publisher` repo. - // tslint:disable-next-line:no-null-keyword + // eslint-disable-next-line no-null/no-null var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); @@ -27014,6 +27477,7 @@ var ts; trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); } } + ts.perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/); switch (moduleResolution) { case ts.ModuleResolutionKind.NodeJs: result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); @@ -27024,6 +27488,9 @@ var ts; default: return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); } + if (result && result.resolvedModule) + ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, result); if (!ts.isExternalModuleNameRelative(moduleName)) { @@ -27233,7 +27700,7 @@ var ts; ts.tryResolveJSModule = tryResolveJSModule; var jsOnlyExtensions = [Extensions.JavaScript]; var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript]; - var tsPlusJsonExtensions = tsExtensions.concat([Extensions.Json]); + var tsPlusJsonExtensions = __spreadArrays(tsExtensions, [Extensions.Json]); var tsconfigExtensions = [Extensions.TSConfig]; function tryResolveJSModuleWorker(moduleName, initialDir, host) { return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); @@ -27269,7 +27736,7 @@ var ts; if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) { var path = realPath(resolvedValue.path, host, traceEnabled); var originalPath = path === resolvedValue.path ? undefined : resolvedValue.path; - resolvedValue = __assign({}, resolvedValue, { path: path, originalPath: originalPath }); + resolvedValue = __assign(__assign({}, resolvedValue), { path: path, originalPath: originalPath }); } // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } }; @@ -27290,7 +27757,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); // tslint:disable-line + ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -27778,24 +28245,24 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. other uninstantiated module declarations. - case 246 /* ModuleBlock */: { + case 247 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -27817,7 +28284,7 @@ var ts; }); return state_1; } - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return getModuleInstanceState(node); case 73 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should @@ -27856,7 +28323,9 @@ var ts; var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); + ts.perfLogger.logStartBindFile("" + file.fileName); binder(file, options); + ts.perfLogger.logStopBindFile(); ts.performance.mark("afterBind"); ts.performance.measure("Bind", "beforeBind", "afterBind"); } @@ -27890,7 +28359,7 @@ var ts; // or if compiler options contain alwaysStrict. var inStrictMode; var symbolCount = 0; - var Symbol; // tslint:disable-line variable-name + var Symbol; var classifiableNames; var unreachableFlow = { flags: 1 /* Unreachable */ }; var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; @@ -27958,7 +28427,7 @@ var ts; function addDeclarationToSymbol(symbol, node, symbolFlags) { symbol.flags |= symbolFlags; node.symbol = symbol; - symbol.declarations = ts.append(symbol.declarations, node); + symbol.declarations = ts.appendIfUnique(symbol.declarations, node); if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -27969,7 +28438,7 @@ var ts; if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 67220415 /* Value */) { + if (symbolFlags & 111551 /* Value */) { setValueDeclaration(symbol, node); } } @@ -27985,7 +28454,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 === 255 /* ExportAssignment */) { + if (node.kind === 256 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -27994,7 +28463,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 151 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -28009,36 +28478,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: return "__constructor" /* Constructor */; - case 166 /* FunctionType */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: + case 167 /* FunctionType */: + case 162 /* CallSignature */: + case 301 /* JSDocSignature */: return "__call" /* Call */; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 168 /* ConstructorType */: + case 163 /* ConstructSignature */: return "__new" /* New */; - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: return "__index" /* Index */; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 285 /* SourceFile */: + case 286 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 152 /* Parameter */: + case 153 /* 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 === 295 /* 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 === 296 /* 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; @@ -28138,7 +28607,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 === 255 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 256 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -28156,7 +28625,7 @@ var ts; } }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); - file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInformation_1)) : diag); + file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInformation_1)) : diag); symbol = createSymbol(0 /* None */, name); } } @@ -28173,7 +28642,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 258 /* ExportSpecifier */ || (node.kind === 249 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 259 /* ExportSpecifier */ || (node.kind === 250 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -28198,10 +28667,10 @@ var ts; if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { - if (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node)) { + if (!container.locals || (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } - var exportKind = symbolFlags & 67220415 /* Value */ ? 1048576 /* ExportValue */ : 0; + var exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -28240,7 +28709,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 !== 198 /* ArrowFunction */) { + if (node.kind !== 199 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -28273,7 +28742,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 === 158 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 159 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -28287,13 +28756,13 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 158 /* Constructor */) { + if (node.kind === 159 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -28337,8 +28806,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 241 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 241 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -28371,78 +28840,82 @@ var ts; return; } switch (node.kind) { - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: bindWhileStatement(node); break; - case 224 /* DoStatement */: + case 225 /* DoStatement */: bindDoStatement(node); break; - case 226 /* ForStatement */: + case 227 /* ForStatement */: bindForStatement(node); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 223 /* IfStatement */: + case 224 /* IfStatement */: bindIfStatement(node); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 232 /* ReturnStatement */: + case 236 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 236 /* TryStatement */: + case 237 /* TryStatement */: bindTryStatement(node); break; - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: bindSwitchStatement(node); break; - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: bindCaseBlock(node); break; - case 272 /* CaseClause */: + case 273 /* CaseClause */: bindCaseClause(node); break; - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: bindLabeledStatement(node); break; - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 192 /* CallExpression */: + case 193 /* CallExpression */: bindCallExpressionFlow(node); break; - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; + case 305 /* JSDocClassTag */: + bindJSDocClassTag(node); + break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 285 /* SourceFile */: { + case 286 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 220 /* Block */: + case 247 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -28455,18 +28928,18 @@ var ts; switch (expr.kind) { case 73 /* Identifier */: case 101 /* ThisKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return isNarrowableReference(expr); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return hasNarrowableArgument(expr); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return expr.operator === 52 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; @@ -28474,7 +28947,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 73 /* Identifier */ || expr.kind === 101 /* ThisKeyword */ || expr.kind === 99 /* SuperKeyword */ || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isElementAccessExpression(expr) && expr.argumentExpression && + ts.isElementAccessExpression(expr) && (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && isNarrowableReference(expr.expression); } @@ -28487,7 +28960,7 @@ var ts; } } } - if (expr.expression.kind === 190 /* PropertyAccessExpression */ && + if (expr.expression.kind === 191 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -28520,9 +28993,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 60 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -28600,33 +29073,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 224 /* IfStatement */: + case 226 /* WhileStatement */: + case 225 /* DoStatement */: return parent.expression === node; - case 226 /* ForStatement */: - case 206 /* ConditionalExpression */: + case 227 /* ForStatement */: + case 207 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 196 /* ParenthesizedExpression */) { + if (node.kind === 197 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 203 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { + else if (node.kind === 204 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 205 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || + return node.kind === 206 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 55 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */ || - node.parent.kind === 203 /* PrefixUnaryExpression */ && + while (node.parent.kind === 197 /* ParenthesizedExpression */ || + node.parent.kind === 204 /* PrefixUnaryExpression */ && node.parent.operator === 52 /* ExclamationToken */) { node = node.parent; } @@ -28668,7 +29141,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 234 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 235 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -28702,13 +29175,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 228 /* ForOfStatement */) { + if (node.kind === 229 /* ForOfStatement */) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 239 /* VariableDeclarationList */) { + if (node.initializer.kind !== 240 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -28730,7 +29203,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 231 /* ReturnStatement */) { + if (node.kind === 232 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -28750,7 +29223,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 230 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 231 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -28878,7 +29351,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 273 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 274 /* 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). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -28945,14 +29418,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 224 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 225 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */) { + if (node.kind === 206 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -28963,10 +29436,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 188 /* ArrayLiteralExpression */) { + else if (node.kind === 189 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 209 /* SpreadElement */) { + if (e.kind === 210 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -28974,16 +29447,16 @@ var ts; } } } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 190 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 276 /* PropertyAssignment */) { + if (p.kind === 277 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 277 /* ShorthandPropertyAssignment */) { + else if (p.kind === 278 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 278 /* SpreadAssignment */) { + else if (p.kind === 279 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -29039,7 +29512,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 60 /* EqualsToken */ && node.left.kind === 191 /* ElementAccessExpression */) { + if (operator === 60 /* EqualsToken */ && node.left.kind === 192 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29050,7 +29523,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + if (node.expression.kind === 191 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -29089,19 +29562,26 @@ var ts; } function bindJSDocTypeAlias(node) { node.tagName.parent = node; - if (node.fullName) { + if (node.kind !== 307 /* JSDocEnumTag */ && node.fullName) { setParentPointers(node, node.fullName); } } + function bindJSDocClassTag(node) { + bindEachChild(node); + var host = ts.getHostSignatureFromJSDoc(node); + if (host && host.kind !== 158 /* MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* Class */); + } + } function bindCallExpressionFlow(node) { // If the target of the call expression is a function expression or arrow function we have // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = node.expression; - while (expr.kind === 196 /* ParenthesizedExpression */) { + while (expr.kind === 197 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 197 /* FunctionExpression */ || expr.kind === 198 /* ArrowFunction */) { + if (expr.kind === 198 /* FunctionExpression */ || expr.kind === 199 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -29109,7 +29589,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + if (node.expression.kind === 191 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29118,54 +29598,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 269 /* JsxAttributes */: + case 211 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 190 /* ObjectLiteralExpression */: + case 170 /* TypeLiteral */: + case 300 /* JSDocTypeLiteral */: + case 270 /* JsxAttributes */: return 1 /* IsContainer */; - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 246 /* ModuleDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 183 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 285 /* SourceFile */: + case 286 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: - case 295 /* JSDocFunctionType */: - case 166 /* FunctionType */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 167 /* ConstructorType */: + case 159 /* Constructor */: + case 241 /* FunctionDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 162 /* CallSignature */: + case 301 /* JSDocSignature */: + case 296 /* JSDocFunctionType */: + case 167 /* FunctionType */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 168 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 275 /* CatchClause */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 247 /* CaseBlock */: + case 276 /* CatchClause */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: + case 248 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 219 /* Block */: + case 220 /* 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 @@ -29198,45 +29678,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 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 285 /* SourceFile */: + case 286 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 242 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 189 /* ObjectLiteralExpression */: - case 242 /* InterfaceDeclaration */: - case 269 /* JsxAttributes */: + case 170 /* TypeLiteral */: + case 300 /* JSDocTypeLiteral */: + case 190 /* ObjectLiteralExpression */: + case 243 /* InterfaceDeclaration */: + case 270 /* 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 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 299 /* JSDocSignature */: - case 163 /* IndexSignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 295 /* JSDocFunctionType */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 301 /* JSDocSignature */: + case 164 /* IndexSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 296 /* JSDocFunctionType */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 244 /* TypeAliasDeclaration */: + case 183 /* 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 @@ -29337,7 +29817,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */ || prop.name.kind !== 73 /* Identifier */) { + if (prop.kind === 279 /* SpreadAssignment */ || prop.name.kind !== 73 /* Identifier */) { continue; } var identifier = prop.name; @@ -29349,7 +29829,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 === 276 /* PropertyAssignment */ || prop.kind === 277 /* ShorthandPropertyAssignment */ || prop.kind === 157 /* MethodDeclaration */ + var currentKind = prop.kind === 277 /* PropertyAssignment */ || prop.kind === 278 /* ShorthandPropertyAssignment */ || prop.kind === 158 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -29381,10 +29861,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -29415,9 +29895,37 @@ var ts; currentFlow = { flags: 2 /* Start */ }; parent = typeAlias; bind(typeAlias.typeExpression); - if (!typeAlias.fullName || typeAlias.fullName.kind === 73 /* Identifier */) { + var declName = ts.getNameOfDeclaration(typeAlias); + if ((ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName) && declName && ts.isPropertyAccessEntityNameExpression(declName.parent)) { + // typedef anchored to an A.B.C assignment - we need to bind into B's namespace under name C + var isTopLevel = isTopLevelNamespaceAssignment(declName.parent); + if (isTopLevel) { + bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); + var oldContainer = container; + switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { + case 1 /* ExportsProperty */: + case 2 /* ModuleExports */: + container = file; + break; + case 4 /* ThisProperty */: + container = declName.parent.expression; + break; + case 3 /* PrototypeProperty */: + container = declName.parent.expression.name; + break; + case 5 /* Property */: + container = ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; + break; + case 0 /* None */: + return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); + } + declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + container = oldContainer; + } + } + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 73 /* Identifier */) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); } else { bind(typeAlias.fullName); @@ -29436,7 +29944,8 @@ var ts; node.originalKeywordKind >= 110 /* FirstFutureReservedWord */ && node.originalKeywordKind <= 118 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && - !(node.flags & 4194304 /* Ambient */)) { + !(node.flags & 4194304 /* Ambient */) && + !(node.flags & 2097152 /* JSDoc */)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -29522,8 +30031,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 285 /* SourceFile */ && - blockScopeContainer.kind !== 245 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 286 /* SourceFile */ && + blockScopeContainer.kind !== 246 /* 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. @@ -29584,7 +30093,7 @@ var ts; file.bindDiagnostics.push(diag); } else { - file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } } function bind(node) { @@ -29618,7 +30127,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 > 148 /* LastToken */) { + if (node.kind > 149 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -29689,17 +30198,17 @@ var ts; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); break; } // falls through case 101 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 277 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 278 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -29710,10 +30219,10 @@ var ts; file.commonJsModuleIndicator && ts.isModuleExportsPropertyAccessExpression(node) && !lookupSymbolForNameWorker(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 67220414 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -29741,76 +30250,76 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return checkStrictModeCatchClause(node); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return checkStrictModeWithStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 179 /* ThisType */: + case 180 /* ThisType */: seenThisKeyword = true; return; - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: break; // Binding the children will handle everything - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return bindTypeParameter(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return bindParameter(node); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 187 /* BindingElement */: + case 188 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return bindPropertyWorker(node); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 279 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 280 /* EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* 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 */ : 67212223 /* MethodExcludes */); - case 240 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); + case 241 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 158 /* Constructor */: + case 159 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 159 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 67154879 /* GetAccessorExcludes */); - case 160 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67187647 /* SetAccessorExcludes */); - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 299 /* JSDocSignature */: - case 167 /* ConstructorType */: + case 160 /* GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); + case 161 /* SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); + case 167 /* FunctionType */: + case 296 /* JSDocFunctionType */: + case 301 /* JSDocSignature */: + case 168 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 182 /* MappedType */: + case 170 /* TypeLiteral */: + case 300 /* JSDocTypeLiteral */: + case 183 /* MappedType */: return bindAnonymousTypeWorker(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return bindFunctionExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -29829,64 +30338,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 242 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 242 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 67897736 /* InterfaceExcludes */); - case 243 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); - case 244 /* EnumDeclaration */: + case 243 /* InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); + case 244 /* TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + case 245 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return bindJsxAttributes(node); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 250 /* ImportEqualsDeclaration */: + case 253 /* NamespaceImport */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return bindImportClause(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return bindExportDeclaration(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return bindExportAssignment(node); - case 285 /* SourceFile */: + case 286 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 219 /* Block */: + case 220 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 306 /* JSDocParameterTag */: - if (node.parent.kind === 299 /* JSDocSignature */) { + case 308 /* JSDocParameterTag */: + if (node.parent.kind === 301 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 298 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 300 /* JSDocTypeLiteral */) { break; } // falls through - case 312 /* JSDocPropertyTag */: + case 314 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 294 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 295 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -30030,8 +30540,8 @@ var ts; ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 198 /* 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 === 60 /* EqualsToken */) { @@ -30045,26 +30555,27 @@ var ts; constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable(); // It's acceptable for multiple 'this' assignments of the same identifier to occur declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 159 /* Constructor */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 285 /* SourceFile */: + case 286 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220414 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); } break; default: @@ -30075,7 +30586,7 @@ var ts; if (node.expression.kind === 101 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 285 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 286 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -30089,7 +30600,7 @@ var ts; node.left.parent = node; node.right.parent = node; var lhs = node.left; - bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false); + bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false, /*containerIsClass*/ true); } function bindObjectDefinePrototypeProperty(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); @@ -30108,12 +30619,12 @@ var ts; lhs.parent = parent; constructorFunction.parent = classPrototype; classPrototype.parent = lhs; - bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true); + bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true, /*containerIsClass*/ true); } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); + var isToplevel = node.parent.parent.kind === 286 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } function bindSpecialPropertyAssignment(node) { @@ -30142,10 +30653,10 @@ var ts; */ function bindStaticPropertyAssignment(node) { node.expression.parent = node; - bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } - function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { - if (isToplevel && !isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */))) { + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { + if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* Assignment */; var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; @@ -30161,6 +30672,9 @@ var ts; } }); } + if (containerIsClass && namespaceSymbol) { + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + } return namespaceSymbol; } function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { @@ -30173,15 +30687,18 @@ var ts; (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); var includes = isMethod ? 8192 /* Method */ : 4 /* Property */; - var excludes = isMethod ? 67212223 /* MethodExcludes */ : 0 /* PropertyExcludes */; + var excludes = isMethod ? 103359 /* MethodExcludes */ : 0 /* PropertyExcludes */; declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + function isTopLevelNamespaceAssignment(propertyAccess) { + return ts.isBinaryExpression(propertyAccess.parent) + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 286 /* SourceFile */ + : propertyAccess.parent.parent.kind === 286 /* SourceFile */; + } + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); - var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 285 /* SourceFile */ - : propertyAccess.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } /** @@ -30250,8 +30767,8 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 241 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); + if (node.kind === 242 /* ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { var bindingName = node.name ? node.name.escapedText : "__class" /* Class */; @@ -30284,19 +30801,16 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 68008831 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 68008191 /* RegularEnumExcludes */); + ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - var isEnum = ts.isInJSFile(node) && !!ts.getJSDocEnumTag(node); - var enumFlags = (isEnum ? 256 /* RegularEnum */ : 0 /* None */); - var enumExcludes = (isEnum ? 68008191 /* RegularEnumExcludes */ : 0 /* None */); if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */ | enumFlags, 67220415 /* BlockScopedVariableExcludes */ | enumExcludes); + bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); } else if (ts.isParameterDeclaration(node)) { // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration @@ -30308,15 +30822,15 @@ var ts; // function foo([a,a]) {} // Duplicate Identifier error // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter // // which correctly set excluded symbols - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220415 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */ | enumFlags, 67220414 /* FunctionScopedVariableExcludes */ | enumExcludes); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); } } } function bindParameter(node) { - if (node.kind === 306 /* JSDocParameterTag */ && container.kind !== 299 /* JSDocSignature */) { + if (node.kind === 308 /* JSDocParameterTag */ && container.kind !== 301 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -30328,11 +30842,11 @@ var ts; bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220415 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); } // If this is a property-parameter, then also declare the property symbol into the // containing class. - if (ts.isParameterPropertyDeclaration(node)) { + if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); } @@ -30346,10 +30860,10 @@ var ts; checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16 /* Function */, 67219887 /* FunctionExcludes */); + bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 67219887 /* FunctionExcludes */); + declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */); } } function bindFunctionExpression(node) { @@ -30387,26 +30901,26 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 177 /* InferType */) { + else if (node.parent.kind === 178 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } else { bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } // reachability checks @@ -30421,11 +30935,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 221 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 222 /* EmptyStatement */) || // report error on class declarations - node.kind === 241 /* ClassDeclaration */ || + node.kind === 242 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 245 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 246 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -30469,12 +30983,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: return true; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; @@ -30523,58 +31037,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 192 /* CallExpression */: + case 193 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 152 /* Parameter */: + case 153 /* Parameter */: return computeParameter(node, subtreeFlags); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 158 /* Constructor */: + case 159 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -30619,12 +31133,12 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 189 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 190 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ES2018 if they contain rest transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 188 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 189 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } @@ -30672,8 +31186,8 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 213 /* AsExpression */ - || expressionKind === 195 /* TypeAssertionExpression */) { + if (expressionKind === 214 /* AsExpression */ + || expressionKind === 196 /* TypeAssertionExpression */) { transformFlags |= 1 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -31011,13 +31525,13 @@ var ts; var excludeFlags = 536870912 /* NodeExcludes */; switch (kind) { case 122 /* AsyncKeyword */: - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ES2018 syntax (for async generators) transformFlags |= 16 /* AssertES2018 */ | 32 /* AssertES2017 */; break; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 315 /* PartiallyEmittedExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: + case 317 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; excludeFlags = 536870912 /* OuterExpressionExcludes */; @@ -31028,25 +31542,25 @@ var ts; case 119 /* AbstractKeyword */: case 126 /* DeclareKeyword */: case 78 /* ConstKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 214 /* NonNullExpression */: + case 245 /* EnumDeclaration */: + case 280 /* EnumMember */: + case 215 /* NonNullExpression */: case 134 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: case 11 /* JsxText */: - case 264 /* JsxClosingElement */: - case 265 /* JsxFragment */: - case 266 /* JsxOpeningFragment */: - case 267 /* JsxClosingFragment */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 271 /* JsxExpression */: + case 265 /* JsxClosingElement */: + case 266 /* JsxFragment */: + case 267 /* JsxOpeningFragment */: + case 268 /* JsxClosingFragment */: + case 269 /* JsxAttribute */: + case 270 /* JsxAttributes */: + case 271 /* JsxSpreadAttribute */: + case 272 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 2 /* AssertJsx */; break; @@ -31054,11 +31568,11 @@ var ts; case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: - case 277 /* ShorthandPropertyAssignment */: + case 208 /* TemplateExpression */: + case 195 /* TaggedTemplateExpression */: + case 278 /* ShorthandPropertyAssignment */: case 117 /* StaticKeyword */: - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; @@ -31075,14 +31589,14 @@ var ts; case 9 /* BigIntLiteral */: transformFlags |= 4 /* AssertESNext */; break; - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 16 /* AssertES2018 */; } transformFlags |= 128 /* AssertES2015 */; break; - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 131072 /* ContainsYield */; @@ -31096,49 +31610,49 @@ var ts; case 124 /* BooleanKeyword */: case 140 /* SymbolKeyword */: case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 164 /* TypePredicate */: - case 165 /* TypeReference */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 168 /* TypeQuery */: - case 169 /* TypeLiteral */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 177 /* InferType */: - case 178 /* ParenthesizedType */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: - case 248 /* NamespaceExportDeclaration */: + case 152 /* TypeParameter */: + case 155 /* PropertySignature */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 165 /* TypePredicate */: + case 166 /* TypeReference */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 169 /* TypeQuery */: + case 170 /* TypeLiteral */: + case 171 /* ArrayType */: + case 172 /* TupleType */: + case 173 /* OptionalType */: + case 174 /* RestType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: + case 177 /* ConditionalType */: + case 178 /* InferType */: + case 179 /* ParenthesizedType */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 180 /* ThisType */: + case 181 /* TypeOperator */: + case 182 /* IndexedAccessType */: + case 183 /* MappedType */: + case 184 /* LiteralType */: + case 249 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 1 /* AssertTypeScript */; excludeFlags = -2 /* TypeExcludes */; break; - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. transformFlags |= 16384 /* ContainsComputedPropertyName */; break; - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: transformFlags |= 128 /* AssertES2015 */ | 4096 /* ContainsRestOrSpread */; break; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; break; case 99 /* SuperKeyword */: @@ -31150,28 +31664,28 @@ var ts; // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 2048 /* ContainsLexicalThis */; break; - case 185 /* ObjectBindingPattern */: + case 186 /* ObjectBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; if (subtreeFlags & 4096 /* ContainsRestOrSpread */) { transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; } excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 187 /* BindingElement */: + case 188 /* BindingElement */: transformFlags |= 128 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 4096 /* ContainsRestOrSpread */; } break; - case 153 /* Decorator */: + case 154 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */ | 1024 /* ContainsTypeScriptClassSyntax */; break; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: excludeFlags = 536896512 /* ObjectLiteralExcludes */; if (subtreeFlags & 16384 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -31184,26 +31698,26 @@ var ts; transformFlags |= 16 /* AssertES2018 */; } break; - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: excludeFlags = 536875008 /* ArrayLiteralOrCallOrNewExcludes */; break; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 32768 /* ContainsBlockScopedBinding */) { transformFlags |= 128 /* AssertES2015 */; } break; - case 285 /* SourceFile */: + case 286 /* SourceFile */: break; - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: // Return statements may require an `await` in ES2018. transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */ | 16 /* AssertES2018 */; break; - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 230 /* ContinueStatement */: + case 231 /* BreakStatement */: transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -31221,33 +31735,33 @@ var ts; * than calling this function. */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) { + if (kind >= 165 /* FirstTypeNode */ && kind <= 185 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 188 /* ArrayLiteralExpression */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 189 /* ArrayLiteralExpression */: return 536875008 /* ArrayLiteralOrCallOrNewExcludes */; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return 537168896 /* ModuleExcludes */; - case 152 /* Parameter */: + case 153 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return 537371648 /* ArrowFunctionExcludes */; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: return 537373696 /* FunctionExcludes */; - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return 536944640 /* VariableDeclarationListExcludes */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return 536888320 /* ClassExcludes */; - case 158 /* Constructor */: + case 159 /* Constructor */: return 537372672 /* ConstructorExcludes */; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return 537372672 /* MethodOrAccessorExcludes */; case 121 /* AnyKeyword */: case 136 /* NumberKeyword */: @@ -31258,30 +31772,30 @@ var ts; case 124 /* BooleanKeyword */: case 140 /* SymbolKeyword */: case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 152 /* TypeParameter */: + case 155 /* PropertySignature */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return 536896512 /* ObjectLiteralExcludes */; - case 275 /* CatchClause */: + case 276 /* CatchClause */: return 536879104 /* CatchClauseExcludes */; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: return 536875008 /* BindingPatternExcludes */; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 315 /* PartiallyEmittedExpression */: - case 196 /* ParenthesizedExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: + case 317 /* PartiallyEmittedExpression */: + case 197 /* ParenthesizedExpression */: case 99 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -31456,7 +31970,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 === 168 /* TypeQuery */) { + if (d.type && d.type.kind === 169 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -31507,6 +32021,179 @@ var ts; WideningKind[WideningKind["Normal"] = 0] = "Normal"; WideningKind[WideningKind["GeneratorYield"] = 1] = "GeneratorYield"; })(WideningKind || (WideningKind = {})); + var TypeFacts; + (function (TypeFacts) { + TypeFacts[TypeFacts["None"] = 0] = "None"; + TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; + TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; + TypeFacts[TypeFacts["TypeofEQBigInt"] = 4] = "TypeofEQBigInt"; + TypeFacts[TypeFacts["TypeofEQBoolean"] = 8] = "TypeofEQBoolean"; + TypeFacts[TypeFacts["TypeofEQSymbol"] = 16] = "TypeofEQSymbol"; + TypeFacts[TypeFacts["TypeofEQObject"] = 32] = "TypeofEQObject"; + TypeFacts[TypeFacts["TypeofEQFunction"] = 64] = "TypeofEQFunction"; + TypeFacts[TypeFacts["TypeofEQHostObject"] = 128] = "TypeofEQHostObject"; + TypeFacts[TypeFacts["TypeofNEString"] = 256] = "TypeofNEString"; + TypeFacts[TypeFacts["TypeofNENumber"] = 512] = "TypeofNENumber"; + TypeFacts[TypeFacts["TypeofNEBigInt"] = 1024] = "TypeofNEBigInt"; + TypeFacts[TypeFacts["TypeofNEBoolean"] = 2048] = "TypeofNEBoolean"; + TypeFacts[TypeFacts["TypeofNESymbol"] = 4096] = "TypeofNESymbol"; + TypeFacts[TypeFacts["TypeofNEObject"] = 8192] = "TypeofNEObject"; + TypeFacts[TypeFacts["TypeofNEFunction"] = 16384] = "TypeofNEFunction"; + TypeFacts[TypeFacts["TypeofNEHostObject"] = 32768] = "TypeofNEHostObject"; + TypeFacts[TypeFacts["EQUndefined"] = 65536] = "EQUndefined"; + TypeFacts[TypeFacts["EQNull"] = 131072] = "EQNull"; + TypeFacts[TypeFacts["EQUndefinedOrNull"] = 262144] = "EQUndefinedOrNull"; + TypeFacts[TypeFacts["NEUndefined"] = 524288] = "NEUndefined"; + TypeFacts[TypeFacts["NENull"] = 1048576] = "NENull"; + TypeFacts[TypeFacts["NEUndefinedOrNull"] = 2097152] = "NEUndefinedOrNull"; + TypeFacts[TypeFacts["Truthy"] = 4194304] = "Truthy"; + TypeFacts[TypeFacts["Falsy"] = 8388608] = "Falsy"; + TypeFacts[TypeFacts["All"] = 16777215] = "All"; + // The following members encode facts about particular kinds of types for use in the getTypeFacts function. + // The presence of a particular fact means that the given test is true for some (and possibly all) values + // of that kind of type. + TypeFacts[TypeFacts["BaseStringStrictFacts"] = 3735041] = "BaseStringStrictFacts"; + TypeFacts[TypeFacts["BaseStringFacts"] = 12582401] = "BaseStringFacts"; + TypeFacts[TypeFacts["StringStrictFacts"] = 16317953] = "StringStrictFacts"; + TypeFacts[TypeFacts["StringFacts"] = 16776705] = "StringFacts"; + TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 12123649] = "EmptyStringStrictFacts"; + TypeFacts[TypeFacts["EmptyStringFacts"] = 12582401] = "EmptyStringFacts"; + TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 7929345] = "NonEmptyStringStrictFacts"; + TypeFacts[TypeFacts["NonEmptyStringFacts"] = 16776705] = "NonEmptyStringFacts"; + TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 3734786] = "BaseNumberStrictFacts"; + TypeFacts[TypeFacts["BaseNumberFacts"] = 12582146] = "BaseNumberFacts"; + TypeFacts[TypeFacts["NumberStrictFacts"] = 16317698] = "NumberStrictFacts"; + TypeFacts[TypeFacts["NumberFacts"] = 16776450] = "NumberFacts"; + TypeFacts[TypeFacts["ZeroNumberStrictFacts"] = 12123394] = "ZeroNumberStrictFacts"; + TypeFacts[TypeFacts["ZeroNumberFacts"] = 12582146] = "ZeroNumberFacts"; + TypeFacts[TypeFacts["NonZeroNumberStrictFacts"] = 7929090] = "NonZeroNumberStrictFacts"; + TypeFacts[TypeFacts["NonZeroNumberFacts"] = 16776450] = "NonZeroNumberFacts"; + TypeFacts[TypeFacts["BaseBigIntStrictFacts"] = 3734276] = "BaseBigIntStrictFacts"; + TypeFacts[TypeFacts["BaseBigIntFacts"] = 12581636] = "BaseBigIntFacts"; + TypeFacts[TypeFacts["BigIntStrictFacts"] = 16317188] = "BigIntStrictFacts"; + TypeFacts[TypeFacts["BigIntFacts"] = 16775940] = "BigIntFacts"; + TypeFacts[TypeFacts["ZeroBigIntStrictFacts"] = 12122884] = "ZeroBigIntStrictFacts"; + TypeFacts[TypeFacts["ZeroBigIntFacts"] = 12581636] = "ZeroBigIntFacts"; + TypeFacts[TypeFacts["NonZeroBigIntStrictFacts"] = 7928580] = "NonZeroBigIntStrictFacts"; + TypeFacts[TypeFacts["NonZeroBigIntFacts"] = 16775940] = "NonZeroBigIntFacts"; + TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 3733256] = "BaseBooleanStrictFacts"; + TypeFacts[TypeFacts["BaseBooleanFacts"] = 12580616] = "BaseBooleanFacts"; + TypeFacts[TypeFacts["BooleanStrictFacts"] = 16316168] = "BooleanStrictFacts"; + TypeFacts[TypeFacts["BooleanFacts"] = 16774920] = "BooleanFacts"; + TypeFacts[TypeFacts["FalseStrictFacts"] = 12121864] = "FalseStrictFacts"; + TypeFacts[TypeFacts["FalseFacts"] = 12580616] = "FalseFacts"; + TypeFacts[TypeFacts["TrueStrictFacts"] = 7927560] = "TrueStrictFacts"; + TypeFacts[TypeFacts["TrueFacts"] = 16774920] = "TrueFacts"; + TypeFacts[TypeFacts["SymbolStrictFacts"] = 7925520] = "SymbolStrictFacts"; + TypeFacts[TypeFacts["SymbolFacts"] = 16772880] = "SymbolFacts"; + TypeFacts[TypeFacts["ObjectStrictFacts"] = 7888800] = "ObjectStrictFacts"; + TypeFacts[TypeFacts["ObjectFacts"] = 16736160] = "ObjectFacts"; + TypeFacts[TypeFacts["FunctionStrictFacts"] = 7880640] = "FunctionStrictFacts"; + TypeFacts[TypeFacts["FunctionFacts"] = 16728000] = "FunctionFacts"; + TypeFacts[TypeFacts["UndefinedFacts"] = 9830144] = "UndefinedFacts"; + TypeFacts[TypeFacts["NullFacts"] = 9363232] = "NullFacts"; + TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts"; + TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts"; + })(TypeFacts || (TypeFacts = {})); + var typeofEQFacts = ts.createMapFromTemplate({ + string: 1 /* TypeofEQString */, + number: 2 /* TypeofEQNumber */, + bigint: 4 /* TypeofEQBigInt */, + boolean: 8 /* TypeofEQBoolean */, + symbol: 16 /* TypeofEQSymbol */, + undefined: 65536 /* EQUndefined */, + object: 32 /* TypeofEQObject */, + function: 64 /* TypeofEQFunction */ + }); + var typeofNEFacts = ts.createMapFromTemplate({ + string: 256 /* TypeofNEString */, + number: 512 /* TypeofNENumber */, + bigint: 1024 /* TypeofNEBigInt */, + boolean: 2048 /* TypeofNEBoolean */, + symbol: 4096 /* TypeofNESymbol */, + undefined: 524288 /* NEUndefined */, + object: 8192 /* TypeofNEObject */, + function: 16384 /* TypeofNEFunction */ + }); + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; + TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; + TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); + var CheckMode; + (function (CheckMode) { + CheckMode[CheckMode["Normal"] = 0] = "Normal"; + CheckMode[CheckMode["Contextual"] = 1] = "Contextual"; + CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; + CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive"; + CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; + CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; + })(CheckMode || (CheckMode = {})); + var ContextFlags; + (function (ContextFlags) { + ContextFlags[ContextFlags["None"] = 0] = "None"; + ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; + })(ContextFlags || (ContextFlags = {})); + var AccessFlags; + (function (AccessFlags) { + AccessFlags[AccessFlags["None"] = 0] = "None"; + AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; + AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; + AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; + AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; + })(AccessFlags || (AccessFlags = {})); + var CallbackCheck; + (function (CallbackCheck) { + CallbackCheck[CallbackCheck["None"] = 0] = "None"; + CallbackCheck[CallbackCheck["Bivariant"] = 1] = "Bivariant"; + CallbackCheck[CallbackCheck["Strict"] = 2] = "Strict"; + })(CallbackCheck || (CallbackCheck = {})); + var MappedTypeModifiers; + (function (MappedTypeModifiers) { + MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly"; + MappedTypeModifiers[MappedTypeModifiers["ExcludeReadonly"] = 2] = "ExcludeReadonly"; + MappedTypeModifiers[MappedTypeModifiers["IncludeOptional"] = 4] = "IncludeOptional"; + MappedTypeModifiers[MappedTypeModifiers["ExcludeOptional"] = 8] = "ExcludeOptional"; + })(MappedTypeModifiers || (MappedTypeModifiers = {})); + var ExpandingFlags; + (function (ExpandingFlags) { + ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; + ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; + ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; + ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; + })(ExpandingFlags || (ExpandingFlags = {})); + var MembersOrExportsResolutionKind; + (function (MembersOrExportsResolutionKind) { + MembersOrExportsResolutionKind["resolvedExports"] = "resolvedExports"; + MembersOrExportsResolutionKind["resolvedMembers"] = "resolvedMembers"; + })(MembersOrExportsResolutionKind || (MembersOrExportsResolutionKind = {})); + var UnusedKind; + (function (UnusedKind) { + UnusedKind[UnusedKind["Local"] = 0] = "Local"; + UnusedKind[UnusedKind["Parameter"] = 1] = "Parameter"; + })(UnusedKind || (UnusedKind = {})); + var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); + var DeclarationMeaning; + (function (DeclarationMeaning) { + DeclarationMeaning[DeclarationMeaning["GetAccessor"] = 1] = "GetAccessor"; + DeclarationMeaning[DeclarationMeaning["SetAccessor"] = 2] = "SetAccessor"; + DeclarationMeaning[DeclarationMeaning["PropertyAssignment"] = 4] = "PropertyAssignment"; + DeclarationMeaning[DeclarationMeaning["Method"] = 8] = "Method"; + DeclarationMeaning[DeclarationMeaning["GetOrSetAccessor"] = 3] = "GetOrSetAccessor"; + DeclarationMeaning[DeclarationMeaning["PropertyAssignmentOrMethod"] = 12] = "PropertyAssignmentOrMethod"; + })(DeclarationMeaning || (DeclarationMeaning = {})); + var DeclarationSpaces; + (function (DeclarationSpaces) { + DeclarationSpaces[DeclarationSpaces["None"] = 0] = "None"; + DeclarationSpaces[DeclarationSpaces["ExportValue"] = 1] = "ExportValue"; + DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; + DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; + })(DeclarationSpaces || (DeclarationSpaces = {})); function getNodeId(node) { if (!node.id) { node.id = nextNodeId; @@ -31554,11 +32241,9 @@ var ts; var cancellationToken; var requestedExternalEmitHelpers; var externalHelpersModule; - // tslint:disable variable-name var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); - // tslint:enable variable-name var typeCount = 0; var symbolCount = 0; var enumCount = 0; @@ -31832,7 +32517,7 @@ var ts; // Ensure file is type checked checkSourceFile(file); ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); - diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.get(file.fileName)); + diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); if (!file.isDeclarationFile && (!unusedIsError(0 /* Local */) || !unusedIsError(1 /* Parameter */))) { addUnusedDiagnostics(); } @@ -31844,7 +32529,7 @@ var ts; function addUnusedDiagnostics() { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { if (!ts.containsParseError(containingNode) && !unusedIsError(kind)) { - (diagnostics || (diagnostics = [])).push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); } @@ -31873,6 +32558,7 @@ var ts; var literalTypes = ts.createMap(); var indexedAccessTypes = ts.createMap(); var substitutionTypes = ts.createMap(); + var structuralTags = ts.createMap(); var evolvingArrayTypes = []; var undefinedProperties = ts.createMap(); var unknownSymbol = createSymbol(4 /* Property */, "unknown"); @@ -32056,102 +32742,7 @@ var ts; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); - // Suggestion diagnostics must have a file. Keyed by source file name. - var suggestionDiagnostics = ts.createMultiMap(); - var TypeFacts; - (function (TypeFacts) { - TypeFacts[TypeFacts["None"] = 0] = "None"; - TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; - TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; - TypeFacts[TypeFacts["TypeofEQBigInt"] = 4] = "TypeofEQBigInt"; - TypeFacts[TypeFacts["TypeofEQBoolean"] = 8] = "TypeofEQBoolean"; - TypeFacts[TypeFacts["TypeofEQSymbol"] = 16] = "TypeofEQSymbol"; - TypeFacts[TypeFacts["TypeofEQObject"] = 32] = "TypeofEQObject"; - TypeFacts[TypeFacts["TypeofEQFunction"] = 64] = "TypeofEQFunction"; - TypeFacts[TypeFacts["TypeofEQHostObject"] = 128] = "TypeofEQHostObject"; - TypeFacts[TypeFacts["TypeofNEString"] = 256] = "TypeofNEString"; - TypeFacts[TypeFacts["TypeofNENumber"] = 512] = "TypeofNENumber"; - TypeFacts[TypeFacts["TypeofNEBigInt"] = 1024] = "TypeofNEBigInt"; - TypeFacts[TypeFacts["TypeofNEBoolean"] = 2048] = "TypeofNEBoolean"; - TypeFacts[TypeFacts["TypeofNESymbol"] = 4096] = "TypeofNESymbol"; - TypeFacts[TypeFacts["TypeofNEObject"] = 8192] = "TypeofNEObject"; - TypeFacts[TypeFacts["TypeofNEFunction"] = 16384] = "TypeofNEFunction"; - TypeFacts[TypeFacts["TypeofNEHostObject"] = 32768] = "TypeofNEHostObject"; - TypeFacts[TypeFacts["EQUndefined"] = 65536] = "EQUndefined"; - TypeFacts[TypeFacts["EQNull"] = 131072] = "EQNull"; - TypeFacts[TypeFacts["EQUndefinedOrNull"] = 262144] = "EQUndefinedOrNull"; - TypeFacts[TypeFacts["NEUndefined"] = 524288] = "NEUndefined"; - TypeFacts[TypeFacts["NENull"] = 1048576] = "NENull"; - TypeFacts[TypeFacts["NEUndefinedOrNull"] = 2097152] = "NEUndefinedOrNull"; - TypeFacts[TypeFacts["Truthy"] = 4194304] = "Truthy"; - TypeFacts[TypeFacts["Falsy"] = 8388608] = "Falsy"; - TypeFacts[TypeFacts["All"] = 16777215] = "All"; - // The following members encode facts about particular kinds of types for use in the getTypeFacts function. - // The presence of a particular fact means that the given test is true for some (and possibly all) values - // of that kind of type. - TypeFacts[TypeFacts["BaseStringStrictFacts"] = 3735041] = "BaseStringStrictFacts"; - TypeFacts[TypeFacts["BaseStringFacts"] = 12582401] = "BaseStringFacts"; - TypeFacts[TypeFacts["StringStrictFacts"] = 16317953] = "StringStrictFacts"; - TypeFacts[TypeFacts["StringFacts"] = 16776705] = "StringFacts"; - TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 12123649] = "EmptyStringStrictFacts"; - TypeFacts[TypeFacts["EmptyStringFacts"] = 12582401] = "EmptyStringFacts"; - TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 7929345] = "NonEmptyStringStrictFacts"; - TypeFacts[TypeFacts["NonEmptyStringFacts"] = 16776705] = "NonEmptyStringFacts"; - TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 3734786] = "BaseNumberStrictFacts"; - TypeFacts[TypeFacts["BaseNumberFacts"] = 12582146] = "BaseNumberFacts"; - TypeFacts[TypeFacts["NumberStrictFacts"] = 16317698] = "NumberStrictFacts"; - TypeFacts[TypeFacts["NumberFacts"] = 16776450] = "NumberFacts"; - TypeFacts[TypeFacts["ZeroNumberStrictFacts"] = 12123394] = "ZeroNumberStrictFacts"; - TypeFacts[TypeFacts["ZeroNumberFacts"] = 12582146] = "ZeroNumberFacts"; - TypeFacts[TypeFacts["NonZeroNumberStrictFacts"] = 7929090] = "NonZeroNumberStrictFacts"; - TypeFacts[TypeFacts["NonZeroNumberFacts"] = 16776450] = "NonZeroNumberFacts"; - TypeFacts[TypeFacts["BaseBigIntStrictFacts"] = 3734276] = "BaseBigIntStrictFacts"; - TypeFacts[TypeFacts["BaseBigIntFacts"] = 12581636] = "BaseBigIntFacts"; - TypeFacts[TypeFacts["BigIntStrictFacts"] = 16317188] = "BigIntStrictFacts"; - TypeFacts[TypeFacts["BigIntFacts"] = 16775940] = "BigIntFacts"; - TypeFacts[TypeFacts["ZeroBigIntStrictFacts"] = 12122884] = "ZeroBigIntStrictFacts"; - TypeFacts[TypeFacts["ZeroBigIntFacts"] = 12581636] = "ZeroBigIntFacts"; - TypeFacts[TypeFacts["NonZeroBigIntStrictFacts"] = 7928580] = "NonZeroBigIntStrictFacts"; - TypeFacts[TypeFacts["NonZeroBigIntFacts"] = 16775940] = "NonZeroBigIntFacts"; - TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 3733256] = "BaseBooleanStrictFacts"; - TypeFacts[TypeFacts["BaseBooleanFacts"] = 12580616] = "BaseBooleanFacts"; - TypeFacts[TypeFacts["BooleanStrictFacts"] = 16316168] = "BooleanStrictFacts"; - TypeFacts[TypeFacts["BooleanFacts"] = 16774920] = "BooleanFacts"; - TypeFacts[TypeFacts["FalseStrictFacts"] = 12121864] = "FalseStrictFacts"; - TypeFacts[TypeFacts["FalseFacts"] = 12580616] = "FalseFacts"; - TypeFacts[TypeFacts["TrueStrictFacts"] = 7927560] = "TrueStrictFacts"; - TypeFacts[TypeFacts["TrueFacts"] = 16774920] = "TrueFacts"; - TypeFacts[TypeFacts["SymbolStrictFacts"] = 7925520] = "SymbolStrictFacts"; - TypeFacts[TypeFacts["SymbolFacts"] = 16772880] = "SymbolFacts"; - TypeFacts[TypeFacts["ObjectStrictFacts"] = 7888800] = "ObjectStrictFacts"; - TypeFacts[TypeFacts["ObjectFacts"] = 16736160] = "ObjectFacts"; - TypeFacts[TypeFacts["FunctionStrictFacts"] = 7880640] = "FunctionStrictFacts"; - TypeFacts[TypeFacts["FunctionFacts"] = 16728000] = "FunctionFacts"; - TypeFacts[TypeFacts["UndefinedFacts"] = 9830144] = "UndefinedFacts"; - TypeFacts[TypeFacts["NullFacts"] = 9363232] = "NullFacts"; - TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts"; - TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts"; - })(TypeFacts || (TypeFacts = {})); - var typeofEQFacts = ts.createMapFromTemplate({ - string: 1 /* TypeofEQString */, - number: 2 /* TypeofEQNumber */, - bigint: 4 /* TypeofEQBigInt */, - boolean: 8 /* TypeofEQBoolean */, - symbol: 16 /* TypeofEQSymbol */, - undefined: 65536 /* EQUndefined */, - object: 32 /* TypeofEQObject */, - function: 64 /* TypeofEQFunction */ - }); - var typeofNEFacts = ts.createMapFromTemplate({ - string: 256 /* TypeofNEString */, - number: 512 /* TypeofNENumber */, - bigint: 1024 /* TypeofNEBigInt */, - boolean: 2048 /* TypeofNEBoolean */, - symbol: 4096 /* TypeofNESymbol */, - undefined: 524288 /* NEUndefined */, - object: 8192 /* TypeofNEObject */, - function: 16384 /* TypeofNEFunction */ - }); + var suggestionDiagnostics = ts.createDiagnosticCollection(); var typeofTypesByName = ts.createMapFromTemplate({ string: stringType, number: numberType, @@ -32169,71 +32760,8 @@ var ts; var comparableRelation = ts.createMap(); var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); - var TypeSystemPropertyName; - (function (TypeSystemPropertyName) { - TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; - TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; - TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; - TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; - TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; - })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); - var CheckMode; - (function (CheckMode) { - CheckMode[CheckMode["Normal"] = 0] = "Normal"; - CheckMode[CheckMode["Contextual"] = 1] = "Contextual"; - CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; - CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive"; - CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; - CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; - })(CheckMode || (CheckMode = {})); - var ContextFlags; - (function (ContextFlags) { - ContextFlags[ContextFlags["None"] = 0] = "None"; - ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; - })(ContextFlags || (ContextFlags = {})); - var AccessFlags; - (function (AccessFlags) { - AccessFlags[AccessFlags["None"] = 0] = "None"; - AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; - AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; - AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; - AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; - })(AccessFlags || (AccessFlags = {})); - var CallbackCheck; - (function (CallbackCheck) { - CallbackCheck[CallbackCheck["None"] = 0] = "None"; - CallbackCheck[CallbackCheck["Bivariant"] = 1] = "Bivariant"; - CallbackCheck[CallbackCheck["Strict"] = 2] = "Strict"; - })(CallbackCheck || (CallbackCheck = {})); - var MappedTypeModifiers; - (function (MappedTypeModifiers) { - MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly"; - MappedTypeModifiers[MappedTypeModifiers["ExcludeReadonly"] = 2] = "ExcludeReadonly"; - MappedTypeModifiers[MappedTypeModifiers["IncludeOptional"] = 4] = "IncludeOptional"; - MappedTypeModifiers[MappedTypeModifiers["ExcludeOptional"] = 8] = "ExcludeOptional"; - })(MappedTypeModifiers || (MappedTypeModifiers = {})); - var ExpandingFlags; - (function (ExpandingFlags) { - ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; - ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; - ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; - ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; - })(ExpandingFlags || (ExpandingFlags = {})); - var MembersOrExportsResolutionKind; - (function (MembersOrExportsResolutionKind) { - MembersOrExportsResolutionKind["resolvedExports"] = "resolvedExports"; - MembersOrExportsResolutionKind["resolvedMembers"] = "resolvedMembers"; - })(MembersOrExportsResolutionKind || (MembersOrExportsResolutionKind = {})); - var UnusedKind; - (function (UnusedKind) { - UnusedKind[UnusedKind["Local"] = 0] = "Local"; - UnusedKind[UnusedKind["Parameter"] = 1] = "Parameter"; - })(UnusedKind || (UnusedKind = {})); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); - var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; function getJsxNamespace(location) { @@ -32245,7 +32773,7 @@ var ts; } var jsxPragma = file.pragmas.get("jsx"); if (jsxPragma) { - var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; // TODO: GH#18217 + var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; file.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion); if (file.localJsxFactory) { return file.localJsxNamespace = getFirstIdentifier(file.localJsxFactory).escapedText; @@ -32298,11 +32826,11 @@ var ts; diagnostics.add(diagnostic); } else { - suggestionDiagnostics.add(diagnostic.file.fileName, __assign({}, diagnostic, { category: ts.DiagnosticCategory.Suggestion })); + suggestionDiagnostics.add(__assign(__assign({}, diagnostic), { category: ts.DiagnosticCategory.Suggestion })); } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { - addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); + addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { var diagnostic = error(location, message, arg0, arg1, arg2, arg3); @@ -32324,35 +32852,35 @@ var ts; function getExcludedSymbolFlags(flags) { var result = 0; if (flags & 2 /* BlockScopedVariable */) - result |= 67220415 /* BlockScopedVariableExcludes */; + result |= 111551 /* BlockScopedVariableExcludes */; if (flags & 1 /* FunctionScopedVariable */) - result |= 67220414 /* FunctionScopedVariableExcludes */; + result |= 111550 /* FunctionScopedVariableExcludes */; if (flags & 4 /* Property */) result |= 0 /* PropertyExcludes */; if (flags & 8 /* EnumMember */) - result |= 68008959 /* EnumMemberExcludes */; + result |= 900095 /* EnumMemberExcludes */; if (flags & 16 /* Function */) - result |= 67219887 /* FunctionExcludes */; + result |= 110991 /* FunctionExcludes */; if (flags & 32 /* Class */) - result |= 68008383 /* ClassExcludes */; + result |= 899503 /* ClassExcludes */; if (flags & 64 /* Interface */) - result |= 67897736 /* InterfaceExcludes */; + result |= 788872 /* InterfaceExcludes */; if (flags & 256 /* RegularEnum */) - result |= 68008191 /* RegularEnumExcludes */; + result |= 899327 /* RegularEnumExcludes */; if (flags & 128 /* ConstEnum */) - result |= 68008831 /* ConstEnumExcludes */; + result |= 899967 /* ConstEnumExcludes */; if (flags & 512 /* ValueModule */) result |= 110735 /* ValueModuleExcludes */; if (flags & 8192 /* Method */) - result |= 67212223 /* MethodExcludes */; + result |= 103359 /* MethodExcludes */; if (flags & 32768 /* GetAccessor */) - result |= 67154879 /* GetAccessorExcludes */; + result |= 46015 /* GetAccessorExcludes */; if (flags & 65536 /* SetAccessor */) - result |= 67187647 /* SetAccessorExcludes */; + result |= 78783 /* SetAccessorExcludes */; if (flags & 262144 /* TypeParameter */) - result |= 67635688 /* TypeParameterExcludes */; + result |= 526824 /* TypeParameterExcludes */; if (flags & 524288 /* TypeAlias */) - result |= 67897832 /* TypeAliasExcludes */; + result |= 788968 /* TypeAliasExcludes */; if (flags & 2097152 /* Alias */) result |= 2097152 /* AliasExcludes */; return result; @@ -32575,7 +33103,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 286 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -32605,8 +33133,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 67220415 /* Value */); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 67220415 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* Value */); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -32633,17 +33161,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 187 /* BindingElement */) { + if (declaration.kind === 188 /* 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, 187 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 188 /* 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, 238 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 239 /* VariableDeclaration */), usage); } - else if (declaration.kind === 238 /* VariableDeclaration */) { + else if (declaration.kind === 239 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -32666,12 +33194,12 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 258 /* ExportSpecifier */ || (usage.parent.kind === 255 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 259 /* ExportSpecifier */ || (usage.parent.kind === 256 /* 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 === 255 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 256 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -32679,9 +33207,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 220 /* VariableStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 221 /* VariableStatement */: + case 227 /* ForStatement */: + case 229 /* 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, container)) { @@ -32702,16 +33230,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 155 /* PropertyDeclaration */ && + current.parent.kind === 156 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 157 /* MethodDeclaration */) { + if (declaration.kind === 158 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 156 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -32732,14 +33260,14 @@ var ts; return "quit"; } switch (node.kind) { - case 198 /* ArrowFunction */: - case 155 /* PropertyDeclaration */: + case 199 /* ArrowFunction */: + case 156 /* PropertyDeclaration */: return true; - case 219 /* Block */: + case 220 /* Block */: switch (node.parent.kind) { - case 159 /* GetAccessor */: - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 158 /* MethodDeclaration */: + case 161 /* SetAccessor */: return true; default: return false; @@ -32785,12 +33313,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 & 67897832 /* Type */ && lastLocation.kind !== 297 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 299 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 152 /* Parameter */ || - lastLocation.kind === 151 /* TypeParameter */ + lastLocation.kind === 153 /* Parameter */ || + lastLocation.kind === 152 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -32807,13 +33335,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 === 152 /* Parameter */ || + lastLocation.kind === 153 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 176 /* ConditionalType */) { + else if (location.kind === 177 /* 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; @@ -32828,14 +33356,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 286 /* SourceFile */ || ts.isAmbientModule(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 */)) { @@ -32859,7 +33387,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 258 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 259 /* ExportSpecifier */)) { break; } } @@ -32873,12 +33401,12 @@ var ts; } } break; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 155 /* PropertyDeclaration */: + case 156 /* 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 @@ -32888,20 +33416,20 @@ var ts; if (!ts.hasModifier(location, 32 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 67220415 /* Value */)) { + if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) { // Remember the property node, it will be used later to report appropriate error propertyWithInvalidInitializer = location; } } } break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* 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! - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 67897832 /* Type */)) { + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -32916,7 +33444,7 @@ var ts; } break loop; } - if (location.kind === 210 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 211 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -32924,11 +33452,11 @@ var ts; } } break; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. if (lastLocation === location.expression && location.parent.token === 87 /* ExtendsKeyword */) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 67897832 /* Type */))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -32944,34 +33472,34 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 242 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 243 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67897832 /* Type */)) { + 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); return undefined; } } break; - case 198 /* ArrowFunction */: + case 199 /* 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 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 241 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -32984,7 +33512,7 @@ var ts; } } break; - case 153 /* Decorator */: + case 154 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -32993,7 +33521,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 === 152 /* Parameter */) { + if (location.parent && location.parent.kind === 153 /* Parameter */) { location = location.parent; } // @@ -33008,24 +33536,25 @@ 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 === 241 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 242 /* ClassDeclaration */)) { location = location.parent; } break; - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; - case 152 /* Parameter */: + case 153 /* Parameter */: if (lastLocation && lastLocation === location.initializer) { associatedDeclarationForContainingInitializer = location; } break; - case 187 /* BindingElement */: + case 188 /* BindingElement */: if (lastLocation && lastLocation === location.initializer) { var root = ts.getRootDeclaration(location); - if (root.kind === 152 /* Parameter */) { + if (root.kind === 153 /* Parameter */) { associatedDeclarationForContainingInitializer = location; } } @@ -33045,7 +33574,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 285 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 286 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -33111,21 +33640,21 @@ var ts; // we want to check for block-scoped if (errorLocation && (meaning & 2 /* BlockScopedVariable */ || - ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 67220415 /* Value */) === 67220415 /* Value */))) { + ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 67220415 /* Value */) === 67220415 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } // If we're in a parameter initializer, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 67220415 /* Value */) === 67220415 /* Value */) { + if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializer); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself @@ -33141,10 +33670,10 @@ var ts; return result; } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 198 /* ArrowFunction */ && location.kind !== 197 /* FunctionExpression */) { + if (location.kind !== 199 /* ArrowFunction */ && location.kind !== 198 /* 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 === 155 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 156 /* PropertyDeclaration */ && !ts.hasModifier(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; @@ -33157,12 +33686,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: // For `namespace N { N; }` + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 246 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -33174,7 +33703,7 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 151 /* TypeParameter */) { + if (decl.kind === 152 /* 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 @@ -33230,9 +33759,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -33242,9 +33771,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 67220415 /* Value */ : 0); + var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* Value */ : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -33263,8 +33792,8 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (67897832 /* Type */ & ~1920 /* Namespace */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~67897832 /* Type */ & 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1920 /* Namespace */)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here, ts.unescapeLeadingUnderscores(name)); return true; @@ -33273,12 +33802,12 @@ var ts; return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 /* Value */ & ~1024 /* NamespaceModule */)) { + if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) { if (name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never") { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 /* Type */ & ~67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { var message = isES2015OrLaterConstructorName(name) ? ts.Diagnostics._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 @@ -33302,15 +33831,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 /* Value */ & ~1024 /* NamespaceModule */ & ~67897832 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */ & ~788968 /* Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (67897832 /* Type */ & ~1024 /* NamespaceModule */ & ~67220415 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~67897832 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + else if (meaning & (788968 /* Type */ & ~1024 /* NamespaceModule */ & ~111551 /* Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~788968 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -33320,10 +33849,14 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { 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 === 244 /* EnumDeclaration */) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 245 /* EnumDeclaration */); }); if (declaration === undefined) - return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); + return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); @@ -33356,13 +33889,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return node; - case 251 /* ImportClause */: + case 252 /* ImportClause */: return node.parent; - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return node.parent.parent; - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -33372,7 +33905,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 261 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -33473,7 +34006,7 @@ var ts; if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (67897832 /* Type */ | 1920 /* Namespace */)) { + if (valueSymbol.flags & (788968 /* Type */ | 1920 /* Namespace */)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -33563,7 +34096,7 @@ var ts; if (ts.isClassExpression(expression)) { return checkExpression(expression).symbol; } - var aliasLike = resolveEntityName(expression, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); + var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } @@ -33573,20 +34106,20 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 258 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 255 /* ExportAssignment */: - case 205 /* BinaryExpression */: + case 259 /* ExportSpecifier */: + return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); + case 256 /* ExportAssignment */: + case 206 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -33597,7 +34130,7 @@ var ts; * OR Is a JSContainer which may merge an alias with a local declaration */ function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */; } + if (excludes === void 0) { excludes = 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */; } if (!symbol) return false; return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* Assignment */); @@ -33631,7 +34164,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 67220415 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); + ((target.flags & 111551 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -33647,17 +34180,15 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 255 /* ExportAssignment */) { - // export default - checkExpressionCached(node.expression); - } - else if (node.kind === 258 /* ExportSpecifier */) { - // export { } or export { as foo } - checkExpressionCached(node.propertyName || node.name); - } - else if (ts.isInternalModuleImportEqualsDeclaration(node)) { - // import foo = - checkExpressionCached(node.moduleReference); + // We defer checking of the reference of an `import =` until the import itself is referenced, + // This way a chain of imports can be elided if ultimately the final input is only used in a type + // position. + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + var target = resolveSymbol(symbol); + if (target === unknownSymbol || target.flags & 111551 /* Value */) { + // import foo = + checkExpressionCached(node.moduleReference); + } } } } @@ -33673,14 +34204,14 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 73 /* Identifier */ || entityName.parent.kind === 149 /* QualifiedName */) { + if (entityName.kind === 73 /* Identifier */ || entityName.parent.kind === 150 /* 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 === 249 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 250 /* ImportEqualsDeclaration */); + return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { @@ -33693,7 +34224,7 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 67220415 /* Value */ : 0); + var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; if (name.kind === 73 /* Identifier */) { var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name)); @@ -33703,9 +34234,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 149 /* QualifiedName */ || name.kind === 190 /* PropertyAccessExpression */) { - var left = name.kind === 149 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 149 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 150 /* QualifiedName */ || name.kind === 191 /* PropertyAccessExpression */) { + var left = name.kind === 150 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 150 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -33796,6 +34327,20 @@ var ts; undefined; return initializer || decl; } + /** + * Get the real symbol of a declaration with an expando initializer. + * + * Normally, declarations have an associated symbol, but when a declaration has an expando + * initializer, the expando's symbol is the one that has all the members merged into it. + */ + function getExpandoSymbol(symbol) { + var decl = symbol.valueDeclaration; + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */) { + return undefined; + } + var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); + return init && getSymbolOfNode(init) || undefined; + } function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0); } @@ -33807,9 +34352,6 @@ var ts; } function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReference === undefined) { - return; - } if (ts.startsWith(moduleReference, "@types/")) { var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1; var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/"); @@ -33938,7 +34480,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 285 /* SourceFile */)) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 286 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -34194,13 +34736,13 @@ var ts; return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? symbol.exportSymbol : symbol); } function symbolIsValue(symbol) { - return !!(symbol.flags & 67220415 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 67220415 /* Value */); + return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 158 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 159 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -34286,12 +34828,12 @@ var ts; } } switch (location.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -34302,7 +34844,7 @@ var ts; } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 67220415 /* Value */ ? 67220415 /* Value */ : 1920 /* Namespace */; + return rightMeaning === 111551 /* Value */ ? 111551 /* Value */ : 1920 /* Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = ts.createMap(); } @@ -34355,7 +34897,7 @@ var ts; && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) // 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, 258 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 259 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -34391,7 +34933,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, 258 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 259 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -34406,10 +34948,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: continue; default: return false; @@ -34420,11 +34962,11 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67897832 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 788968 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); return access.accessibility === 0 /* Accessible */; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67220415 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 111551 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false); return access.accessibility === 0 /* Accessible */; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible) { @@ -34467,7 +35009,7 @@ var ts; // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. var firstDecl = ts.first(symbol.declarations); - if (!ts.length(containers) && meaning & 67220415 /* Value */ && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { + if (!ts.length(containers) && meaning & 111551 /* Value */ && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { if (firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent) && firstDecl === firstDecl.parent.initializer) { containers = [getSymbolOfNode(firstDecl.parent)]; } @@ -34526,10 +35068,10 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 286 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 286 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -34576,21 +35118,21 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 168 /* TypeQuery */ || + if (entityName.parent.kind === 169 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 150 /* ComputedPropertyName */) { + entityName.parent.kind === 151 /* ComputedPropertyName */) { // Typeof value - meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; + meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 149 /* QualifiedName */ || entityName.kind === 190 /* PropertyAccessExpression */ || - entityName.parent.kind === 249 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 150 /* QualifiedName */ || entityName.kind === 191 /* PropertyAccessExpression */ || + entityName.parent.kind === 250 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; } else { // Type Reference or TypeAlias entity = Identifier - meaning = 67897832 /* Type */; + meaning = 788968 /* Type */; } var firstIdentifier = getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); @@ -34632,15 +35174,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 167 /* ConstructorType */ : 166 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 168 /* ConstructorType */ : 167 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 162 /* ConstructSignature */ : 161 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 163 /* ConstructSignature */ : 162 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } @@ -34663,14 +35205,17 @@ var ts; return result; } function getTypeNamesForErrorDisplay(left, right) { - var leftStr = typeToString(left); - var rightStr = typeToString(right); + var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left); + var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right); if (leftStr === rightStr) { leftStr = typeToString(left, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); rightStr = typeToString(right, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); } return [leftStr, rightStr]; } + function symbolValueDeclarationIsContextSensitive(symbol) { + return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0 /* None */; } return flags & 9469291 /* NodeBuilderFlagsMask */; @@ -34762,14 +35307,14 @@ var ts; } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 67897832 /* Type */); + var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */); var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), /*typeArguments*/ undefined)); return enumLiteralName; } if (type.flags & 1056 /* EnumLike */) { - return symbolToTypeNode(type.symbol, context, 67897832 /* Type */); + return symbolToTypeNode(type.symbol, context, 788968 /* Type */); } if (type.flags & 128 /* StringLiteral */) { context.approximateLength += (type.value.length + 2); @@ -34792,7 +35337,7 @@ var ts; if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 67220415 /* Value */); + return symbolToTypeNode(type.symbol, context, 111551 /* Value */); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); @@ -34855,14 +35400,14 @@ var ts; } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. return type.symbol - ? symbolToTypeNode(type.symbol, context, 67897832 /* Type */) + ? symbolToTypeNode(type.symbol, context, 788968 /* Type */) : ts.createTypeReferenceNode(ts.createIdentifier("?"), /*typeArguments*/ undefined); } if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 67897832 /* Type */, typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); } if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; @@ -34871,7 +35416,7 @@ var ts; } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 174 /* UnionType */ : 175 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 175 /* UnionType */ : 176 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -34912,6 +35457,36 @@ var ts; if (type.flags & 33554432 /* Substitution */) { return typeToTypeNodeHelper(type.typeVariable, context); } + if (type.flags & 134217728 /* StructuralTag */) { + var innerType = type.type; + if (innerType.flags & 2097152 /* Intersection */) { + // If some inner type of the intersection has an alias when hoisted out, (attempt to) hoist out all of the aliasable things + if (ts.some(innerType.types, function (t) { return !!getStructuralTagForType(t).aliasSymbol; })) { + var aliasingTypes = []; + var nonAliasingTypes = []; + for (var _i = 0, _a = innerType.types; _i < _a.length; _i++) { + var t = _a[_i]; + var taggedVersion = getStructuralTagForType(t); + if (taggedVersion.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(taggedVersion.aliasSymbol, context.enclosingDeclaration))) { + aliasingTypes.push(taggedVersion); + } + else { + nonAliasingTypes.push(t); + } + } + if (ts.length(aliasingTypes)) { + if (ts.length(nonAliasingTypes)) { + aliasingTypes.push(getStructuralTagForType(getIntersectionType(nonAliasingTypes))); + } + // Do note: this can make an intersection become nested within another intersection - this _is_ handled correctly + // during emit, so is fine (and honestly is more clear, since it groups all the tags together) + return ts.createUnionOrIntersectionTypeNode(176 /* IntersectionType */, ts.map(aliasingTypes, function (t) { return typeToTypeNodeHelper(t, context); })); + } + } + } + context.approximateLength += 4; + return ts.createTypeOperatorNode(148 /* TagKeyword */, typeToTypeNodeHelper(innerType, context)); + } return ts.Debug.fail("Should be unreachable."); function createMappedTypeNodeFromType(type) { ts.Debug.assert(!!(type.flags & 524288 /* Object */)); @@ -34941,21 +35516,21 @@ var ts; id = (isConstructorObject ? "+" : "") + getSymbolId(symbol); if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. - var isInstanceType = type === getInferredClassType(symbol) ? 67897832 /* Type */ : 67220415 /* Value */; + var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 /* Type */ : 111551 /* Value */; 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 === 210 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 211 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { - return symbolToTypeNode(symbol, context, 67220415 /* Value */); + return symbolToTypeNode(symbol, context, 111551 /* Value */); } else if (context.visitedTypes && context.visitedTypes.has(typeId)) { // If type is an anonymous type literal in a type alias declaration, use type alias name var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags - return symbolToTypeNode(typeAlias, context, 67897832 /* Type */); + return symbolToTypeNode(typeAlias, context, 788968 /* Type */); } else { return createElidedInformationPlaceholder(context); @@ -34992,12 +35567,12 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 285 /* SourceFile */ || declaration.parent.kind === 246 /* ModuleBlock */; + return declaration.parent.kind === 286 /* SourceFile */ || declaration.parent.kind === 247 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedTypes && context.visitedTypes.has(typeId))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // TODO: GH#18217 // And the build is going to succeed without visibility error or there is no structural fallback allowed + (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } @@ -35013,12 +35588,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 166 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 167 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 167 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 168 /* ConstructorType */, context); return signatureNode; } } @@ -35088,7 +35663,7 @@ var ts; var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_2 = context.flags; context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var ref = symbolToTypeNode(parent, context, 67897832 /* Type */, typeArgumentSlice); + var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice); context.flags = flags_2; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -35101,7 +35676,7 @@ var ts; } var flags = context.flags; context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var finalRef = symbolToTypeNode(type.symbol, context, 67897832 /* Type */, typeArgumentNodes); + var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* Type */, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -35153,11 +35728,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 161 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 162 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 162 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 163 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; @@ -35218,7 +35793,7 @@ var ts; trackComputedName(decl.name, saveEnclosingDeclaration, context); } } - var propertyName = symbolToName(propertySymbol, context, 67220415 /* Value */, /*expectsIdentifier*/ true); + var propertyName = symbolToName(propertySymbol, context, 111551 /* Value */, /*expectsIdentifier*/ true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(56 /* QuestionToken */) : undefined; @@ -35226,7 +35801,7 @@ var ts; var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 156 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 157 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; if (propertySymbol.valueDeclaration) { @@ -35322,7 +35897,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 158 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 159 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -35366,9 +35941,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 152 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 153 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 306 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 308 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -35378,13 +35953,12 @@ var ts; var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(25 /* DotDotDotToken */) : undefined; - var name = parameterDeclaration - ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 73 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 149 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : - cloneBindingName(parameterDeclaration.name) : - ts.symbolName(parameterSymbol) - : ts.symbolName(parameterSymbol); + var name = parameterDeclaration ? parameterDeclaration.name ? + parameterDeclaration.name.kind === 73 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 150 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + cloneBindingName(parameterDeclaration.name) : + ts.symbolName(parameterSymbol) : + ts.symbolName(parameterSymbol); var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */; var questionToken = isOptional ? ts.createToken(56 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( @@ -35400,7 +35974,7 @@ var ts; } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 187 /* BindingElement */) { + if (clone.kind === 188 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); @@ -35412,9 +35986,9 @@ var ts; return; // get symbol of the first identifier of the entityName var firstIdentifier = getFirstIdentifier(node.expression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 67220415 /* Value */); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { @@ -35531,7 +36105,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 285 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 286 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -35567,7 +36141,7 @@ var ts; // using the `baseUrl` compiler option (which we would otherwise never use in declaration emit) and a non-relative // specifier preference var moduleResolverHost = context.tracker.moduleResolverHost; - var specifierCompilerOptions = isBundle_1 ? __assign({}, compilerOptions, { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; + var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, host.getSourceFiles(), { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative" }, host.redirectTargetsMap)); links.specifierCache = links.specifierCache || ts.createMap(); links.specifierCache.set(contextFile.path, specifier); @@ -35576,7 +36150,7 @@ var ts; } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - var isTypeOf = meaning === 67220415 /* Value */; + var isTypeOf = meaning === 111551 /* Value */; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; @@ -35655,7 +36229,7 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context) { - return !!resolveName(context.enclosingDeclaration, escapedName, 67897832 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + return !!resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); } function typeParameterToName(type, context) { if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { @@ -35664,7 +36238,7 @@ var ts; return cached; } } - var result = symbolToName(type.symbol, context, 67897832 /* Type */, /*expectsIdentifier*/ true); + var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = 0; @@ -35710,9 +36284,6 @@ var ts; function createExpressionFromSymbolChain(chain, index) { var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; - if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { - return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); - } if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; } @@ -35721,6 +36292,9 @@ var ts; context.flags ^= 16777216 /* InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); + if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); + } var canUsePropertyAccess = ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); @@ -35798,8 +36372,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 178 /* ParenthesizedType */; }); - if (node.kind === 243 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 179 /* ParenthesizedType */; }); + if (node.kind === 244 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -35807,11 +36381,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 246 /* ModuleBlock */ && + node.parent.kind === 247 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 286 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -35849,9 +36423,9 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - var name_2 = ts.getNameOfDeclaration(declaration); - if (name_2) { + var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; }); // Try using a declaration with a name, first + var name_2 = declaration && ts.getNameOfDeclaration(declaration); + if (declaration && name_2) { if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } @@ -35864,17 +36438,20 @@ var ts; } return ts.declarationNameToString(name_2); } - if (declaration.parent && declaration.parent.kind === 238 /* VariableDeclaration */) { + if (!declaration) { + declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway + } + if (declaration.parent && declaration.parent.kind === 239 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 211 /* ClassExpression */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 210 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 211 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -35891,27 +36468,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 307 /* 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 187 /* BindingElement */: + case 188 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 238 /* VariableDeclaration */: + case 239 /* 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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 240 /* FunctionDeclaration */: - case 244 /* EnumDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 246 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 241 /* FunctionDeclaration */: + case 245 /* EnumDeclaration */: + case 250 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -35919,53 +36497,54 @@ 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 !== 249 /* ImportEqualsDeclaration */ && parent.kind !== 285 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 250 /* ImportEqualsDeclaration */ && parent.kind !== 286 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.hasModifier(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 158 /* Constructor */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 152 /* Parameter */: - case 246 /* ModuleBlock */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 165 /* TypeReference */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 178 /* ParenthesizedType */: + case 159 /* Constructor */: + case 163 /* ConstructSignature */: + case 162 /* CallSignature */: + case 164 /* IndexSignature */: + case 153 /* Parameter */: + case 247 /* ModuleBlock */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 170 /* TypeLiteral */: + case 166 /* TypeReference */: + case 171 /* ArrayType */: + case 172 /* TupleType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: + case 179 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: + case 252 /* ImportClause */: + case 253 /* NamespaceImport */: + case 255 /* ImportSpecifier */: return false; // Type parameters are always visible - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: // Source file and namespace export are always visible - case 285 /* SourceFile */: - case 248 /* NamespaceExportDeclaration */: + // falls through + case 286 /* SourceFile */: + case 249 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return false; default: return false; @@ -35974,11 +36553,11 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 255 /* ExportAssignment */) { - exportSymbol = resolveName(node, node.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); + if (node.parent && node.parent.kind === 256 /* ExportAssignment */) { + exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 258 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + else if (node.parent.kind === 259 /* ExportSpecifier */) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; if (exportSymbol) { @@ -35999,7 +36578,7 @@ var ts; // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); if (importSymbol) { buildVisibleNodeList(importSymbol.declarations); } @@ -36063,8 +36642,10 @@ var ts; } return ts.Debug.assertNever(propertyName); } - // Pop an entry from the type resolution stack and return its associated result value. The result value will - // be true if no circularities were detected, or false if a circularity was found. + /** + * Pop an entry from the type resolution stack and return its associated result value. The result value will + * be true if no circularities were detected, or false if a circularity was found. + */ function popTypeResolution() { resolutionTargets.pop(); resolutionPropertyNames.pop(); @@ -36073,12 +36654,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 238 /* VariableDeclaration */: - case 239 /* VariableDeclarationList */: - case 254 /* ImportSpecifier */: - case 253 /* NamedImports */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + case 239 /* VariableDeclaration */: + case 240 /* VariableDeclarationList */: + case 255 /* ImportSpecifier */: + case 254 /* NamedImports */: + case 253 /* NamespaceImport */: + case 252 /* ImportClause */: return false; default: return true; @@ -36111,7 +36692,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 150 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 151 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); @@ -36163,7 +36744,7 @@ var ts; if (parentAccess && parentAccess.flowNode) { var propName = getDestructuringPropertyName(node); if (propName) { - var result = ts.createNode(191 /* ElementAccessExpression */, node.pos, node.end); + var result = ts.createNode(192 /* ElementAccessExpression */, node.pos, node.end); result.parent = node; result.expression = parentAccess; var literal = ts.createNode(10 /* StringLiteral */, node.pos, node.end); @@ -36178,23 +36759,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 187 /* BindingElement */: - case 276 /* PropertyAssignment */: + case 188 /* BindingElement */: + case 277 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ancestor.initializer; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 187 /* BindingElement */ && parent.kind === 185 /* ObjectBindingPattern */) { + if (node.kind === 188 /* BindingElement */ && parent.kind === 186 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 276 /* PropertyAssignment */ || node.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.kind === 277 /* PropertyAssignment */ || node.kind === 278 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -36216,7 +36797,7 @@ var ts; parentType = getNonNullableType(parentType); } var type; - if (pattern.kind === 185 /* ObjectBindingPattern */) { + if (pattern.kind === 186 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -36288,26 +36869,26 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 188 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 189 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function isParameterOfContextuallyTypedFunction(node) { - return node.kind === 152 /* Parameter */ && - (node.parent.kind === 197 /* FunctionExpression */ || node.parent.kind === 198 /* ArrowFunction */) && + return node.kind === 153 /* Parameter */ && + (node.parent.kind === 198 /* FunctionExpression */ || node.parent.kind === 199 /* ArrowFunction */) && !!getContextualType(node.parent); } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 227 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 228 /* 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 === 228 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 229 /* 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, @@ -36326,7 +36907,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 238 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 239 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no @@ -36340,11 +36921,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 152 /* Parameter */) { + if (declaration.kind === 153 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 160 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 159 /* GetAccessor */); + if (func.kind === 161 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 160 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -36554,9 +37135,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 === 158 /* Constructor */ || - thisContainer.kind === 240 /* FunctionDeclaration */ || - (thisContainer.kind === 197 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 159 /* Constructor */ || + thisContainer.kind === 241 /* FunctionDeclaration */ || + (thisContainer.kind === 198 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -36631,7 +37212,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 187 /* BindingElement */ && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 188 /* BindingElement */ && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -36654,7 +37235,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 185 /* ObjectBindingPattern */ + return pattern.kind === 186 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -36693,7 +37274,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 152 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 153 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -36755,7 +37336,7 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 255 /* ExportAssignment */) { + if (declaration.kind === 256 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } else if (ts.isInJSFile(declaration) && @@ -36819,7 +37400,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 160 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -36846,8 +37427,8 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 160 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 160 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 161 /* SetAccessor */); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -36877,7 +37458,9 @@ var ts; // Otherwise, fall back to 'any'. else { if (setter) { - errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); + 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 existed getter as we are current checking either setter or getter in this function"); @@ -36890,7 +37473,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 160 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -36906,19 +37489,10 @@ var ts; if (!links.type) { var jsDeclaration = ts.getDeclarationOfExpando(symbol.valueDeclaration); if (jsDeclaration) { - var jsSymbol = getSymbolOfNode(jsDeclaration); - if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { - symbol = cloneSymbol(symbol); + var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration)); + if (merged) { // note:we overwrite links because we just cloned the symbol - links = symbol; - if (ts.hasEntries(jsSymbol.exports)) { - symbol.exports = symbol.exports || ts.createSymbolTable(); - mergeSymbolTable(symbol.exports, jsSymbol.exports); - } - if (ts.hasEntries(jsSymbol.members)) { - symbol.members = symbol.members || ts.createSymbolTable(); - mergeSymbolTable(symbol.members, jsSymbol.members); - } + symbol = links = merged; } } originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol); @@ -36930,8 +37504,8 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 205 /* BinaryExpression */ || - declaration.kind === 190 /* PropertyAccessExpression */ && declaration.parent.kind === 205 /* BinaryExpression */) { + else if (declaration.kind === 206 /* BinaryExpression */ || + declaration.kind === 191 /* PropertyAccessExpression */ && declaration.parent.kind === 206 /* BinaryExpression */) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -36970,7 +37544,7 @@ var ts; // 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 & 67220415 /* Value */ + links.type = targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) : errorType; } @@ -36998,7 +37572,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 152 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 153 /* 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 @@ -37079,39 +37653,50 @@ var ts; function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; // TODO: GH#18217 Use SourceFile kind check instead + if (node && ts.isBinaryExpression(node)) { + // prototype assignments get the outer type parameters of their constructor function + var assignmentKind = ts.getAssignmentDeclarationKind(node); + if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + var symbol = getSymbolOfNode(node.left); + if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { + node = symbol.parent.valueDeclaration; + } + } + } if (!node) { return undefined; } switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 182 /* MappedType */: - case 176 /* ConditionalType */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 243 /* InterfaceDeclaration */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 157 /* MethodSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 296 /* JSDocFunctionType */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 244 /* TypeAliasDeclaration */: + case 312 /* JSDocTemplateTag */: + case 313 /* JSDocTypedefTag */: + case 307 /* JSDocEnumTag */: + case 306 /* JSDocCallbackTag */: + case 183 /* MappedType */: + case 177 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 182 /* MappedType */) { + if (node.kind === 183 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 176 /* ConditionalType */) { + else if (node.kind === 177 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */ || node.kind === 242 /* InterfaceDeclaration */) && + (node.kind === 242 /* ClassDeclaration */ || node.kind === 211 /* ClassExpression */ || node.kind === 243 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -37119,7 +37704,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 243 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -37128,9 +37713,10 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 241 /* ClassDeclaration */ || - node.kind === 210 /* ClassExpression */ || + if (node.kind === 243 /* InterfaceDeclaration */ || + node.kind === 242 /* ClassDeclaration */ || + node.kind === 211 /* ClassExpression */ || + isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -37161,7 +37747,7 @@ var ts; var constraint = getBaseConstraintOfType(type); return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } - return isJSConstructorType(type); + return false; } function getBaseTypeNodeOfClass(type) { return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); @@ -37256,9 +37842,7 @@ var ts; var baseTypeNode = getBaseTypeNodeOfClass(type); var typeArgs = typeArgumentsFromTypeReferenceNode(baseTypeNode); var baseType; - var originalBaseType = isJSConstructorType(baseConstructorType) ? baseConstructorType : - baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : - undefined; + var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the @@ -37269,9 +37853,6 @@ var ts; else if (baseConstructorType.flags & 1 /* Any */) { baseType = baseConstructorType; } - else if (isJSConstructorType(baseConstructorType)) { - baseType = !baseTypeNode.typeArguments && getJSClassType(baseConstructorType.symbol) || anyType; - } else { // The class derives from a "class-like" constructor function, check that we have at least one construct signature // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere @@ -37324,7 +37905,7 @@ var ts; 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 === 242 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 243 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -37360,7 +37941,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242 /* InterfaceDeclaration */) { + if (declaration.kind === 243 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -37369,7 +37950,7 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 67897832 /* Type */, /*ignoreErrors*/ true); + var baseSymbol = resolveEntityName(node.expression, 788968 /* Type */, /*ignoreErrors*/ true); if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } @@ -37382,9 +37963,15 @@ var ts; } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); + var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; - var type = links.declaredType = createObjectType(kind, symbol); + var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + if (merged) { + // note:we overwrite links because we just cloned the symbol + symbol = links = merged; + } + var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type @@ -37416,9 +38003,10 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return errorType; } - var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 243 /* TypeAliasDeclaration */; - }); + var declaration = ts.find(symbol.declarations, ts.isTypeAlias); + if (!declaration) { + return ts.Debug.fail("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; @@ -37434,7 +38022,7 @@ var ts; } else { type = errorType; - error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + error(ts.isJSDocEnumTag(declaration) ? declaration : declaration.name || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } links.declaredType = type; } @@ -37444,7 +38032,7 @@ var ts; if (expr.kind === 10 /* StringLiteral */) { return true; } - else if (expr.kind === 205 /* BinaryExpression */) { + else if (expr.kind === 206 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -37458,12 +38046,12 @@ var ts; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return true; - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return expr.operator === 39 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; case 73 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -37477,7 +38065,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 245 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && member.initializer.kind === 10 /* StringLiteral */) { @@ -37504,7 +38092,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 245 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -37588,11 +38176,11 @@ var ts; case 142 /* UndefinedKeyword */: case 97 /* NullKeyword */: case 133 /* NeverKeyword */: - case 183 /* LiteralType */: + case 184 /* LiteralType */: return true; - case 170 /* ArrayType */: + case 171 /* ArrayType */: return isThislessType(node.elementType); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -37618,7 +38206,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 158 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 159 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -37634,14 +38222,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -37751,7 +38339,7 @@ var ts; else { symbol.declarations.push(member); } - if (symbolFlags & 67220415 /* Value */) { + if (symbolFlags & 111551 /* Value */) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -38013,7 +38601,7 @@ var ts; var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; // TODO: GH#18217 + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -38057,8 +38645,9 @@ var ts; } var result; for (var i = 0; i < signatureLists.length; i++) { - // Allow matching non-generic signatures to have excess parameters and different return types - var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true); + // Allow matching non-generic signatures to have excess parameters and different return types. + // Prefer matching this types if possible. + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true); if (!match) { return undefined; } @@ -38082,7 +38671,7 @@ var ts; for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { var signature = _a[_i]; // Only process signatures with parameter lists that aren't already in the result list - if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true)) { + if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true)) { var unionSignatures = findMatchingSignatures(signatureLists, signature, i); if (unionSignatures) { var s = signature; @@ -38091,7 +38680,7 @@ var ts; var thisParameter = signature.thisParameter; var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; }); if (firstThisParameterOfUnionSignatures) { - var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType; }), 2 /* Subtype */); + var thisType = getIntersectionType(ts.mapDefined(unionSignatures, function (sig) { return sig.thisParameter && getTypeOfSymbol(sig.thisParameter); })); thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType); } s = createUnionSignature(signature, unionSignatures); @@ -38135,8 +38724,8 @@ var ts; } // 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 - // permissive when calling, for now, we'll union the `this` types just like the overlapping-union-signature check does - var thisType = getUnionType([getTypeOfSymbol(left), getTypeOfSymbol(right)], 2 /* Subtype */); + // permissive when calling, for now, we'll intersect the `this` types just like we do for param types in union signatures. + var thisType = getIntersectionType([getTypeOfSymbol(left), getTypeOfSymbol(right)]); return createSymbolWithType(left, thisType); } function combineUnionParameters(left, right) { @@ -38290,7 +38879,7 @@ var ts; * Converts an AnonymousType to a ResolvedType. */ function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; + var symbol = getMergedSymbol(type.symbol); if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); @@ -38346,14 +38935,18 @@ var ts; // will never be observed because a qualified name can't reference signatures. if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); - type.constructSignatures = ts.filter(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration); }); } // And likewise for construct signatures for classes if (symbol.flags & 32 /* Class */) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)); + var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* Function */) { + constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes) : + undefined; })); + } if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); + constructSignatures = getDefaultConstructSignatures(classType_1); } type.constructSignatures = constructSignatures; } @@ -38496,7 +39089,7 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 180 /* TypeOperator */ && + return constraintDeclaration.kind === 181 /* TypeOperator */ && constraintDeclaration.operator === 130 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { @@ -38510,7 +39103,7 @@ var ts; else { // Otherwise, get the declared constraint type, and if the constraint type is a type parameter, // get the constraint of that type parameter. If the resulting type is an indexed type 'keyof T', - // the modifiers type is T. Otherwise, the modifiers type is {}. + // the modifiers type is T. Otherwise, the modifiers type is unknown. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; @@ -38564,9 +39157,16 @@ var ts; else if (type.flags & 2097152 /* Intersection */) { resolveIntersectionTypeMembers(type); } + else if (type.flags & 134217728 /* StructuralTag */) { + resolveStructuralTagTypeMembers(type); + } } return type; } + function resolveStructuralTagTypeMembers(type) { + // Explicitly do nothing - structured tags, despite "containing structure" (in their argument), do not have any visible structure. + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { if (type.flags & 524288 /* Object */) { @@ -38881,6 +39481,9 @@ var ts; if (t.flags & 33554432 /* Substitution */) { return getBaseConstraint(t.substitute); } + if (t.flags & 134217728 /* StructuralTag */) { + return unknownType; + } return t; } } @@ -39127,7 +39730,7 @@ var ts; return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 137887744 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; } @@ -39141,7 +39744,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 137887744 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* String */ ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -39200,10 +39803,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 === 294 /* JSDocOptionalType */ + node.type && node.type.kind === 295 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 295 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -39237,7 +39840,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 295 /* JSDocOptionalType */; } function createIdentifierTypePredicate(parameterName, parameterIndex, type) { return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -39309,7 +39912,7 @@ var ts; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; // Include parameter symbol instead of property symbol in the signature if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 67220415 /* Value */, undefined, undefined, /*isUse*/ false); + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } if (i === 0 && paramSymbol.escapedName === "this" /* This */) { @@ -39319,7 +39922,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 183 /* LiteralType */) { + if (type && type.kind === 184 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -39333,16 +39936,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 === 159 /* GetAccessor */ || declaration.kind === 160 /* SetAccessor */) && + if ((declaration.kind === 160 /* GetAccessor */ || declaration.kind === 161 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = declaration.kind === 160 /* GetAccessor */ ? 161 /* SetAccessor */ : 160 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 158 /* Constructor */ ? + var classType = declaration.kind === 159 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -39402,11 +40005,11 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return node.name.kind === 150 /* ComputedPropertyName */ + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + return node.name.kind === 151 /* ComputedPropertyName */ && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -39496,7 +40099,6 @@ var ts; var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) : getReturnTypeFromAnnotation(signature.declaration) || - isJSConstructor(signature.declaration) && getJSClassType(getSymbolOfNode(signature.declaration)) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); if (!popTypeResolution()) { if (signature.declaration) { @@ -39522,7 +40124,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 158 /* Constructor */) { + if (declaration.kind === 159 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -39532,12 +40134,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 159 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 160 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 160 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 161 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -39627,7 +40229,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 === 158 /* Constructor */ || kind === 162 /* ConstructSignature */ || kind === 167 /* ConstructorType */; + var isConstructor = kind === 159 /* Constructor */ || kind === 163 /* ConstructSignature */ || kind === 168 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -39668,7 +40270,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 151 /* TypeParameter */); + var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 152 /* TypeParameter */); return decl && ts.getEffectiveConstraintOfTypeParameter(decl); } function getInferredTypeParameterConstraint(typeParameter) { @@ -39676,13 +40278,13 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 177 /* InferType */) { + if (declaration.parent.kind === 178 /* 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 grandParent = declaration.parent.parent; - if (grandParent.kind === 165 /* TypeReference */) { + if (grandParent.kind === 166 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -39707,7 +40309,7 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter // declaration, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 152 /* Parameter */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 153 /* Parameter */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -39731,7 +40333,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 151 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 152 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -39808,13 +40410,13 @@ var ts; var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent); - var diag = minTypeArgumentCount === typeParameters.length - ? missingAugmentsTag - ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : missingAugmentsTag - ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; + var diag = minTypeArgumentCount === typeParameters.length ? + missingAugmentsTag ? + ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + missingAugmentsTag ? + ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { @@ -39853,9 +40455,9 @@ var ts; var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { - error(node, minTypeArgumentCount === typeParameters.length - ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); + error(node, minTypeArgumentCount === typeParameters.length ? + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } return getTypeAliasInstantiation(symbol, typeArguments); @@ -39864,9 +40466,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 166 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -39877,34 +40479,23 @@ var ts; } return undefined; } - function resolveTypeReferenceName(typeReferenceName, meaning) { + function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) { if (!typeReferenceName) { return unknownSymbol; } - return resolveEntityName(typeReferenceName, meaning) || unknownSymbol; + return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. if (symbol === unknownSymbol) { return errorType; } - var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); - if (type) { - return type; + symbol = getExpandoSymbol(symbol) || symbol; + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); } - // JS enums are 'string' or 'number', not an enum type. - var enumTag = ts.isInJSFile(node) && symbol.valueDeclaration && ts.getJSDocEnumTag(symbol.valueDeclaration); - if (enumTag) { - var links = getNodeLinks(enumTag); - if (!pushTypeResolution(enumTag, 5 /* EnumTagType */)) { - return errorType; - } - var type_4 = enumTag.typeExpression ? getTypeFromTypeNode(enumTag.typeExpression) : errorType; - if (!popTypeResolution()) { - type_4 = errorType; - error(node, ts.Diagnostics.Enum_type_0_circularly_references_itself, symbolToString(symbol)); - } - return (links.resolvedEnumType = type_4); + if (symbol.flags & 524288 /* TypeAlias */) { + return getTypeFromTypeAliasReference(node, symbol, typeArguments); } // Get type from reference to named type that cannot be generic (enum or type parameter) var res = tryGetDeclaredTypeOfSymbol(symbol); @@ -39913,55 +40504,31 @@ var ts; res.flags & 262144 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } - if (!(symbol.flags & 67220415 /* Value */ && isJSDocTypeReference(node))) { - return errorType; - } - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; + if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + var jsdocType = getTypeFromJSAlias(node, symbol); + if (jsdocType) { + return jsdocType; + } + else { + // Resolve the type reference as a Type for the purpose of reporting errors. + resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */); + return getTypeOfSymbol(symbol); + } } - // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(getTypeReferenceName(node), 67897832 /* Type */); - return getTypeOfSymbol(symbol); + return errorType; } /** - * A jsdoc TypeReference may have resolved to a value (as opposed to a type). If - * the symbol is a constructor function, return the inferred class type; otherwise, - * the type of this reference is just the type of the value we resolved to. + * A JSdoc TypeReference may be to a value imported from commonjs. + * These should really be aliases, but this special-case code fakes alias resolution + * by producing a type from a value. */ - function getJSDocTypeReference(node, symbol, typeArguments) { - // In the case of an assignment of a function expression (binary expressions, variable declarations, etc.), we will get the - // correct instance type for the symbol on the LHS by finding the type for RHS. For example if we want to get the type of the symbol `foo`: - // var foo = function() {} - // We will find the static type of the assigned anonymous function. - var staticType = getTypeOfSymbol(symbol); - var instanceType = staticType.symbol && - staticType.symbol !== symbol && // Make sure this is an assignment like expression by checking that symbol -> type -> symbol doesn't roundtrips. - getTypeReferenceTypeWorker(node, staticType.symbol, typeArguments); // Get the instance type of the RHS symbol. - if (instanceType) { - return getSymbolLinks(symbol).resolvedJSDocType = instanceType; - } - } - function getTypeReferenceTypeWorker(node, symbol, typeArguments) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (symbol.valueDeclaration && symbol.valueDeclaration.parent && ts.isBinaryExpression(symbol.valueDeclaration.parent)) { - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; - } - } - return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); - } - if (symbol.flags & 524288 /* TypeAlias */) { - return getTypeFromTypeAliasReference(node, symbol, typeArguments); - } - if (symbol.flags & 16 /* Function */ && - isJSDocTypeReference(node) && - isJSConstructor(symbol.valueDeclaration)) { - var resolved = resolveStructuredTypeMembers(getTypeOfSymbol(symbol)); - if (resolved.callSignatures.length === 1) { - return getReturnTypeOfSignature(resolved.callSignatures[0]); - } + function getTypeFromJSAlias(node, symbol) { + var valueType = getTypeOfSymbol(symbol); + var typeType = valueType.symbol && + valueType.symbol !== symbol && // Make sure this is a commonjs export by checking that symbol -> type -> symbol doesn't roundtrip. + getTypeReferenceType(node, valueType.symbol); + if (typeType) { + return getSymbolLinks(symbol).resolvedJSDocType = typeType; } } function getSubstitutionType(typeVariable, substitute) { @@ -39980,7 +40547,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 171 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 172 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -39989,9 +40556,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 297 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 299 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 176 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 177 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -40002,7 +40569,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 165 /* TypeReference */ || node.kind === 184 /* ImportType */); + return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 166 /* TypeReference */ || node.kind === 185 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -40039,10 +40606,10 @@ var ts; return globalFunctionType; case "Array": case "array": - return !typeArgs || !typeArgs.length ? anyArrayType : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined; case "Promise": case "promise": - return !typeArgs || !typeArgs.length ? createPromiseType(anyType) : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined; case "Object": if (typeArgs && typeArgs.length === 2) { if (ts.isJSDocIndexSignature(node)) { @@ -40054,7 +40621,7 @@ var ts; return anyType; } checkNoTypeArguments(node); - return anyType; + return !noImplicitAny ? anyType : undefined; } } } @@ -40067,10 +40634,19 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - var meaning = 67897832 /* Type */; + var meaning = 788968 /* Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); - meaning |= 67220415 /* Value */; + if (!type) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, /*ignoreErrors*/ true); + if (symbol === unknownSymbol) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551 /* Value */); + } + else { + resolveTypeReferenceName(getTypeReferenceName(node), meaning); // Resolve again to mark errors, if any + } + type = getTypeReferenceType(node, symbol); + } } if (!type) { symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning); @@ -40103,9 +40679,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 245 /* EnumDeclaration */: return declaration; } } @@ -40125,10 +40701,10 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67220415 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67897832 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { // Don't track references for global symbols anyway, so value if `isReference` is arbitrary @@ -40197,7 +40773,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 67897832 /* Type */, /*diagnostic*/ undefined); + var symbol = getGlobalSymbol(name, 788968 /* Type */, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -40307,8 +40883,8 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 173 /* RestType */ ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 172 /* OptionalType */ && n !== restElement_1; }) + 1; + var restElement_1 = lastElement && lastElement.kind === 174 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 173 /* OptionalType */ && n !== restElement_1; }) + 1; var elementTypes = ts.map(node.elementTypes, function (n) { var type = getTypeFromTypeNode(n); return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; @@ -40351,7 +40927,7 @@ var ts; // We ignore 'never' types in unions if (!(flags & 131072 /* Never */)) { includes |= flags & 68943871 /* IncludesMask */; - if (flags & 66846720 /* StructuredOrInstantiable */) + if (flags & 201064448 /* StructuredOrInstantiable */) includes |= 262144 /* IncludesStructuredOrInstantiable */; if (type === wildcardType) includes |= 4194304 /* IncludesWildcard */; @@ -40483,7 +41059,7 @@ var ts; neverType; } } - return getUnionTypeFromSortedList(typeSet, includes & 66994211 /* NotPrimitiveUnion */ ? 0 : 131072 /* PrimitiveUnion */, aliasSymbol, aliasTypeArguments); + return getUnionTypeFromSortedList(typeSet, includes & 201211939 /* NotPrimitiveUnion */ ? 0 : 131072 /* PrimitiveUnion */, aliasSymbol, aliasTypeArguments); } function getUnionTypePredicate(signatures) { var first; @@ -40553,10 +41129,10 @@ var ts; } return links.resolvedType; } - function addTypeToIntersection(typeSet, includes, type) { + function addTypeToIntersection(typeSet, includes, type, tagSet) { var flags = type.flags; if (flags & 2097152 /* Intersection */) { - return addTypesToIntersection(typeSet, includes, type.types); + return addTypesToIntersection(typeSet, includes, type.types, tagSet); } if (isEmptyAnonymousObjectType(type)) { if (!(includes & 8388608 /* IncludesEmptyObject */)) { @@ -40569,6 +41145,9 @@ var ts; if (type === wildcardType) includes |= 4194304 /* IncludesWildcard */; } + else if (flags & 134217728 /* StructuralTag */) { + tagSet.set(type.id.toString(), type); + } else if ((strictNullChecks || !(flags & 98304 /* Nullable */)) && !typeSet.has(type.id.toString())) { if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) { // We have seen two distinct unit types which means we should reduce to an @@ -40583,10 +41162,27 @@ var ts; } // Add the given types to the given type set. Order is preserved, freshness is removed from literal // types, duplicates are removed, and nested types of the given kind are flattened into the set. - function addTypesToIntersection(typeSet, includes, types) { + function addTypesToIntersection(typeSet, includes, types, tagSet) { + var isTopLevel = !tagSet; + tagSet = tagSet || ts.createMap(); for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { var type = types_8[_i]; - includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); + includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type), tagSet); + } + if (isTopLevel && tagSet.size) { + var tag = void 0; + if (tagSet.size === 1) { + tag = tagSet.values().next().value; + } + else { + var tagTypes_1 = []; + tagSet.forEach(function (t) { return tagTypes_1.push(t.type); }); + tag = getStructuralTagForType(getIntersectionType(tagTypes_1)); + if (tag.flags & 1048576 /* Union */) { + includes |= 1048576 /* Union */; + } + } + typeSet.set(tag.id.toString(), tag); } return includes; } @@ -40623,6 +41219,15 @@ var ts; } return true; } + function extractIrreducible(types, flag) { + if (ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); })) { + for (var i = 0; i < types.length; i++) { + types[i] = filterType(types[i], function (t) { return !(t.flags & flag); }); + } + return true; + } + return false; + } // If the given list of types contains more than one union of primitive types, replace the // first with a union containing an intersection of those primitive types, then remove the // other unions and return true. Otherwise, do nothing and return false. @@ -40741,6 +41346,12 @@ var ts; // reduced we'll never reduce again, so this occurs at most once. result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } + else if (extractIrreducible(typeSet, 32768 /* Undefined */)) { + result = getUnionType([getIntersectionType(typeSet), undefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + } + else if (extractIrreducible(typeSet, 65536 /* Null */)) { + result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + } else { // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain. @@ -40856,9 +41467,16 @@ var ts; case 134 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; + case 148 /* TagKeyword */: + var aliasSymbol = getAliasSymbolForTypeNode(node); + var aliasParams = getTypeArgumentsForAliasSymbol(aliasSymbol); + links.resolvedType = getStructuralTagForType(getTypeFromTypeNode(node.type), aliasSymbol, aliasParams); + break; + default: + throw ts.Debug.assertNever(node.operator); } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function createIndexedAccessType(objectType, indexType) { var type = createType(8388608 /* IndexedAccess */); @@ -40866,6 +41484,26 @@ var ts; type.indexType = indexType; return type; } + function getStructuralTagForType(type, aliasSymbol, aliasTypeArguments) { + if (typeof aliasSymbol === "number") { + aliasSymbol = undefined; + } + var tid = "" + getTypeId(type); + if (structuralTags.has(tid)) { + return structuralTags.get(tid); + } + if (type.flags & 1048576 /* Union */) { + var union = getUnionType(ts.map(type.types, getStructuralTagForType), 2 /* Subtype */, aliasSymbol, aliasTypeArguments); + structuralTags.set(tid, union); + return union; + } + var tag = createType(134217728 /* StructuralTag */); + tag.type = type; + tag.aliasSymbol = aliasSymbol; + tag.aliasTypeArguments = aliasTypeArguments; + structuralTags.set(tid, tag); + return tag; + } /** * Returns if a type is or consists of a JSLiteral object type * In addition to objects which are directly literals, @@ -40894,7 +41532,7 @@ var ts; return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 192 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -40905,7 +41543,7 @@ var ts; undefined; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 192 /* ElementAccessExpression */ ? accessNode : undefined; var propName = getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); @@ -41042,13 +41680,10 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 191 /* ElementAccessExpression */ - ? accessNode.argumentExpression - : accessNode.kind === 181 /* IndexedAccessType */ - ? accessNode.indexType - : accessNode.kind === 150 /* ComputedPropertyName */ - ? accessNode.expression - : accessNode; + return accessNode.kind === 192 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 182 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 151 /* ComputedPropertyName */ ? accessNode.expression : + accessNode; } function isGenericObjectType(type) { return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 131072 /* GenericMappedType */); @@ -41173,7 +41808,7 @@ var ts; // object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in // an expression. This is to preserve backwards compatibility. For example, an element access 'this["foo"]' // has always been resolved eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 181 /* IndexedAccessType */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 182 /* IndexedAccessType */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -41385,7 +42020,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 67220415 /* Value */ : node.flags & 2097152 /* JSDoc */ ? 67220415 /* Value */ | 67897832 /* Type */ : 67897832 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 2097152 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { @@ -41408,14 +42043,14 @@ var ts; getNodeLinks(current.parent).resolvedSymbol = next; currentNamespace = next; } - resolveImportSymbolType(node, links, currentNamespace, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning); } else { if (moduleSymbol.flags & targetMeaning) { - resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 67220415 /* Value */ + var errorMessage = targetMeaning === 111551 /* Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -41424,16 +42059,16 @@ var ts; } } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 67220415 /* Value */) { - return links.resolvedType = getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias + if (meaning === 111551 /* Value */) { + return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { - return links.resolvedType = getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol + return getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol } } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { @@ -41457,7 +42092,11 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined; + var host = node.parent; + while (ts.isParenthesizedTypeNode(host)) { + host = host.parent; + } + return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; } function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; @@ -41646,12 +42285,26 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 242 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 243 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 158 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } + // inside x.prototype = { ... } + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; + } + // /** @return {this} */ + // x.prototype.m = function() { ... } + var host = node.flags & 2097152 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; + } + // inside constructor function C() { ... } + if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType; + } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); return errorType; } @@ -41665,8 +42318,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 121 /* AnyKeyword */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 291 /* JSDocAllType */: + case 292 /* JSDocUnknownType */: return anyType; case 144 /* UnknownKeyword */: return unknownType; @@ -41690,63 +42343,63 @@ var ts; return neverType; case 137 /* ObjectKeyword */: return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 179 /* ThisType */: + case 180 /* ThisType */: case 101 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 183 /* LiteralType */: + case 184 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return getTypeFromTypeReference(node); - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return booleanType; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 171 /* TupleType */: + case 172 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 172 /* OptionalType */: + case 173 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 174 /* UnionType */: + case 175 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 175 /* IntersectionType */: + case 176 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 292 /* JSDocNullableType */: + case 293 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 294 /* JSDocOptionalType */: + case 295 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 178 /* ParenthesizedType */: - case 173 /* RestType */: - case 293 /* JSDocNonNullableType */: - case 289 /* JSDocTypeExpression */: + case 179 /* ParenthesizedType */: + case 174 /* RestType */: + case 294 /* JSDocNonNullableType */: + case 290 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 296 /* JSDocVariadicType */: + case 297 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 295 /* JSDocFunctionType */: - case 299 /* JSDocSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 170 /* TypeLiteral */: + case 300 /* JSDocTypeLiteral */: + case 296 /* JSDocFunctionType */: + case 301 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 182 /* MappedType */: + case 183 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 177 /* InferType */: + case 178 /* InferType */: return getTypeFromInferTypeNode(node); - case 184 /* ImportType */: + case 185 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -41875,7 +42528,7 @@ var ts; } function instantiateSymbol(symbol, mapper) { var links = getSymbolLinks(symbol); - if (links.type && !maybeTypeOfKind(links.type, 524288 /* Object */ | 63176704 /* Instantiable */)) { + if (links.type && !maybeTypeOfKind(links.type, 524288 /* Object */ | 63176704 /* Instantiable */ | 134217728 /* StructuralTag */)) { // If the type of the symbol is already resolved, and if that type could not possibly // be affected by instantiation, simply return the symbol itself. return symbol; @@ -41955,8 +42608,9 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 149 /* QualifiedName */ || - node.parent.kind === 165 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 150 /* QualifiedName */ || + node.parent.kind === 166 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 185 /* 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 @@ -41965,7 +42619,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 219 /* Block */ || n.kind === 176 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 220 /* Block */ || n.kind === 177 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -41974,12 +42628,12 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 179 /* ThisType */: + case 180 /* ThisType */: return !!tp.isThisType; case 73 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return true; } return !!ts.forEachChild(node, containsReference); @@ -42173,6 +42827,10 @@ var ts; return sub; } } + if (flags & 134217728 /* StructuralTag */) { + var newType = instantiateType(type.type, mapper); + return newType !== type ? getStructuralTagForType(newType, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; + } return type; } function getPermissiveInstantiation(type) { @@ -42201,35 +42859,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 !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return node.operatorToken.kind === 55 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 268 /* JsxAttribute */: { + case 269 /* 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 271 /* JsxExpression */: { + case 272 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -42249,7 +42907,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 198 /* ArrowFunction */) { + if (node.kind !== 199 /* 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); @@ -42261,7 +42919,7 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !!node.body && node.body.kind !== 219 /* Block */ && isContextSensitive(node.body); + return !!node.body && node.body.kind !== 220 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -42364,23 +43022,23 @@ var ts; return true; } switch (node.kind) { - case 271 /* JsxExpression */: - case 196 /* ParenthesizedExpression */: + case 272 /* JsxExpression */: + case 197 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (node.operatorToken.kind) { case 60 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -42552,7 +43210,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -42561,9 +43219,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 262 /* JsxElement */: + case 263 /* JsxSelfClosingElement */: + case 266 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -42637,7 +43295,7 @@ var ts; var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName); var childrenTargetType = getIndexedAccessType(target, getLiteralType(childrenPropName)); var diagnostic = ts.Diagnostics._0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2; - invalidTextDiagnostic = __assign({}, diagnostic, { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); + invalidTextDiagnostic = __assign(__assign({}, diagnostic), { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); } return invalidTextDiagnostic; } @@ -42705,11 +43363,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 160 /* SetAccessor */: return [3 /*break*/, 2]; - case 159 /* GetAccessor */: return [3 /*break*/, 2]; - case 157 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 277 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 276 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 161 /* SetAccessor */: return [3 /*break*/, 2]; + case 160 /* GetAccessor */: return [3 /*break*/, 2]; + case 158 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 278 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 277 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -42781,8 +43439,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 157 /* MethodDeclaration */ && - kind !== 156 /* MethodSignature */ && kind !== 158 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 158 /* MethodDeclaration */ && + kind !== 157 /* MethodSignature */ && kind !== 159 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -42830,15 +43488,17 @@ var ts; result &= related; } if (!ignoreReturnTypes) { - // If a signature reolution is already in-flight, skip issuing a circularity error + // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly - var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType : (target.declaration && isJSConstructor(target.declaration)) ? - getJSClassType(target.declaration.symbol) : getReturnTypeOfSignature(target); + var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType + : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(target.declaration.symbol) + : getReturnTypeOfSignature(target); if (targetReturnType === voidType) { return result; } - var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType : (source.declaration && isJSConstructor(source.declaration)) ? - getJSClassType(source.declaration.symbol) : getReturnTypeOfSignature(source); + var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType + : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(source.declaration.symbol) + : getReturnTypeOfSignature(source); // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions var targetTypePredicate = getTypePredicateOfSignature(target); if (targetTypePredicate) { @@ -43024,7 +43684,7 @@ var ts; return related === 1 /* Succeeded */; } } - if (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */) { + if (source.flags & 201064448 /* StructuredOrInstantiable */ || target.flags & 201064448 /* StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; @@ -43085,7 +43745,7 @@ var ts; } var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); if (relatedInfo) { - ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInfo)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInfo)); } if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -43130,8 +43790,8 @@ var ts; reportError(message, sourceType, targetType); } function tryElaborateErrorsForPrimitivesAndObjects(source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); + var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source); + var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target); if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || @@ -43224,7 +43884,7 @@ var ts; isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); - var isPerformingExcessPropertyChecks = (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); + var isPerformingExcessPropertyChecks = !isApparentIntersectionConstituent && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); if (isPerformingExcessPropertyChecks) { var discriminantType = target.flags & 1048576 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { @@ -43234,11 +43894,11 @@ var ts; return 0 /* False */; } } - if (relation !== comparableRelation && !isApparentIntersectionConstituent && + var isPerformingCommonPropertyChecks = relation !== comparableRelation && !isApparentIntersectionConstituent && source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType && target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) && - (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)) && - !hasCommonProperties(source, target, isComparingJsxAttributes)) { + (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); + if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var calls = getSignaturesOfType(source, 0 /* Call */); var constructs = getSignaturesOfType(source, 1 /* Construct */); @@ -43260,16 +43920,16 @@ var ts; // and we need to handle "each" relations before "some" relations for the same kind of type. if (source.flags & 1048576 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)) : + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), isIntersectionConstituent) : eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)); } else { if (target.flags & 1048576 /* Union */) { result = typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { // Validate against excess props using the original `source` var discriminantType = findMatchingDiscriminantType(source, target) || filterPrimitivesIfContainsNonPrimitive(target); - if (!propertiesRelatedTo(source, discriminantType, reportErrors, /*excludedProperties*/ undefined)) { + if (!propertiesRelatedTo(source, discriminantType, reportErrors, /*excludedProperties*/ undefined, isIntersectionConstituent)) { return 0 /* False */; } } @@ -43277,9 +43937,9 @@ var ts; else if (target.flags & 2097152 /* Intersection */) { isIntersectionConstituent = true; // set here to affect the following trio of checks result = typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { // Validate against excess props using the original `source` - if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined)) { + if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, /*isIntersectionConstituent*/ false)) { return 0 /* False */; } } @@ -43298,9 +43958,9 @@ var ts; // // - For a primitive type or type parameter (such as 'number = A & B') there is no point in // breaking the intersection apart. - result = someTypeRelatedToType(source, target, /*reportErrors*/ false); + result = someTypeRelatedToType(source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ true); } - if (!result && (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */)) { + if (!result && (source.flags & 201064448 /* StructuredOrInstantiable */ || target.flags & 201064448 /* StructuredOrInstantiable */)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { errorInfo = saveErrorInfo; } @@ -43567,14 +44227,14 @@ var ts; } return result; } - function someTypeRelatedToType(source, target, reportErrors) { + function someTypeRelatedToType(source, target, reportErrors, isIntersectionConstituent) { var sourceTypes = source.types; if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, isIntersectionConstituent); if (related) { return related; } @@ -43594,7 +44254,7 @@ var ts; } return result; } - function typeArgumentsRelatedTo(sources, targets, variances, reportErrors) { + function typeArgumentsRelatedTo(sources, targets, variances, reportErrors, isIntersectionConstituent) { if (sources === void 0) { sources = ts.emptyArray; } if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } @@ -43621,10 +44281,10 @@ var ts; related = relation === identityRelation ? isRelatedTo(s, t, /*reportErrors*/ false) : compareTypesIdentical(s, t); } else if (variance === 1 /* Covariant */) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } else if (variance === 2 /* Contravariant */) { - related = isRelatedTo(t, s, reportErrors); + related = isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } else if (variance === 3 /* Bivariant */) { // In the bivariant case we first compare contravariantly without reporting @@ -43633,16 +44293,16 @@ var ts; // which is generally easier to reason about. related = isRelatedTo(t, s, /*reportErrors*/ false); if (!related) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } else { // In the invariant case we first compare covariantly, and only when that // succeeds do we proceed to compare contravariantly. Thus, error elaboration // will typically be based on the covariant check. - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); if (related) { - related &= isRelatedTo(t, s, reportErrors); + related &= isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } if (!related) { @@ -43772,6 +44432,9 @@ var ts; if (flags & 33554432 /* Substitution */) { return isRelatedTo(source.substitute, target.substitute, /*reportErrors*/ false); } + if (flags & 134217728 /* StructuralTag */) { + return isRelatedTo(source.type, target.type, /*reportErrors*/ false); + } return 0 /* False */; } var result; @@ -43785,7 +44448,7 @@ var ts; source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) { var variances = getAliasVariances(source.aliasSymbol); - var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances); + var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -43871,6 +44534,12 @@ var ts; } } } + else if (target.flags & 134217728 /* StructuralTag */) { + if (source.flags & 134217728 /* StructuralTag */) { + return isRelatedTo(source.type, target.type, reportErrors); + } + return 0 /* False */; + } 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. @@ -43914,9 +44583,19 @@ var ts; // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. - if (isTypeIdenticalTo(source.extendsType, target.extendsType) && + var sourceParams = source.root.inferTypeParameters; + var sourceExtends = source.extendsType; + var mapper = void 0; + if (sourceParams) { + // If the source has infer type parameters, we instantiate them in the context of the target + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedTo); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 64 /* NoConstraints */ | 128 /* AlwaysStrict */); + sourceExtends = instantiateType(sourceExtends, ctx.mapper); + mapper = ctx.mapper; + } + if (isTypeIdenticalTo(sourceExtends, target.extendsType) && (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { - if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } if (result) { @@ -43969,7 +44648,7 @@ var ts; // type references (which are intended by be compared structurally). Obtain the variance // information for the type parameters and relate the type arguments accordingly. var variances = getVariances(source.target); - var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances); + var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -43997,7 +44676,7 @@ var ts; if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 524288 /* Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; - result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined); + result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, isIntersectionConstituent); if (result) { result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); if (result) { @@ -44032,8 +44711,8 @@ var ts; } } return 0 /* False */; - function relateVariances(sourceTypeArguments, targetTypeArguments, variances) { - if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors)) { + function relateVariances(sourceTypeArguments, targetTypeArguments, variances, isIntersectionConstituent) { + if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, isIntersectionConstituent)) { return result; } if (ts.some(variances, function (v) { return !!(v & 24 /* AllowsStructuralFallback */); })) { @@ -44158,7 +44837,7 @@ var ts; if (sourceProperty === targetProperty) return "continue"; // We compare the source property to the target in the context of a single discriminant type. - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, /*isIntersectionConstituent*/ false); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -44188,7 +44867,7 @@ var ts; var result = -1 /* True */; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties); + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, /*isIntersectionConstituent*/ false); if (result) { result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false); if (result) { @@ -44223,7 +44902,7 @@ var ts; } return result || properties; } - function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); var source = getTypeOfSourceProperty(sourceProp); if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { @@ -44263,10 +44942,10 @@ var ts; return result_7; } else { - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } - function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { @@ -44304,7 +44983,7 @@ var ts; return 0 /* False */; } // If the target comes from a partial union prop, allow `undefined` in the target type - var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors); + var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); @@ -44327,7 +45006,7 @@ var ts; } return related; } - function propertiesRelatedTo(source, target, reportErrors, excludedProperties) { + function propertiesRelatedTo(source, target, reportErrors, excludedProperties, isIntersectionConstituent) { if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } @@ -44343,7 +45022,7 @@ var ts; } if (props.length === 1) { var propName = symbolToString(unmatchedProperty); - reportError.apply(void 0, [ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName].concat(getTypeNamesForErrorDisplay(source, target))); + reportError.apply(void 0, __spreadArrays([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target))); if (ts.length(unmatchedProperty.declarations)) { associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); } @@ -44416,7 +45095,7 @@ var ts; if (!(targetProp.flags & 4194304 /* Prototype */)) { var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp && sourceProp !== targetProp) { - var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors); + var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, isIntersectionConstituent); if (!related) { return 0 /* False */; } @@ -44595,7 +45274,7 @@ var ts; if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U } // if T is related to U. - return (kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); // TODO: GH#18217 + return kind === 0 /* String */ ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) : 0 /* False */; } if (isObjectTypeWithInferableIndex(source)) { var related = -1 /* True */; @@ -44651,23 +45330,27 @@ var ts; } } function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue) { - var match; + // undefined=unknown, true=discriminated, false=not discriminated + // The state of each type progresses from left to right. Discriminated types stop at 'true'. + var discriminable = target.types.map(function (_) { return undefined; }); for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; + var i = 0; for (var _b = 0, _c = target.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, propertyName); if (targetType && related(getDiscriminatingType(), targetType)) { - if (match) { - if (type === match) - continue; // Finding multiple fields which discriminate to the same type is fine - return defaultValue; - } - match = type; + discriminable[i] = discriminable[i] === undefined ? true : discriminable[i]; } + else { + discriminable[i] = false; + } + i++; } } - return match || defaultValue; + var match = discriminable.indexOf(/*searchElement*/ true); + // make sure exactly 1 matches before returning it + return match === -1 || discriminable.indexOf(/*searchElement*/ true, match + 1) !== -1 ? defaultValue : target.types[match]; } /** * A type is 'weak' if it is an object type with at least one optional property @@ -44870,6 +45553,9 @@ var ts; // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least 5 // levels, but unequal at some level beyond that. + // In addition, this will also detect when an indexed access has been chained off of 5 or more times (which is essentially + // the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding false positives + // for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`). function isDeeplyNestedType(type, stack, depth) { // We track all object types that have an associated symbol (representing the origin of the type) if (depth >= 5 && type.flags & 524288 /* Object */) { @@ -44886,8 +45572,30 @@ var ts; } } } + if (depth >= 5 && type.flags & 8388608 /* IndexedAccess */) { + var root = getRootObjectTypeFromIndexedAccessChain(type); + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (getRootObjectTypeFromIndexedAccessChain(t) === root) { + count++; + if (count >= 5) + return true; + } + } + } return false; } + /** + * Gets the leftmost object type in a chain of indexed accesses, eg, in A[P][Q], returns A + */ + function getRootObjectTypeFromIndexedAccessChain(type) { + var t = type; + while (t.flags & 8388608 /* IndexedAccess */) { + t = t.objectType; + } + return t; + } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; } @@ -45249,8 +45957,8 @@ var ts; * with no call or construct signatures. */ function isObjectTypeWithInferableIndex(type) { - return type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && - !typeHasCallOrConstructSignatures(type); + return !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); @@ -45469,17 +46177,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 205 /* BinaryExpression */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 206 /* BinaryExpression */: + case 156 /* PropertyDeclaration */: + case 155 /* 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 152 /* Parameter */: + case 153 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 67897832 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || + (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, ts.declarationNameToString(param.name)); @@ -45489,23 +46197,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 187 /* BindingElement */: + case 188 /* 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 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 241 /* FunctionDeclaration */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 1 /* 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); @@ -45519,7 +46227,7 @@ var ts; wideningKind === 1 /* 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 182 /* MappedType */: + case 183 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -45640,10 +46348,11 @@ var ts; function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); return !!(type.flags & 63176704 /* Instantiable */ || + type.flags & 134217728 /* StructuralTag */ && couldContainTypeVariables(type.type) || objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, 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 */ || - type.flags & 3145728 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { @@ -45798,8 +46507,7 @@ var ts; var visited; var bivariant = false; var propagationType; - var inferenceCount = 0; - var inferenceIncomplete = false; + var inferencePriority = 256 /* MaxValue */; var allowComplexConstraintInference = true; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { @@ -45822,50 +46530,57 @@ var ts; inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); return; } - if (source.flags & 1048576 /* Union */ && target.flags & 1048576 /* Union */ && !(source.flags & 1024 /* EnumLiteral */ && target.flags & 1024 /* EnumLiteral */) || - source.flags & 2097152 /* Intersection */ && target.flags & 2097152 /* Intersection */) { - // Source and target are both unions or both intersections. If source and target - // are the same type, just relate each constituent type to itself. - if (source === target) { - for (var _i = 0, _a = source.types; _i < _a.length; _i++) { - var t = _a[_i]; - inferFromTypes(t, t); - } - return; - } - // Find each source constituent type that has an identically matching target constituent - // type, and for each such type infer from the type to itself. When inferring from a - // type to itself we effectively find all type parameter occurrences within that type - // and infer themselves as their type arguments. We have special handling for numeric - // and string literals because the number and string types are not represented as unions - // of all their possible values. - var matchingTypes = void 0; - for (var _b = 0, _c = source.types; _b < _c.length; _b++) { - var t = _c[_b]; - var matched = findMatchedType(t, target); - if (matched) { - (matchingTypes || (matchingTypes = [])).push(matched); - inferFromTypes(matched, matched); - } - } - // Next, to improve the quality of inferences, reduce the source and target types by - // removing the identically matched constituents. For example, when inferring from - // 'string | string[]' to 'string | T' we reduce the types to 'string[]' and 'T'. - if (matchingTypes) { - var s = removeTypesFromUnionOrIntersection(source, matchingTypes); - var t = removeTypesFromUnionOrIntersection(target, matchingTypes); - if (!(s && t)) - return; - source = s; - target = t; + if (source === target && source.flags & 3145728 /* UnionOrIntersection */) { + // When source and target are the same union or intersection type, just relate each constituent + // type to itself. + for (var _i = 0, _a = source.types; _i < _a.length; _i++) { + var t = _a[_i]; + inferFromTypes(t, t); } + return; } - else if (target.flags & 1048576 /* Union */ && !(target.flags & 1024 /* EnumLiteral */) || target.flags & 2097152 /* Intersection */) { - var matched = findMatchedType(source, target); - if (matched) { - inferFromTypes(matched, matched); + if (target.flags & 1048576 /* Union */) { + // First, infer between identically matching source and target constituents and remove the + // matching types. + var _b = inferFromMatchingTypes(source.flags & 1048576 /* Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + // Next, infer between closely matching source and target constituents and remove + // the matching types. Types closely match when they are instantiations of the same + // object type or instantiations of the same type alias. + var _c = inferFromMatchingTypes(tempSources, tempTargets, isTypeCloselyMatchedBy), sources = _c[0], targets = _c[1]; + if (targets.length === 0) { return; } + target = getUnionType(targets); + if (sources.length === 0) { + // All source constituents have been matched and there is nothing further to infer from. + // However, simply making no inferences is undesirable because it could ultimately mean + // inferring a type parameter constraint. Instead, make a lower priority inference from + // the full source to whatever remains in the target. For example, when inferring from + // string to 'string | T', make a lower priority inference of string for T. + var savePriority = priority; + priority |= 1 /* NakedTypeVariable */; + inferFromTypes(source, target); + priority = savePriority; + return; + } + source = getUnionType(sources); + } + else if (target.flags & 2097152 /* Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + // We reduce intersection types only when they contain naked type parameters. For example, when + // inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and + // infer { extra: any } for T. But when inferring to 'string[] & Iterable' we want to keep the + // string[] on the source side and infer string for T. + // Likewise, we consider a homomorphic mapped type constrainted to the target type parameter as similar to a "naked type variable" + // in such scenarios. + if (!(source.flags & 1048576 /* Union */)) { + // Infer between identically matching source and target constituents and remove the matching types. + var _d = inferFromMatchingTypes(source.flags & 2097152 /* Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + if (sources.length === 0 || targets.length === 0) { + return; + } + source = getIntersectionType(sources); + target = getIntersectionType(targets); + } } else if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) { target = getActualTypeVariable(target); @@ -45910,7 +46625,7 @@ var ts; clearCachedInferences(inferences); } } - inferenceCount++; + inferencePriority = Math.min(inferencePriority, priority); return; } else { @@ -45941,6 +46656,9 @@ var ts; inferFromTypes(source.type, target.type); contravariant = !contravariant; } + else if (source.flags & 134217728 /* StructuralTag */ && target.flags & 134217728 /* StructuralTag */) { + inferFromTypes(source.type, target.type); + } else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; @@ -45967,11 +46685,17 @@ var ts; else if (target.flags & 3145728 /* UnionOrIntersection */) { inferToMultipleTypes(source, target.types, target.flags); } + else if (target.flags & 134217728 /* StructuralTag */ && source.flags & 2097152 /* Intersection */) { + var tagsOnly = getIntersectionType(ts.filter(source.types, function (t) { return !!(t.flags & 134217728 /* StructuralTag */); })); + if (tagsOnly !== source) { + inferFromTypes(tagsOnly, target); + } + } else if (source.flags & 1048576 /* Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; - for (var _d = 0, sourceTypes_3 = sourceTypes; _d < sourceTypes_3.length; _d++) { - var sourceType = sourceTypes_3[_d]; + for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { + var sourceType = sourceTypes_3[_e]; inferFromTypes(sourceType, target); } } @@ -46001,15 +46725,36 @@ var ts; } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; - var count = visited && visited.get(key); - if (count !== undefined) { - inferenceCount += count; + var status = visited && visited.get(key); + if (status !== undefined) { + inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = ts.createMap())).set(key, 0); - var startCount = inferenceCount; + (visited || (visited = ts.createMap())).set(key, -1 /* Circularity */); + var saveInferencePriority = inferencePriority; + inferencePriority = 256 /* MaxValue */; action(source, target); - visited.set(key, inferenceCount - startCount); + visited.set(key, inferencePriority); + inferencePriority = Math.min(inferencePriority, saveInferencePriority); + } + function inferFromMatchingTypes(sources, targets, matches) { + var matchedSources; + var matchedTargets; + for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { + var t = targets_1[_i]; + for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) { + var s = sources_1[_a]; + if (matches(s, t)) { + inferFromTypes(s, t); + matchedSources = ts.appendIfUnique(matchedSources, s); + matchedTargets = ts.appendIfUnique(matchedTargets, t); + } + } + } + return [ + matchedSources ? ts.filter(sources, function (t) { return !ts.contains(matchedSources, t); }) : sources, + matchedTargets ? ts.filter(targets, function (t) { return !ts.contains(matchedTargets, t); }) : targets, + ]; } function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; @@ -46049,31 +46794,34 @@ var ts; var nakedTypeVariable = void 0; var sources = source.flags & 1048576 /* Union */ ? source.types : [source]; var matched_1 = new Array(sources.length); - var saveInferenceIncomplete = inferenceIncomplete; - inferenceIncomplete = false; + var inferenceCircularity = false; // First infer to types that are not naked type variables. For each source type we - // track whether inferences were made from that particular type to some target. - for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { - var t = targets_1[_i]; + // track whether inferences were made from that particular type to some target with + // equal priority (i.e. of equal quality) to what we would infer for a naked type + // parameter. + for (var _i = 0, targets_2 = targets; _i < targets_2.length; _i++) { + var t = targets_2[_i]; if (getInferenceInfoForType(t)) { nakedTypeVariable = t; typeVariableCount++; } else { for (var i = 0; i < sources.length; i++) { - var count = inferenceCount; + var saveInferencePriority = inferencePriority; + inferencePriority = 256 /* MaxValue */; inferFromTypes(sources[i], t); - if (count !== inferenceCount) + if (inferencePriority === priority) matched_1[i] = true; + inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* Circularity */; + inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } } - var inferenceComplete = !inferenceIncomplete; - inferenceIncomplete = inferenceIncomplete || saveInferenceIncomplete; - // If the target has a single naked type variable and inference completed (meaning we - // explored the types fully), create a union of the source types from which no inferences - // have been made so far and infer from that union to the naked type variable. - if (typeVariableCount === 1 && inferenceComplete) { + // If the target has a single naked type variable and no inference circularities were + // encountered above (meaning we explored the types fully), create a union of the source + // types from which no inferences have been made so far and infer from that union to the + // naked type variable. + if (typeVariableCount === 1 && !inferenceCircularity) { var unmatched = ts.flatMap(sources, function (s, i) { return matched_1[i] ? undefined : s; }); if (unmatched.length) { inferFromTypes(getUnionType(unmatched), nakedTypeVariable); @@ -46085,8 +46833,8 @@ var ts; // We infer from types that are not naked type variables first so that inferences we // make from nested naked type variables and given slightly higher priority by virtue // of being first in the candidates array. - for (var _a = 0, targets_2 = targets; _a < targets_2.length; _a++) { - var t = targets_2[_a]; + for (var _a = 0, targets_3 = targets; _a < targets_3.length; _a++) { + var t = targets_3[_a]; if (getInferenceInfoForType(t)) { typeVariableCount++; } @@ -46102,8 +46850,8 @@ var ts; if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { var savePriority = priority; priority |= 1 /* NakedTypeVariable */; - for (var _b = 0, targets_3 = targets; _b < targets_3.length; _b++) { - var t = targets_3[_b]; + for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { + var t = targets_4[_b]; if (getInferenceInfoForType(t)) { inferFromTypes(source, t); } @@ -46177,7 +46925,7 @@ var ts; var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { if (ts.contains(symbolStack, symbol)) { - inferenceIncomplete = true; + inferencePriority = -1 /* Circularity */; return; } (symbolStack || (symbolStack = [])).push(symbol); @@ -46261,7 +47009,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 === 157 /* MethodDeclaration */ || kind === 156 /* MethodSignature */ || kind === 158 /* Constructor */; + bivariant = bivariant || kind === 158 /* MethodDeclaration */ || kind === 157 /* MethodSignature */ || kind === 159 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -46287,46 +47035,12 @@ var ts; } } } - function isMatchableType(type) { - // We exclude non-anonymous object types because some frameworks (e.g. Ember) rely on the ability to - // infer between types that don't witness their type variables. Such types would otherwise be eliminated - // because they appear identical. - return !(type.flags & 524288 /* Object */) || !!(ts.getObjectFlags(type) & 16 /* Anonymous */); - } - function typeMatchedBySomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; - if (t === type || isMatchableType(t) && isMatchableType(type) && isTypeIdenticalTo(t, type)) { - return true; - } - } - return false; - } - function findMatchedType(type, target) { - if (typeMatchedBySomeType(type, target.types)) { - return type; - } - if (type.flags & (256 /* NumberLiteral */ | 128 /* StringLiteral */) && target.flags & 1048576 /* Union */) { - var base = getBaseTypeOfLiteralType(type); - if (typeMatchedBySomeType(base, target.types)) { - return base; - } - } - return undefined; + function isTypeOrBaseIdenticalTo(s, t) { + return isTypeIdenticalTo(s, t) || !!(s.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) && isTypeIdenticalTo(getBaseTypeOfLiteralType(s), t); } - /** - * Return a new union or intersection type computed by removing a given set of types - * from a given union or intersection type. - */ - function removeTypesFromUnionOrIntersection(type, typesToRemove) { - var reducedTypes = []; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (!typeMatchedBySomeType(t, typesToRemove)) { - reducedTypes.push(t); - } - } - return reducedTypes.length ? type.flags & 1048576 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes) : undefined; + function isTypeCloselyMatchedBy(s, t) { + return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || + s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); @@ -46465,7 +47179,7 @@ var ts; case "AsyncIterator": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later; default: - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 278 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -46477,7 +47191,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), + resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), /*excludeGlobals*/ false, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; } return links.resolvedSymbol; @@ -46486,7 +47200,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 168 /* TypeQuery */ ? true : n.kind === 73 /* Identifier */ || n.kind === 149 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 169 /* TypeQuery */ ? true : n.kind === 73 /* Identifier */ || n.kind === 150 /* 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 @@ -46501,11 +47215,11 @@ var ts; return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; case 101 /* ThisKeyword */: return "0"; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 215 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -46516,24 +47230,24 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 196 /* ParenthesizedExpression */: - case 214 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: + case 215 /* NonNullExpression */: return isMatchingReference(source, target.expression); } switch (source.kind) { case 73 /* Identifier */: return target.kind === 73 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 238 /* VariableDeclaration */ || target.kind === 187 /* BindingElement */) && + (target.kind === 239 /* VariableDeclaration */ || target.kind === 188 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 101 /* ThisKeyword */: return target.kind === 101 /* ThisKeyword */; case 99 /* SuperKeyword */: return target.kind === 99 /* SuperKeyword */; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 215 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); @@ -46541,7 +47255,7 @@ var ts; return false; } function getAccessedPropertyName(access) { - return access.kind === 190 /* PropertyAccessExpression */ ? access.name.escapedText : + return access.kind === 191 /* PropertyAccessExpression */ ? access.name.escapedText : ts.isStringLiteral(access.argumentExpression) || ts.isNumericLiteral(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } @@ -46625,7 +47339,7 @@ var ts; } } } - if (callExpression.expression.kind === 190 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 191 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -46674,8 +47388,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; result |= getTypeFacts(t); } return result; @@ -46780,15 +47494,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 188 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 189 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 277 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 205 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 228 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 206 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 229 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -46805,21 +47519,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return stringType; - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return undefinedType; - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -46827,7 +47541,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 185 /* ObjectBindingPattern */ ? + var type = pattern.kind === 186 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -46845,35 +47559,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 227 /* ForInStatement */) { + if (node.parent.parent.kind === 228 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.parent.kind === 229 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 238 /* VariableDeclaration */ ? + return node.kind === 239 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */ ? + return getConstraintForLocation(node.kind === 239 /* VariableDeclaration */ || node.kind === 188 /* BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } function isEmptyArrayAssignment(node) { - return node.kind === 238 /* VariableDeclaration */ && node.initializer && + return node.kind === 239 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 187 /* BindingElement */ && node.parent.kind === 205 /* BinaryExpression */ && + node.kind !== 188 /* BindingElement */ && node.parent.kind === 206 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: switch (node.operatorToken.kind) { case 60 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -46885,13 +47599,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 196 /* ParenthesizedExpression */ || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */ && parent.left === node || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 197 /* ParenthesizedExpression */ || + parent.kind === 206 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */ && parent.left === node || + parent.kind === 206 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 273 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -46913,7 +47627,7 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 273 /* CaseClause */) { if (clause.expression.kind === 10 /* StringLiteral */) { witnesses.push(clause.expression.text); continue; @@ -46997,8 +47711,7 @@ var ts; return mapType(typeWithPrimitives, function (t) { return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */) : t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : - t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : - t; + t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -47050,8 +47763,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -47074,11 +47787,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 190 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 192 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 191 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 191 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 193 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 192 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 205 /* BinaryExpression */ && + parent.parent.kind === 206 /* BinaryExpression */ && parent.parent.operatorToken.kind === 60 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -47116,7 +47829,7 @@ var ts; if (flowAnalysisDisabled) { return errorType; } - if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943 /* Narrowable */)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 268188671 /* Narrowable */)) { return declaredType; } var sharedFlowStart = sharedFlowCount; @@ -47127,7 +47840,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 (reference.parent && reference.parent.kind === 214 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (reference.parent && reference.parent.kind === 215 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -47224,8 +47937,8 @@ var ts; // Check if we should continue with the control flow of the containing function. var container = flow.container; if (container && container !== flowContainer && - reference.kind !== 190 /* PropertyAccessExpression */ && - reference.kind !== 191 /* ElementAccessExpression */ && + reference.kind !== 191 /* PropertyAccessExpression */ && + reference.kind !== 192 /* ElementAccessExpression */ && reference.kind !== 101 /* ThisKeyword */) { flow = container.flowNode; continue; @@ -47278,14 +47991,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 === 197 /* FunctionExpression */ || init.kind === 198 /* ArrowFunction */)) { + if (init && (init.kind === 198 /* FunctionExpression */ || init.kind === 199 /* 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 === 227 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 228 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference @@ -47294,7 +48007,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 192 /* CallExpression */ ? + var expr = node.kind === 193 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -47302,7 +48015,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 193 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -47355,7 +48068,7 @@ var ts; else if (isMatchingReferenceDiscriminant(expr, type)) { type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); } - else if (expr.kind === 200 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 201 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else if (containsMatchingReferenceDiscriminant(reference, expr)) { @@ -47530,10 +48243,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 201 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 201 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -47611,7 +48324,7 @@ var ts; return type; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { - // We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands + // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { // For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the @@ -47893,16 +48606,16 @@ var ts; case 73 /* Identifier */: case 101 /* ThisKeyword */: case 99 /* SuperKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: if (expr.operator === 52 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -47938,9 +48651,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 246 /* ModuleBlock */ || - node.kind === 285 /* SourceFile */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 247 /* ModuleBlock */ || + node.kind === 286 /* SourceFile */ || + node.kind === 156 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -47962,7 +48675,7 @@ var ts; if (node.kind === 73 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 152 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 153 /* Parameter */) { symbol.isAssigned = true; } } @@ -47977,7 +48690,7 @@ var ts; /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 152 /* Parameter */ && + declaration.kind === 153 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -47985,10 +48698,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 190 /* PropertyAccessExpression */ || - parent.kind === 192 /* CallExpression */ && parent.expression === node || - parent.kind === 191 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 187 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 191 /* PropertyAccessExpression */ || + parent.kind === 193 /* CallExpression */ && parent.expression === node || + parent.kind === 192 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 188 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); @@ -48003,8 +48716,11 @@ var ts; } return type; } + function isExportOrExportExpression(location) { + return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); + } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 67220415 /* Value */) && !isInTypeQuery(location) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && ((compilerOptions.preserveConstEnums && isExportOrExportExpression(location)) || !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol)))) { markAliasSymbolAsReferenced(symbol); } } @@ -48022,7 +48738,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 198 /* ArrowFunction */) { + if (container.kind === 199 /* 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.hasModifier(container, 256 /* Async */)) { @@ -48043,7 +48759,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 241 /* ClassDeclaration */ + if (declaration.kind === 242 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -48055,14 +48771,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 210 /* ClassExpression */) { + else if (declaration.kind === 211 /* 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 !== 285 /* SourceFile */) { + while (container.kind !== 286 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 155 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 156 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -48111,7 +48827,7 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 152 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 153 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -48120,8 +48836,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 === 197 /* FunctionExpression */ || - flowContainer.kind === 198 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 198 /* FunctionExpression */ || + flowContainer.kind === 199 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -48129,10 +48845,10 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 258 /* ExportSpecifier */) || - node.parent.kind === 214 /* NonNullExpression */ || - declaration.kind === 238 /* VariableDeclaration */ && declaration.exclamationToken || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 259 /* ExportSpecifier */) || + node.parent.kind === 215 /* NonNullExpression */ || + declaration.kind === 239 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 4194304 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -48167,7 +48883,7 @@ var ts; if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 275 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 276 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -48190,7 +48906,7 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container) && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 240 /* VariableDeclarationList */).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -48208,8 +48924,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 226 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container && + if (container.kind === 227 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 240 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -48227,7 +48943,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 196 /* ParenthesizedExpression */) { + while (current.parent.kind === 197 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -48235,7 +48951,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 203 /* PrefixUnaryExpression */ || current.parent.kind === 204 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 204 /* PrefixUnaryExpression */ || current.parent.kind === 205 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; } @@ -48248,7 +48964,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 155 /* PropertyDeclaration */ || container.kind === 158 /* Constructor */) { + if (container.kind === 156 /* PropertyDeclaration */ || container.kind === 159 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -48316,37 +49032,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 158 /* Constructor */) { + if (container.kind === 159 /* 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 === 198 /* ArrowFunction */) { + if (container.kind === 199 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 245 /* ModuleDeclaration */: + case 246 /* 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 244 /* EnumDeclaration */: + case 245 /* 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 158 /* Constructor */: + case 159 /* 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 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: if (ts.hasModifier(container, 32 /* Static */)) { 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 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -48385,10 +49101,8 @@ var ts; if (isInJS && className) { var classSymbol = checkExpression(className).symbol; if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { - var classType = getJSClassType(classSymbol); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(classSymbol).thisType; + return getFlowTypeOfReference(node, classType); } } // Check if it's a constructor definition, can be either a variable decl or function decl @@ -48396,12 +49110,10 @@ var ts; // * /** @constructor */ function [name]() { ... } // * /** @constructor */ var x = function() { ... } else if (isInJS && - (container.kind === 197 /* FunctionExpression */ || container.kind === 240 /* FunctionDeclaration */) && + (container.kind === 198 /* FunctionExpression */ || container.kind === 241 /* FunctionDeclaration */) && ts.getJSDocClassTag(container)) { - var classType = getJSClassType(getMergedSymbol(container.symbol)); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType; + return getFlowTypeOfReference(node, classType); } var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { @@ -48432,7 +49144,7 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 197 /* FunctionExpression */ && + if (container.kind === 198 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -48442,16 +49154,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 157 /* MethodDeclaration */ && - container.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 158 /* MethodDeclaration */ && + container.parent.kind === 190 /* 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 === 197 /* FunctionExpression */ && - container.parent.kind === 276 /* PropertyAssignment */ && - container.parent.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 198 /* FunctionExpression */ && + container.parent.kind === 277 /* PropertyAssignment */ && + container.parent.parent.kind === 190 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -48459,7 +49171,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 === 197 /* FunctionExpression */ && + else if (container.kind === 198 /* 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") && @@ -48484,7 +49196,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 295 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 296 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -48498,15 +49210,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 152 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 153 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 192 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 193 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); 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 === 198 /* ArrowFunction */) { + while (container && container.kind === 199 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -48519,14 +49231,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 150 /* ComputedPropertyName */; }); - if (current && current.kind === 150 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 151 /* ComputedPropertyName */; }); + if (current && current.kind === 151 /* 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 === 189 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 190 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -48534,7 +49246,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 158 /* Constructor */) { + if (!isCallExpression && container.kind === 159 /* 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.hasModifier(container, 32 /* Static */) || isCallExpression) { @@ -48603,7 +49315,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 === 157 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 158 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -48617,7 +49329,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 189 /* ObjectLiteralExpression */) { + if (container.parent.kind === 190 /* 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; @@ -48638,7 +49350,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 158 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 159 /* 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; @@ -48653,7 +49365,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 === 158 /* Constructor */; + return container.kind === 159 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -48661,21 +49373,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 === 189 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 190 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */; + return container.kind === 158 /* MethodDeclaration */ || + container.kind === 157 /* MethodSignature */ || + container.kind === 160 /* GetAccessor */ || + container.kind === 161 /* SetAccessor */; } else { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */ || - container.kind === 155 /* PropertyDeclaration */ || - container.kind === 154 /* PropertySignature */ || - container.kind === 158 /* Constructor */; + return container.kind === 158 /* MethodDeclaration */ || + container.kind === 157 /* MethodSignature */ || + container.kind === 160 /* GetAccessor */ || + container.kind === 161 /* SetAccessor */ || + container.kind === 156 /* PropertyDeclaration */ || + container.kind === 155 /* PropertySignature */ || + container.kind === 159 /* Constructor */; } } } @@ -48683,10 +49395,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 157 /* MethodDeclaration */ || - func.kind === 159 /* GetAccessor */ || - func.kind === 160 /* SetAccessor */) && func.parent.kind === 189 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 197 /* FunctionExpression */ && func.parent.kind === 276 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 158 /* MethodDeclaration */ || + func.kind === 160 /* GetAccessor */ || + func.kind === 161 /* SetAccessor */) && func.parent.kind === 190 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 198 /* FunctionExpression */ && func.parent.kind === 277 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -48698,7 +49410,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 199 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -48725,7 +49437,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 276 /* PropertyAssignment */) { + if (literal.parent.kind !== 277 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -48739,9 +49451,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent.kind === 206 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */) { var target = parent.left; - if (target.kind === 190 /* PropertyAccessExpression */ || target.kind === 191 /* ElementAccessExpression */) { + if (target.kind === 191 /* PropertyAccessExpression */ || target.kind === 192 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -48805,9 +49517,9 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 152 /* Parameter */: + case 153 /* Parameter */: return getContextuallyTypedParameterType(declaration, /*forCache*/ false); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return getContextualTypeForBindingElement(declaration); // By default, do nothing and return undefined - only parameters and binding elements have context implied by a parent } @@ -48897,6 +49609,15 @@ var ts; } return false; } + function getContextualIterationType(kind, functionDecl) { + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */); + var contextualReturnType = getContextualReturnType(functionDecl); + if (contextualReturnType) { + return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) + || undefined; + } + return undefined; + } function getContextualReturnType(functionDecl) { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed @@ -48928,7 +49649,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 194 /* TaggedTemplateExpression */) { + if (template.parent.kind === 195 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -48990,7 +49711,7 @@ var ts; } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 67220415 /* Value */, undefined, id.escapedText, /*isUse*/ true); + var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated) { @@ -49041,7 +49762,7 @@ var ts; return substituteIndexedMappedType(t, propertyNameType); } } - else if (t.flags & 3670016 /* StructuredType */) { + else if (t.flags & 137887744 /* StructuredType */) { var prop = getPropertyOfType(t, name); if (prop) { return getTypeOfSymbol(prop); @@ -49161,26 +49882,29 @@ var ts; case 73 /* Identifier */: case 142 /* UndefinedKeyword */: return true; - case 190 /* PropertyAccessExpression */: - case 196 /* ParenthesizedExpression */: + case 191 /* PropertyAccessExpression */: + case 197 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 271 /* JsxExpression */: + case 272 /* 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 === 276 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 277 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 268 /* 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.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 269 /* 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 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. function getApparentTypeOfContextualType(node, contextFlags) { - var contextualType = instantiateContextualType(getContextualType(node, contextFlags), node, contextFlags); - if (contextualType) { - var apparentType = mapType(contextualType, getApparentType, /*noReductions*/ true); + var contextualType = ts.isObjectLiteralMethod(node) ? + getContextualTypeForObjectLiteralMethod(node, contextFlags) : + getContextualType(node, contextFlags); + var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); + if (instantiatedType) { + var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); if (apparentType.flags & 1048576 /* Union */) { if (ts.isObjectLiteralExpression(node)) { return discriminateContextualTypeByObjectMembers(node, apparentType); @@ -49218,7 +49942,7 @@ var ts; // are classified as instantiable (i.e. it doesn't instantiate object types), and (b) it performs // no reductions on instantiated union types. function instantiateInstantiableTypes(type, mapper) { - if (type.flags & 63176704 /* Instantiable */) { + if (type.flags & (63176704 /* Instantiable */ | 134217728 /* StructuralTag */)) { return instantiateType(type, mapper); } if (type.flags & 1048576 /* Union */) { @@ -49256,58 +49980,58 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 187 /* BindingElement */: + case 239 /* VariableDeclaration */: + case 153 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 188 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 198 /* ArrowFunction */: - case 231 /* ReturnStatement */: + case 199 /* ArrowFunction */: + case 232 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent); - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (parent.expression.kind === 93 /* ImportKeyword */) { return stringType; } /* falls through */ - case 193 /* NewExpression */: + case 194 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 188 /* ArrayLiteralExpression */: { + case 189 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 217 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 207 /* TemplateExpression */); + case 218 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 208 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 196 /* ParenthesizedExpression */: { + case 197 /* 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 271 /* JsxExpression */: + case 272 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: + case 269 /* JsxAttribute */: + case 271 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -49462,7 +50186,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 197 /* FunctionExpression */ || node.kind === 198 /* ArrowFunction */; + return node.kind === 198 /* FunctionExpression */ || node.kind === 199 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -49476,14 +50200,12 @@ 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 !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = ts.isObjectLiteralMethod(node) ? - getContextualTypeForObjectLiteralMethod(node, 1 /* Signature */) : - getApparentTypeOfContextualType(node, 1 /* Signature */); + var type = getApparentTypeOfContextualType(node, 1 /* Signature */); if (!type) { return undefined; } @@ -49492,8 +50214,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var current = types_13[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -49523,8 +50245,8 @@ var ts; return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); } function hasDefaultValue(node) { - return (node.kind === 187 /* BindingElement */ && !!node.initializer) || - (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */); + return (node.kind === 188 /* BindingElement */ && !!node.initializer) || + (node.kind === 206 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -49536,7 +50258,7 @@ var ts; var inConstContext = isConstContext(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 209 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 210 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -49561,12 +50283,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 209 /* SpreadElement */) { + if (index < elementCount - 1 && e.kind === 210 /* SpreadElement */) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 209 /* SpreadElement */; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 210 /* SpreadElement */; var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". @@ -49608,7 +50330,7 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return isNumericComputedName(name); case 73 /* Identifier */: return isNumericLiteralName(name.escapedText); @@ -49698,7 +50420,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 185 /* ObjectBindingPattern */ || contextualType.pattern.kind === 189 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 186 /* ObjectBindingPattern */ || contextualType.pattern.kind === 190 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -49713,13 +50435,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 150 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 151 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 276 /* PropertyAssignment */ || - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 277 /* PropertyAssignment */ || + memberDecl.kind === 278 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 276 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 277 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 278 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -49742,8 +50464,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 === 276 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 277 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 277 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 278 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -49768,7 +50490,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 278 /* SpreadAssignment */) { + else if (memberDecl.kind === 279 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -49794,7 +50516,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 === 159 /* GetAccessor */ || memberDecl.kind === 160 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 160 /* GetAccessor */ || memberDecl.kind === 161 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -49854,7 +50576,13 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (3 /* AnyOrUnknown */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || + if (type.flags & 63176704 /* Instantiable */) { + var constraint = getBaseConstraintOfType(type); + if (constraint !== undefined) { + return isValidSpreadType(constraint); + } + } + return !!(type.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 134217728 /* StructuralTag */ | 58982400 /* InstantiableNonPrimitive */) || getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } @@ -49947,7 +50675,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 270 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 271 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -49970,7 +50698,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 261 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 262 /* 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); @@ -50044,7 +50772,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 67897832 /* Type */); + var typeSymbol = exports && getSymbol(exports, name, 788968 /* Type */); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** @@ -50118,7 +50846,7 @@ var ts; */ function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 67897832 /* Type */); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* Type */); // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute @@ -50142,7 +50870,7 @@ var ts; } function getJsxLibraryManagedAttributes(jsxNamespace) { // JSX.LibraryManagedAttributes [symbol] - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67897832 /* Type */); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* Type */); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -50294,13 +51022,13 @@ var ts; var reactRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var reactNamespace = getJsxNamespace(node); var reactLocation = isNodeOpeningLikeElement ? node.tagName : node; - var reactSym = resolveName(reactLocation, reactNamespace, 67220415 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); + var reactSym = resolveName(reactLocation, reactNamespace, 111551 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); if (reactSym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not react as there wont be error being emitted reactSym.isReferenced = 67108863 /* All */; - // If react symbol is alias, mark it as referenced - if (reactSym.flags & 2097152 /* Alias */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { + // If react symbol is alias, mark it as refereced + if (reactSym.flags & 2097152 /* Alias */) { markAliasSymbolAsReferenced(reactSym); } } @@ -50389,7 +51117,7 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 149 /* QualifiedName */ ? node.right : node.kind === 184 /* ImportType */ ? node : node.name; + var errorNode = node.kind === 150 /* QualifiedName */ ? node.right : node.kind === 185 /* ImportType */ ? node : node.name; if (ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */) { // Synthetic property with private constituent property error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); @@ -50524,7 +51252,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } function isMethodAccessForCall(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */) { + while (node.parent.kind === 197 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -50590,7 +51318,7 @@ var ts; // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (node.kind !== 191 /* ElementAccessExpression */ && node.kind !== 190 /* PropertyAccessExpression */ || + if (node.kind !== 192 /* ElementAccessExpression */ && node.kind !== 191 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; @@ -50604,7 +51332,7 @@ var ts; var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 158 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 159 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -50625,7 +51353,7 @@ var ts; } function checkPropertyNotUsedBeforeDeclaration(prop, node, right) { var valueDeclaration = prop.valueDeclaration; - if (!valueDeclaration) { + if (!valueDeclaration || ts.getSourceFileOfNode(node).isDeclarationFile) { return; } var diagnosticMessage; @@ -50635,8 +51363,8 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 241 /* ClassDeclaration */ && - node.parent.kind !== 165 /* TypeReference */ && + else if (valueDeclaration.kind === 242 /* ClassDeclaration */ && + node.parent.kind !== 166 /* TypeReference */ && !(valueDeclaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -50648,22 +51376,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return true; - case 276 /* PropertyAssignment */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 278 /* SpreadAssignment */: - case 150 /* ComputedPropertyName */: - case 217 /* TemplateSpan */: - case 271 /* JsxExpression */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 263 /* JsxOpeningElement */: - case 212 /* ExpressionWithTypeArguments */: - case 274 /* HeritageClause */: + case 277 /* PropertyAssignment */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 279 /* SpreadAssignment */: + case 151 /* ComputedPropertyName */: + case 218 /* TemplateSpan */: + case 272 /* JsxExpression */: + case 269 /* JsxAttribute */: + case 270 /* JsxAttributes */: + case 271 /* JsxSpreadAttribute */: + case 264 /* JsxOpeningElement */: + case 213 /* ExpressionWithTypeArguments */: + case 275 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -50703,7 +51431,7 @@ var ts; if (containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; - if (!getPropertyOfType(subtype, propNode.escapedText)) { + if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0 /* String */)) { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); break; } @@ -50741,7 +51469,7 @@ var ts; return prop !== undefined && prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 32 /* Static */); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { - return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67220415 /* Value */); + return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551 /* Value */); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -50836,16 +51564,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return isValidPropertyAccessWithType(node, node.expression.kind === 99 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 184 /* ImportType */: + case 185 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 190 /* PropertyAccessExpression */ && node.expression.kind === 99 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 191 /* PropertyAccessExpression */ && node.expression.kind === 99 /* 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) { @@ -50862,7 +51590,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer.kind === 240 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -50891,7 +51619,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 227 /* ForInStatement */ && + if (node.kind === 228 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -50908,20 +51636,6 @@ var ts; var exprType = checkNonNullExpression(node.expression); var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; - if (!indexExpression) { - var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 193 /* NewExpression */ && node.parent.expression === node) { - var start = ts.skipTrivia(sourceFile.text, node.expression.end); - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - return errorType; - } var indexType = checkExpression(indexExpression); if (objectType === errorType || objectType === silentNeverType) { return objectType; @@ -50981,13 +51695,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 195 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 153 /* Decorator */) { + else if (node.kind !== 154 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -51051,7 +51765,7 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 209 /* SpreadElement */ || arg.kind === 216 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 210 /* SpreadElement */ || arg.kind === 217 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -51065,9 +51779,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 === 194 /* TaggedTemplateExpression */) { + if (node.kind === 195 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 207 /* TemplateExpression */) { + if (node.template.kind === 208 /* 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. @@ -51082,7 +51796,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 153 /* Decorator */) { + else if (node.kind === 154 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -51097,7 +51811,7 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 193 /* NewExpression */); + ts.Debug.assert(node.kind === 194 /* NewExpression */); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -51190,7 +51904,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 !== 153 /* Decorator */) { + if (node.kind !== 154 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -51233,7 +51947,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 !== 211 /* OmittedExpression */) { + if (arg.kind !== 212 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -51257,7 +51971,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 arg.kind === 216 /* SyntheticExpression */ ? + return arg.kind === 217 /* SyntheticExpression */ ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0 /* Normal */)); } @@ -51332,12 +52046,12 @@ var ts; if (ts.isJsxOpeningLikeElement(node)) { if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 193 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 194 /* 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. @@ -51347,7 +52061,7 @@ var ts; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; @@ -51355,7 +52069,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 !== 211 /* OmittedExpression */) { + if (arg.kind !== 212 /* 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), @@ -51365,7 +52079,7 @@ var ts; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } } @@ -51375,7 +52089,7 @@ var ts; if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, /*containingMessageChain*/ undefined, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(errorNode, spreadType, restType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } return undefined; @@ -51396,15 +52110,15 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 193 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 190 /* PropertyAccessExpression */ || callee.kind === 191 /* ElementAccessExpression */) { + if (callee.kind === 191 /* PropertyAccessExpression */ || callee.kind === 192 /* ElementAccessExpression */) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(216 /* SyntheticExpression */, parent.pos, parent.end); + var result = ts.createNode(217 /* SyntheticExpression */, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; @@ -51414,17 +52128,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 195 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 207 /* TemplateExpression */) { + if (template.kind === 208 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 153 /* Decorator */) { + if (node.kind === 154 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -51454,30 +52168,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* 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 152 /* Parameter */: + case 153 /* 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 === 158 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 159 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* 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 !== 155 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 156 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -51491,17 +52205,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return 1; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return 2; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* 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 152 /* Parameter */: + case 153 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -51626,8 +52340,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, fallbackError) { - var isTaggedTemplate = node.kind === 194 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 153 /* Decorator */; + var isTaggedTemplate = node.kind === 195 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 154 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; @@ -51689,7 +52403,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 === 192 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 193 /* 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 @@ -52225,8 +52939,8 @@ var ts; if (apparentType.flags & 1048576 /* Union */) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var constituent = types_15[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var constituent = types_14[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -52324,16 +53038,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 152 /* Parameter */: + case 153 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -52377,8 +53091,8 @@ var ts; var exports = namespace && getExportsOfSymbol(namespace); // We fake up a SFC signature for each intrinsic, however a more specific per-element signature drawn from the JSX declaration // file would probably be preferable. - var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 67897832 /* Type */); - var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 67897832 /* Type */, node); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node); var declaration = ts.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.createKeywordTypeNode(121 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; @@ -52426,16 +53140,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 192 /* CallExpression */: + case 193 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 153 /* Decorator */: + case 154 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -52486,43 +53200,45 @@ var ts; return true; // If the symbol of the node has members, treat it like a constructor. var symbol = getSymbolOfNode(func); - return !!symbol && (symbol.members !== undefined || symbol.exports !== undefined && symbol.exports.get("prototype") !== undefined); + return !!symbol && ts.hasEntries(symbol.members); } return false; } - function isJSConstructorType(type) { - if (type.flags & 524288 /* Object */) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); - } - return false; - } - function getJSClassType(symbol) { - var inferred; - if (isJSConstructor(symbol.valueDeclaration)) { - inferred = getInferredClassType(symbol); + function mergeJSSymbols(target, source) { + if (source && (ts.hasEntries(source.exports) || ts.hasEntries(source.members))) { + var links = getSymbolLinks(source); + if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) { + var inferred = isTransientSymbol(target) ? target : cloneSymbol(target); + inferred.exports = inferred.exports || ts.createSymbolTable(); + inferred.members = inferred.members || ts.createSymbolTable(); + inferred.flags |= source.flags & 32 /* Class */; + if (ts.hasEntries(source.exports)) { + mergeSymbolTable(inferred.exports, source.exports); + } + if (ts.hasEntries(source.members)) { + mergeSymbolTable(inferred.members, source.members); + } + (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred); + return inferred; + } + return links.inferredClassSymbol.get("" + getSymbolId(target)); } - var assigned = getAssignedClassType(symbol); - return assigned && inferred ? - getIntersectionType([inferred, assigned]) : - assigned || inferred; } - function getAssignedClassType(symbol) { - var decl = symbol.valueDeclaration; + function getAssignedClassSymbol(decl) { var assignmentSymbol = decl && decl.parent && (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype"); var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration); - return init ? getWidenedType(checkExpressionCached(init)) : undefined; + return init ? getSymbolOfNode(init) : undefined; } function getAssignedJSPrototype(node) { if (!node.parent) { return false; } var parent = node.parent; - while (parent && parent.kind === 190 /* PropertyAccessExpression */) { + while (parent && parent.kind === 191 /* PropertyAccessExpression */) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 60 /* EqualsToken */) { @@ -52530,13 +53246,6 @@ var ts; return ts.isObjectLiteralExpression(right) && right; } } - function getInferredClassType(symbol) { - var links = getSymbolLinks(symbol); - if (!links.inferredClassType) { - links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol) || emptySymbols, ts.emptyArray, ts.emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined); - } - return links.inferredClassType; - } /** * Syntactically and semantically checks a call or new expression. * @param node The call/new expression to be checked. @@ -52554,12 +53263,12 @@ var ts; if (node.expression.kind === 99 /* SuperKeyword */) { return voidType; } - if (node.kind === 193 /* NewExpression */) { + if (node.kind === 194 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 158 /* Constructor */ && - declaration.kind !== 162 /* ConstructSignature */ && - declaration.kind !== 167 /* ConstructorType */ && + declaration.kind !== 159 /* Constructor */ && + declaration.kind !== 163 /* ConstructSignature */ && + declaration.kind !== 168 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -52607,7 +53316,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } function checkImportCallExpression(node) { // Check grammar of dynamic import @@ -52667,7 +53376,7 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } @@ -52676,9 +53385,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 240 /* FunctionDeclaration */ + ? 241 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 238 /* VariableDeclaration */ + ? 239 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -52705,18 +53414,18 @@ var ts; case 9 /* BigIntLiteral */: case 103 /* TrueKeyword */: case 88 /* FalseKeyword */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return true; - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; return op === 39 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || op === 38 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -52766,7 +53475,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 === 158 /* Constructor */) { + else if (container.kind === 159 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -52776,8 +53485,8 @@ var ts; } } function checkImportMetaProperty(node) { - if (languageVersion < 99 /* ESNext */ || moduleKind < ts.ModuleKind.ESNext) { - error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options); + if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) { + error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system); } var file = ts.getSourceFileOfNode(node); ts.Debug.assert(!!(file.flags & 1048576 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); @@ -52967,7 +53676,7 @@ var ts; links.type = contextualType; var decl = parameter.valueDeclaration; if (decl.name.kind !== 73 /* Identifier */) { - // if inference didn't come up with anything but {}, fall back to the binding pattern if present. + // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(decl.name); } @@ -53021,7 +53730,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 219 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 220 /* 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 @@ -53093,7 +53802,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* Next */, func) || unknownType, isAsync); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -53207,14 +53916,14 @@ var ts; if (!node.possiblyExhaustive) { return false; } - if (node.expression.kind === 200 /* TypeOfExpression */) { + if (node.expression.kind === 201 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); // This cast is safe because the switch is possibly exhaustive and does not contain a default case, so there can be no undefined. var witnesses = getSwitchClauseTypeOfWitnesses(node); // notEqualFacts states that the type of the switched value is not equal to every type in the switch. var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true); - var type_5 = getBaseConstraintOfType(operandType) || operandType; - return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); + var type_4 = getBaseConstraintOfType(operandType) || operandType; + return !!(filterType(type_4, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -53230,7 +53939,7 @@ var ts; if (!(func.flags & 128 /* HasImplicitReturn */)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 233 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 234 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -53273,11 +53982,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return true; - case 157 /* MethodDeclaration */: - return func.parent.kind === 189 /* ObjectLiteralExpression */; + case 158 /* MethodDeclaration */: + return func.parent.kind === 190 /* ObjectLiteralExpression */; default: return false; } @@ -53303,7 +54012,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 156 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 219 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 157 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 220 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -53336,7 +54045,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 /* 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)) { @@ -53356,7 +54065,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 197 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 198 /* FunctionExpression */) { checkGrammarForGenerator(node); } var type = getTypeOfSymbol(getMergedSymbol(node.symbol)); @@ -53410,7 +54119,7 @@ var ts; type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 158 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -53423,7 +54132,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 219 /* Block */) { + if (node.body.kind === 220 /* Block */) { checkSourceElement(node.body); } else { @@ -53504,11 +54213,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) && + (expr.kind === 191 /* PropertyAccessExpression */ || expr.kind === 192 /* ElementAccessExpression */) && expr.expression.kind === 101 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 158 /* Constructor */)) { + if (!(func && func.kind === 159 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -53521,13 +54230,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) { + if (expr.kind === 191 /* PropertyAccessExpression */ || expr.kind === 192 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); if (node.kind === 73 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 252 /* NamespaceImport */; + return !!declaration && declaration.kind === 253 /* NamespaceImport */; } } } @@ -53536,7 +54245,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 73 /* Identifier */ && node.kind !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 73 /* Identifier */ && node.kind !== 191 /* PropertyAccessExpression */ && node.kind !== 192 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -53545,7 +54254,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 190 /* PropertyAccessExpression */ && expr.kind !== 191 /* ElementAccessExpression */) { + if (expr.kind !== 191 /* PropertyAccessExpression */ && expr.kind !== 192 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -53574,7 +54283,7 @@ var ts; var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); var func = ts.getContainingFunction(node); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 159 /* 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); @@ -53587,7 +54296,11 @@ var ts; } } var operandType = checkExpression(node.expression); - return checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + var awaitedType = checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + if (awaitedType === operandType && awaitedType !== errorType && !(operandType.flags & 3 /* AnyOrUnknown */)) { + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); + } + return awaitedType; } function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); @@ -53621,7 +54334,7 @@ var ts; } if (node.operator === 38 /* PlusToken */) { if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { - error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(operandType)); + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } @@ -53672,8 +54385,8 @@ var ts; } if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -53762,7 +54475,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 276 /* PropertyAssignment */ || property.kind === 277 /* ShorthandPropertyAssignment */) { + if (property.kind === 277 /* PropertyAssignment */ || property.kind === 278 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -53775,9 +54488,9 @@ var ts; } var elementType = getIndexedAccessType(objectLiteralType, exprType, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 277 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 278 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 278 /* SpreadAssignment */) { + else if (property.kind === 279 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -53820,8 +54533,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 211 /* OmittedExpression */) { - if (element.kind !== 209 /* SpreadElement */) { + if (element.kind !== 212 /* OmittedExpression */) { + if (element.kind !== 210 /* SpreadElement */) { var indexType = getLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused @@ -53839,7 +54552,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 205 /* BinaryExpression */ && restExpression.operatorToken.kind === 60 /* EqualsToken */) { + if (restExpression.kind === 206 /* BinaryExpression */ && restExpression.operatorToken.kind === 60 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -53855,7 +54568,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 277 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 278 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -53871,21 +54584,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 205 /* BinaryExpression */ && target.operatorToken.kind === 60 /* EqualsToken */) { + if (target.kind === 206 /* BinaryExpression */ && target.operatorToken.kind === 60 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 189 /* ObjectLiteralExpression */) { + if (target.kind === 190 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 188 /* ArrayLiteralExpression */) { + if (target.kind === 189 /* 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 === 278 /* SpreadAssignment */ ? + var error = target.parent.kind === 279 /* 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; if (checkReferenceExpression(target, error)) { @@ -53907,8 +54620,8 @@ var ts; case 73 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 194 /* TaggedTemplateExpression */: - case 207 /* TemplateExpression */: + case 195 /* TaggedTemplateExpression */: + case 208 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: @@ -53916,27 +54629,27 @@ var ts; case 88 /* FalseKeyword */: case 97 /* NullKeyword */: case 142 /* UndefinedKeyword */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 200 /* TypeOfExpression */: - case 214 /* NonNullExpression */: - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: + case 198 /* FunctionExpression */: + case 211 /* ClassExpression */: + case 199 /* ArrowFunction */: + case 189 /* ArrayLiteralExpression */: + case 190 /* ObjectLiteralExpression */: + case 201 /* TypeOfExpression */: + case 215 /* NonNullExpression */: + case 263 /* JsxSelfClosingElement */: + case 262 /* JsxElement */: return true; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -53948,9 +54661,9 @@ var ts; } return false; // Some forms listed here for clarity - case 201 /* VoidExpression */: // Explicit opt-out - case 195 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 213 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 202 /* VoidExpression */: // Explicit opt-out + case 196 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 214 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -53966,7 +54679,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 60 /* EqualsToken */ && (left.kind === 189 /* ObjectLiteralExpression */ || left.kind === 188 /* ArrayLiteralExpression */)) { + if (operator === 60 /* EqualsToken */ && (left.kind === 190 /* ObjectLiteralExpression */ || left.kind === 189 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 101 /* ThisKeyword */); } var leftType; @@ -54026,7 +54739,7 @@ var ts; resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */)) { + else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { case 48 /* GreaterThanGreaterThanGreaterThanToken */: case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: @@ -54036,7 +54749,7 @@ var ts; } // Exactly one of leftType/rightType is assignable to bigint else { - reportOperatorError(function (awaitedLeft, awaitedRight) { return isTypeAssignableToKind(awaitedLeft, 2112 /* BigIntLike */) && isTypeAssignableToKind(awaitedRight, 2112 /* BigIntLike */); }); + reportOperatorError(bothAreBigIntLike); resultType_1 = errorType; } if (leftOk && rightOk) { @@ -54082,9 +54795,9 @@ var ts; // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 3 /* AnyOrUnknown */; - reportOperatorError(function (awaitedLeft, awaitedRight) { - return isTypeAssignableToKind(awaitedLeft, closeEnoughKind_1) && - isTypeAssignableToKind(awaitedRight, closeEnoughKind_1); + reportOperatorError(function (left, right) { + return isTypeAssignableToKind(left, closeEnoughKind_1) && + isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } @@ -54149,6 +54862,9 @@ var ts; default: return ts.Debug.fail(); } + function bothAreBigIntLike(left, right) { + return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + } function checkAssignmentDeclaration(kind, rightType) { if (kind === 2 /* ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { @@ -54156,7 +54872,7 @@ var ts; var propType = getTypeOfSymbol(prop); if (propType.symbol && propType.symbol.flags & 32 /* Class */) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 67897832 /* Type */, undefined, name, /*isUse*/ false); + var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) { grammarErrorOnNode(symbol.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); return grammarErrorOnNode(prop.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); @@ -54236,17 +54952,23 @@ var ts; } return false; } - function reportOperatorError(awaitedTypesAreCompatible) { + function reportOperatorError(isRelated) { + var _a; var wouldWorkWithAwait = false; var errNode = errorNode || operatorToken; - var _a = getTypeNamesForErrorDisplay(leftType, rightType), leftStr = _a[0], rightStr = _a[1]; - if (awaitedTypesAreCompatible) { + if (isRelated) { var awaitedLeftType = getAwaitedType(leftType); var awaitedRightType = getAwaitedType(rightType); wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType) && !!(awaitedLeftType && awaitedRightType) - && awaitedTypesAreCompatible(awaitedLeftType, awaitedRightType); + && isRelated(awaitedLeftType, awaitedRightType); + } + var effectiveLeft = leftType; + var effectiveRight = rightType; + if (!wouldWorkWithAwait && isRelated) { + _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1]; } + var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1]; if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) { errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); } @@ -54268,6 +54990,17 @@ var ts; return undefined; } } + function getBaseTypesIfUnrelated(leftType, rightType, isRelated) { + var effectiveLeft = leftType; + var effectiveRight = rightType; + var leftBase = getBaseTypeOfLiteralType(leftType); + var rightBase = getBaseTypeOfLiteralType(rightType); + if (!isRelated(leftBase, rightBase)) { + effectiveLeft = leftBase; + effectiveRight = rightBase; + } + return [effectiveLeft, effectiveRight]; + } function isYieldExpressionInClass(node) { var current = node; var parent = node.parent; @@ -54335,12 +55068,7 @@ var ts; return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync) || anyType; } - var contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, contextualReturnType, isAsync) - || anyType; - } - return anyType; + return getContextualIterationType(2 /* Next */, func) || anyType; } function checkConditionalExpression(node, checkMode) { checkTruthinessExpression(node.condition); @@ -54362,7 +55090,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 269 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 270 /* 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; @@ -54401,12 +55129,12 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 195 /* TypeAssertionExpression */ || node.kind === 213 /* AsExpression */; + return node.kind === 196 /* TypeAssertionExpression */ || node.kind === 214 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, /*cache*/ true); - var padded = ts.isParameter(declaration) && declaration.name.kind === 186 /* ArrayBindingPattern */ && + var padded = ts.isParameter(declaration) && declaration.name.kind === 187 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || @@ -54431,7 +55159,7 @@ var ts; var elementTypes = arity ? type.typeArguments.slice() : []; for (var i = arity; i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 187 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 188 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); @@ -54483,7 +55211,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -54494,7 +55222,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -54637,7 +55365,7 @@ var ts; var expr = ts.skipParentheses(node); // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (expr.kind === 192 /* CallExpression */ && expr.expression.kind !== 99 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (expr.kind === 193 /* CallExpression */ && expr.expression.kind !== 99 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var funcType = checkNonNullExpression(expr.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -54687,10 +55415,11 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 191 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 168 /* TypeQuery */ && node.parent.exprName === node)); + var ok = (node.parent.kind === 191 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 192 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 73 /* Identifier */ || node.kind === 150 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 169 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 259 /* ExportSpecifier */ && (compilerOptions.preserveConstEnums || node.flags & 4194304 /* Ambient */)); // 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); } @@ -54710,7 +55439,18 @@ var ts; return checkExpression(node.expression, checkMode); } function checkExpressionWorker(node, checkMode, forceTuple) { - switch (node.kind) { + var kind = node.kind; + if (cancellationToken) { + // 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 211 /* ClassExpression */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + cancellationToken.throwIfCancellationRequested(); + } + } + switch (kind) { case 73 /* Identifier */: return checkIdentifier(node); case 101 /* ThisKeyword */: @@ -54732,78 +55472,78 @@ var ts; return trueType; case 88 /* FalseKeyword */: return falseType; - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return checkQualifiedName(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (node.expression.kind === 93 /* ImportKeyword */) { return checkImportCallExpression(node); } - /* falls through */ - case 193 /* NewExpression */: + // falls through + case 194 /* NewExpression */: return checkCallExpression(node, checkMode); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return checkClassExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: return checkAssertion(node); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: return checkNonNullAssertion(node); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return checkMetaProperty(node); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return checkDeleteExpression(node); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return checkVoidExpression(node); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return checkAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 211 /* OmittedExpression */: + case 212 /* OmittedExpression */: return undefinedWideningType; - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return checkYieldExpression(node); - case 216 /* SyntheticExpression */: + case 217 /* SyntheticExpression */: return node.type; - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 261 /* JsxElement */: + case 262 /* JsxElement */: return checkJsxElement(node, checkMode); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return checkJsxFragment(node); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 263 /* JsxOpeningElement */: + case 264 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -54840,7 +55580,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 158 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 159 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -54851,10 +55591,10 @@ 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 === 158 /* Constructor */ || func.kind === 162 /* ConstructSignature */ || func.kind === 167 /* ConstructorType */) { + if (func.kind === 159 /* Constructor */ || func.kind === 163 /* ConstructSignature */ || func.kind === 168 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 199 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -54910,13 +55650,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 198 /* ArrowFunction */: - case 161 /* CallSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 166 /* FunctionType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 199 /* ArrowFunction */: + case 162 /* CallSignature */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 167 /* FunctionType */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -54934,7 +55674,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 === 186 /* ArrayBindingPattern */ || name.kind === 185 /* ObjectBindingPattern */) { + else if (name.kind === 187 /* ArrayBindingPattern */ || name.kind === 186 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -54943,13 +55683,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 164 /* 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 === 166 /* FunctionType */ || node.kind === 240 /* FunctionDeclaration */ || node.kind === 167 /* ConstructorType */ || - node.kind === 161 /* CallSignature */ || node.kind === 158 /* Constructor */ || - node.kind === 162 /* ConstructSignature */) { + else if (node.kind === 167 /* FunctionType */ || node.kind === 241 /* FunctionDeclaration */ || node.kind === 168 /* ConstructorType */ || + node.kind === 162 /* CallSignature */ || node.kind === 159 /* Constructor */ || + node.kind === 163 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -54979,10 +55719,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 161 /* CallSignature */: + case 162 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -55012,28 +55752,21 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 163 /* IndexSignature */ && node.kind !== 295 /* JSDocFunctionType */) { + if (node.kind !== 164 /* IndexSignature */ && node.kind !== 296 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } } function checkClassForDuplicateDeclarations(node) { - var Declaration; - (function (Declaration) { - Declaration[Declaration["Getter"] = 1] = "Getter"; - Declaration[Declaration["Setter"] = 2] = "Setter"; - Declaration[Declaration["Method"] = 4] = "Method"; - Declaration[Declaration["Property"] = 3] = "Property"; - })(Declaration || (Declaration = {})); var instanceNames = ts.createUnderscoreEscapedMap(); var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 158 /* Constructor */) { + if (member.kind === 159 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; - if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { - addName(instanceNames, param.name, param.name.escapedText, 3 /* Property */); + if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { + addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); } } } @@ -55044,17 +55777,17 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 159 /* GetAccessor */: - addName(names, name, memberName, 1 /* Getter */); + case 160 /* GetAccessor */: + addName(names, name, memberName, 1 /* GetAccessor */); break; - case 160 /* SetAccessor */: - addName(names, name, memberName, 2 /* Setter */); + case 161 /* SetAccessor */: + addName(names, name, memberName, 2 /* SetAccessor */); break; - case 155 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* Property */); + case 156 /* PropertyDeclaration */: + addName(names, name, memberName, 3 /* GetOrSetAccessor */); break; - case 157 /* MethodDeclaration */: - addName(names, name, memberName, 4 /* Method */); + case 158 /* MethodDeclaration */: + addName(names, name, memberName, 8 /* Method */); break; } } @@ -55063,8 +55796,8 @@ var ts; function addName(names, location, name, meaning) { var prev = names.get(name); if (prev) { - if (prev & 4 /* Method */) { - if (meaning !== 4 /* Method */) { + if (prev & 8 /* Method */) { + if (meaning !== 8 /* Method */) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } } @@ -55116,7 +55849,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154 /* PropertySignature */) { + if (member.kind === 155 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -55141,7 +55874,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 243 /* 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 @@ -55196,7 +55929,7 @@ var ts; 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.hasModifier(node, 128 /* Abstract */) && node.kind === 157 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 158 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -55221,7 +55954,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 155 /* PropertyDeclaration */ && + return n.kind === 156 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -55251,7 +55984,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 223 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -55276,7 +56009,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 160 /* GetAccessor */) { if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -55286,13 +56019,13 @@ 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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(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 === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = node.kind === 160 /* GetAccessor */ ? 161 /* SetAccessor */ : 160 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -55310,7 +56043,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 160 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -55358,7 +56091,7 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 165 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 166 /* 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); } var type = getTypeFromTypeReference(node); @@ -55406,7 +56139,7 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 173 /* RestType */) { + if (e.kind === 174 /* RestType */) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; @@ -55415,7 +56148,7 @@ var ts; error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 172 /* OptionalType */) { + else if (e.kind === 173 /* OptionalType */) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -55436,7 +56169,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 191 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 192 /* 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)); } @@ -55487,7 +56220,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 176 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 177 /* 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); @@ -55504,9 +56237,9 @@ var ts; var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 242 /* InterfaceDeclaration */ && - n.parent.kind !== 241 /* ClassDeclaration */ && - n.parent.kind !== 210 /* ClassExpression */ && + if (n.parent.kind !== 243 /* InterfaceDeclaration */ && + n.parent.kind !== 242 /* ClassDeclaration */ && + n.parent.kind !== 211 /* ClassExpression */ && n.flags & 4194304 /* 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 @@ -55597,7 +56330,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */) && + var reportError = (node.kind === 158 /* MethodDeclaration */ || node.kind === 157 /* MethodSignature */) && ts.hasModifier(node, 32 /* Static */) !== ts.hasModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -55632,11 +56365,12 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; + var hasNonAmbientClass = false; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 242 /* InterfaceDeclaration */ || node.parent.kind === 169 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 243 /* InterfaceDeclaration */ || node.parent.kind === 170 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -55647,7 +56381,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 240 /* FunctionDeclaration */ || node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */ || node.kind === 158 /* Constructor */) { + if ((node.kind === 242 /* ClassDeclaration */ || node.kind === 211 /* ClassExpression */) && !inAmbientContext) { + hasNonAmbientClass = true; + } + if (node.kind === 241 /* FunctionDeclaration */ || node.kind === 158 /* MethodDeclaration */ || node.kind === 157 /* MethodSignature */ || node.kind === 159 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -55688,6 +56425,15 @@ var ts; error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Duplicate_function_implementation); }); } + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */) { + // A non-ambient class cannot be an implementation for a non-constructor function/class merge + // TODO: The below just replicates our older error from when classes and functions were + // entirely unable to merge - a more helpful message like "Class declaration cannot implement overload list" + // might be warranted. :shrug: + ts.forEach(declarations, function (declaration) { + addDuplicateDeclarationError(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), ts.filter(declarations, function (d) { return d !== declaration; })); + }); + } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && !ts.hasModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { @@ -55709,13 +56455,6 @@ var ts; } } } - var DeclarationSpaces; - (function (DeclarationSpaces) { - DeclarationSpaces[DeclarationSpaces["None"] = 0] = "None"; - DeclarationSpaces[DeclarationSpaces["ExportValue"] = 1] = "ExportValue"; - DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; - DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; - })(DeclarationSpaces || (DeclarationSpaces = {})); function checkExportsOnMergedDeclarations(node) { if (!produceDiagnostics) { return; @@ -55776,40 +56515,42 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - // A jsdoc typedef and callback are, by definition, type aliases - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + // A jsdoc typedef and callback are, by definition, type aliases. + // falls through + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: return 2 /* ExportType */; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 285 /* SourceFile */: + case 286 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; } d = d.expression; - /* falls through */ - // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + // The below options all declare an Alias, which is allowed to merge with other values within the importing module. + // falls through + case 250 /* ImportEqualsDeclaration */: + case 253 /* NamespaceImport */: + case 252 /* ImportClause */: var result_8 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_8 |= getDeclarationSpaces(d); }); return result_8; - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 240 /* FunctionDeclaration */: - case 254 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 239 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 241 /* FunctionDeclaration */: + case 255 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); @@ -55878,9 +56619,6 @@ var ts; */ function checkAwaitedType(type, errorNode, diagnosticMessage, arg0) { var awaitedType = getAwaitedType(type, errorNode, diagnosticMessage, arg0); - if (awaitedType === type && !(type.flags & 3 /* AnyOrUnknown */)) { - addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(errorNode, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); - } return awaitedType || errorType; } function getAwaitedType(type, errorNode, diagnosticMessage, arg0) { @@ -56039,7 +56777,7 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67220415 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { if (promiseConstructorName.kind === 73 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { @@ -56062,7 +56800,7 @@ var ts; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 67220415 /* Value */); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -56081,24 +56819,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 152 /* Parameter */: + case 153 /* 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 155 /* PropertyDeclaration */: + case 156 /* 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 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -56119,7 +56857,7 @@ var ts; if (!typeName) return; var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 73 /* Identifier */ ? 67897832 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 73 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -56144,23 +56882,23 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 176 /* IntersectionType */: + case 175 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return node.typeName; } } } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var typeNode = types_17[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var typeNode = types_16[_i]; + while (typeNode.kind === 179 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 133 /* NeverKeyword */) { @@ -56212,14 +56950,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 152 /* Parameter */) { + if (node.kind === 153 /* 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 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -56228,23 +56966,23 @@ var ts; } } break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - var otherKind = node.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + var otherKind = node.kind === 160 /* GetAccessor */ ? 161 /* SetAccessor */ : 160 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 157 /* MethodDeclaration */: + case 158 /* 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 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 152 /* Parameter */: + case 153 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -56307,7 +57045,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 === 149 /* 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 === 150 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -56342,7 +57080,7 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return node; - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -56355,7 +57093,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 151 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -56384,7 +57122,7 @@ var ts; } } } - var body = node.kind === 156 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 157 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -56426,42 +57164,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 285 /* SourceFile */: - case 245 /* ModuleDeclaration */: - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 286 /* SourceFile */: + case 246 /* ModuleDeclaration */: + case 220 /* Block */: + case 248 /* CaseBlock */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 159 /* Constructor */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 244 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 177 /* InferType */: + case 178 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -56481,11 +57219,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 157 /* MethodDeclaration */: - case 155 /* PropertyDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - if (member.kind === 160 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 158 /* MethodDeclaration */: + case 156 /* PropertyDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + if (member.kind === 161 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -56494,7 +57232,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 158 /* Constructor */: + case 159 /* Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { @@ -56502,8 +57240,8 @@ var ts; } } break; - case 163 /* IndexSignature */: - case 218 /* SemicolonClassElement */: + case 164 /* IndexSignature */: + case 219 /* SemicolonClassElement */: // Can't be private break; default: @@ -56530,7 +57268,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 177 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 178 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) // Whole @template tag @@ -56600,7 +57338,7 @@ var ts; var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -56615,7 +57353,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 252 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 253 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -56633,7 +57371,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 === 238 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 239 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 239 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 240 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -56654,7 +57392,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 === 220 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 221 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -56668,22 +57406,22 @@ var ts; switch (name.kind) { case 73 /* Identifier */: return ts.idText(name); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 251 /* ImportClause */ || node.kind === 254 /* ImportSpecifier */ || node.kind === 252 /* NamespaceImport */; + return node.kind === 252 /* ImportClause */ || node.kind === 255 /* ImportSpecifier */ || node.kind === 253 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 251 /* ImportClause */ ? decl : decl.kind === 252 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 252 /* ImportClause */ ? decl : decl.kind === 253 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 219 /* Block */) { + if (node.kind === 220 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -56713,12 +57451,12 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 155 /* PropertyDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 157 /* MethodDeclaration */ || - node.kind === 156 /* MethodSignature */ || - node.kind === 159 /* GetAccessor */ || - node.kind === 160 /* SetAccessor */) { + if (node.kind === 156 /* PropertyDeclaration */ || + node.kind === 155 /* PropertySignature */ || + node.kind === 158 /* MethodDeclaration */ || + node.kind === 157 /* MethodSignature */ || + node.kind === 160 /* GetAccessor */ || + node.kind === 161 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -56727,7 +57465,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 152 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 153 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -56778,7 +57516,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 === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 286 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -56793,7 +57531,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 === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 286 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(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)); } @@ -56828,7 +57566,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 === 238 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 239 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -56840,17 +57578,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 239 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 220 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 240 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 221 /* 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 === 219 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 246 /* ModuleBlock */ || - container.kind === 245 /* ModuleDeclaration */ || - container.kind === 285 /* SourceFile */); + (container.kind === 220 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 247 /* ModuleBlock */ || + container.kind === 246 /* ModuleDeclaration */ || + container.kind === 286 /* 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 @@ -56880,18 +57618,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 187 /* BindingElement */) { - if (node.parent.kind === 185 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (node.kind === 188 /* BindingElement */) { + if (node.parent.kind === 186 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 150 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 151 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -56912,19 +57650,19 @@ var ts; } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 186 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 187 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 152 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 153 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 227 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 228 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -56961,7 +57699,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 227 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 228 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -56987,10 +57725,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */) { + if (node.kind !== 156 /* PropertyDeclaration */ && node.kind !== 155 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 239 /* VariableDeclaration */ || node.kind === 188 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -56999,7 +57737,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 155 /* PropertyDeclaration */ || nextDeclaration.kind === 154 /* PropertySignature */ + var message = nextDeclaration.kind === 156 /* PropertyDeclaration */ || nextDeclaration.kind === 155 /* 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); @@ -57009,8 +57747,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 152 /* Parameter */ && right.kind === 238 /* VariableDeclaration */) || - (left.kind === 238 /* VariableDeclaration */ && right.kind === 152 /* Parameter */)) { + if ((left.kind === 153 /* Parameter */ && right.kind === 239 /* VariableDeclaration */) || + (left.kind === 239 /* VariableDeclaration */ && right.kind === 153 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -57049,7 +57787,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkTruthinessExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 221 /* EmptyStatement */) { + if (node.thenStatement.kind === 222 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -57076,12 +57814,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 240 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 240 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -57115,14 +57853,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 === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 240 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 189 /* ArrayLiteralExpression */ || varExpr.kind === 190 /* 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. @@ -57154,7 +57892,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 === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 240 /* 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); @@ -57168,7 +57906,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 === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 189 /* ArrayLiteralExpression */ || varExpr.kind === 190 /* 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)) { @@ -57832,12 +58570,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 === 160 /* SetAccessor */) { + if (func.kind === 161 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 158 /* Constructor */) { + else if (func.kind === 159 /* 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); } @@ -57855,7 +58593,7 @@ var ts; } } } - else if (func.kind !== 158 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 159 /* 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); } @@ -57884,7 +58622,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 === 273 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 274 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -57896,7 +58634,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 272 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 273 /* 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. @@ -57925,7 +58663,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 234 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 235 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -58032,8 +58770,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 === 205 /* BinaryExpression */ || - name.kind === 150 /* ComputedPropertyName */ || + (propDeclaration.kind === 206 /* BinaryExpression */ || + name.kind === 151 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -58110,7 +58848,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 165 /* TypeReference */) { + if (node.kind === 166 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -58359,7 +59097,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 241 /* ClassDeclaration */ || d.kind === 242 /* InterfaceDeclaration */; + return d.kind === 242 /* ClassDeclaration */ || d.kind === 243 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -58378,7 +59116,7 @@ var ts; // derived class instance member variables and accessors, but not by other kinds of members. // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfType(baseType); - for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { + basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); if (base.flags & 4194304 /* Prototype */) { @@ -58387,53 +59125,64 @@ var ts; var derived = getTargetSymbol(getPropertyOfObjectType(type, base.escapedName)); // TODO: GH#18217 var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base); ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); - if (derived) { - // In order to resolve whether the inherited method was overridden in the base class or not, - // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* - // type declaration, derived and base resolve to the same symbol even in the case of generic classes. - if (derived === base) { - // derived class inherits base without override/redeclaration - var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); - // It is an error to inherit an abstract member without implementing it or being declared abstract. - // If there is no declaration for the derived class (as in the case of class expressions), - // then the class cannot be declared abstract. - if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 210 /* ClassExpression */) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); - } - else { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + // In order to resolve whether the inherited method was overridden in the base class or not, + // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* + // type declaration, derived and base resolve to the same symbol even in the case of generic classes. + if (derived === base) { + // derived class inherits base without override/redeclaration + var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); + // It is an error to inherit an abstract member without implementing it or being declared abstract. + // If there is no declaration for the derived class (as in the case of class expressions), + // then the class cannot be declared abstract. + if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { + // 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]; + if (otherBaseType === baseType) + continue; + var baseSymbol = getPropertyOfObjectType(otherBaseType, base.escapedName); + var derivedElsewhere = baseSymbol && getTargetSymbol(baseSymbol); + if (derivedElsewhere && derivedElsewhere !== base) { + continue basePropertyCheck; } } - } - else { - // derived overrides base. - var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { - // either base or derived property is private - not override, skip it - continue; - } - if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; + if (derivedClassDecl.kind === 211 /* ClassExpression */) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } - var errorMessage = void 0; - if (isPrototypeProperty(base)) { - if (derived.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } - else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); } - else if (base.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + } + else { + // derived overrides base. + var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); + if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + // either base or derived property is private - not override, skip it + continue; + } + if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { + // method is overridden with method or property/accessor is overridden with property/accessor - correct case + continue; + } + var errorMessage = void 0; + if (isPrototypeProperty(base)) { + if (derived.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } - error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } + else if (base.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } @@ -58490,7 +59239,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 155 /* PropertyDeclaration */ && + return node.kind === 156 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -58514,7 +59263,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 243 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -58619,7 +59368,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -58629,7 +59378,7 @@ var ts; } } break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -58657,7 +59406,7 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return evaluate(expr.expression); case 73 /* Identifier */: var identifier = expr; @@ -58665,20 +59414,18 @@ var ts; return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: + case 191 /* 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 === 190 /* PropertyAccessExpression */) { + if (ex.kind === 191 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { - var argument = ex.argumentExpression; - ts.Debug.assert(ts.isLiteralExpression(argument)); - name = ts.escapeLeadingUnderscores(argument.text); + name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text); } return evaluateEnumMember(expr, type.symbol, name); } @@ -58704,8 +59451,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 73 /* Identifier */ || - node.kind === 190 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 191 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.kind === 191 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 192 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && node.argumentExpression.kind === 10 /* StringLiteral */; } function checkEnumDeclaration(node) { @@ -58740,7 +59487,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 !== 244 /* EnumDeclaration */) { + if (declaration.kind !== 245 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -58763,8 +59510,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 241 /* ClassDeclaration */ || - (declaration.kind === 240 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 242 /* ClassDeclaration */ || + (declaration.kind === 241 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304 /* Ambient */)) { return declaration; } @@ -58827,7 +59574,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, 241 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 242 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -58877,23 +59624,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* 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]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 256 /* ExportAssignment */: + case 257 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 239 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -58904,12 +59651,12 @@ var ts; break; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 240 /* FunctionDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 241 /* FunctionDeclaration */: + case 243 /* InterfaceDeclaration */: + case 246 /* ModuleDeclaration */: + case 244 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -58932,12 +59679,12 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return node; - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: do { node = node.left; } while (node.kind !== 73 /* Identifier */); return node; - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 73 /* Identifier */); @@ -58954,9 +59701,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 256 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 247 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 286 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 257 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -58978,26 +59725,27 @@ var ts; function checkAliasSymbol(node) { var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); - if (target !== unknownSymbol) { - // For external modules symbol represent local symbol for an alias. + var shouldSkipWithJSExpandoTargets = symbol.flags & 67108864 /* Assignment */; + if (!shouldSkipWithJSExpandoTargets && target !== unknownSymbol) { + // For external modules symbol represents local symbol for an alias. // This local symbol will merge any other local declarations (excluding other aliases) // and symbol.flags will contains combined representation for all merged declaration. // Based on symbol.flags we can compute a set of excluded meanings (meaning that resolved alias should not have, // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export* // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). - var excludedMeanings = (symbol.flags & (67220415 /* Value */ | 1048576 /* ExportValue */) ? 67220415 /* Value */ : 0) | - (symbol.flags & 67897832 /* Type */ ? 67897832 /* Type */ : 0) | + var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | + (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 258 /* ExportSpecifier */ ? + var message = node.kind === 259 /* 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 === 258 /* ExportSpecifier */ - && !(target.flags & 67220415 /* Value */) + && node.kind === 259 /* ExportSpecifier */ + && !(target.flags & 111551 /* Value */) && !(node.flags & 4194304 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); } @@ -59023,7 +59771,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 253 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -59047,17 +59795,17 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 261 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 67220415 /* Value */) { + if (target.flags & 111551 /* Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name var moduleName = getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 67220415 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { + if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 67897832 /* Type */) { + if (target.flags & 788968 /* Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } @@ -59083,10 +59831,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 246 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 247 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 247 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 286 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -59103,7 +59851,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 285 /* SourceFile */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 245 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 286 /* SourceFile */ || node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 246 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -59117,13 +59865,17 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) - var symbol = resolveName(exportedName, exportedName.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || 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 { markExportAsReferenced(node); + var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) { + checkExpressionCached(node.propertyName || node.name); + } } } } @@ -59132,8 +59884,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 286 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 246 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -59147,7 +59899,17 @@ var ts; grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 73 /* Identifier */) { - markExportAsReferenced(node); + var id = node.expression; + var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); + if (sym) { + markAliasReferenced(sym, id); + // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`) + var target = sym.flags & 2097152 /* Alias */ ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551 /* Value */) { + // However if it is a value, we need to check it's being used correctly + checkExpressionCached(node.expression); + } + } if (ts.getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression, /*setVisibility*/ true); } @@ -59216,14 +59978,6 @@ var ts; links.exportsChecked = true; } } - function isNotAccessor(declaration) { - // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks - return !ts.isAccessor(declaration); - } - function isNotOverload(declaration) { - return (declaration.kind !== 240 /* FunctionDeclaration */ && declaration.kind !== 157 /* MethodDeclaration */) || - !!declaration.body; - } function checkSourceElement(node) { if (node) { var saveCurrentNode = currentNode; @@ -59245,158 +59999,159 @@ 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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 241 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return checkTypeParameter(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return checkParameter(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return checkPropertyDeclaration(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 162 /* CallSignature */: + case 163 /* ConstructSignature */: + case 164 /* IndexSignature */: return checkSignatureDeclaration(node); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: return checkMethodDeclaration(node); - case 158 /* Constructor */: + case 159 /* Constructor */: return checkConstructorDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return checkAccessorDeclaration(node); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return checkTypeReferenceNode(node); - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return checkTypePredicate(node); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return checkTypeQuery(node); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return checkTypeLiteral(node); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return checkArrayType(node); - case 171 /* TupleType */: + case 172 /* TupleType */: return checkTupleType(node); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 178 /* ParenthesizedType */: - case 172 /* OptionalType */: - case 173 /* RestType */: + case 179 /* ParenthesizedType */: + case 173 /* OptionalType */: + case 174 /* RestType */: return checkSourceElement(node.type); - case 179 /* ThisType */: + case 180 /* ThisType */: return checkThisType(node); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: return checkTypeOperator(node); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return checkConditionalType(node); - case 177 /* InferType */: + case 178 /* InferType */: return checkInferType(node); - case 184 /* ImportType */: + case 185 /* ImportType */: return checkImportType(node); - case 301 /* JSDocAugmentsTag */: + case 303 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 313 /* JSDocTypedefTag */: + case 306 /* JSDocCallbackTag */: + case 307 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 309 /* JSDocTypeTag */: + case 311 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 306 /* JSDocParameterTag */: + case 308 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: - case 298 /* JSDocTypeLiteral */: + case 294 /* JSDocNonNullableType */: + case 293 /* JSDocNullableType */: + case 291 /* JSDocAllType */: + case 292 /* JSDocUnknownType */: + case 300 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 296 /* JSDocVariadicType */: + case 297 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 289 /* JSDocTypeExpression */: + case 290 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 182 /* MappedType */: + case 183 /* MappedType */: return checkMappedType(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 220 /* Block */: + case 247 /* ModuleBlock */: return checkBlock(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return checkVariableStatement(node); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return checkExpressionStatement(node); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return checkIfStatement(node); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return checkDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return checkWhileStatement(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return checkForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return checkForInStatement(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return checkForOfStatement(node); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 230 /* ContinueStatement */: + case 231 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return checkReturnStatement(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return checkWithStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return checkSwitchStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return checkLabeledStatement(node); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return checkThrowStatement(node); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return checkTryStatement(node); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return checkBindingElement(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return checkClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return checkImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return checkExportDeclaration(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return checkExportAssignment(node); - case 221 /* EmptyStatement */: - case 237 /* DebuggerStatement */: + case 222 /* EmptyStatement */: + case 238 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 259 /* MissingDeclaration */: + case 260 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -59491,23 +60246,23 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 261 /* JsxElement */: + case 262 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -59637,35 +60392,35 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 285 /* SourceFile */: + case 286 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; // falls through - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - // falls through // this fall-through is necessary because we would like to handle - // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. + // falls through + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!isStatic) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67897832 /* Type */); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -59713,11 +60468,11 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 151 /* TypeParameter */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 152 /* TypeParameter */: + case 242 /* ClassDeclaration */: + case 243 /* InterfaceDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 245 /* EnumDeclaration */: return true; default: return false; @@ -59725,16 +60480,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 150 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 165 /* TypeReference */; + return node.parent.kind === 166 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 190 /* PropertyAccessExpression */) { + while (node.parent.kind === 191 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 212 /* ExpressionWithTypeArguments */; + return node.parent.kind === 213 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -59762,13 +60517,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 149 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 150 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 249 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 250 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 255 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 256 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -59794,7 +60549,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 184 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 185 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -59804,7 +60559,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 190 /* PropertyAccessExpression */ && + entityName.parent.kind === 191 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -59812,17 +60567,17 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 255 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 256 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, - /*all meanings*/ 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); + /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); if (success && success !== unknownSymbol) { return success; } } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 249 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 250 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -59840,11 +60595,11 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 212 /* ExpressionWithTypeArguments */) { - meaning = 67897832 /* Type */; + if (entityName.parent.kind === 213 /* ExpressionWithTypeArguments */) { + meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { - meaning |= 67220415 /* Value */; + meaning |= 111551 /* Value */; } } else { @@ -59856,10 +60611,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 306 /* JSDocParameterTag */) { + if (entityName.parent.kind === 308 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 151 /* TypeParameter */ && entityName.parent.parent.kind === 310 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 152 /* TypeParameter */ && entityName.parent.parent.kind === 312 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -59874,14 +60629,14 @@ var ts; var symbol = getIntrinsicTagSymbol(entityName.parent); return symbol === unknownSymbol ? undefined : symbol; } - return resolveEntityName(entityName, 67220415 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); + return resolveEntityName(entityName, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 190 /* PropertyAccessExpression */ || entityName.kind === 149 /* QualifiedName */) { + else if (entityName.kind === 191 /* PropertyAccessExpression */ || entityName.kind === 150 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 190 /* PropertyAccessExpression */) { + if (entityName.kind === 191 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -59891,17 +60646,17 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 165 /* TypeReference */ ? 67897832 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 166 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - if (entityName.parent.kind === 164 /* TypePredicate */) { + if (entityName.parent.kind === 165 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -59924,8 +60679,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 187 /* BindingElement */ && - grandParent.kind === 185 /* ObjectBindingPattern */ && + else if (parent.kind === 188 /* BindingElement */ && + grandParent.kind === 186 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -59936,8 +60691,8 @@ var ts; } switch (node.kind) { case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 191 /* PropertyAccessExpression */: + case 150 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 101 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); @@ -59951,14 +60706,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 179 /* ThisType */: + case 180 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; case 99 /* SuperKeyword */: return checkExpression(node).symbol; case 125 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 158 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 159 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -59969,7 +60724,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 === 250 /* ImportDeclaration */ || node.parent.kind === 256 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 251 /* ImportDeclaration */ || node.parent.kind === 257 /* 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); @@ -59991,7 +60746,7 @@ var ts; case 37 /* EqualsGreaterThanToken */: case 77 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 184 /* ImportType */: + case 185 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; case 86 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; @@ -60000,8 +60755,8 @@ var ts; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 277 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 67220415 /* Value */ | 2097152 /* Alias */); + if (location && location.kind === 278 /* ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; } @@ -60009,7 +60764,7 @@ var ts; function getExportSpecifierLocalTargetSymbol(node) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } function getTypeOfNode(node) { if (node.flags & 8388608 /* InWithStatement */) { @@ -60068,27 +60823,27 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 189 /* ObjectLiteralExpression */ || expr.kind === 188 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 190 /* ObjectLiteralExpression */ || expr.kind === 189 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 228 /* ForOfStatement */) { + if (expr.parent.kind === 229 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 205 /* BinaryExpression */) { + if (expr.parent.kind === 206 /* 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 === 276 /* 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); + if (expr.parent.kind === 277 /* PropertyAssignment */) { + var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); + var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType; + var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex); } // Array literal assignment - array destructuring pattern var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); @@ -60132,7 +60887,7 @@ var ts; case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: @@ -60189,7 +60944,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 191 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -60210,13 +60965,13 @@ var ts; // for export assignments - check if resolved symbol for RHS is itself a value // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 67220415 /* Value */) + ? !!(moduleSymbol.flags & 111551 /* Value */) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 67220415 /* Value */); + return s && !!(s.flags & 111551 /* Value */); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -60245,7 +61000,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 285 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 286 /* 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. @@ -60265,7 +61020,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 67220415 /* Value */)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -60273,7 +61028,7 @@ var ts; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 276 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { @@ -60282,7 +61037,7 @@ var ts; var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { + if (resolveName(container.parent, symbol.escapedName, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } @@ -60304,7 +61059,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 === 219 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 220 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -60345,26 +61100,25 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 250 /* ImportEqualsDeclaration */: + case 252 /* ImportClause */: + case 253 /* NamespaceImport */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 255 /* ExportAssignment */: - return node.expression - && node.expression.kind === 73 /* Identifier */ - ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) - : true; + case 256 /* ExportAssignment */: + return node.expression && node.expression.kind === 73 /* Identifier */ ? + isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : + true; } return false; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 285 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 286 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -60378,7 +61132,7 @@ var ts; } // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true - return !!(target.flags & 67220415 /* Value */) && + return !!(target.flags & 111551 /* Value */) && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -60392,7 +61146,7 @@ var ts; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 if (target && ts.getModifierFlags(node) & 1 /* Export */ && - target.flags & 67220415 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { + target.flags & 111551 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -60446,7 +61200,7 @@ var ts; if (!symbol || !(symbol.flags & 16 /* Function */)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 67220415 /* Value */ && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -60465,15 +61219,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 279 /* EnumMember */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 280 /* EnumMember */: + case 191 /* PropertyAccessExpression */: + case 192 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 279 /* EnumMember */) { + if (node.kind === 280 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -60500,9 +61254,9 @@ var ts; return ts.TypeReferenceSerializationKind.Unknown; } // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. - var valueSymbol = resolveEntityName(typeName, 67220415 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 67897832 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (valueSymbol && valueSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { @@ -60607,7 +61361,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + return resolveName(location, reference.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -60628,7 +61382,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 67220415 /* Value */, enclosing, /*flags*/ undefined, tracker) + var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse(); return enumResult || ts.createLiteral(type.value); } @@ -60709,12 +61463,12 @@ var ts; getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 160 /* SetAccessor */ ? 159 /* GetAccessor */ : 160 /* SetAccessor */; + var otherKind = accessor.kind === 161 /* SetAccessor */ ? 160 /* GetAccessor */ : 161 /* 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 === 160 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 159 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 161 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 160 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -60730,7 +61484,7 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 212 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 274 /* HeritageClause */; + return node.parent && node.parent.kind === 213 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 275 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -60741,9 +61495,9 @@ var ts; // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = 67897832 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 73 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 190 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { - meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; + var meaning = 788968 /* Type */ | 1920 /* Namespace */; + if ((node.kind === 73 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 191 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -60793,7 +61547,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 285 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 286 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -60821,12 +61575,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 245 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 246 /* 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, 285 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 286 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -60966,7 +61720,7 @@ var ts; for (var helper = 1 /* FirstEmitHelper */; helper <= 131072 /* LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 67220415 /* Value */); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); if (!symbol) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); } @@ -61015,14 +61769,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 157 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 158 /* 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 === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */) { + else if (node.kind === 160 /* GetAccessor */ || node.kind === 161 /* 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); @@ -61040,16 +61794,16 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 134 /* ReadonlyKeyword */) { - if (node.kind === 154 /* PropertySignature */ || node.kind === 156 /* MethodSignature */) { + if (node.kind === 155 /* PropertySignature */ || node.kind === 157 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 164 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 78 /* ConstKeyword */: - if (node.kind !== 244 /* EnumDeclaration */) { + if (node.kind !== 245 /* EnumDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(78 /* ConstKeyword */)); } break; @@ -61069,7 +61823,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 === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 286 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -61092,10 +61846,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 286 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 153 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -61108,7 +61862,7 @@ var ts; if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */ && node.kind !== 163 /* IndexSignature */ && node.kind !== 152 /* Parameter */) { + else if (node.kind !== 156 /* PropertyDeclaration */ && node.kind !== 155 /* PropertySignature */ && node.kind !== 164 /* IndexSignature */ && node.kind !== 153 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report 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); } @@ -61128,17 +61882,17 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 153 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; case 81 /* DefaultKeyword */: - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 286 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 246 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; @@ -61150,13 +61904,13 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 153 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 246 /* ModuleBlock */) { + else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 247 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -61166,14 +61920,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 241 /* ClassDeclaration */) { - if (node.kind !== 157 /* MethodDeclaration */ && - node.kind !== 155 /* PropertyDeclaration */ && - node.kind !== 159 /* GetAccessor */ && - node.kind !== 160 /* SetAccessor */) { + if (node.kind !== 242 /* ClassDeclaration */) { + if (node.kind !== 158 /* MethodDeclaration */ && + node.kind !== 156 /* PropertyDeclaration */ && + node.kind !== 160 /* GetAccessor */ && + node.kind !== 161 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 241 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 242 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -61192,7 +61946,7 @@ var ts; else if (flags & 2 /* Ambient */ || node.parent.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 153 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -61200,7 +61954,7 @@ var ts; break; } } - if (node.kind === 158 /* Constructor */) { + if (node.kind === 159 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -61215,13 +61969,13 @@ var ts; } return false; } - else if ((node.kind === 250 /* ImportDeclaration */ || node.kind === 249 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 251 /* ImportDeclaration */ || node.kind === 250 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 153 /* Parameter */ && (flags & 92 /* 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 === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 153 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -61242,37 +61996,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 245 /* ModuleDeclaration */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 152 /* Parameter */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 159 /* Constructor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: + case 164 /* IndexSignature */: + case 246 /* ModuleDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 257 /* ExportDeclaration */: + case 256 /* ExportAssignment */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: + case 153 /* Parameter */: return false; default: - if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 286 /* SourceFile */) { return false; } switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 122 /* AsyncKeyword */); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 119 /* AbstractKeyword */); - case 242 /* InterfaceDeclaration */: - case 220 /* VariableStatement */: - case 243 /* TypeAliasDeclaration */: + case 243 /* InterfaceDeclaration */: + case 221 /* VariableStatement */: + case 244 /* TypeAliasDeclaration */: return true; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 78 /* ConstKeyword */); default: ts.Debug.fail(); @@ -61285,10 +62039,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + case 241 /* FunctionDeclaration */: + case 198 /* FunctionExpression */: + case 199 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -61351,7 +62105,7 @@ var ts; ts.addRelatedInfo(error(parameter, ts.Diagnostics.This_parameter_is_not_allowed_with_use_strict_directive), ts.createDiagnosticForNode(useStrictDirective_1, ts.Diagnostics.use_strict_directive_used_here)); }); var diagnostics_1 = nonSimpleParameters.map(function (parameter, index) { return (index === 0 ? ts.createDiagnosticForNode(parameter, ts.Diagnostics.Non_simple_parameter_declared_here) : ts.createDiagnosticForNode(parameter, ts.Diagnostics.and_here)); }); - ts.addRelatedInfo.apply(void 0, [error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)].concat(diagnostics_1)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)], diagnostics_1)); return true; } } @@ -61439,7 +62193,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 === 211 /* OmittedExpression */) { + if (arg.kind === 212 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -61516,20 +62270,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 150 /* ComputedPropertyName */) { + if (node.kind !== 151 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 205 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 206 /* 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 === 240 /* FunctionDeclaration */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 157 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 241 /* FunctionDeclaration */ || + node.kind === 198 /* FunctionExpression */ || + node.kind === 158 /* MethodDeclaration */); if (node.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -61545,17 +62299,10 @@ var ts; return !!exclamationToken && grammarErrorOnNode(exclamationToken, message); } function checkGrammarObjectLiteralExpression(node, inDestructuring) { - var Flags; - (function (Flags) { - Flags[Flags["Property"] = 1] = "Property"; - Flags[Flags["GetAccessor"] = 2] = "GetAccessor"; - Flags[Flags["SetAccessor"] = 4] = "SetAccessor"; - Flags[Flags["GetOrSetAccessor"] = 6] = "GetOrSetAccessor"; - })(Flags || (Flags = {})); var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */) { + if (prop.kind === 279 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -61566,11 +62313,11 @@ var ts; continue; } var name = prop.name; - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 151 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 277 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 278 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -61579,7 +62326,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 157 /* MethodDeclaration */) { + if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 158 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -61594,24 +62341,25 @@ 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 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); - /* tslint:disable:no-switch-case-fall-through */ - case 276 /* PropertyAssignment */: + // falls through + case 277 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name); } - // falls through - case 157 /* MethodDeclaration */: - currentKind = 1 /* Property */; + currentKind = 4 /* PropertyAssignment */; + break; + case 158 /* MethodDeclaration */: + currentKind = 8 /* Method */; break; - case 159 /* GetAccessor */: - currentKind = 2 /* GetAccessor */; + case 160 /* GetAccessor */: + currentKind = 1 /* GetAccessor */; break; - case 160 /* SetAccessor */: - currentKind = 4 /* SetAccessor */; + case 161 /* SetAccessor */: + currentKind = 2 /* SetAccessor */; break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); @@ -61625,11 +62373,11 @@ var ts; seen.set(effectiveName, currentKind); } else { - if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { + if ((currentKind & 12 /* PropertyAssignmentOrMethod */) && (existingKind & 12 /* PropertyAssignmentOrMethod */)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 6 /* GetOrSetAccessor */) && (existingKind & 6 /* GetOrSetAccessor */)) { - if (existingKind !== 6 /* GetOrSetAccessor */ && currentKind !== existingKind) { + else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) { + if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -61647,7 +62395,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 270 /* JsxSpreadAttribute */) { + if (attr.kind === 271 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -61657,7 +62405,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 271 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 272 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -61671,14 +62419,14 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 228 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 229 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { // use of 'for-await-of' in non-async function var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 159 /* 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); @@ -61689,7 +62437,7 @@ var ts; return false; } } - if (forInOrOfStatement.initializer.kind === 239 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 240 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -61704,20 +62452,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 228 /* 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 === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 228 /* 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 === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 228 /* 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); @@ -61727,42 +62475,38 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - var kind = accessor.kind; - if (languageVersion < 1 /* ES5 */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (accessor.flags & 4194304 /* Ambient */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); - } - else if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { - return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + if (!(accessor.flags & 4194304 /* Ambient */)) { + if (languageVersion < 1 /* ES5 */) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { + return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + } } - else if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { + if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - else if (accessor.typeParameters) { + if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 159 /* GetAccessor */ ? + if (!doesAccessorHaveCorrectParameterCount(accessor)) { + return grammarErrorOnNode(accessor.name, accessor.kind === 160 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 160 /* SetAccessor */) { + if (accessor.kind === 161 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } - else { - var parameter = accessor.parameters[0]; - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); - } - else if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); - } - else if (parameter.initializer) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); - } + var parameter = ts.Debug.assertDefined(ts.getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion."); + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); + } + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); + } + if (parameter.initializer) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); } } return false; @@ -61772,10 +62516,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 === 159 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 160 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 159 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 160 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -61786,7 +62530,7 @@ var ts; } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: var decl = parent; if (decl.name.kind !== 73 /* Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); @@ -61798,13 +62542,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: if (!ts.hasModifier(parent, 32 /* Static */) || !ts.hasModifier(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 154 /* PropertySignature */: + case 155 /* PropertySignature */: if (!ts.hasModifier(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); } @@ -61814,7 +62558,7 @@ var ts; } } else if (node.operator === 134 /* ReadonlyKeyword */) { - if (node.type.kind !== 170 /* ArrayType */ && node.type.kind !== 171 /* TupleType */) { + if (node.type.kind !== 171 /* ArrayType */ && node.type.kind !== 172 /* TupleType */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(140 /* SymbolKeyword */)); } } @@ -61828,8 +62572,8 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 157 /* MethodDeclaration */) { - if (node.parent.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 158 /* MethodDeclaration */) { + if (node.parent.kind === 190 /* 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 === 122 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -61857,14 +62601,14 @@ var ts; if (node.flags & 4194304 /* 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 === 157 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 158 /* 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 === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 243 /* 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 === 169 /* TypeLiteral */) { + else if (node.parent.kind === 170 /* 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); } } @@ -61875,11 +62619,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 234 /* LabeledStatement */: + case 235 /* 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 === 229 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 230 /* 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); @@ -61887,8 +62631,8 @@ var ts; return false; } break; - case 233 /* SwitchStatement */: - if (node.kind === 230 /* BreakStatement */ && !node.label) { + case 234 /* SwitchStatement */: + if (node.kind === 231 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -61903,13 +62647,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 230 /* BreakStatement */ + var message = node.kind === 231 /* 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 === 230 /* BreakStatement */ + var message = node.kind === 231 /* 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); @@ -61933,12 +62677,12 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 10 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.kind === 204 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.kind === 204 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -61968,7 +62712,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 227 /* ForInStatement */ && node.parent.parent.kind !== 228 /* ForOfStatement */) { + if (node.parent.parent.kind !== 228 /* ForInStatement */ && node.parent.parent.kind !== 229 /* ForOfStatement */) { if (node.flags & 4194304 /* Ambient */) { checkAmbientInitializer(node); } @@ -61981,7 +62725,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 220 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 221 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && @@ -62043,15 +62787,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 224 /* IfStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 233 /* WithStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: return false; - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -62132,7 +62876,7 @@ var ts; return true; } } - else if (node.parent.kind === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 243 /* 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; } @@ -62140,7 +62884,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 169 /* TypeLiteral */) { + else if (node.parent.kind === 170 /* 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; } @@ -62169,13 +62913,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 243 /* TypeAliasDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 256 /* ExportDeclaration */ || - node.kind === 255 /* ExportAssignment */ || - node.kind === 248 /* NamespaceExportDeclaration */ || + if (node.kind === 243 /* InterfaceDeclaration */ || + node.kind === 244 /* TypeAliasDeclaration */ || + node.kind === 251 /* ImportDeclaration */ || + node.kind === 250 /* ImportEqualsDeclaration */ || + node.kind === 257 /* ExportDeclaration */ || + node.kind === 256 /* ExportAssignment */ || + node.kind === 249 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -62184,7 +62928,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 === 220 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 221 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -62197,13 +62941,9 @@ var ts; } function checkGrammarStatementInAmbientContext(node) { if (node.flags & 4194304 /* Ambient */) { - // An accessors is already reported about the ambient context - if (ts.isAccessor(node.parent)) { - return getNodeLinks(node).hasReportedStatementInAmbientContext = true; - } // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); - if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { + if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } // We are either parented by another statement, or some sort of block. @@ -62211,7 +62951,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 === 219 /* Block */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 220 /* Block */ || node.parent.kind === 247 /* ModuleBlock */ || node.parent.kind === 286 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -62233,10 +62973,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, 183 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 184 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 279 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 280 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -62245,8 +62985,27 @@ var ts; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + // Realism (size) checking + checkNumericLiteralValueSize(node); return false; } + function checkNumericLiteralValueSize(node) { + // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint + // Literals with 15 or fewer characters aren't long enough to reach past 2^53 - 1 + // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway + if (node.numericLiteralFlags & 16 /* Scientific */ || node.text.length <= 15 || node.text.indexOf(".") !== -1) { + return; + } + // We can't rely on the runtime to accurately store and compare extremely large numeric values + // Even for internal use, we use getTextOfNode: https://github.com/microsoft/TypeScript/issues/33298 + // Thus, if the runtime claims a too-large number is lower than Number.MAX_SAFE_INTEGER, + // it's likely addition operations on it will fail too + var apparentValue = +ts.getTextOfNode(node); + if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) { + return; + } + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers)); + } function checkGrammarBigIntLiteral(node) { var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); @@ -62301,11 +63060,19 @@ var ts; } } ts.createTypeChecker = createTypeChecker; + function isNotAccessor(declaration) { + // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks + return !ts.isAccessor(declaration); + } + function isNotOverload(declaration) { + return (declaration.kind !== 241 /* FunctionDeclaration */ && declaration.kind !== 158 /* 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 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -62313,21 +63080,20 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 251 /* ImportClause */: // For default import - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: // For rename import `x as y` + case 252 /* ImportClause */: // For default import + case 250 /* ImportEqualsDeclaration */: + case 253 /* NamespaceImport */: + case 255 /* ImportSpecifier */: // For rename import `x as y` return true; case 73 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 254 /* ImportSpecifier */; + return decl.parent.kind === 255 /* ImportSpecifier */; default: return false; } } var JsxNames; (function (JsxNames) { - // tslint:disable variable-name JsxNames.JSX = "JSX"; JsxNames.IntrinsicElements = "IntrinsicElements"; JsxNames.ElementClass = "ElementClass"; @@ -62337,7 +63103,6 @@ var ts; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; - // tslint:enable variable-name })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { @@ -62408,6 +63173,7 @@ var ts; if (typeof value === "number") { return createNumericLiteral(value + ""); } + // eslint-disable-next-line no-in-operator if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n"); } @@ -62600,7 +63366,7 @@ var ts; ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(149 /* QualifiedName */); + var node = createSynthesizedNode(150 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -62619,7 +63385,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(150 /* ComputedPropertyName */); + var node = createSynthesizedNode(151 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -62632,7 +63398,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(151 /* TypeParameter */); + var node = createSynthesizedNode(152 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -62648,7 +63414,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(152 /* Parameter */); + var node = createSynthesizedNode(153 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -62672,7 +63438,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(153 /* Decorator */); + var node = createSynthesizedNode(154 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -62685,7 +63451,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(154 /* PropertySignature */); + var node = createSynthesizedNode(155 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -62705,7 +63471,7 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(155 /* PropertyDeclaration */); + var node = createSynthesizedNode(156 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62729,7 +63495,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(156 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(157 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -62746,7 +63512,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(157 /* MethodDeclaration */); + var node = createSynthesizedNode(158 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -62774,7 +63540,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(158 /* Constructor */); + var node = createSynthesizedNode(159 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -62794,7 +63560,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(159 /* GetAccessor */); + var node = createSynthesizedNode(160 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62817,7 +63583,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(160 /* SetAccessor */); + var node = createSynthesizedNode(161 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62838,7 +63604,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(161 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(162 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -62846,7 +63612,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(162 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(163 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -62854,7 +63620,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(163 /* IndexSignature */); + var node = createSynthesizedNode(164 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -62894,7 +63660,7 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(164 /* TypePredicate */); + var node = createSynthesizedNode(165 /* TypePredicate */); node.parameterName = asName(parameterName); node.type = type; return node; @@ -62908,7 +63674,7 @@ var ts; } ts.updateTypePredicateNode = updateTypePredicateNode; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(165 /* TypeReference */); + var node = createSynthesizedNode(166 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -62922,7 +63688,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(166 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(167 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -62930,7 +63696,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(167 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(168 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -62938,7 +63704,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(168 /* TypeQuery */); + var node = createSynthesizedNode(169 /* TypeQuery */); node.exprName = exprName; return node; } @@ -62950,7 +63716,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(169 /* TypeLiteral */); + var node = createSynthesizedNode(170 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -62962,7 +63728,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(170 /* ArrayType */); + var node = createSynthesizedNode(171 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -62974,7 +63740,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(171 /* TupleType */); + var node = createSynthesizedNode(172 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -62986,7 +63752,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(172 /* OptionalType */); + var node = createSynthesizedNode(173 /* OptionalType */); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -62998,7 +63764,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(173 /* RestType */); + var node = createSynthesizedNode(174 /* RestType */); node.type = type; return node; } @@ -63010,7 +63776,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(174 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(175 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -63018,7 +63784,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(175 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(176 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -63037,7 +63803,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(176 /* ConditionalType */); + var node = createSynthesizedNode(177 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -63055,7 +63821,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(177 /* InferType */); + var node = createSynthesizedNode(178 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -63067,7 +63833,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(184 /* ImportType */); + var node = createSynthesizedNode(185 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = ts.parenthesizeTypeParameters(typeArguments); @@ -63085,7 +63851,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(178 /* ParenthesizedType */); + var node = createSynthesizedNode(179 /* ParenthesizedType */); node.type = type; return node; } @@ -63097,11 +63863,11 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(179 /* ThisType */); + return createSynthesizedNode(180 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(180 /* TypeOperator */); + var node = createSynthesizedNode(181 /* TypeOperator */); node.operator = typeof operatorOrType === "number" ? operatorOrType : 130 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; @@ -63112,7 +63878,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(181 /* IndexedAccessType */); + var node = createSynthesizedNode(182 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -63126,7 +63892,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(182 /* MappedType */); + var node = createSynthesizedNode(183 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -63144,7 +63910,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(183 /* LiteralType */); + var node = createSynthesizedNode(184 /* LiteralType */); node.literal = literal; return node; } @@ -63157,7 +63923,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(185 /* ObjectBindingPattern */); + var node = createSynthesizedNode(186 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63169,7 +63935,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(186 /* ArrayBindingPattern */); + var node = createSynthesizedNode(187 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63181,7 +63947,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(187 /* BindingElement */); + var node = createSynthesizedNode(188 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -63200,7 +63966,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(188 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(189 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -63214,7 +63980,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(189 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(190 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -63228,7 +63994,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(190 /* PropertyAccessExpression */); + var node = createSynthesizedNode(191 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072 /* NoIndentation */); @@ -63245,7 +64011,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(191 /* ElementAccessExpression */); + var node = createSynthesizedNode(192 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -63259,7 +64025,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(192 /* CallExpression */); + var node = createSynthesizedNode(193 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -63275,7 +64041,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(193 /* NewExpression */); + var node = createSynthesizedNode(194 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -63291,7 +64057,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(194 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(195 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -63314,7 +64080,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(195 /* TypeAssertionExpression */); + var node = createSynthesizedNode(196 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -63328,7 +64094,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(196 /* ParenthesizedExpression */); + var node = createSynthesizedNode(197 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -63340,7 +64106,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(197 /* FunctionExpression */); + var node = createSynthesizedNode(198 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -63364,7 +64130,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(198 /* ArrowFunction */); + var node = createSynthesizedNode(199 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); @@ -63386,7 +64152,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(199 /* DeleteExpression */); + var node = createSynthesizedNode(200 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63398,7 +64164,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(200 /* TypeOfExpression */); + var node = createSynthesizedNode(201 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63410,7 +64176,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(201 /* VoidExpression */); + var node = createSynthesizedNode(202 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63422,7 +64188,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(202 /* AwaitExpression */); + var node = createSynthesizedNode(203 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63434,7 +64200,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(203 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(204 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -63447,7 +64213,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(204 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(205 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -63460,7 +64226,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(205 /* BinaryExpression */); + var node = createSynthesizedNode(206 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -63477,7 +64243,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(206 /* ConditionalExpression */); + var node = createSynthesizedNode(207 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); @@ -63497,7 +64263,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(207 /* TemplateExpression */); + var node = createSynthesizedNode(208 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -63510,32 +64276,91 @@ var ts; : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createTemplateHead(text) { - var node = createSynthesizedNode(15 /* TemplateHead */); + var rawTextScanner; + var invalidValueSentinel = {}; + function getCookedText(kind, rawText) { + if (!rawTextScanner) { + rawTextScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + } + switch (kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + rawTextScanner.setText("`" + rawText + "`"); + break; + case 15 /* TemplateHead */: + rawTextScanner.setText("`" + rawText + "${"); + break; + case 16 /* TemplateMiddle */: + rawTextScanner.setText("}" + rawText + "${"); + break; + case 17 /* TemplateTail */: + rawTextScanner.setText("}" + rawText + "`"); + break; + } + var token = rawTextScanner.scan(); + if (token === 23 /* CloseBracketToken */) { + token = rawTextScanner.reScanTemplateToken(); + } + if (rawTextScanner.isUnterminated()) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + var tokenValue; + switch (token) { + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + tokenValue = rawTextScanner.getTokenValue(); + break; + } + if (rawTextScanner.scan() !== 1 /* EndOfFileToken */) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + rawTextScanner.setText(undefined); + return tokenValue; + } + function createTemplateLiteralLikeNode(kind, text, rawText) { + var node = createSynthesizedNode(kind); + node.text = text; + if (rawText === undefined || text === rawText) { + node.rawText = rawText; + } + else { + var cooked = getCookedText(kind, rawText); + if (typeof cooked === "object") { + return ts.Debug.fail("Invalid raw text"); + } + ts.Debug.assert(text === cooked, "Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'."); + node.rawText = rawText; + } + return node; + } + function createTemplateHead(text, rawText) { + var node = createTemplateLiteralLikeNode(15 /* TemplateHead */, text, rawText); node.text = text; return node; } ts.createTemplateHead = createTemplateHead; - function createTemplateMiddle(text) { - var node = createSynthesizedNode(16 /* TemplateMiddle */); + function createTemplateMiddle(text, rawText) { + var node = createTemplateLiteralLikeNode(16 /* TemplateMiddle */, text, rawText); node.text = text; return node; } ts.createTemplateMiddle = createTemplateMiddle; - function createTemplateTail(text) { - var node = createSynthesizedNode(17 /* TemplateTail */); + function createTemplateTail(text, rawText) { + var node = createTemplateLiteralLikeNode(17 /* TemplateTail */, text, rawText); node.text = text; return node; } ts.createTemplateTail = createTemplateTail; - function createNoSubstitutionTemplateLiteral(text) { - var node = createSynthesizedNode(14 /* NoSubstitutionTemplateLiteral */); - node.text = text; + function createNoSubstitutionTemplateLiteral(text, rawText) { + var node = createTemplateLiteralLikeNode(14 /* NoSubstitutionTemplateLiteral */, text, rawText); return node; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(208 /* YieldExpression */); + var node = createSynthesizedNode(209 /* YieldExpression */); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; @@ -63549,7 +64374,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(209 /* SpreadElement */); + var node = createSynthesizedNode(210 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -63561,7 +64386,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(210 /* ClassExpression */); + var node = createSynthesizedNode(211 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63582,11 +64407,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(211 /* OmittedExpression */); + return createSynthesizedNode(212 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(212 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(213 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -63600,7 +64425,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(213 /* AsExpression */); + var node = createSynthesizedNode(214 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -63614,7 +64439,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(214 /* NonNullExpression */); + var node = createSynthesizedNode(215 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -63626,7 +64451,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(215 /* MetaProperty */); + var node = createSynthesizedNode(216 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -63640,7 +64465,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(217 /* TemplateSpan */); + var node = createSynthesizedNode(218 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -63654,12 +64479,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(218 /* SemicolonClassElement */); + return createSynthesizedNode(219 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(219 /* Block */); + var block = createSynthesizedNode(220 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -63673,7 +64498,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(220 /* VariableStatement */); + var node = createSynthesizedNode(221 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -63688,11 +64513,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(221 /* EmptyStatement */); + return createSynthesizedNode(222 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(222 /* ExpressionStatement */); + var node = createSynthesizedNode(223 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -63708,7 +64533,7 @@ var ts; /** @deprecated Use `updateExpressionStatement` instead. */ ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(223 /* IfStatement */); + var node = createSynthesizedNode(224 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -63724,7 +64549,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(224 /* DoStatement */); + var node = createSynthesizedNode(225 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; return node; @@ -63738,7 +64563,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(225 /* WhileStatement */); + var node = createSynthesizedNode(226 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -63752,7 +64577,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(226 /* ForStatement */); + var node = createSynthesizedNode(227 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -63770,7 +64595,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(227 /* ForInStatement */); + var node = createSynthesizedNode(228 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -63786,7 +64611,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(228 /* ForOfStatement */); + var node = createSynthesizedNode(229 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -63804,7 +64629,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(229 /* ContinueStatement */); + var node = createSynthesizedNode(230 /* ContinueStatement */); node.label = asName(label); return node; } @@ -63816,7 +64641,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(230 /* BreakStatement */); + var node = createSynthesizedNode(231 /* BreakStatement */); node.label = asName(label); return node; } @@ -63828,7 +64653,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(231 /* ReturnStatement */); + var node = createSynthesizedNode(232 /* ReturnStatement */); node.expression = expression; return node; } @@ -63840,7 +64665,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(232 /* WithStatement */); + var node = createSynthesizedNode(233 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -63854,7 +64679,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(233 /* SwitchStatement */); + var node = createSynthesizedNode(234 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -63868,7 +64693,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(234 /* LabeledStatement */); + var node = createSynthesizedNode(235 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); return node; @@ -63882,7 +64707,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(235 /* ThrowStatement */); + var node = createSynthesizedNode(236 /* ThrowStatement */); node.expression = expression; return node; } @@ -63894,7 +64719,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(236 /* TryStatement */); + var node = createSynthesizedNode(237 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -63910,11 +64735,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(237 /* DebuggerStatement */); + return createSynthesizedNode(238 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(238 /* VariableDeclaration */); + var node = createSynthesizedNode(239 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -63931,7 +64756,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* VariableDeclarationList */); + var node = createSynthesizedNode(240 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -63944,7 +64769,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(240 /* FunctionDeclaration */); + var node = createSynthesizedNode(241 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -63970,7 +64795,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(241 /* ClassDeclaration */); + var node = createSynthesizedNode(242 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63992,7 +64817,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(242 /* InterfaceDeclaration */); + var node = createSynthesizedNode(243 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64014,7 +64839,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(243 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(244 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64034,7 +64859,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(244 /* EnumDeclaration */); + var node = createSynthesizedNode(245 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64053,7 +64878,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(245 /* ModuleDeclaration */); + var node = createSynthesizedNode(246 /* ModuleDeclaration */); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -64072,7 +64897,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(246 /* ModuleBlock */); + var node = createSynthesizedNode(247 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -64084,7 +64909,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(247 /* CaseBlock */); + var node = createSynthesizedNode(248 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -64096,7 +64921,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(248 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(249 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -64108,7 +64933,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(249 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(250 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64126,7 +64951,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ImportDeclaration */); + var node = createSynthesizedNode(251 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -64144,7 +64969,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(251 /* ImportClause */); + var node = createSynthesizedNode(252 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -64158,7 +64983,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(252 /* NamespaceImport */); + var node = createSynthesizedNode(253 /* NamespaceImport */); node.name = name; return node; } @@ -64170,7 +64995,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(253 /* NamedImports */); + var node = createSynthesizedNode(254 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -64182,7 +65007,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(254 /* ImportSpecifier */); + var node = createSynthesizedNode(255 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -64196,7 +65021,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(255 /* ExportAssignment */); + var node = createSynthesizedNode(256 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -64213,7 +65038,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(256 /* ExportDeclaration */); + var node = createSynthesizedNode(257 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -64231,7 +65056,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(257 /* NamedExports */); + var node = createSynthesizedNode(258 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -64243,7 +65068,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(258 /* ExportSpecifier */); + var node = createSynthesizedNode(259 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -64258,7 +65083,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(260 /* ExternalModuleReference */); + var node = createSynthesizedNode(261 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -64272,14 +65097,14 @@ var ts; // JSDoc /* @internal */ function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(289 /* JSDocTypeExpression */); + var node = createSynthesizedNode(290 /* JSDocTypeExpression */); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; /* @internal */ function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(309 /* JSDocTypeTag */, "type"); + var tag = createJSDocTag(311 /* JSDocTypeTag */, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64287,7 +65112,7 @@ var ts; ts.createJSDocTypeTag = createJSDocTypeTag; /* @internal */ function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(307 /* JSDocReturnTag */, "returns"); + var tag = createJSDocTag(309 /* JSDocReturnTag */, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64295,14 +65120,14 @@ var ts; ts.createJSDocReturnTag = createJSDocReturnTag; /** @internal */ function createJSDocThisTag(typeExpression) { - var tag = createJSDocTag(308 /* JSDocThisTag */, "this"); + var tag = createJSDocTag(310 /* JSDocThisTag */, "this"); tag.typeExpression = typeExpression; return tag; } ts.createJSDocThisTag = createJSDocThisTag; /* @internal */ function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(306 /* JSDocParameterTag */, "param"); + var tag = createJSDocTag(308 /* JSDocParameterTag */, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -64312,7 +65137,7 @@ var ts; ts.createJSDocParamTag = createJSDocParamTag; /* @internal */ function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(297 /* JSDocComment */); + var node = createSynthesizedNode(299 /* JSDocComment */); node.comment = comment; node.tags = tags; return node; @@ -64326,7 +65151,7 @@ var ts; } // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(261 /* JsxElement */); + var node = createSynthesizedNode(262 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -64342,7 +65167,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(262 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(263 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64358,7 +65183,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(263 /* JsxOpeningElement */); + var node = createSynthesizedNode(264 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64374,7 +65199,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(264 /* JsxClosingElement */); + var node = createSynthesizedNode(265 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -64386,7 +65211,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(265 /* JsxFragment */); + var node = createSynthesizedNode(266 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -64408,11 +65233,11 @@ var ts; } ts.updateJsxText = updateJsxText; function createJsxOpeningFragment() { - return createSynthesizedNode(266 /* JsxOpeningFragment */); + return createSynthesizedNode(267 /* JsxOpeningFragment */); } ts.createJsxOpeningFragment = createJsxOpeningFragment; function createJsxJsxClosingFragment() { - return createSynthesizedNode(267 /* JsxClosingFragment */); + return createSynthesizedNode(268 /* JsxClosingFragment */); } ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment; function updateJsxFragment(node, openingFragment, children, closingFragment) { @@ -64424,7 +65249,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(268 /* JsxAttribute */); + var node = createSynthesizedNode(269 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -64438,7 +65263,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(269 /* JsxAttributes */); + var node = createSynthesizedNode(270 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -64450,7 +65275,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(270 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(271 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -64462,7 +65287,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(271 /* JsxExpression */); + var node = createSynthesizedNode(272 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -64476,7 +65301,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(272 /* CaseClause */); + var node = createSynthesizedNode(273 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -64490,7 +65315,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(273 /* DefaultClause */); + var node = createSynthesizedNode(274 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -64502,7 +65327,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(274 /* HeritageClause */); + var node = createSynthesizedNode(275 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -64515,7 +65340,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(275 /* CatchClause */); + var node = createSynthesizedNode(276 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -64530,7 +65355,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(276 /* PropertyAssignment */); + var node = createSynthesizedNode(277 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -64545,7 +65370,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(277 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(278 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -64559,7 +65384,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(278 /* SpreadAssignment */); + var node = createSynthesizedNode(279 /* SpreadAssignment */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -64572,7 +65397,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(279 /* EnumMember */); + var node = createSynthesizedNode(280 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -64593,7 +65418,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(285 /* SourceFile */); + var updated = createSynthesizedNode(286 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -64677,7 +65502,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(314 /* NotEmittedStatement */); + var node = createSynthesizedNode(316 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -64689,7 +65514,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(318 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(320 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -64701,7 +65526,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(317 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(319 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -64716,7 +65541,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(315 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(317 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -64732,7 +65557,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 316 /* CommaListExpression */) { + if (node.kind === 318 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { @@ -64742,7 +65567,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(316 /* CommaListExpression */); + var node = createSynthesizedNode(318 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -64755,7 +65580,7 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(286 /* Bundle */); + var node = ts.createNode(287 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -64786,7 +65611,7 @@ var ts; ], function (helper) { return helper.name; })); } function createUnparsedSource() { - var node = ts.createNode(287 /* UnparsedSource */); + var node = ts.createNode(288 /* UnparsedSource */); node.prologues = ts.emptyArray; node.referencedFiles = ts.emptyArray; node.libReferenceDirectives = ts.emptyArray; @@ -64918,10 +65743,10 @@ var ts; } function mapBundleFileSectionKindToSyntaxKind(kind) { switch (kind) { - case "prologue" /* Prologue */: return 280 /* UnparsedPrologue */; - case "prepend" /* Prepend */: return 281 /* UnparsedPrepend */; - case "internal" /* Internal */: return 283 /* UnparsedInternalText */; - case "text" /* Text */: return 282 /* UnparsedText */; + case "prologue" /* Prologue */: return 281 /* UnparsedPrologue */; + case "prepend" /* Prepend */: return 282 /* UnparsedPrepend */; + case "internal" /* Internal */: return 284 /* UnparsedInternalText */; + case "text" /* Text */: return 283 /* UnparsedText */; case "emitHelpers" /* EmitHelpers */: case "no-default-lib" /* NoDefaultLib */: case "reference" /* Reference */: @@ -64939,14 +65764,14 @@ var ts; return node; } function createUnparsedSyntheticReference(section, parent) { - var node = ts.createNode(284 /* UnparsedSyntheticReference */, section.pos, section.end); + var node = ts.createNode(285 /* UnparsedSyntheticReference */, section.pos, section.end); node.parent = parent; node.data = section.data; node.section = section; return node; } function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { - var node = ts.createNode(288 /* InputFiles */); + var node = ts.createNode(289 /* InputFiles */); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -64992,8 +65817,8 @@ var ts; node.declarationMapPath = declarationMapPath; node.declarationMapText = declarationMapTextOrBuildInfoPath; node.javascriptPath = javascriptPath; - node.declarationPath = declarationPath, - node.buildInfoPath = buildInfoPath; + node.declarationPath = declarationPath; + node.buildInfoPath = buildInfoPath; node.buildInfo = buildInfo; node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } @@ -65136,7 +65961,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 === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -65201,7 +66026,6 @@ var ts; return node; } ts.setSourceMapRange = setSourceMapRange; - // tslint:disable-next-line variable-name var SourceMapSource; /** * Create an external source map source file reference @@ -65487,9 +66311,9 @@ var ts; ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createFunctionCall(func, thisArg, argumentsList, location) { return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ thisArg - ].concat(argumentsList)), location); + ], argumentsList)), location); } ts.createFunctionCall = createFunctionCall; function createFunctionApply(func, thisArg, argumentsExpression, location) { @@ -65590,29 +66414,34 @@ var ts; } ts.createExpressionForJsxFragment = createExpressionForJsxFragment; // Helpers - function getHelperName(name) { + /** + * Gets an identifier for the name of an *unscoped* emit helper. + */ + function getUnscopedHelperName(name) { return ts.setEmitFlags(ts.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } - ts.getHelperName = getHelperName; + ts.getUnscopedHelperName = getUnscopedHelperName; ts.valuesHelper = { name: "typescript:values", + importName: "__values", scoped: false, - text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };" + text: "\n var __values = (this && this.__values) || function(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n };" }; function createValuesHelper(context, expression, location) { context.requestEmitHelper(ts.valuesHelper); - return ts.setTextRange(ts.createCall(getHelperName("__values"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__values"), /*typeArguments*/ undefined, [expression]), location); } ts.createValuesHelper = createValuesHelper; ts.readHelper = { name: "typescript:read", + importName: "__read", scoped: false, text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };" }; function createReadHelper(context, iteratorRecord, count, location) { context.requestEmitHelper(ts.readHelper); - return ts.setTextRange(ts.createCall(getHelperName("__read"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__read"), /*typeArguments*/ undefined, count !== undefined ? [iteratorRecord, ts.createLiteral(count)] : [iteratorRecord]), location); @@ -65620,24 +66449,26 @@ var ts; ts.createReadHelper = createReadHelper; ts.spreadHelper = { name: "typescript:spread", + importName: "__spread", scoped: false, text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" }; function createSpreadHelper(context, argumentList, location) { context.requestEmitHelper(ts.readHelper); context.requestEmitHelper(ts.spreadHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spread"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spread"), /*typeArguments*/ undefined, argumentList), location); } ts.createSpreadHelper = createSpreadHelper; ts.spreadArraysHelper = { name: "typescript:spreadArrays", + importName: "__spreadArrays", scoped: false, text: "\n var __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n };" }; function createSpreadArraysHelper(context, argumentList, location) { context.requestEmitHelper(ts.spreadArraysHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spreadArrays"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spreadArrays"), /*typeArguments*/ undefined, argumentList), location); } ts.createSpreadArraysHelper = createSpreadArraysHelper; @@ -65659,7 +66490,7 @@ var ts; ts.createForOfBindingStatement = createForOfBindingStatement; function insertLeadingStatement(dest, source) { if (ts.isBlock(dest)) { - return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray([source].concat(dest.statements)), dest.statements)); + return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray(__spreadArrays([source], dest.statements)), dest.statements)); } else { return ts.createBlock(ts.createNodeArray([dest, source]), /*multiLine*/ true); @@ -65670,7 +66501,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 234 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 235 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -65689,13 +66520,13 @@ var ts; case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -65722,7 +66553,7 @@ var ts; } else { switch (callee.kind) { - case 190 /* PropertyAccessExpression */: { + case 191 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -65735,7 +66566,7 @@ var ts; } break; } - case 191 /* ElementAccessExpression */: { + case 192 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -65792,14 +66623,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -66106,9 +66937,9 @@ var ts; function ensureUseStrict(statements) { var foundUseStrict = findUseStrictPrologue(statements); if (!foundUseStrict) { - return ts.setTextRange(ts.createNodeArray([ + return ts.setTextRange(ts.createNodeArray(__spreadArrays([ startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) - ].concat(statements)), statements); + ], statements)), statements); } return statements; } @@ -66125,7 +66956,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 === 196 /* ParenthesizedExpression */) { + if (skipped.kind === 197 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -66159,10 +66990,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(205 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(205 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(206 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(206 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 198 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 199 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -66174,7 +67005,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 208 /* YieldExpression */) { + && operand.kind === 209 /* YieldExpression */) { return false; } return true; @@ -66262,22 +67093,20 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { + if (node.kind === 206 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0 /* Unknown */; + var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind : + 0 /* Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(206 /* ConditionalExpression */, 56 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(207 /* ConditionalExpression */, 56 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -66312,8 +67141,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: + case 211 /* ClassExpression */: + case 198 /* FunctionExpression */: needsParens = true; } } @@ -66329,9 +67158,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 192 /* CallExpression */: + case 193 /* CallExpression */: return ts.createParen(expression); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -66354,7 +67183,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 193 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 194 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -66392,7 +67221,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(205 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(206 /* BinaryExpression */, 27 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -66403,29 +67232,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 197 /* FunctionExpression */ || kind === 198 /* ArrowFunction */) { + if (kind === 198 /* FunctionExpression */ || kind === 199 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 189 /* ObjectLiteralExpression */ || leftmostExpressionKind === 197 /* FunctionExpression */) { + if (leftmostExpressionKind === 190 /* ObjectLiteralExpression */ || leftmostExpressionKind === 198 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 176 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 177 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -66433,9 +67262,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 168 /* TypeQuery */: - case 180 /* TypeOperator */: - case 177 /* InferType */: + case 169 /* TypeQuery */: + case 181 /* TypeOperator */: + case 178 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -66461,28 +67290,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: node = node.operand; continue; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: node = node.left; continue; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: node = node.condition; continue; - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: node = node.tag; continue; - case 192 /* CallExpression */: + case 193 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 213 /* AsExpression */: - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: - case 214 /* NonNullExpression */: - case 315 /* PartiallyEmittedExpression */: + case 214 /* AsExpression */: + case 192 /* ElementAccessExpression */: + case 191 /* PropertyAccessExpression */: + case 215 /* NonNullExpression */: + case 317 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -66491,15 +67320,15 @@ var ts; } ts.getLeftmostExpression = getLeftmostExpression; function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 189 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 190 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 316 /* CommaListExpression */; + return node.kind === 206 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 318 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -66512,13 +67341,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 214 /* NonNullExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: + case 215 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -66543,7 +67372,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 214 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 215 /* NonNullExpression */) { node = node.expression; } return node; @@ -66551,11 +67380,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 196 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 195 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 213 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 214 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 315 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 197 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 196 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 214 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 215 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 317 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -66573,7 +67402,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 196 /* ParenthesizedExpression */ + return node.kind === 197 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -66598,6 +67427,60 @@ var ts; return emitNode && emitNode.externalHelpersModuleName; } ts.getExternalHelpersModuleName = getExternalHelpersModuleName; + function hasRecordedExternalHelpers(sourceFile) { + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = parseNode && parseNode.emitNode; + return !!emitNode && (!!emitNode.externalHelpersModuleName || !!emitNode.externalHelpers); + } + ts.hasRecordedExternalHelpers = hasRecordedExternalHelpers; + function createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault) { + if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + var namedBindings = void 0; + var moduleKind = ts.getEmitModuleKind(compilerOptions); + if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) { + // use named imports + var helpers = ts.getEmitHelpers(sourceFile); + if (helpers) { + var helperNames = []; + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; + if (!helper.scoped) { + var importName = helper.importName; + if (importName) { + ts.pushIfUnique(helperNames, importName); + } + } + } + if (ts.some(helperNames)) { + helperNames.sort(ts.compareStringsCaseSensitive); + // Alias the imports if the names are used somewhere in the file. + // NOTE: We don't need to care about global import collisions as this is a module. + namedBindings = ts.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name) + ? ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name)) + : ts.createImportSpecifier(ts.createIdentifier(name), getUnscopedHelperName(name)); })); + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = ts.getOrCreateEmitNode(parseNode); + emitNode.externalHelpers = true; + } + } + } + else { + // use a namespace import + var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar || hasImportDefault); + if (externalHelpersModuleName) { + namedBindings = ts.createNamespaceImport(externalHelpersModuleName); + } + } + if (namedBindings) { + var externalHelpersImportDeclaration = ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, namedBindings), ts.createLiteral(ts.externalHelpersModuleNameText)); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); + return externalHelpersImportDeclaration; + } + } + } + ts.createExternalHelpersImportDeclarationIfNeeded = createExternalHelpersImportDeclarationIfNeeded; function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault) { if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(node, compilerOptions)) { var externalHelpersModuleName = getExternalHelpersModuleName(node); @@ -66612,8 +67495,8 @@ var ts; if (!create) { var helpers = ts.getEmitHelpers(node); if (helpers) { - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; + for (var _i = 0, helpers_3 = helpers; _i < helpers_3.length; _i++) { + var helper = helpers_3[_i]; if (!helper.scoped) { create = true; break; @@ -66638,10 +67521,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 250 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 251 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 256 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 257 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -66760,7 +67643,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -66772,11 +67655,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -66808,12 +67691,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 153 /* Parameter */: + case 188 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 209 /* SpreadElement */: - case 278 /* SpreadAssignment */: + case 210 /* SpreadElement */: + case 279 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -66825,7 +67708,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 187 /* BindingElement */: + case 188 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -66837,7 +67720,7 @@ var ts; : propertyName; } break; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -66849,7 +67732,7 @@ var ts; : propertyName; } break; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -66872,13 +67755,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: + case 189 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -66918,11 +67801,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 187 /* ArrayBindingPattern */: + case 189 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 186 /* ObjectBindingPattern */: + case 190 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -67045,11 +67928,9 @@ var ts; function visitLexicalEnvironment(statements, visitor, context, start, ensureUseStrict) { context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); - if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); - } - var declarations = context.endLexicalEnvironment(); - return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); + if (ensureUseStrict) + statements = ts.ensureUseStrict(statements); // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier + return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment()); } ts.visitLexicalEnvironment = visitLexicalEnvironment; /** @@ -67083,278 +67964,278 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */) || kind === 179 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 149 /* LastToken */) || kind === 180 /* ThisType */) { return node; } switch (kind) { // Names case 73 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 152 /* Parameter */: + case 153 /* Parameter */: return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 153 /* Decorator */: + case 154 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 154 /* PropertySignature */: + case 155 /* PropertySignature */: return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too visitNode(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 156 /* MethodSignature */: + case 157 /* MethodSignature */: return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 158 /* Constructor */: + case 159 /* Constructor */: return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 159 /* GetAccessor */: + case 160 /* GetAccessor */: return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 161 /* CallSignature */: + case 162 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); // Types - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 166 /* FunctionType */: + case 167 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 167 /* ConstructorType */: + case 168 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 171 /* TupleType */: + case 172 /* TupleType */: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 172 /* OptionalType */: + case 173 /* OptionalType */: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 173 /* RestType */: + case 174 /* RestType */: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174 /* UnionType */: + case 175 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 175 /* IntersectionType */: + case 176 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 177 /* InferType */: + case 178 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 184 /* ImportType */: + case 185 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 182 /* MappedType */: + case 183 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 183 /* LiteralType */: + case 184 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 186 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 213 /* AsExpression */: + case 214 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 219 /* Block */: + case 220 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 229 /* ContinueStatement */: + case 230 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 230 /* BreakStatement */: + case 231 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 253 /* NamedImports */: + case 254 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 257 /* NamedExports */: + case 258 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 258 /* ExportSpecifier */: + case 259 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 261 /* JsxElement */: + case 262 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 263 /* JsxOpeningElement */: + case 264 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 272 /* CaseClause */: + case 273 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 279 /* EnumMember */: + case 280 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 285 /* SourceFile */: + case 286 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -67396,58 +68277,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 149 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 164 /* TypePredicate */ && kind <= 183 /* LiteralType */)) { + if ((kind >= 165 /* TypePredicate */ && kind <= 184 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 218 /* SemicolonClassElement */: - case 221 /* EmptyStatement */: - case 211 /* OmittedExpression */: - case 237 /* DebuggerStatement */: - case 314 /* NotEmittedStatement */: + case 219 /* SemicolonClassElement */: + case 222 /* EmptyStatement */: + case 212 /* OmittedExpression */: + case 238 /* DebuggerStatement */: + case 316 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 152 /* Parameter */: + case 153 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 153 /* Decorator */: + case 154 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 154 /* PropertySignature */: + case 155 /* PropertySignature */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67456,12 +68337,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 158 /* Constructor */: + case 159 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 159 /* GetAccessor */: + case 160 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67469,7 +68350,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67477,50 +68358,50 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 187 /* BindingElement */: + case 188 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 192 /* CallExpression */: + case 193 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 193 /* NewExpression */: + case 194 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -67528,123 +68409,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 196 /* ParenthesizedExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 197 /* ParenthesizedExpression */: + case 200 /* DeleteExpression */: + case 201 /* TypeOfExpression */: + case 202 /* VoidExpression */: + case 203 /* AwaitExpression */: + case 209 /* YieldExpression */: + case 210 /* SpreadElement */: + case 215 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 213 /* AsExpression */: + case 214 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 219 /* Block */: + case 220 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 223 /* IfStatement */: + case 224 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 224 /* DoStatement */: + case 225 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 225 /* WhileStatement */: - case 232 /* WithStatement */: + case 226 /* WhileStatement */: + case 233 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 226 /* ForStatement */: + case 227 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 232 /* ReturnStatement */: + case 236 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 236 /* TryStatement */: + case 237 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67653,7 +68534,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67661,140 +68542,140 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.members, cbNodes, result); break; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 251 /* ImportClause */: + case 252 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 254 /* NamedImports */: + case 258 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 255 /* ImportSpecifier */: + case 259 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // Module references - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 261 /* JsxElement */: + case 262 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 264 /* JsxClosingElement */: + case 265 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 272 /* CaseClause */: + case 273 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 275 /* CatchClause */: + case 276 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 279 /* EnumMember */: + case 280 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 285 /* SourceFile */: + case 286 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -67867,7 +68748,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 212 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 213 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -67940,19 +68821,20 @@ var ts; exit(); return sourceIndex; } + /* eslint-disable boolean-trivia, no-null/no-null */ function setSourceContent(sourceIndex, content) { enter(); if (content !== null) { if (!sourcesContent) sourcesContent = []; while (sourcesContent.length < sourceIndex) { - // tslint:disable-next-line:no-null-keyword boolean-trivia sourcesContent.push(null); } sourcesContent[sourceIndex] = content; } exit(); } + /* eslint-enable boolean-trivia, no-null/no-null */ function addName(name) { enter(); if (!nameToNameIndexMap) @@ -68155,12 +69037,11 @@ var ts; } } ts.tryGetSourceMappingURL = tryGetSourceMappingURL; + /* eslint-disable no-null/no-null */ function isStringOrNull(x) { - // tslint:disable-next-line:no-null-keyword return typeof x === "string" || x === null; } function isRawSourceMap(x) { - // tslint:disable-next-line:no-null-keyword return x !== null && typeof x === "object" && x.version === 3 @@ -68172,6 +69053,7 @@ var ts; && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString)); } ts.isRawSourceMap = isRawSourceMap; + /* eslint-enable no-null/no-null */ function tryParseRawSourceMap(text) { try { var parsed = JSON.parse(text); @@ -68540,7 +69422,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 285 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 286 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -68582,25 +69464,31 @@ var ts; var hasExportDefault = false; var exportEquals; var hasExportStarsToExportValues = false; - var hasImportStarOrImportDefault = false; + var hasImportStar = false; + var hasImportDefault = false; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); - hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); + if (!hasImportStar && getImportNeedsImportStarHelper(node)) { + hasImportStar = true; + } + if (!hasImportDefault && getImportNeedsImportDefaultHelper(node)) { + hasImportDefault = true; + } break; - case 249 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + case 250 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 261 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -68630,13 +69518,13 @@ var ts; } } break; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -68644,7 +69532,7 @@ var ts; } } break; - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -68664,7 +69552,7 @@ var ts; } } break; - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -68686,12 +69574,8 @@ var ts; break; } } - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault); - var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault); if (externalHelpersImportDeclaration) { - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); externalImports.unshift(externalHelpersImportDeclaration); } return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames, externalHelpersImportDeclaration: externalHelpersImportDeclaration }; @@ -68766,7 +69650,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 223 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -68830,7 +69714,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 155 /* PropertyDeclaration */ + return member.kind === 156 /* PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; @@ -69279,6 +70163,7 @@ var ts; } ts.restHelper = { name: "typescript:rest", + importName: "__rest", scoped: false, text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n };" }; @@ -69303,7 +70188,7 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), + return ts.createCall(ts.getUnscopedHelperName("__rest"), /*typeArguments*/ undefined, [ value, ts.setTextRange(ts.createArrayLiteral(propertyNames), location) @@ -69356,8 +70241,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(191 /* PropertyAccessExpression */); + context.enableSubstitution(192 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -69383,14 +70268,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 286 /* Bundle */) { + if (node.kind === 287 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288 /* InputFiles */) { + if (prepend.kind === 289 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -69441,16 +70326,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 246 /* ModuleBlock */: - case 219 /* Block */: + case 286 /* SourceFile */: + case 248 /* CaseBlock */: + case 247 /* ModuleBlock */: + case 220 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 241 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -69462,7 +70347,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 === 241 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 242 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -69505,10 +70390,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 256 /* ExportAssignment */: + case 257 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -69529,13 +70414,13 @@ var ts; return node; } switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -69555,11 +70440,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 256 /* ExportDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 251 /* ImportClause */ || - (node.kind === 249 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 260 /* ExternalModuleReference */)) { + if (node.kind === 257 /* ExportDeclaration */ || + node.kind === 251 /* ImportDeclaration */ || + node.kind === 252 /* ImportClause */ || + (node.kind === 250 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 261 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -69583,19 +70468,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: return visitConstructor(node); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 164 /* IndexSignature */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 158 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 218 /* SemicolonClassElement */: + case 219 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -69633,14 +70518,15 @@ var ts; case 78 /* ConstKeyword */: case 126 /* DeclareKeyword */: case 134 /* ReadonlyKeyword */: - // TypeScript accessibility and readonly modifiers are elided. - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 169 /* TypeLiteral */: - case 164 /* TypePredicate */: - case 151 /* TypeParameter */: + // TypeScript accessibility and readonly modifiers are elided + // falls through + case 171 /* ArrayType */: + case 172 /* TupleType */: + case 173 /* OptionalType */: + case 174 /* RestType */: + case 170 /* TypeLiteral */: + case 165 /* TypePredicate */: + case 152 /* TypeParameter */: case 121 /* AnyKeyword */: case 144 /* UnknownKeyword */: case 124 /* BooleanKeyword */: @@ -69649,40 +70535,43 @@ var ts; case 133 /* NeverKeyword */: case 107 /* VoidKeyword */: case 140 /* SymbolKeyword */: - case 167 /* ConstructorType */: - case 166 /* FunctionType */: - case 168 /* TypeQuery */: - case 165 /* TypeReference */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 178 /* ParenthesizedType */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: + case 168 /* ConstructorType */: + case 167 /* FunctionType */: + case 169 /* TypeQuery */: + case 166 /* TypeReference */: + case 175 /* UnionType */: + case 176 /* IntersectionType */: + case 177 /* ConditionalType */: + case 179 /* ParenthesizedType */: + case 180 /* ThisType */: + case 181 /* TypeOperator */: + case 182 /* IndexedAccessType */: + case 183 /* MappedType */: + case 184 /* LiteralType */: // TypeScript type nodes are elided. - case 163 /* IndexSignature */: + // falls through + case 164 /* IndexSignature */: // TypeScript index signatures are elided. - case 153 /* Decorator */: + // falls through + case 154 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 243 /* TypeAliasDeclaration */: + // falls through + case 244 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 155 /* PropertyDeclaration */: + case 156 /* 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 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 158 /* Constructor */: + case 159 /* Constructor */: return visitConstructor(node); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -69692,7 +70581,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -69702,35 +70591,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 159 /* GetAccessor */: + case 160 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 160 /* SetAccessor */: + case 161 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 152 /* Parameter */: + case 153 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -69740,35 +70629,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* TypeAssertionExpression */: + case 214 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return visitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -70072,7 +70961,7 @@ var ts; var members = []; var constructor = ts.getFirstConstructorWithBody(node); var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (parametersWithPropertyAssignments) { for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) { var parameter = parametersWithPropertyAssignments_1[_i]; @@ -70178,12 +71067,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -70336,7 +71225,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 155 /* PropertyDeclaration */ + ? member.kind === 156 /* 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`. ? ts.createVoidZero() @@ -70459,10 +71348,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 155 /* PropertyDeclaration */; + return kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */ + || kind === 156 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -70472,7 +71361,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 158 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -70483,12 +71372,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return true; } return false; @@ -70505,15 +71394,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 153 /* Parameter */: return serializeTypeNode(node.type); - case 160 /* SetAccessor */: - case 159 /* GetAccessor */: + case 161 /* SetAccessor */: + case 160 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 157 /* MethodDeclaration */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 158 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -70550,7 +71439,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 159 /* GetAccessor */) { + if (container && node.kind === 160 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -70600,26 +71489,26 @@ var ts; case 97 /* NullKeyword */: case 133 /* NeverKeyword */: return ts.createVoidZero(); - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: return ts.createIdentifier("Function"); - case 170 /* ArrayType */: - case 171 /* TupleType */: + case 171 /* ArrayType */: + case 172 /* TupleType */: return ts.createIdentifier("Array"); - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: case 124 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); case 139 /* StringKeyword */: return ts.createIdentifier("String"); case 137 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 183 /* LiteralType */: + case 184 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: return ts.createIdentifier("String"); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); case 9 /* BigIntLiteral */: @@ -70638,26 +71527,26 @@ var ts; return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return serializeTypeReferenceNode(node); - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 176 /* IntersectionType */: + case 175 /* UnionType */: return serializeTypeList(node.types); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: if (node.operator === 134 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 168 /* TypeQuery */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 169 /* TypeLiteral */: + case 169 /* TypeQuery */: + case 182 /* IndexedAccessType */: + case 183 /* MappedType */: + case 170 /* TypeLiteral */: case 121 /* AnyKeyword */: case 144 /* UnknownKeyword */: - case 179 /* ThisType */: - case 184 /* ImportType */: + case 180 /* ThisType */: + case 185 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -70668,9 +71557,9 @@ var ts; // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var typeNode = types_18[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var typeNode = types_17[_i]; + while (typeNode.kind === 179 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 133 /* NeverKeyword */) { @@ -70785,7 +71674,7 @@ var ts; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. return name; - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -70919,7 +71808,7 @@ var ts; } function transformConstructorBody(body, constructor) { var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (!ts.some(parametersWithPropertyAssignments)) { return ts.visitFunctionBody(body, visitor, context); } @@ -71332,12 +72221,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 285 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 286 /* 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 === 244 /* EnumDeclaration */) { + if (node.kind === 245 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -71462,7 +72351,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 246 /* ModuleBlock */) { + if (body.kind === 247 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -71508,13 +72397,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 (body.kind !== 246 /* ModuleBlock */) { + if (body.kind !== 247 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 246 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -71555,7 +72444,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 252 /* NamespaceImport */) { + if (node.kind === 253 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -71787,16 +72676,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(73 /* Identifier */); - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); + context.enableSubstitution(278 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(245 /* ModuleDeclaration */); + context.enableEmitNotification(246 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 245 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 246 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 244 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 245 /* EnumDeclaration */; } /** * Hook for node emit. @@ -71857,9 +72746,9 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return substituteExpressionIdentifier(node); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -71897,9 +72786,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 !== 285 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 245 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 244 /* EnumDeclaration */); + if (container && container.kind !== 286 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 246 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 245 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -71949,18 +72838,19 @@ var ts; } } context.requestEmitHelper(ts.decorateHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray), location); } ts.decorateHelper = { name: "typescript:decorate", + importName: "__decorate", scoped: false, priority: 2, text: "\n var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n };" }; function createMetadataHelper(context, metadataKey, metadataValue) { context.requestEmitHelper(ts.metadataHelper); - return ts.createCall(ts.getHelperName("__metadata"), + return ts.createCall(ts.getUnscopedHelperName("__metadata"), /*typeArguments*/ undefined, [ ts.createLiteral(metadataKey), metadataValue @@ -71968,13 +72858,14 @@ var ts; } ts.metadataHelper = { name: "typescript:metadata", + importName: "__metadata", scoped: false, priority: 3, text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(ts.paramHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__param"), /*typeArguments*/ undefined, [ ts.createLiteral(parameterOffset), expression @@ -71982,6 +72873,7 @@ var ts; } ts.paramHelper = { name: "typescript:param", + importName: "__param", scoped: false, priority: 4, text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" @@ -72035,11 +72927,11 @@ var ts; if (!(node.transformFlags & 1048576 /* ContainsClassFields */)) return node; switch (node.kind) { - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return visitClassExpression(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); } return ts.visitEachChild(node, visitor, context); @@ -72051,20 +72943,20 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 158 /* Constructor */: + case 159 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 158 /* MethodDeclaration */: // Visit the name of the member (if it's a computed property name). return ts.visitEachChild(node, classElementVisitor, context); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 218 /* SemicolonClassElement */: + case 219 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -72074,7 +72966,7 @@ var ts; var savedPendingStatements = pendingStatements; pendingStatements = []; var visitedNode = ts.visitEachChild(node, visitor, context); - var statement = ts.some(pendingStatements) ? [visitedNode].concat(pendingStatements) : + var statement = ts.some(pendingStatements) ? __spreadArrays([visitedNode], pendingStatements) : visitedNode; pendingStatements = savedPendingStatements; return statement; @@ -72244,7 +73136,7 @@ var ts; if (constructor && constructor.body) { var parameterPropertyDeclarationCount = 0; for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) { - if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]))) { + if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) { parameterPropertyDeclarationCount++; } else { @@ -72426,6 +73318,7 @@ var ts; var hasSuperElementAccess; /** A set of node IDs for generated super accessors (variable statements). */ var substitutedSuperAccessors = []; + var topLevel; // Save the previous transformation hooks. var previousOnEmitNode = context.onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; @@ -72437,10 +73330,23 @@ var ts; if (node.isDeclarationFile) { return node; } + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitor(node) { if ((node.transformFlags & 32 /* ContainsES2017 */) === 0) { return node; @@ -72449,26 +73355,32 @@ var ts; case 122 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return visitAwaitExpression(node); - case 157 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 240 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: - return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 158 /* MethodDeclaration */: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 241 /* FunctionDeclaration */: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 198 /* FunctionExpression */: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 199 /* ArrowFunction */: return visitArrowFunction(node); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 159 /* Constructor */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -72476,27 +73388,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 219 /* Block */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 232 /* WithStatement */: - case 234 /* LabeledStatement */: + case 220 /* Block */: + case 234 /* SwitchStatement */: + case 248 /* CaseBlock */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: + case 237 /* TryStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: + case 224 /* IfStatement */: + case 233 /* WithStatement */: + case 235 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -72697,7 +73609,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 === 198 /* ArrowFunction */; + var isArrowFunction = node.kind === 199 /* 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 @@ -72720,7 +73632,7 @@ var ts; if (!isArrowFunction) { var statements = []; var statementOffset = ts.addPrologue(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); - statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); + statements.push(ts.createReturn(createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. @@ -72747,7 +73659,7 @@ var ts; result = block; } else { - var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); + var expression = createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); @@ -72788,17 +73700,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(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(193 /* CallExpression */); + context.enableSubstitution(191 /* PropertyAccessExpression */); + context.enableSubstitution(192 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(242 /* ClassDeclaration */); + context.enableEmitNotification(158 /* MethodDeclaration */); + context.enableEmitNotification(160 /* GetAccessor */); + context.enableEmitNotification(161 /* SetAccessor */); + context.enableEmitNotification(159 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(221 /* VariableStatement */); } } /** @@ -72846,11 +73758,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -72874,19 +73786,19 @@ var ts; ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 242 /* ClassDeclaration */ + || kind === 159 /* Constructor */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -72946,11 +73858,12 @@ var ts; ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; ts.awaiterHelper = { name: "typescript:awaiter", + importName: "__awaiter", scoped: false, priority: 5, text: "\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };" }; - function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { + function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression( /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), @@ -72960,9 +73873,9 @@ var ts; /*type*/ undefined, body); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; - return ts.createCall(ts.getHelperName("__awaiter"), + return ts.createCall(ts.getUnscopedHelperName("__awaiter"), /*typeArguments*/ undefined, [ - ts.createThis(), + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), generatorFunc @@ -72996,9 +73909,11 @@ var ts; context.onEmitNode = onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; + var exportedVariableStatement = false; var enabledSubstitutions; var enclosingFunctionFlags; var enclosingSuperContainerFlags = 0; + var topLevel; /** Keeps track of property names accessed on super (`super.x`) within async functions. */ var capturedSuperProperties; /** Whether the async function contains an element access on super (`super[x]`). */ @@ -73010,6 +73925,8 @@ var ts; if (node.isDeclarationFile) { return node; } + exportedVariableStatement = false; + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -73026,63 +73943,80 @@ var ts; } return node; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitorWorker(node, noDestructuringValue) { if ((node.transformFlags & 16 /* ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return visitAwaitExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return visitYieldExpression(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitReturnStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitLabeledStatement(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClause(node); - case 238 /* VariableDeclaration */: + case 221 /* VariableStatement */: + return visitVariableStatement(node); + case 239 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return visitVoidExpression(node); - case 158 /* Constructor */: - return visitConstructorDeclaration(node); - case 157 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - return visitGetAccessorDeclaration(node); - case 160 /* SetAccessor */: - return visitSetAccessorDeclaration(node); - case 240 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: - return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 159 /* Constructor */: + return doOutsideOfTopLevel(visitConstructorDeclaration, node); + case 158 /* MethodDeclaration */: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 160 /* GetAccessor */: + return doOutsideOfTopLevel(visitGetAccessorDeclaration, node); + case 161 /* SetAccessor */: + return doOutsideOfTopLevel(visitSetAccessorDeclaration, node); + case 241 /* FunctionDeclaration */: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 198 /* FunctionExpression */: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 199 /* ArrowFunction */: return visitArrowFunction(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return visitParameter(node); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return visitExpressionStatement(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -73115,7 +74049,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 228 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 229 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -73127,7 +74061,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 === 278 /* SpreadAssignment */) { + if (e.kind === 279 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -73136,7 +74070,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 276 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 277 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -73170,7 +74104,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 !== 189 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 190 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } var expression = objects[0]; @@ -73215,23 +74149,44 @@ var ts; var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { - block = ts.updateBlock(block, [ + block = ts.updateBlock(block, __spreadArrays([ ts.createVariableStatement(/*modifiers*/ undefined, visitedBindings) - ].concat(block.statements)); + ], block.statements)); } return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, /*type*/ undefined, /*initializer*/ undefined), block); } return ts.visitEachChild(node, visitor, context); } + function visitVariableStatement(node) { + if (ts.hasModifier(node, 1 /* Export */)) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = true; + var visited = ts.visitEachChild(node, visitor, context); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return ts.visitEachChild(node, visitor, context); + } /** * Visits a VariableDeclaration node with a binding pattern. * * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { + if (exportedVariableStatement) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = false; + var visited = visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ true); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ false); + } + 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 & 8192 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */); + return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, + /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); } @@ -73449,7 +74404,7 @@ var ts; /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))))); + /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !topLevel)); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); @@ -73515,17 +74470,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(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(193 /* CallExpression */); + context.enableSubstitution(191 /* PropertyAccessExpression */); + context.enableSubstitution(192 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(242 /* ClassDeclaration */); + context.enableEmitNotification(158 /* MethodDeclaration */); + context.enableEmitNotification(160 /* GetAccessor */); + context.enableEmitNotification(161 /* SetAccessor */); + context.enableEmitNotification(159 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(221 /* VariableStatement */); } } /** @@ -73573,11 +74528,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -73601,19 +74556,19 @@ var ts; ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 242 /* ClassDeclaration */ + || kind === 159 /* Constructor */ + || kind === 158 /* MethodDeclaration */ + || kind === 160 /* GetAccessor */ + || kind === 161 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -73629,65 +74584,69 @@ var ts; ts.transformES2018 = transformES2018; ts.assignHelper = { name: "typescript:assign", + importName: "__assign", scoped: false, priority: 1, text: "\n var __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n };" }; function createAssignHelper(context, attributesSegments) { if (context.getCompilerOptions().target >= 2 /* ES2015 */) { - return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), - /*typeArguments*/ undefined, attributesSegments); + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } context.requestEmitHelper(ts.assignHelper); - return ts.createCall(ts.getHelperName("__assign"), + return ts.createCall(ts.getUnscopedHelperName("__assign"), /*typeArguments*/ undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; ts.awaitHelper = { name: "typescript:await", + importName: "__await", scoped: false, text: "\n var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }" }; function createAwaitHelper(context, expression) { context.requestEmitHelper(ts.awaitHelper); - return ts.createCall(ts.getHelperName("__await"), /*typeArguments*/ undefined, [expression]); + return ts.createCall(ts.getUnscopedHelperName("__await"), /*typeArguments*/ undefined, [expression]); } ts.asyncGeneratorHelper = { name: "typescript:asyncGenerator", + importName: "__asyncGenerator", scoped: false, text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n };" }; - function createAsyncGeneratorHelper(context, generatorFunc) { + function createAsyncGeneratorHelper(context, generatorFunc, hasLexicalThis) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */; - return ts.createCall(ts.getHelperName("__asyncGenerator"), + return ts.createCall(ts.getUnscopedHelperName("__asyncGenerator"), /*typeArguments*/ undefined, [ - ts.createThis(), + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), ts.createIdentifier("arguments"), generatorFunc ]); } ts.asyncDelegator = { name: "typescript:asyncDelegator", + importName: "__asyncDelegator", scoped: false, text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\n };" }; function createAsyncDelegatorHelper(context, expression, location) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncDelegator); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncDelegator"), /*typeArguments*/ undefined, [expression]), location); } ts.asyncValues = { name: "typescript:asyncValues", + importName: "__asyncValues", scoped: false, text: "\n var __asyncValues = (this && this.__asyncValues) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n };" }; function createAsyncValuesHelper(context, expression, location) { context.requestEmitHelper(ts.asyncValues); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncValues"), /*typeArguments*/ undefined, [expression]), location); } })(ts || (ts = {})); @@ -73707,7 +74666,7 @@ var ts; return node; } switch (node.kind) { - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -73776,13 +74735,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 261 /* JsxElement */: + case 262 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -73792,13 +74751,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return visitJsxExpression(node); - case 261 /* JsxElement */: + case 262 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -73873,7 +74832,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 271 /* JsxExpression */) { + else if (node.kind === 272 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -73967,7 +74926,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 261 /* JsxElement */) { + if (node.kind === 262 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -74273,7 +75232,7 @@ var ts; return node; } switch (node.kind) { - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74486,13 +75445,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 231 /* ReturnStatement */ + && node.kind === 232 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */))) + || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 220 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -74514,63 +75473,63 @@ var ts; switch (node.kind) { case 117 /* StaticKeyword */: return undefined; // elide static keyword - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return visitClassExpression(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return visitParameter(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return visitArrowFunction(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return visitFunctionExpression(node); - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return visitVariableDeclaration(node); case 73 /* Identifier */: return visitIdentifier(node); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return visitCaseBlock(node); - case 219 /* Block */: + case 220 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 231 /* BreakStatement */: + case 230 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitLabeledStatement(node); - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return visitExpressionStatement(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClause(node); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return visitNewExpression(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -74581,28 +75540,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return visitTemplateExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return visitYieldExpression(node); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return visitSpreadElement(node); case 99 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); case 101 /* ThisKeyword */: return visitThisKeyword(node); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return visitMetaProperty(node); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -74693,14 +75652,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 === 230 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 231 /* 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 === 230 /* BreakStatement */) { + if (node.kind === 231 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -74711,7 +75670,7 @@ var ts; } } else { - if (node.kind === 230 /* BreakStatement */) { + if (node.kind === 231 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -75107,11 +76066,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 231 /* ReturnStatement */) { + if (statement.kind === 232 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 223 /* IfStatement */) { + else if (statement.kind === 224 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -75119,7 +76078,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 219 /* Block */) { + else if (statement.kind === 220 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -75317,7 +76276,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 199 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, ts.createThis()); return true; } @@ -75338,22 +76297,22 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return statements; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 158 /* Constructor */: + case 159 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 198 /* 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 = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 95 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); @@ -75385,20 +76344,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 218 /* SemicolonClassElement */: + case 219 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 158 /* Constructor */: + case 159 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -75586,7 +76545,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 === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 241 /* FunctionDeclaration */ || node.kind === 198 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -75630,7 +76589,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 198 /* ArrowFunction */); + ts.Debug.assert(node.kind === 199 /* 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 @@ -75698,9 +76657,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -75719,9 +76678,9 @@ var ts; // expression. If we are in a state where we do not need the destructuring value, // we pass that information along to the children that care about it. switch (node.expression.kind) { - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -75930,14 +76889,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -76125,7 +77084,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 150 /* ComputedPropertyName */) { + if (property.name.kind === 151 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -76246,11 +77205,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 226 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 227 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 228 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 224 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 225 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 227 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 228 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 229 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 225 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 226 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -76275,11 +77234,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 227 /* ForStatement */: + case 228 /* ForInStatement */: + case 229 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 240 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -76678,20 +77637,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -76767,7 +77726,7 @@ var ts; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); - return ts.updateBlock(block, [statement].concat(transformedStatements)); + return ts.updateBlock(block, __spreadArrays([statement], transformedStatements)); } /** * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a @@ -76798,7 +77757,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 160 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -77035,7 +77994,7 @@ var ts; // [output] // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray(__spreadArrays([ts.createVoidZero()], node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), /*typeArguments*/ undefined, []); } return ts.visitEachChild(node, visitor, context); @@ -77199,13 +78158,16 @@ var ts; // Find original source text, since we need to emit the raw strings of the tagged template. // The raw strings contain the (escaped) strings of what the user wrote. // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), - // thus we need to remove those characters. - // First template piece starts with "`", others with "}" - // Last template piece ends with "`", others with "${" - var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; - text = text.substring(1, text.length - (isLast ? 1 : 2)); + var text = node.rawText; + if (text === undefined) { + text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), + // thus we need to remove those characters. + // First template piece starts with "`", others with "}" + // Last template piece ends with "`", others with "${" + var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; + text = text.substring(1, text.length - (isLast ? 1 : 2)); + } // Newline normalization: // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's // and LineTerminatorSequences are normalized to for both TV and TRV. @@ -77296,10 +78258,8 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ - && !isExpressionOfCall - ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") - : ts.createFileLevelUniqueName("_super"); + return hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") : + ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { if (node.keywordToken === 96 /* NewKeyword */ && node.name.escapedText === "target") { @@ -77345,13 +78305,13 @@ var ts; if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; context.enableSubstitution(101 /* ThisKeyword */); - context.enableEmitNotification(158 /* Constructor */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(198 /* ArrowFunction */); - context.enableEmitNotification(197 /* FunctionExpression */); - context.enableEmitNotification(240 /* FunctionDeclaration */); + context.enableEmitNotification(159 /* Constructor */); + context.enableEmitNotification(158 /* MethodDeclaration */); + context.enableEmitNotification(160 /* GetAccessor */); + context.enableEmitNotification(161 /* SetAccessor */); + context.enableEmitNotification(199 /* ArrowFunction */); + context.enableEmitNotification(198 /* FunctionExpression */); + context.enableEmitNotification(241 /* FunctionDeclaration */); } } /** @@ -77392,10 +78352,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 238 /* VariableDeclaration */: + case 188 /* BindingElement */: + case 242 /* ClassDeclaration */: + case 245 /* EnumDeclaration */: + case 239 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -77477,11 +78437,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 222 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 223 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 192 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 193 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -77489,7 +78449,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 209 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 210 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -77499,7 +78459,7 @@ var ts; ts.transformES2015 = transformES2015; function createExtendsHelper(context, name) { context.requestEmitHelper(ts.extendsHelper); - return ts.createCall(ts.getHelperName("__extends"), + return ts.createCall(ts.getUnscopedHelperName("__extends"), /*typeArguments*/ undefined, [ name, ts.createFileLevelUniqueName("_super") @@ -77507,7 +78467,7 @@ var ts; } function createTemplateObjectHelper(context, cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); - return ts.createCall(ts.getHelperName("__makeTemplateObject"), + return ts.createCall(ts.getUnscopedHelperName("__makeTemplateObject"), /*typeArguments*/ undefined, [ cooked, raw @@ -77515,12 +78475,14 @@ var ts; } ts.extendsHelper = { name: "typescript:extends", + importName: "__extends", scoped: false, priority: 0, text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; ts.templateObjectHelper = { name: "typescript:makeTemplateObject", + importName: "__makeTemplateObject", scoped: false, priority: 0, text: "\n var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n };" @@ -77542,15 +78504,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(263 /* JsxOpeningElement */); - context.enableEmitNotification(264 /* JsxClosingElement */); - context.enableEmitNotification(262 /* JsxSelfClosingElement */); + context.enableEmitNotification(264 /* JsxOpeningElement */); + context.enableEmitNotification(265 /* JsxClosingElement */); + context.enableEmitNotification(263 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(276 /* PropertyAssignment */); + context.enableSubstitution(191 /* PropertyAccessExpression */); + context.enableSubstitution(277 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -77569,9 +78531,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 265 /* JsxClosingElement */: + case 263 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -77903,13 +78865,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 224 /* DoStatement */: + case 225 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return visitWhileStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return visitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -77922,24 +78884,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return visitFunctionExpression(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatement(node); - case 230 /* BreakStatement */: + case 231 /* BreakStatement */: return visitBreakStatement(node); - case 229 /* ContinueStatement */: + case 230 /* ContinueStatement */: return visitContinueStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 131072 /* ContainsYield */) { @@ -77960,21 +78922,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return visitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return visitConditionalExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return visitYieldExpression(node); - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -77987,9 +78949,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -78217,7 +79179,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -78229,7 +79191,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -78455,13 +79417,13 @@ var ts; temp = declareLocal(); var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements); emitAssignment(temp, ts.createArrayLiteral(leadingElement - ? [leadingElement].concat(initialElements) : initialElements)); + ? __spreadArrays([leadingElement], initialElements) : initialElements)); leadingElement = undefined; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return temp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { var hasAssignedTemp = temp !== undefined; @@ -78470,7 +79432,7 @@ var ts; } emitAssignment(temp, hasAssignedTemp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); + : ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine)); leadingElement = undefined; expressions = []; } @@ -78605,35 +79567,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 219 /* Block */: + case 220 /* Block */: return transformAndEmitBlock(node); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return transformAndEmitIfStatement(node); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return transformAndEmitDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return transformAndEmitForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 229 /* ContinueStatement */: + case 230 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 230 /* BreakStatement */: + case 231 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return transformAndEmitWithStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -79063,7 +80025,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 273 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 274 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -79076,7 +80038,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 273 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -79249,11 +80211,10 @@ var ts; return node; } function cacheExpression(node) { - var temp; if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { return node; } - temp = ts.createTempVariable(hoistVariableDeclaration); + var temp = ts.createTempVariable(hoistVariableDeclaration); emitAssignment(temp, node, /*location*/ node); return temp; } @@ -80214,7 +81175,7 @@ var ts; ts.transformGenerators = transformGenerators; function createGeneratorHelper(context, body) { context.requestEmitHelper(ts.generatorHelper); - return ts.createCall(ts.getHelperName("__generator"), + return ts.createCall(ts.getUnscopedHelperName("__generator"), /*typeArguments*/ undefined, [ts.createThis(), body]); } // The __generator helper is used by down-level transformations to emulate the runtime @@ -80278,6 +81239,7 @@ var ts; // For examples of how these are used, see the comments in ./transformers/generators.ts ts.generatorHelper = { name: "typescript:generator", + importName: "__generator", scoped: false, priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" @@ -80305,11 +81267,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(206 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(204 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(205 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(278 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(286 /* 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. @@ -80407,14 +81369,14 @@ var ts; // define(moduleName?, ["module1", "module2"], function ... var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createExpressionStatement(ts.createCall(define, - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ + /*typeArguments*/ undefined, __spreadArrays((moduleName ? [moduleName] : []), [ // Add the dependency array argument: // // ["require", "exports", module1", "module2", ...] - ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : [ + ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : __spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), // Add the module body function argument: // // function (require, exports, module1, module2) ... @@ -80424,10 +81386,10 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ + /*typeParameters*/ undefined, __spreadArrays([ ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), + ], importAliasNames), /*type*/ undefined, transformAsynchronousModuleBody(node)) ]))) ]), @@ -80462,11 +81424,11 @@ var ts; ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ - ts.createArrayLiteral([ + /*typeArguments*/ undefined, __spreadArrays((moduleName ? [moduleName] : []), [ + ts.createArrayLiteral(__spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), ts.createIdentifier("factory") ]))) ]))) @@ -80494,10 +81456,10 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ + /*typeParameters*/ undefined, __spreadArrays([ ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), + ], importAliasNames), /*type*/ undefined, transformAsynchronousModuleBody(node)) ])) ]), @@ -80637,23 +81599,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return visitExportDeclaration(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitExportAssignment(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return visitClassDeclaration(node); - case 317 /* MergeDeclarationMarker */: + case 319 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 318 /* EndOfDeclarationMarker */: + case 320 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -80680,24 +81642,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -80812,7 +81774,7 @@ var ts; var promise = ts.createNew(ts.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getHelperName("__importStar")]); + return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getUnscopedHelperName("__importStar")]); } return promise; } @@ -80826,7 +81788,7 @@ var ts; var requireCall = ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - requireCall = ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); + requireCall = ts.createCall(ts.getUnscopedHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); } var func; if (languageVersion >= 2 /* ES2015 */) { @@ -80860,11 +81822,11 @@ var ts; } if (ts.getImportNeedsImportStarHelper(node)) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); } if (ts.getImportNeedsImportDefaultHelper(node)) { context.requestEmitHelper(ts.importDefaultHelper); - return ts.createCall(ts.getHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); } return innerExpr; } @@ -81175,7 +82137,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 221 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -81230,10 +82192,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 254 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -81432,7 +82394,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -81496,10 +82458,10 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return substituteBinaryExpression(node); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -81520,7 +82482,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 286 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -81595,7 +82557,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 /* PostfixUnaryExpression */ + var expression = node.kind === 205 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 /* PlusPlusToken */ ? 61 /* PlusEqualsToken */ : 62 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; @@ -81636,7 +82598,7 @@ var ts; function createExportStarHelper(context, module) { var compilerOptions = context.getCompilerOptions(); return compilerOptions.importHelpers - ? ts.createCall(ts.getHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]) + ? ts.createCall(ts.getUnscopedHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]) : ts.createCall(ts.createIdentifier("__export"), /*typeArguments*/ undefined, [module]); } // emit helper for dynamic import @@ -81648,12 +82610,14 @@ var ts; // emit helper for `import * as Name from "foo"` ts.importStarHelper = { name: "typescript:commonjsimportstar", + importName: "__importStar", scoped: false, text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};" }; // emit helper for `import Name from "foo"` ts.importDefaultHelper = { name: "typescript:commonjsimportdefault", + importName: "__importDefault", scoped: false, text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};" }; @@ -81671,15 +82635,17 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(278 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(206 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(204 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(205 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(216 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(286 /* 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. var noSubstitutionMap = []; // Set of nodes for which substitution rules should be ignored for each file. + var contextObjectMap = []; // The context object associated with a source file. var currentSourceFile; // The current file. var moduleInfo; // ExternalModuleInfo for the current file. var exportFunction; // The export function for the current file. @@ -81718,7 +82684,7 @@ var ts; // existing identifiers. exportFunction = ts.createUniqueName("exports"); exportFunctionsMap[id] = exportFunction; - contextObject = ts.createUniqueName("context"); + contextObject = contextObjectMap[id] = ts.createUniqueName("context"); // Add the body of the module. var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups); @@ -81896,7 +82862,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 256 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 257 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -81921,7 +82887,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 256 /* ExportDeclaration */) { + if (externalImport.kind !== 257 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -81999,19 +82965,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -82061,15 +83027,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -82245,7 +83211,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 === 285 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 286 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -82309,7 +83275,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 === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 221 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -82371,10 +83337,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 254 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -82554,43 +83520,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return visitForInStatement(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return visitForOfStatement(node); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return visitWhileStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return visitLabeledStatement(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return visitWithStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return visitCaseBlock(node); - case 272 /* CaseClause */: + case 273 /* CaseClause */: return visitCaseClause(node); - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: return visitDefaultClause(node); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return visitTryStatement(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return visitCatchClause(node); - case 219 /* Block */: + case 220 /* Block */: return visitBlock(node); - case 317 /* MergeDeclarationMarker */: + case 319 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 318 /* EndOfDeclarationMarker */: + case 320 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -82837,7 +83803,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 285 /* SourceFile */; + return container !== undefined && container.kind === 286 /* SourceFile */; } else { return false; @@ -82870,12 +83836,13 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 286 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; exportFunction = exportFunctionsMap[id]; noSubstitution = noSubstitutionMap[id]; + contextObject = contextObjectMap[id]; if (noSubstitution) { delete noSubstitutionMap[id]; } @@ -82883,6 +83850,7 @@ var ts; currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; + contextObject = undefined; noSubstitution = undefined; } else { @@ -82918,7 +83886,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -82954,11 +83922,13 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return substituteBinaryExpression(node); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); + case 216 /* MetaProperty */: + return substituteMetaProperty(node); } return node; } @@ -83050,14 +84020,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 /* PostfixUnaryExpression */ + var expression = node.kind === 205 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(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 === 204 /* PostfixUnaryExpression */) { + if (node.kind === 205 /* PostfixUnaryExpression */) { expression = node.operator === 44 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -83067,6 +84037,12 @@ var ts; } return node; } + function substituteMetaProperty(node) { + if (ts.isImportMeta(node)) { + return ts.createPropertyAccess(contextObject, ts.createIdentifier("meta")); + } + return node; + } /** * Gets the exports of a name. * @@ -83079,7 +84055,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 286 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -83118,24 +84094,20 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(285 /* SourceFile */); + context.enableEmitNotification(286 /* SourceFile */); context.enableSubstitution(73 /* Identifier */); - var currentSourceFile; + var helperNameSubstitutions; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { return node; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); - if (externalHelpersModuleName) { + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(node, compilerOptions); + if (externalHelpersImportDeclaration) { var statements = []; var statementOffset = ts.addPrologue(statements, node.statements); - var tslibImport = ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); - ts.addEmitFlags(tslibImport, 67108864 /* NeverApplyImportHelper */); - ts.append(statements, tslibImport); + ts.append(statements, externalHelpersImportDeclaration); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } @@ -83147,10 +84119,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -83171,9 +84143,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { if (ts.isSourceFile(node)) { - currentSourceFile = node; + helperNameSubstitutions = ts.createMap(); previousOnEmitNode(hint, node, emitCallback); - currentSourceFile = undefined; + helperNameSubstitutions = undefined; } else { previousOnEmitNode(hint, node, emitCallback); @@ -83190,19 +84162,18 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (ts.isIdentifier(node) && hint === 1 /* Expression */) { - return substituteExpressionIdentifier(node); + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* HelperName */) { + return substituteHelperName(node); } return node; } - function substituteExpressionIdentifier(node) { - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { - var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); - if (externalHelpersModuleName) { - return ts.createPropertyAccess(externalHelpersModuleName, node); - } + function substituteHelperName(node) { + var name = ts.idText(node); + var substitution = helperNameSubstitutions.get(name); + if (!substitution) { + helperNameSubstitutions.set(name, substitution = ts.createFileLevelUniqueName(name)); } - return node; + return substitution; } } ts.transformES2015Module = transformES2015Module; @@ -83258,7 +84229,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 242 /* 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 : @@ -83287,7 +84258,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 242 /* 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 : @@ -83313,7 +84284,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node) && ts.hasModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8 /* Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -83334,7 +84305,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 === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 239 /* VariableDeclaration */ || node.kind === 188 /* 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 : @@ -83343,8 +84314,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 === 155 /* PropertyDeclaration */ || node.kind === 190 /* PropertyAccessExpression */ || node.kind === 154 /* PropertySignature */ || - (node.kind === 152 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 156 /* PropertyDeclaration */ || node.kind === 191 /* PropertyAccessExpression */ || node.kind === 155 /* PropertySignature */ || + (node.kind === 153 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -83353,7 +84324,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 === 241 /* ClassDeclaration */ || node.kind === 152 /* Parameter */) { + else if (node.parent.kind === 242 /* ClassDeclaration */ || node.kind === 153 /* 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 : @@ -83378,7 +84349,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 161 /* 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.hasModifier(node, 32 /* Static */)) { @@ -83417,26 +84388,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 162 /* ConstructSignature */: + case 163 /* 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 161 /* CallSignature */: + case 162 /* 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 163 /* IndexSignature */: + case 164 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -83444,7 +84415,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 242 /* 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 : @@ -83458,7 +84429,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 240 /* FunctionDeclaration */: + case 241 /* 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 : @@ -83483,30 +84454,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 158 /* Constructor */: + case 159 /* 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 162 /* ConstructSignature */: - case 167 /* ConstructorType */: + case 163 /* ConstructSignature */: + case 168 /* 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 161 /* CallSignature */: + case 162 /* 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 163 /* IndexSignature */: + case 164 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -83514,7 +84485,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 === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 242 /* 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 : @@ -83527,8 +84498,8 @@ 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 240 /* FunctionDeclaration */: - case 166 /* FunctionType */: + case 241 /* FunctionDeclaration */: + case 167 /* 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 : @@ -83542,39 +84513,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 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 182 /* MappedType */: + case 183 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 168 /* ConstructorType */: + case 163 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 161 /* CallSignature */: + case 162 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* MethodDeclaration */: + case 157 /* MethodSignature */: if (ts.hasModifier(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 === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 242 /* 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 166 /* FunctionType */: - case 240 /* FunctionDeclaration */: + case 167 /* FunctionType */: + case 241 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -83589,7 +84560,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + if (node.parent.parent.kind === 242 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 110 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -83640,7 +84611,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 152 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 153 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -83701,6 +84672,7 @@ var ts; var currentSourceFile; var refs; var libs; + var emittedImports; // must be declared in container so it can be `undefined` while transformer's first pass var resolver = context.getEmitResolver(); var options = context.getCompilerOptions(); var newLine = ts.getNewLineCharacter(options); @@ -83790,10 +84762,10 @@ var ts; return ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createNamedExports([]), /*moduleSpecifier*/ undefined); } function transformRoot(node) { - if (node.kind === 285 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 286 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { return node; } - if (node.kind === 286 /* Bundle */) { + if (node.kind === 287 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); @@ -83823,7 +84795,7 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288 /* InputFiles */) { + if (prepend.kind === 289 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -83863,9 +84835,9 @@ var ts; var statements = ts.visitNodes(node.statements, visitDeclarationStatements); var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); refs.forEach(referenceVisitor); - var emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { - combinedStatements = ts.setTextRange(ts.createNodeArray(combinedStatements.concat([createEmptyExports()])), combinedStatements); + combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [createEmptyExports()])), combinedStatements); } var updated = ts.updateSourceFileNode(node, combinedStatements, /*isDeclarationFile*/ true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences()); updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit; @@ -83907,6 +84879,15 @@ 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, host.getSourceFiles(), + /*preferences*/ undefined, host.redirectTargetsMap); + if (!ts.pathIsRelative(specifier)) { + // If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration + // via a non-relative name, emit a type reference directive to that non-relative name, rather than + // a relative path to the declaration file + recordTypeReferenceDirectivesIfNecessary([specifier]); + return; + } var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); if (ts.startsWith(fileName, "./") && ts.hasExtension(fileName)) { @@ -83947,7 +84928,7 @@ var ts; return name; } else { - if (name.kind === 186 /* ArrayBindingPattern */) { + if (name.kind === 187 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -83955,20 +84936,20 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 211 /* OmittedExpression */) { + if (elem.kind === 212 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); } } - function ensureParameter(p, modifierMask) { + function ensureParameter(p, modifierMask, type) { var oldDiag; if (!suppressNewDiagnosticContexts) { oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } var newParam = ts.updateParameter(p, - /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(56 /* QuestionToken */)) : undefined, ensureType(p, p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param + /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(56 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -83993,7 +84974,7 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 152 /* Parameter */ && + var shouldUseResolverType = node.kind === 153 /* Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { @@ -84002,7 +84983,7 @@ var ts; if (!ts.getParseTreeNode(node)) { return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(121 /* AnyKeyword */); } - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 161 /* 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 ts.createKeywordTypeNode(121 /* AnyKeyword */); @@ -84013,12 +84994,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 239 /* VariableDeclaration */ || node.kind === 188 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 152 /* Parameter */ - || node.kind === 155 /* PropertyDeclaration */ - || node.kind === 154 /* PropertySignature */) { + if (node.kind === 153 /* Parameter */ + || node.kind === 156 /* PropertyDeclaration */ + || node.kind === 155 /* 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)); @@ -84035,20 +85016,20 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 241 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 243 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 245 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 250 /* ImportEqualsDeclaration */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: + case 256 /* ExportAssignment */: return false; } return false; @@ -84075,6 +85056,33 @@ var ts; } return ts.createNodeArray(newParams, params.hasTrailingComma); } + function updateAccessorParamsList(input, isPrivate) { + var newParams; + if (!isPrivate) { + var thisParameter = ts.getThisParameter(input); + if (thisParameter) { + newParams = [ensureParameter(thisParameter)]; + } + } + if (ts.isSetAccessorDeclaration(input)) { + var newValueParameter = void 0; + if (!isPrivate) { + var valueParameter = ts.getSetAccessorValueParameter(input); + if (valueParameter) { + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + newValueParameter = ensureParameter(valueParameter, /*modifierMask*/ undefined, accessorType); + } + } + if (!newValueParameter) { + newValueParameter = ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "value"); + } + newParams = ts.append(newParams, newValueParameter); + } + return ts.createNodeArray(newParams || ts.emptyArray); + } function ensureTypeParams(node, params) { return ts.hasModifier(node, 8 /* Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } @@ -84102,7 +85110,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 245 /* ModuleDeclaration */ && parent.kind !== 184 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 246 /* ModuleDeclaration */ && parent.kind !== 185 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -84122,7 +85130,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 261 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -84149,7 +85157,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 253 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -84241,6 +85249,11 @@ var ts; enclosingDeclaration = input; } var oldDiag = getSymbolAccessibilityDiagnostic; + // Setup diagnostic-related flags before first potential `cleanup` call, otherwise + // We'd see a TDZ violation at runtime + var canProduceDiagnostic = ts.canProduceDiagnostics(input); + var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 170 /* TypeLiteral */ || input.kind === 183 /* MappedType */) && input.parent.kind !== 244 /* TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { if (ts.hasModifier(input, 8 /* Private */)) { @@ -84249,76 +85262,87 @@ var ts; return cleanup(ts.createProperty(/*decorators*/ undefined, ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); } } - var canProdiceDiagnostic = ts.canProduceDiagnostics(input); - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input); } if (ts.isTypeQueryNode(input)) { checkEntityNameVisibility(input.exprName, enclosingDeclaration); } - var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 169 /* TypeLiteral */ || input.kind === 182 /* MappedType */) && input.parent.kind !== 243 /* TypeAliasDeclaration */); if (shouldEnterSuppressNewDiagnosticsContextContext) { // We stop making new diagnostic contexts within object literal types. Unless it's an object type on the RHS of a type alias declaration. Then we do. suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 212 /* ExpressionWithTypeArguments */: { + case 213 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 165 /* TypeReference */: { + case 166 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 158 /* Constructor */: { + case 159 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(158 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + var ctor = ts.createSignatureDeclaration(159 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), // TODO: GH#18217 isPrivate ? undefined : updateParamsList(input, input.parameters, 0 /* None */), /*type*/ undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 157 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(156 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 158 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(157 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 159 /* GetAccessor */: { + case 160 /* GetAccessor */: { + // For now, only emit class accessors as accessors if they were already declared in an ambient context. + if (input.flags & 4194304 /* Ambient */) { + var isPrivate = ts.hasModifier(input, 8 /* Private */); + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + return cleanup(ts.updateGetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, + /*body*/ undefined)); + } var newNode = ensureAccessor(input); return cleanup(newNode); } - case 160 /* SetAccessor */: { + case 161 /* SetAccessor */: { + // For now, only emit class accessors as accessors if they were already declared in an ambient context. + if (input.flags & 4194304 /* Ambient */) { + return cleanup(ts.updateSetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8 /* Private */)), + /*body*/ undefined)); + } var newNode = ensureAccessor(input); return cleanup(newNode); } - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return cleanup(ts.updateProperty(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 154 /* PropertySignature */: + case 155 /* PropertySignature */: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 156 /* MethodSignature */: { + case 157 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 161 /* CallSignature */: { + case 162 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 163 /* IndexSignature */: { + case 164 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(121 /* AnyKeyword */))); } - case 238 /* VariableDeclaration */: { + case 239 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -84326,13 +85350,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(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 151 /* TypeParameter */: { + case 152 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 176 /* ConditionalType */: { + case 177 /* 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); @@ -84344,13 +85368,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 166 /* FunctionType */: { + case 167 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 167 /* ConstructorType */: { + case 168 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 184 /* ImportType */: { + case 185 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -84360,13 +85384,13 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { - if (returnValue && canProdiceDiagnostic && ts.hasDynamicName(input)) { + if (returnValue && canProduceDiagnostic && ts.hasDynamicName(input)) { checkName(input); } if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; } - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } if (shouldEnterSuppressNewDiagnosticsContextContext) { @@ -84379,7 +85403,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 157 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 158 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -84389,7 +85413,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 256 /* ExportDeclaration */: { + case 257 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -84398,7 +85422,7 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 255 /* ExportAssignment */: { + case 256 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; @@ -84439,10 +85463,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249 /* ImportEqualsDeclaration */: { + case 250 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 250 /* ImportDeclaration */: { + case 251 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -84463,14 +85487,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 243 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 244 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 242 /* InterfaceDeclaration */: { + case 243 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 240 /* FunctionDeclaration */: { + case 241 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -84518,10 +85542,10 @@ var ts; return clean; } } - case 245 /* ModuleDeclaration */: { + case 246 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 246 /* ModuleBlock */) { + if (inner && inner.kind === 247 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; @@ -84537,7 +85561,7 @@ var ts; // 3. Some things are exported, some are not, and there's no marker - add an empty marker if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) { if (needsScopeFixMarker) { - lateStatements = ts.createNodeArray(lateStatements.concat([createEmptyExports()])); + lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [createEmptyExports()])); } else { lateStatements = ts.visitNodes(lateStatements, stripExportModifiers); @@ -84564,7 +85588,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 241 /* ClassDeclaration */: { + case 242 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -84635,10 +85659,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 220 /* VariableStatement */: { + case 221 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 244 /* EnumDeclaration */: { + case 245 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -84657,7 +85681,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 245 /* ModuleDeclaration */) { + if (input.kind === 246 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -84678,7 +85702,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 211 /* OmittedExpression */) { + if (e.kind === 212 /* OmittedExpression */) { return; } if (e.name) { @@ -84728,24 +85752,33 @@ var ts; function ensureModifierFlags(node) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 285 /* SourceFile */; + var parentIsFile = node.parent.kind === 286 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; } return maskModifierFlags(node, mask, additions); } - function ensureAccessor(node) { - var accessors = resolver.getAllAccessorDeclarations(node); - if (node.kind !== accessors.firstAccessor.kind) { - return; - } + function getTypeAnnotationFromAllAccessorDeclarations(node, accessors) { var accessorType = getTypeAnnotationFromAccessor(node); - if (!accessorType && accessors.secondAccessor) { + if (!accessorType && node !== accessors.firstAccessor) { + accessorType = getTypeAnnotationFromAccessor(accessors.firstAccessor); + // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message + getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.firstAccessor); + } + if (!accessorType && accessors.secondAccessor && node !== accessors.secondAccessor) { accessorType = getTypeAnnotationFromAccessor(accessors.secondAccessor); // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.secondAccessor); } + return accessorType; + } + function ensureAccessor(node) { + var accessors = resolver.getAllAccessorDeclarations(node); + if (node.kind !== accessors.firstAccessor.kind) { + return; + } + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(node, accessors); var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); if (leadingsSyntheticCommentRanges) { @@ -84756,7 +85789,7 @@ var ts; if (lines.length > 1) { var lastLines = lines.slice(1); var indentation_1 = ts.guessIndentation(lastLines); - text = [lines[0]].concat(ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); + text = __spreadArrays([lines[0]], ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); } ts.addSyntheticLeadingComment(prop, range.kind, text, range.hasTrailingNewLine); } @@ -84776,7 +85809,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 243 /* InterfaceDeclaration */) { return true; } return false; @@ -84801,7 +85834,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 159 /* GetAccessor */ + return accessor.kind === 160 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -84810,52 +85843,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: return !ts.hasModifier(node, 8 /* Private */); - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 153 /* Parameter */: + case 239 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 220 /* VariableStatement */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 241 /* FunctionDeclaration */: + case 246 /* ModuleDeclaration */: + case 250 /* ImportEqualsDeclaration */: + case 243 /* InterfaceDeclaration */: + case 242 /* ClassDeclaration */: + case 244 /* TypeAliasDeclaration */: + case 245 /* EnumDeclaration */: + case 221 /* VariableStatement */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: + case 256 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 238 /* VariableDeclaration */: - case 151 /* TypeParameter */: - case 212 /* ExpressionWithTypeArguments */: - case 165 /* TypeReference */: - case 176 /* ConditionalType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 184 /* ImportType */: + case 163 /* ConstructSignature */: + case 159 /* Constructor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 156 /* PropertyDeclaration */: + case 155 /* PropertySignature */: + case 157 /* MethodSignature */: + case 162 /* CallSignature */: + case 164 /* IndexSignature */: + case 239 /* VariableDeclaration */: + case 152 /* TypeParameter */: + case 213 /* ExpressionWithTypeArguments */: + case 166 /* TypeReference */: + case 177 /* ConditionalType */: + case 167 /* FunctionType */: + case 168 /* ConstructorType */: + case 185 /* ImportType */: return true; } return false; @@ -84984,7 +86017,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(319 /* Count */); + var enabledSyntaxKindFeatures = new Array(321 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -85191,7 +86224,7 @@ var ts; var statements; if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) { if (lexicalEnvironmentFunctionDeclarations) { - statements = lexicalEnvironmentFunctionDeclarations.slice(); + statements = __spreadArrays(lexicalEnvironmentFunctionDeclarations); } if (lexicalEnvironmentVariableDeclarations) { var statement = ts.createVariableStatement( @@ -85269,15 +86302,15 @@ var ts; * If an array, the full list of source files to emit. * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) { + if (forceDtsEmit === void 0) { forceDtsEmit = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { var prepends = host.getPrependNodes(); if (sourceFiles.length || prepends.length) { var bundle = ts.createBundle(sourceFiles, prepends); - var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); + var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle); if (result) { return result; } @@ -85287,7 +86320,7 @@ var ts; if (!onlyBuildInfo) { for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { var sourceFile = sourceFiles_1[_a]; - var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); + var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile); if (result) { return result; } @@ -85340,7 +86373,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 286 /* Bundle */) { + if (sourceFile.kind === 287 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -85398,6 +86431,8 @@ var ts; } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; function getOutputJSFileName(inputFileName, configFile, ignoreCase) { + if (configFile.options.emitDeclarationOnly) + return undefined; var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ? ".json" /* Json */ : @@ -85429,7 +86464,7 @@ var ts; addOutput(js); if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) continue; - if (configFile.options.sourceMap) { + if (js && configFile.options.sourceMap) { addOutput(js + ".map"); } if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { @@ -85458,6 +86493,11 @@ var ts; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase); if (jsFilePath) return jsFilePath; + if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + continue; + if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { + return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + } } var buildInfoPath = getOutputPathForBuildInfo(configFile.options); if (buildInfoPath) @@ -85467,7 +86507,7 @@ var ts; ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo) { + function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) { var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers; var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; @@ -85481,7 +86521,7 @@ var ts; var exportedModulesFromDeclarationEmit; // Emit each output file enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), forceDtsEmit, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -85619,7 +86659,7 @@ var ts; }); var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit; emitSkipped = emitSkipped || declBlocked; - if (!declBlocked || emitOnlyDtsFiles) { + 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, @@ -85627,12 +86667,8 @@ var ts; mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 285 /* SourceFile */) { - // Improved narrowing in master/3.6 makes this cast unnecessary, triggering a lint rule. - // But at the same time, the LKG (3.5) necessitates it because it doesn’t narrow. - // Once the LKG is updated to 3.6, this comment, the cast to `SourceFile`, and the - // tslint directive can be all be removed. - var sourceFile = declarationTransform.transformed[0]; // tslint:disable-line + if (forceDtsEmit && declarationTransform.transformed[0].kind === 286 /* SourceFile */) { + var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } } @@ -85654,8 +86690,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 286 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 285 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 287 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 286 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -85696,7 +86732,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 285 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 286 /* 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 @@ -85806,7 +86842,7 @@ var ts; }; function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) { var sourceFiles = bundle.sourceFiles.map(function (fileName) { - var sourceFile = ts.createNode(285 /* SourceFile */, 0, 0); + var sourceFile = ts.createNode(286 /* SourceFile */, 0, 0); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = ""; sourceFile.statements = ts.createNodeArray(); @@ -85818,7 +86854,7 @@ var ts; sourceFile.text = prologueInfo.text; sourceFile.end = prologueInfo.text.length; sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { - var statement = ts.createNode(222 /* ExpressionStatement */, directive.pos, directive.end); + var statement = ts.createNode(223 /* ExpressionStatement */, directive.pos, directive.end); statement.expression = ts.createNode(10 /* StringLiteral */, directive.expression.pos, directive.expression.end); statement.expression.text = directive.expression.text; return statement; @@ -85857,7 +86893,7 @@ var ts; var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); }); var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host); var emitHost = { - getPrependNodes: ts.memoize(function () { return prependNodes.concat([ownPrependInput]); }), + getPrependNodes: ts.memoize(function () { return __spreadArrays(prependNodes, [ownPrependInput]); }), getCanonicalFileName: host.getCanonicalFileName, getCommonSourceDirectory: function () { return ts.getNormalizedAbsolutePath(buildInfo.bundle.commonSourceDirectory, buildInfoDirectory); }, getCompilerOptions: function () { return config.options; }, @@ -85911,6 +86947,7 @@ var ts; useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: ts.returnUndefined, getSourceFileFromReference: ts.returnUndefined, + redirectTargetsMap: ts.createMultiMap() }; emitFiles(ts.notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers)); @@ -85991,9 +87028,9 @@ var ts; break; } switch (node.kind) { - case 285 /* SourceFile */: return printFile(node); - case 286 /* Bundle */: return printBundle(node); - case 287 /* UnparsedSource */: return printUnparsedSource(node); + case 286 /* SourceFile */: return printFile(node); + case 287 /* Bundle */: return printBundle(node); + case 288 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -86175,7 +87212,7 @@ var ts; } function setWriter(_writer, _sourceMapGenerator) { if (_writer && printerOptions.omitTrailingSemicolon) { - _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + _writer = ts.getTrailingSemicolonDeferringWriter(_writer); } writer = _writer; // TODO: GH#18217 sourceMapGenerator = _sourceMapGenerator; @@ -86229,12 +87266,12 @@ var ts; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 285 /* SourceFile */) { + if (!commentsDisabled && node.kind !== 286 /* SourceFile */) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 285 /* SourceFile */ && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 286 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through @@ -86271,272 +87308,272 @@ var ts; case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node); - case 287 /* UnparsedSource */: - case 281 /* UnparsedPrepend */: + case 288 /* UnparsedSource */: + case 282 /* UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 280 /* UnparsedPrologue */: + case 281 /* UnparsedPrologue */: return writeUnparsedNode(node); - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 283 /* UnparsedText */: + case 284 /* UnparsedInternalText */: return emitUnparsedTextLike(node); - case 284 /* UnparsedSyntheticReference */: + case 285 /* UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Identifiers case 73 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 149 /* QualifiedName */: + case 150 /* QualifiedName */: return emitQualifiedName(node); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 151 /* TypeParameter */: + case 152 /* TypeParameter */: return emitTypeParameter(node); - case 152 /* Parameter */: + case 153 /* Parameter */: return emitParameter(node); - case 153 /* Decorator */: + case 154 /* Decorator */: return emitDecorator(node); // Type members - case 154 /* PropertySignature */: + case 155 /* PropertySignature */: return emitPropertySignature(node); - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 156 /* MethodSignature */: + case 157 /* MethodSignature */: return emitMethodSignature(node); - case 157 /* MethodDeclaration */: + case 158 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 158 /* Constructor */: + case 159 /* Constructor */: return emitConstructor(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return emitAccessorDeclaration(node); - case 161 /* CallSignature */: + case 162 /* CallSignature */: return emitCallSignature(node); - case 162 /* ConstructSignature */: + case 163 /* ConstructSignature */: return emitConstructSignature(node); - case 163 /* IndexSignature */: + case 164 /* IndexSignature */: return emitIndexSignature(node); // Types - case 164 /* TypePredicate */: + case 165 /* TypePredicate */: return emitTypePredicate(node); - case 165 /* TypeReference */: + case 166 /* TypeReference */: return emitTypeReference(node); - case 166 /* FunctionType */: + case 167 /* FunctionType */: return emitFunctionType(node); - case 295 /* JSDocFunctionType */: + case 296 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 167 /* ConstructorType */: + case 168 /* ConstructorType */: return emitConstructorType(node); - case 168 /* TypeQuery */: + case 169 /* TypeQuery */: return emitTypeQuery(node); - case 169 /* TypeLiteral */: + case 170 /* TypeLiteral */: return emitTypeLiteral(node); - case 170 /* ArrayType */: + case 171 /* ArrayType */: return emitArrayType(node); - case 171 /* TupleType */: + case 172 /* TupleType */: return emitTupleType(node); - case 172 /* OptionalType */: + case 173 /* OptionalType */: return emitOptionalType(node); - case 174 /* UnionType */: + case 175 /* UnionType */: return emitUnionType(node); - case 175 /* IntersectionType */: + case 176 /* IntersectionType */: return emitIntersectionType(node); - case 176 /* ConditionalType */: + case 177 /* ConditionalType */: return emitConditionalType(node); - case 177 /* InferType */: + case 178 /* InferType */: return emitInferType(node); - case 178 /* ParenthesizedType */: + case 179 /* ParenthesizedType */: return emitParenthesizedType(node); - case 212 /* ExpressionWithTypeArguments */: + case 213 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 179 /* ThisType */: + case 180 /* ThisType */: return emitThisType(); - case 180 /* TypeOperator */: + case 181 /* TypeOperator */: return emitTypeOperator(node); - case 181 /* IndexedAccessType */: + case 182 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 182 /* MappedType */: + case 183 /* MappedType */: return emitMappedType(node); - case 183 /* LiteralType */: + case 184 /* LiteralType */: return emitLiteralType(node); - case 184 /* ImportType */: + case 185 /* ImportType */: return emitImportTypeNode(node); - case 290 /* JSDocAllType */: + case 291 /* JSDocAllType */: writePunctuation("*"); return; - case 291 /* JSDocUnknownType */: + case 292 /* JSDocUnknownType */: writePunctuation("?"); return; - case 292 /* JSDocNullableType */: + case 293 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 293 /* JSDocNonNullableType */: + case 294 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 294 /* JSDocOptionalType */: + case 295 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 173 /* RestType */: - case 296 /* JSDocVariadicType */: + case 174 /* RestType */: + case 297 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 186 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 186 /* ArrayBindingPattern */: + case 187 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 187 /* BindingElement */: + case 188 /* BindingElement */: return emitBindingElement(node); // Misc - case 217 /* TemplateSpan */: + case 218 /* TemplateSpan */: return emitTemplateSpan(node); - case 218 /* SemicolonClassElement */: + case 219 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 219 /* Block */: + case 220 /* Block */: return emitBlock(node); - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: return emitVariableStatement(node); - case 221 /* EmptyStatement */: + case 222 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 222 /* ExpressionStatement */: + case 223 /* ExpressionStatement */: return emitExpressionStatement(node); - case 223 /* IfStatement */: + case 224 /* IfStatement */: return emitIfStatement(node); - case 224 /* DoStatement */: + case 225 /* DoStatement */: return emitDoStatement(node); - case 225 /* WhileStatement */: + case 226 /* WhileStatement */: return emitWhileStatement(node); - case 226 /* ForStatement */: + case 227 /* ForStatement */: return emitForStatement(node); - case 227 /* ForInStatement */: + case 228 /* ForInStatement */: return emitForInStatement(node); - case 228 /* ForOfStatement */: + case 229 /* ForOfStatement */: return emitForOfStatement(node); - case 229 /* ContinueStatement */: + case 230 /* ContinueStatement */: return emitContinueStatement(node); - case 230 /* BreakStatement */: + case 231 /* BreakStatement */: return emitBreakStatement(node); - case 231 /* ReturnStatement */: + case 232 /* ReturnStatement */: return emitReturnStatement(node); - case 232 /* WithStatement */: + case 233 /* WithStatement */: return emitWithStatement(node); - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: return emitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 235 /* LabeledStatement */: return emitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 236 /* ThrowStatement */: return emitThrowStatement(node); - case 236 /* TryStatement */: + case 237 /* TryStatement */: return emitTryStatement(node); - case 237 /* DebuggerStatement */: + case 238 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 238 /* VariableDeclaration */: + case 239 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 242 /* ClassDeclaration */: return emitClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 246 /* ModuleBlock */: + case 247 /* ModuleBlock */: return emitModuleBlock(node); - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: return emitCaseBlock(node); - case 248 /* NamespaceExportDeclaration */: + case 249 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: return emitImportDeclaration(node); - case 251 /* ImportClause */: + case 252 /* ImportClause */: return emitImportClause(node); - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: return emitNamespaceImport(node); - case 253 /* NamedImports */: + case 254 /* NamedImports */: return emitNamedImports(node); - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: return emitImportSpecifier(node); - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: return emitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 257 /* ExportDeclaration */: return emitExportDeclaration(node); - case 257 /* NamedExports */: + case 258 /* NamedExports */: return emitNamedExports(node); - case 258 /* ExportSpecifier */: + case 259 /* ExportSpecifier */: return emitExportSpecifier(node); - case 259 /* MissingDeclaration */: + case 260 /* MissingDeclaration */: return; // Module references - case 260 /* ExternalModuleReference */: + case 261 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: + case 264 /* JsxOpeningElement */: + case 267 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 264 /* JsxClosingElement */: - case 267 /* JsxClosingFragment */: + case 265 /* JsxClosingElement */: + case 268 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 268 /* JsxAttribute */: + case 269 /* JsxAttribute */: return emitJsxAttribute(node); - case 269 /* JsxAttributes */: + case 270 /* JsxAttributes */: return emitJsxAttributes(node); - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 271 /* JsxExpression */: + case 272 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 272 /* CaseClause */: + case 273 /* CaseClause */: return emitCaseClause(node); - case 273 /* DefaultClause */: + case 274 /* DefaultClause */: return emitDefaultClause(node); - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: return emitHeritageClause(node); - case 275 /* CatchClause */: + case 276 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 276 /* PropertyAssignment */: + case 277 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 277 /* ShorthandPropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 278 /* SpreadAssignment */: + case 279 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 279 /* EnumMember */: + case 280 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 308 /* JSDocParameterTag */: + case 314 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 308 /* JSDocThisTag */: - case 305 /* JSDocEnumTag */: + case 309 /* JSDocReturnTag */: + case 311 /* JSDocTypeTag */: + case 310 /* JSDocThisTag */: + case 307 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); - case 301 /* JSDocAugmentsTag */: + case 303 /* JSDocAugmentsTag */: return emitJSDocAugmentsTag(node); - case 310 /* JSDocTemplateTag */: + case 312 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 311 /* JSDocTypedefTag */: + case 313 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 304 /* JSDocCallbackTag */: + case 306 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); - case 299 /* JSDocSignature */: + case 301 /* JSDocSignature */: return emitJSDocSignature(node); - case 298 /* JSDocTypeLiteral */: + case 300 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 303 /* JSDocClassTag */: - case 300 /* JSDocTag */: + case 305 /* JSDocClassTag */: + case 302 /* JSDocTag */: return emitJSDocSimpleTag(node); - case 297 /* JSDocComment */: + case 299 /* JSDocComment */: return emitJSDoc(node); // Transformation nodes (ignored) } @@ -86573,71 +87610,71 @@ var ts; writeTokenNode(node, writeKeyword); return; // Expressions - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 190 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 190 /* PropertyAccessExpression */: + case 191 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 192 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 192 /* CallExpression */: + case 193 /* CallExpression */: return emitCallExpression(node); - case 193 /* NewExpression */: + case 194 /* NewExpression */: return emitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 195 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 196 /* ParenthesizedExpression */: + case 197 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 197 /* FunctionExpression */: + case 198 /* FunctionExpression */: return emitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 199 /* ArrowFunction */: return emitArrowFunction(node); - case 199 /* DeleteExpression */: + case 200 /* DeleteExpression */: return emitDeleteExpression(node); - case 200 /* TypeOfExpression */: + case 201 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 201 /* VoidExpression */: + case 202 /* VoidExpression */: return emitVoidExpression(node); - case 202 /* AwaitExpression */: + case 203 /* AwaitExpression */: return emitAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 204 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 205 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 206 /* BinaryExpression */: return emitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 207 /* ConditionalExpression */: return emitConditionalExpression(node); - case 207 /* TemplateExpression */: + case 208 /* TemplateExpression */: return emitTemplateExpression(node); - case 208 /* YieldExpression */: + case 209 /* YieldExpression */: return emitYieldExpression(node); - case 209 /* SpreadElement */: + case 210 /* SpreadElement */: return emitSpreadExpression(node); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return emitClassExpression(node); - case 211 /* OmittedExpression */: + case 212 /* OmittedExpression */: return; - case 213 /* AsExpression */: + case 214 /* AsExpression */: return emitAsExpression(node); - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: return emitNonNullExpression(node); - case 215 /* MetaProperty */: + case 216 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 261 /* JsxElement */: + case 262 /* JsxElement */: return emitJsxElement(node); - case 262 /* JsxSelfClosingElement */: + case 263 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 265 /* JsxFragment */: + case 266 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 317 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 316 /* CommaListExpression */: + case 318 /* CommaListExpression */: return emitCommaList(node); } } @@ -86665,8 +87702,8 @@ var ts; var helpers = getSortedEmitHelpers(sourceFile); if (!helpers) continue; - for (var _c = 0, helpers_3 = helpers; _c < helpers_3.length; _c++) { - var helper = helpers_3[_c]; + for (var _c = 0, helpers_4 = helpers; _c < helpers_4.length; _c++) { + var helper = helpers_4[_c]; if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) { bundledHelpers.set(helper.name, true); (result || (result = [])).push(helper.name); @@ -86677,7 +87714,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 286 /* Bundle */ ? node : undefined; + var bundle = node.kind === 287 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -86686,12 +87723,12 @@ var ts; for (var i = 0; i < numNodes; i++) { var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node; var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile; - var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.hasRecordedExternalHelpers(sourceFile)); var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit; var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode); if (helpers) { - for (var _a = 0, helpers_4 = helpers; _a < helpers_4.length; _a++) { - var helper = helpers_4[_a]; + for (var _a = 0, helpers_5 = helpers; _a < helpers_5.length; _a++) { + var helper = helpers_5[_a]; if (!helper.scoped) { // Skip the helper if it can be skipped and the noEmitHelpers compiler // option is set, or if it can be imported and the importHelpers compiler @@ -86777,7 +87814,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 282 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 283 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -86846,7 +87883,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 295 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 296 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -86908,7 +87945,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 159 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 160 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -87315,7 +88352,7 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 203 /* PrefixUnaryExpression */ + return operand.kind === 204 /* PrefixUnaryExpression */ && ((node.operator === 38 /* PlusToken */ && (operand.operator === 38 /* PlusToken */ || operand.operator === 44 /* PlusPlusToken */)) || (node.operator === 39 /* MinusToken */ && (operand.operator === 39 /* MinusToken */ || operand.operator === 45 /* MinusMinusToken */))); } @@ -87444,7 +88481,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); emitTokenWithComment(84 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 223 /* IfStatement */) { + if (node.elseStatement.kind === 224 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -87470,7 +88507,7 @@ var ts; writeLineOrSpace(node); } emitWhileClause(node, node.statement.end); - writePunctuation(";"); + writeTrailingSemicolon(); } function emitWhileStatement(node) { emitWhileClause(node, node.pos); @@ -87507,7 +88544,7 @@ var ts; emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(148 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(149 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -87515,7 +88552,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 240 /* VariableDeclarationList */) { emit(node); } else { @@ -87630,7 +88667,7 @@ var ts; writeKeyword("function"); emit(node.asteriskToken); writeSpace(); - emitIdentifierName(node.name); // TODO: GH#18217 + emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } function emitBlockCallback(_hint, body) { @@ -87810,7 +88847,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 245 /* ModuleDeclaration */) { + while (body.kind === 246 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -88131,7 +89168,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 309 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 311 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -88165,7 +89202,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 290 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -88184,7 +89221,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 298 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 300 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -88318,8 +89355,8 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } - for (var _d = 0, types_19 = types; _d < types_19.length; _d++) { - var directive = types_19[_d]; + for (var _d = 0, types_18 = types; _d < types_18.length; _d++) { + var directive = types_18[_d]; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) @@ -88962,7 +89999,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 197 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -89027,81 +90064,81 @@ var ts; if (!node) return; switch (node.kind) { - case 219 /* Block */: + case 220 /* Block */: ts.forEach(node.statements, generateNames); break; - case 234 /* LabeledStatement */: - case 232 /* WithStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 235 /* LabeledStatement */: + case 233 /* WithStatement */: + case 225 /* DoStatement */: + case 226 /* WhileStatement */: generateNames(node.statement); break; - case 223 /* IfStatement */: + case 224 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 227 /* ForStatement */: + case 229 /* ForOfStatement */: + case 228 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 233 /* SwitchStatement */: + case 234 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 247 /* CaseBlock */: + case 248 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 273 /* CaseClause */: + case 274 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 236 /* TryStatement */: + case 237 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 275 /* CatchClause */: + case 276 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: generateNames(node.declarationList); break; - case 239 /* VariableDeclarationList */: + case 240 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: + case 239 /* VariableDeclaration */: + case 153 /* Parameter */: + case 188 /* BindingElement */: + case 242 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 240 /* FunctionDeclaration */: + case 241 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 186 /* ObjectBindingPattern */: + case 187 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 250 /* ImportDeclaration */: + case 251 /* ImportDeclaration */: generateNames(node.importClause); break; - case 251 /* ImportClause */: + case 252 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 252 /* NamespaceImport */: + case 253 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 253 /* NamedImports */: + case 254 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 254 /* ImportSpecifier */: + case 255 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -89110,12 +90147,12 @@ var ts; if (!node) return; switch (node.kind) { - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 277 /* PropertyAssignment */: + case 278 /* ShorthandPropertyAssignment */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -89173,7 +90210,7 @@ var ts; if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (local && local.flags & (67220415 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { + if (local && local.flags & (111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { return false; } } @@ -89297,23 +90334,23 @@ var ts; switch (node.kind) { case 73 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: + case 246 /* ModuleDeclaration */: + case 245 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 251 /* ImportDeclaration */: + case 257 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 255 /* ExportAssignment */: + case 241 /* FunctionDeclaration */: + case 242 /* ClassDeclaration */: + case 256 /* ExportAssignment */: return generateNameForExportDefault(); - case 210 /* ClassExpression */: + case 211 /* ClassExpression */: return generateNameForClassExpression(); - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* MethodDeclaration */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 150 /* ComputedPropertyName */: + case 151 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -89360,7 +90397,7 @@ var ts; hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 314 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 316 /* 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 */; @@ -89384,7 +90421,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 240 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -89641,7 +90678,7 @@ var ts; 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 !== 314 /* NotEmittedStatement */ + if (node.kind !== 316 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -89654,7 +90691,7 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 314 /* NotEmittedStatement */ + if (node.kind !== 316 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); @@ -90022,6 +91059,9 @@ var ts; var createFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile); var createFilePathWatcher = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher; var createDirectoryWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory); + if (watchLogLevel === WatchLogLevel.Verbose && ts.sysLog === ts.noop) { + ts.sysLog = function (s) { return log(s); }; + } return { watchFile: function (host, file, callback, pollingInterval, detailInfo1, detailInfo2) { return createFileWatcher(host, file, callback, pollingInterval, /*passThrough*/ undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo); @@ -90377,7 +91417,7 @@ var ts; } ts.changeCompilerHostLikeToUseCache = changeCompilerHostLikeToUseCache; function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { - var diagnostics = program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (ts.getEmitDeclarations(program.getCompilerOptions())) { ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } @@ -90566,8 +91606,8 @@ var ts; } var resolutions = []; var cache = ts.createMap(); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name = names_1[_i]; + for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { + var name = names_2[_i]; var result = void 0; if (cache.has(name)) { result = cache.get(name); @@ -90654,7 +91694,7 @@ var ts; } ts.isProgramUptoDate = isProgramUptoDate; function getConfigFileParsingDiagnostics(configFileParseResult) { - return configFileParseResult.options.configFile ? configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : + return configFileParseResult.options.configFile ? __spreadArrays(configFileParseResult.options.configFile.parseDiagnostics, configFileParseResult.errors) : configFileParseResult.errors; } ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; @@ -90684,7 +91724,6 @@ var ts; var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217 var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; var oldProgram = createProgramOptions.oldProgram; - var program; var processingDefaultLibFiles; var processingOtherFiles; var files; @@ -90693,6 +91732,8 @@ var ts; var noDiagnosticsTypeChecker; var classifiableNames; var ambientModuleNameToUnmodifiedFileName = ts.createMap(); + // Todo:: Use this to report why file was included in --extendedDiagnostics + var refFileMap; var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -90728,7 +91769,7 @@ var ts; var resolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference).map(function (resolved) { + resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).map(function (resolved) { // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName. if (!resolved || resolved.extension !== undefined) { return resolved; @@ -90745,7 +91786,7 @@ var ts; } var resolveTypeReferenceDirectiveNamesWorker; if (host.resolveTypeReferenceDirectives) { - resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference); }; + resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); }; } else { var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 @@ -90775,7 +91816,10 @@ var ts; var projectReferenceRedirects; var mapFromFileToProjectReferenceRedirects; var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); - var structuralIsReused = tryReuseStructureFromOldProgram(); + // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks + // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. + var structuralIsReused; + structuralIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const if (structuralIsReused !== 2 /* Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -90862,12 +91906,13 @@ var ts; } // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; - program = { + var program = { getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFileByPath: getSourceFileByPath, getSourceFiles: function () { return files; }, getMissingFilePaths: function () { return missingFilePaths; }, + getRefFileMap: function () { return refFileMap; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, getOptionsDiagnostics: getOptionsDiagnostics, @@ -91299,6 +92344,7 @@ var ts; return oldProgram.structureIsReused = 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); + refFileMap = oldProgram.getRefFileMap(); // update fileName -> file mapping for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) { var newSourceFile = newSourceFiles_1[_f]; @@ -91321,7 +92367,7 @@ var ts; return oldProgram.structureIsReused = 2 /* Completely */; } function getEmitHost(writeFileCallback) { - return __assign({ getPrependNodes: getPrependNodes, + return __assign(__assign({ getPrependNodes: getPrependNodes, getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { // Use local caches @@ -91332,7 +92378,7 @@ var ts; return false; // Before falling back to the host return host.fileExists(f); - } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); } }); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); }, redirectTargetsMap: redirectTargetsMap }); } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!options.out && !options.outFile); @@ -91388,15 +92434,15 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.has(toPath(emitFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) { var declarationDiagnostics = []; - if (!emitOnlyDtsFiles) { + if (!forceDtsEmit) { if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; } @@ -91404,7 +92450,7 @@ var ts; // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we // get any preEmit diagnostics, not just the ones if (options.noEmitOnError) { - var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (diagnostics.length === 0 && ts.getEmitDeclarations(program.getCompilerOptions())) { declarationDiagnostics = program.getDeclarationDiagnostics(/*sourceFile*/ undefined, cancellationToken); } @@ -91428,7 +92474,8 @@ var ts; // checked is to not pass the file to getEmitResolver. var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, + /*onlyBuildInfo*/ false, forceDtsEmit); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -91570,22 +92617,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 152 /* Parameter */: - case 155 /* PropertyDeclaration */: + case 153 /* Parameter */: + case 156 /* PropertyDeclaration */: + case 158 /* MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 238 /* VariableDeclaration */: + case 157 /* MethodSignature */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: + case 239 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -91593,41 +92640,41 @@ var ts; } } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 250 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 255 /* ExportAssignment */: + case 256 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 274 /* HeritageClause */: + case 275 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 110 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 242 /* InterfaceDeclaration */: + case 243 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 245 /* ModuleDeclaration */: + case 246 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 243 /* TypeAliasDeclaration */: + case 244 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 244 /* EnumDeclaration */: + case 245 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 214 /* NonNullExpression */: + case 215 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 213 /* AsExpression */: + case 214 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 195 /* TypeAssertionExpression */: + case 196 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -91640,28 +92687,28 @@ 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 241 /* ClassDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 242 /* ClassDeclaration */: + case 211 /* ClassExpression */: + case 158 /* MethodDeclaration */: + case 159 /* Constructor */: + case 160 /* GetAccessor */: + case 161 /* SetAccessor */: + case 198 /* FunctionExpression */: + case 241 /* FunctionDeclaration */: + case 199 /* ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // falls through - case 220 /* VariableStatement */: + case 221 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 220 /* VariableStatement */); + return checkModifiers(parent.modifiers, parent.kind === 221 /* VariableStatement */); } break; - case 155 /* PropertyDeclaration */: + case 156 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { @@ -91673,18 +92720,19 @@ var ts; return; } break; - case 152 /* Parameter */: + case 153 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 193 /* CallExpression */: + case 194 /* NewExpression */: + case 213 /* ExpressionWithTypeArguments */: + case 263 /* JsxSelfClosingElement */: + case 264 /* JsxOpeningElement */: + case 195 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -91875,7 +92923,7 @@ var ts; } function collectDynamicImportOrRequireCalls(file) { var r = /import|require/g; - while (r.exec(file.text) !== null) { + while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null var node = getNodeAtPosition(file, r.lastIndex); if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { imports = ts.append(imports, node.arguments[0]); @@ -91956,24 +93004,18 @@ var ts; } } /** This has side effects through `findSourceFile`. */ - function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId); }, // TODO: GH#18217 + function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, // TODO: GH#18217 function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined - ? ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(args)) : ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(args))); - }, refFile); + return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args))); + }, refFile && refFile.file); } - function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile) { + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { var redirect = Object.create(redirectTarget); @@ -91996,7 +93038,7 @@ var ts; return redirect; } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId) { + function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) { var originalFileName = fileName; if (filesByName.has(path)) { var file_1 = filesByName.get(path); @@ -92013,7 +93055,7 @@ var ts; var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory); var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory); if (checkedAbsolutePath !== inputAbsolutePath) { - reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile); } } // If the file was previously found via a node_modules search, but is now being processed as a root file, @@ -92037,6 +93079,7 @@ var ts; processImportedModules(file_1); } } + addFileToRefFileMap(file_1 || undefined, refFile); return file_1 || undefined; } var redirectedPath; @@ -92058,14 +93101,7 @@ var ts; } } // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }, shouldCreateNewSourceFile); + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { return fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); }, shouldCreateNewSourceFile); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); @@ -92096,7 +93132,7 @@ var ts; // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case var existingFile = filesByNameIgnoreCase.get(pathLowerCase); if (existingFile) { - reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile); } else { filesByNameIgnoreCase.set(pathLowerCase, file); @@ -92119,8 +93155,18 @@ var ts; processingOtherFiles.push(file); } } + addFileToRefFileMap(file, refFile); return file; } + function addFileToRefFileMap(file, refFile) { + if (refFile && file) { + (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, { + kind: refFile.kind, + index: refFile.index, + file: refFile.file.path + }); + } + } function addFileToFilesByName(file, path, redirectedPath) { if (redirectedPath) { filesByName.set(redirectedPath, file); @@ -92209,9 +93255,17 @@ var ts; return projectReferenceRedirects.get(projectReferencePath) || undefined; } function processReferencedFiles(file, isDefaultLib) { - ts.forEach(file.referencedFiles, function (ref) { + ts.forEach(file.referencedFiles, function (ref, index) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); - processSourceFile(referencedFileName, isDefaultLib, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, + /*ignoreNoDefaultLib*/ false, + /*packageId*/ undefined, { + kind: ts.RefFileKind.ReferenceFile, + index: index, + file: file, + pos: ref.pos, + end: ref.end + }); }); } function processTypeReferenceDirectives(file) { @@ -92227,10 +93281,16 @@ var ts; // store resolved type directive on the file var fileName = ref.fileName.toLocaleLowerCase(); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); - processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); + processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { + kind: ts.RefFileKind.TypeReferenceDirective, + index: i, + file: file, + pos: ref.pos, + end: ref.end + }); } } - function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { + function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) { // If we already found this library as a primary reference - nothing to do var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { @@ -92242,7 +93302,7 @@ var ts; currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); // TODO: GH#18217 } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -92252,8 +93312,7 @@ var ts; if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, // TODO: GH#18217 - ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); } } // don't overwrite previous resolution result @@ -92261,14 +93320,14 @@ var ts; } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); } } if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--; } else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); @@ -92286,20 +93345,20 @@ var ts; var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts"); var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; - fileProcessingDiagnostics.add(createDiagnostic(file, libReference.pos, libReference.end, message, libName, suggestion)); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion)); } }); } - function createDiagnostic(refFile, refPos, refEnd, message) { + function createRefFileDiagnostic(refFile, message) { var args = []; - for (var _i = 4; _i < arguments.length; _i++) { - args[_i - 4] = arguments[_i]; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; } - if (refFile === undefined || refPos === undefined || refEnd === undefined) { - return ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)); + if (!refFile) { + return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)); } else { - return ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, message].concat(args)); + return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args)); } } function getCanonicalFileName(fileName) { @@ -92346,7 +93405,15 @@ var ts; else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, file, pos, file.imports[i].end, resolution.packageId); + findSourceFile(resolvedFileName, path, + /*isDefaultLib*/ false, + /*ignoreNoDefaultLib*/ false, { + kind: ts.RefFileKind.Import, + index: i, + file: file, + pos: pos, + end: file.imports[i].end + }, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -92365,12 +93432,15 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + var rootPaths; for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { var sourceFile = sourceFiles_2[_i]; if (!sourceFile.isDeclarationFile) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory)); + if (!rootPaths) + rootPaths = ts.arrayToSet(rootNames, toPath); + addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory); allFilesBelongToPath = false; } } @@ -92464,17 +93534,20 @@ var ts; else if (options.incremental && !options.outFile && !options.out && !options.configFilePath) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified)); } + if (options.noEmit && ts.isIncrementalCompilation(options)) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", options.incremental ? "incremental" : "composite"); + } verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { - var rootPaths = rootNames.map(toPath); + var rootPaths = ts.arrayToSet(rootNames, toPath); for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { var file = files_3[_i]; // Ignore file that is not emitted if (!ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) continue; - if (rootPaths.indexOf(file.path) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || "")); + if (!rootPaths.has(file.path)) { + addProgramDiagnosticAtRefPath(file, rootPaths, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || ""); } } } @@ -92656,6 +93729,39 @@ var ts; } } } + function addProgramDiagnosticAtRefPath(file, rootPaths, message) { + var _a, _b; + var args = []; + for (var _i = 3; _i < arguments.length; _i++) { + args[_i - 3] = arguments[_i]; + } + var refPaths = refFileMap && refFileMap.get(file.path); + var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) || + ts.elementAt(refPaths, 0); + if (refPathToReportErrorOn) { + var refFile = ts.Debug.assertDefined(getSourceFileByPath(refPathToReportErrorOn.file)); + var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index; + var pos = void 0, end = void 0; + switch (kind) { + case ts.RefFileKind.Import: + pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos); + end = refFile.imports[index].end; + break; + case ts.RefFileKind.ReferenceFile: + (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end); + break; + case ts.RefFileKind.TypeReferenceDirective: + (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end); + break; + default: + return ts.Debug.assertNever(kind); + } + programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args))); + } + else { + programDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); + } + } function verifyProjectReferences() { var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { @@ -92759,7 +93865,7 @@ var ts; } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { - _compilerOptionsObjectLiteralSyntax = null; // tslint:disable-line:no-null-keyword + _compilerOptionsObjectLiteralSyntax = null; // eslint-disable-line no-null/no-null var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); if (jsonObjectLiteral) { for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) { @@ -92915,9 +94021,9 @@ var ts; /*@internal*/ var ts; (function (ts) { - function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers) { + function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit); return { outputFiles: outputFiles, emitSkipped: emitResult.emitSkipped, exportedModulesFromDeclarationEmit: emitResult.exportedModulesFromDeclarationEmit }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); @@ -93163,11 +94269,19 @@ var ts; } } else { - var emitOutput = ts.getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken); - if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { - latestSignature = computeHash(emitOutput.outputFiles[0].text); + var emitOutput_1 = ts.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; + 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(firstDts_1.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { - updateExportedModules(sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache); + updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); } } else { @@ -93373,6 +94487,11 @@ var ts; /*@internal*/ var ts; (function (ts) { + var BuilderFileEmit; + (function (BuilderFileEmit) { + BuilderFileEmit[BuilderFileEmit["DtsOnly"] = 0] = "DtsOnly"; + BuilderFileEmit[BuilderFileEmit["Full"] = 1] = "Full"; + })(BuilderFileEmit = ts.BuilderFileEmit || (ts.BuilderFileEmit = {})); function hasSameKeys(map1, map2) { // Has same size and every key is present in both maps return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); @@ -93410,7 +94529,8 @@ var ts; ts.copyEntries(changedFilesSet, state.changedFilesSet); } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; + state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice(); + state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind); state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; } } @@ -93456,7 +94576,7 @@ var ts; }); if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - addToAffectedFilesPendingEmit(state, newProgram.getSourceFiles().map(function (f) { return f.path; })); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.path, 1 /* Full */); }); ts.Debug.assert(state.seenAffectedFiles === undefined); state.seenAffectedFiles = ts.createMap(); } @@ -93484,7 +94604,7 @@ var ts; } function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); } /** * Releases program and other related not needed properties @@ -93510,7 +94630,8 @@ var ts; newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState); newState.program = state.program; newState.compilerOptions = state.compilerOptions; - newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit; + newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); + newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind); newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles); newState.programEmitComplete = state.programEmitComplete; @@ -93542,7 +94663,6 @@ var ts; handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash); return affectedFile; } - seenAffectedFiles.set(affectedFile.path, true); affectedFilesIndex++; } // Remove the changed file from the change set @@ -93588,13 +94708,18 @@ var ts; var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap()); for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) { var affectedFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]); - if (affectedFile && !seenEmittedFiles.has(affectedFile.path)) { - // emit this file - state.affectedFilesPendingEmitIndex = i; - return affectedFile; + if (affectedFile) { + var seenKind = seenEmittedFiles.get(affectedFile.path); + var emitKind = ts.Debug.assertDefined(ts.Debug.assertDefined(state.affectedFilesPendingEmitKind).get(affectedFile.path)); + if (seenKind === undefined || seenKind < emitKind) { + // emit this file + state.affectedFilesPendingEmitIndex = i; + return { affectedFile: affectedFile, emitKind: emitKind }; + } } } state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; state.affectedFilesPendingEmitIndex = undefined; } return undefined; @@ -93638,7 +94763,7 @@ var ts; ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.assertDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, [path]); + addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); } } } @@ -93732,7 +94857,7 @@ var ts; * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly */ - function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit) { + function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) { if (isBuildInfoEmit) { state.emittedBuildInfo = true; } @@ -93742,6 +94867,9 @@ var ts; } else { state.seenAffectedFiles.set(affected.path, true); + if (emitKind !== undefined) { + (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, emitKind); + } if (isPendingEmit) { state.affectedFilesPendingEmitIndex++; } @@ -93753,8 +94881,15 @@ var ts; /** * Returns the result with affected file */ - function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); + function toAffectedFileResult(state, result, affected) { + doneWithAffectedFile(state, affected); + return { result: result, affected: affected }; + } + /** + * Returns the result with affected file + */ + function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } /** @@ -93879,7 +95014,7 @@ var ts; } function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? relativeToBuildInfo(file.path) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.path) : undefined }); } var BuilderProgramKind; (function (BuilderProgramKind) { @@ -93977,22 +95112,24 @@ var ts; */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var emitKind = 1 /* Full */; var isPendingEmitFile = false; if (!affected) { if (!state.compilerOptions.out && !state.compilerOptions.outFile) { - affected = getNextAffectedFilePendingEmit(state); - if (!affected) { + var pendingAffectedFile = getNextAffectedFilePendingEmit(state); + if (!pendingAffectedFile) { if (state.emittedBuildInfo) { return undefined; } var affected_1 = ts.Debug.assertDefined(state.program); - return toAffectedFileResult(state, + return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } + (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind); isPendingEmitFile = true; } else { @@ -94005,10 +95142,10 @@ var ts; affected = program; } } - return toAffectedFileResult(state, + return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers), affected, isPendingEmitFile); + ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); } /** * Emits the JavaScript and declaration files. @@ -94064,7 +95201,7 @@ var ts; } // Add file to affected file pending emit to handle for later emit time if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - addToAffectedFilesPendingEmit(state, [affected.path]); + addToAffectedFilesPendingEmit(state, affected.path, 1 /* Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -94096,7 +95233,7 @@ var ts; } // When semantic builder asks for diagnostics of the whole program, // ensure that all the affected files are handled - // tslint:disable-next-line no-empty + // eslint-disable-next-line no-empty while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) { } var diagnostics; @@ -94108,8 +95245,14 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; - function addToAffectedFilesPendingEmit(state, affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit); + function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) { + if (!state.affectedFilesPendingEmit) + state.affectedFilesPendingEmit = []; + if (!state.affectedFilesPendingEmitKind) + state.affectedFilesPendingEmitKind = ts.createMap(); + var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit); + state.affectedFilesPendingEmit.push(affectedFilePendingEmit); + state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind); // affectedFilesPendingEmitIndex === undefined // - means the emit state.affectedFilesPendingEmit was undefined before adding current affected files // so start from 0 as array would be affectedFilesPendingEmit @@ -94145,7 +95288,7 @@ var ts; compilerOptions: convertFromReusableCompilerOptions(program.options, toAbsolutePath), referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), - semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return ts.isString(value) ? value : value[0]; }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), + 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]; }), hasReusableDiagnostic: true }; return { @@ -94271,15 +95414,27 @@ var ts; // ignore "/user", "c:/users" or "c:/folderAtRoot" return false; } - if (dirPath.charCodeAt(0) !== 47 /* slash */ && - dirPath.substr(rootLength, nextDirectorySeparator).search(/users/i) === -1) { + var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + if (isNonDirectorySeparatorRoot && + dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths + pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart + nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1); + if (nextDirectorySeparator === -1) { + // ignore "//vda1cs4850/c$/folderAtRoot" + return false; + } + pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1); + } + if (isNonDirectorySeparatorRoot && + pathPartForUserCheck.search(/users\//i) !== 0) { // Paths like c:/folderAtRoot/subFolder are allowed return true; } for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) { searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1; if (searchIndex === 0) { - // Folder isnt at expected minimun levels + // Folder isnt at expected minimum levels return false; } } @@ -94444,8 +95599,8 @@ var ts; !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path : !!redirectedReference; var seenNamesInFile = ts.createMap(); - for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name = names_2[_i]; + for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { + var name = names_3[_i]; var resolution = resolutionsInFile.get(name); // Resolution is valid if it is present and not invalidated if (!seenNamesInFile.has(name) && @@ -94525,7 +95680,7 @@ var ts; if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { // Ensure failed look up is normalized path failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); - ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); // tslint:disable-line + ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); var subDirectoryInRoot = failedLookupLocationPath.indexOf(ts.directorySeparator, rootPath.length + 1); if (subDirectoryInRoot !== -1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution @@ -94921,8 +96076,9 @@ var ts; function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, - ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? + 2 /* JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, oldImportSpecifier) { @@ -94951,7 +96107,7 @@ var ts; return [ambient]; var info = getInfo(importingSourceFile.path, host); var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); - var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.fileName, info.getCanonicalFileName, host, redirectTargetsMap); + var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.originalFileName, info.getCanonicalFileName, host, redirectTargetsMap); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); var global = ts.mapDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }); return global.length ? global : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifier(moduleFileName, info, compilerOptions, preferences); }); @@ -94967,7 +96123,7 @@ var ts; var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; var ending = _b.ending, relativePreference = _b.relativePreference; var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; - var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); if (!baseUrl || relativePreference === 0 /* Relative */) { return relativePath; @@ -95042,7 +96198,7 @@ var ts; */ function getAllModulePaths(files, importingFileName, importedFileName, getCanonicalFileName, host, redirectTargetsMap) { var redirects = redirectTargetsMap.get(importedFileName); - var importedFileNames = redirects ? redirects.concat([importedFileName]) : [importedFileName]; + var importedFileNames = redirects ? __spreadArrays(redirects, [importedFileName]) : [importedFileName]; var cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); var links = discoverProbableSymlinks(files, getCanonicalFileName, cwd); @@ -95093,14 +96249,16 @@ var ts; } } } - function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) { + function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) { var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName); if (normalizedTargetPath === undefined) { return undefined; } var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName); var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath; - return ts.removeFileExtension(relativePath); + return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs + ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) + : ts.removeFileExtension(relativePath); } function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; @@ -95532,7 +96690,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); if (result) { result.version = computeHash.call(host, result.text); } @@ -95546,7 +96704,9 @@ var ts; function createProgramHost(system, createProgram) { var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); }); var host = system; - host; // tslint:disable-line no-unused-expression (TODO: `host` is unused!) + // TODO: `host` is unused! + // eslint-disable-next-line no-unused-expressions + host; return { useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; }, getNewLine: function () { return system.newLine; }, @@ -95580,7 +96740,7 @@ var ts; result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); }); }; return result; } @@ -95722,7 +96882,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - return getVersionedSourceFileByPath.apply(void 0, [fileName, toPath(fileName)].concat(args)); + return getVersionedSourceFileByPath.apply(void 0, __spreadArrays([fileName, toPath(fileName)], args)); }; compilerHost.getSourceFileByPath = getVersionedSourceFileByPath; compilerHost.getNewLine = function () { return newLine; }; @@ -95750,10 +96910,22 @@ var ts; /*logChangesWhenResolvingModule*/ false); // Resolve module using host module resolution strategy if provided otherwise use resolution cache to resolve module names compilerHost.resolveModuleNames = host.resolveModuleNames ? - (function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveModuleNames.apply(host, args); + }) : (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }); compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ? - (function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveTypeReferenceDirectives.apply(host, args); + }) : (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; builderProgram = readBuilderProgram(compilerOptions, compilerHost); @@ -95979,13 +97151,19 @@ var ts; reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); switch (reloadLevel) { case ts.ConfigFileProgramReloadLevel.Partial: - return reloadFileNamesFromConfigFile(); + ts.perfLogger.logStartUpdateProgram("PartialConfigReload"); + reloadFileNamesFromConfigFile(); + break; case ts.ConfigFileProgramReloadLevel.Full: - return reloadConfigFile(); + ts.perfLogger.logStartUpdateProgram("FullConfigReload"); + reloadConfigFile(); + break; default: + ts.perfLogger.logStartUpdateProgram("SynchronizeProgram"); synchronizeProgram(); - return; + break; } + ts.perfLogger.logStopUpdateProgram("Done"); } function reloadFileNamesFromConfigFile() { writeLog("Reloading new file names and options"); @@ -96169,6 +97347,16 @@ var ts; function isDeclarationFile(fileName) { return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */); } + /*@internal*/ + function isCircularBuildOrder(buildOrder) { + return !!buildOrder && !!buildOrder.buildOrder; + } + ts.isCircularBuildOrder = isCircularBuildOrder; + /*@internal*/ + function getBuildOrderFromAnyBuildOrder(anyBuildOrder) { + return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder; + } + ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ @@ -96330,11 +97518,14 @@ var ts; var permanentMarks = ts.createMap(); var circularityReportStack = []; var buildOrder; + var circularDiagnostics; for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { var root = roots_1[_i]; visit(root); } - return buildOrder || ts.emptyArray; + return circularDiagnostics ? + { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } : + buildOrder || ts.emptyArray; function visit(configFileName, inCircularContext) { var projPath = toResolvedConfigFilePath(state, configFileName); // Already visited @@ -96343,8 +97534,7 @@ var ts; // Circular if (temporaryMarks.has(projPath)) { if (!inCircularContext) { - // TODO:: Do we report this as error? - reportStatus(state, ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")); + (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n"))); } return; } @@ -96364,12 +97554,35 @@ var ts; } } function getBuildOrder(state) { - return state.buildOrder || - (state.buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }))); + return state.buildOrder || createStateBuildOrder(state); + } + function createStateBuildOrder(state) { + var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); })); + // Clear all to ResolvedConfigFilePaths cache to start fresh + state.resolvedConfigFilePaths.clear(); + var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); }); + var noopOnDelete = { onDeleteValue: ts.noop }; + // Config file cache + ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete); + // Remove watches for the program no longer in the solution + if (state.watch) { + ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher }); + ts.mutateMapSkippingNewValues(state.allWatchedWildcardDirectories, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcherOf); } }); + ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } }); + } + return state.buildOrder = buildOrder; } function getBuildOrderFor(state, project, onlyReferences) { var resolvedProject = project && resolveProjectName(state, project); var buildOrderFromState = getBuildOrder(state); + if (isCircularBuildOrder(buildOrderFromState)) + return buildOrderFromState; if (resolvedProject) { var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject); var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; }); @@ -96377,6 +97590,7 @@ var ts; return undefined; } var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState; + ts.Debug.assert(!isCircularBuildOrder(buildOrder)); ts.Debug.assert(!onlyReferences || resolvedProject !== undefined); ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject); return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder; @@ -96393,7 +97607,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); }), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, getSourceFileWithCache = _a.getSourceFileWithCache, readFileWithCache = _a.readFileWithCache; state.readFileWithCache = readFileWithCache; compilerHost.getSourceFile = getSourceFileWithCache; @@ -96448,7 +97662,7 @@ var ts; reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode); } enableCache(state); - var buildOrder = getBuildOrder(state); + var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state)); buildOrder.forEach(function (configFileName) { return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None); }); @@ -96620,7 +97834,7 @@ var ts; } function getSyntaxDiagnostics(cancellationToken) { ts.Debug.assertDefined(program); - handleDiagnostics(program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); + handleDiagnostics(__spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); } function getSemanticDiagnostics(cancellationToken) { handleDiagnostics(ts.Debug.assertDefined(program).getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic"); @@ -96788,6 +98002,8 @@ var ts; function getNextInvalidatedProject(state, buildOrder, reportQueue) { if (!state.projectPendingBuild.size) return undefined; + if (isCircularBuildOrder(buildOrder)) + return undefined; if (state.currentInvalidatedProject) { // Only if same buildOrder the currentInvalidated project can be sent again return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ? @@ -96844,8 +98060,11 @@ var ts; if (status.type === ts.UpToDateStatusType.UpstreamBlocked) { reportAndStoreErrors(state, projectPath, config.errors); projectPendingBuild.delete(projectPath); - if (options.verbose) - reportStatus(state, ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + if (options.verbose) { + reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built : + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + } continue; } if (status.type === ts.UpToDateStatusType.ContainerOnly) { @@ -97016,10 +98235,12 @@ var ts; continue; } // An upstream project is blocked - if (refStatus.type === ts.UpToDateStatusType.Unbuildable) { + if (refStatus.type === ts.UpToDateStatusType.Unbuildable || + refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) { return { type: ts.UpToDateStatusType.UpstreamBlocked, - upstreamProjectName: ref.path + upstreamProjectName: ref.path, + upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked }; } // If the upstream project is out of date, then so are we (someone shouldn't have asked, though?) @@ -97243,16 +98464,22 @@ var ts; disableCache(state); reportErrorSummary(state, buildOrder); startWatching(state, buildOrder); - return errorProjects ? - successfulProjects ? - ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : - ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : - ts.ExitStatus.Success; + return isCircularBuildOrder(buildOrder) ? + ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped : + errorProjects ? + successfulProjects ? + ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : + ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : + ts.ExitStatus.Success; } function clean(state, project, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; + if (isCircularBuildOrder(buildOrder)) { + reportErrors(state, buildOrder.circularDiagnostics); + return ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped; + } var options = state.options, host = state.host; var filesToDelete = options.dry ? [] : undefined; for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) { @@ -97395,8 +98622,8 @@ var ts; if (!state.watchAllProjectsPending) return; state.watchAllProjectsPending = false; - for (var _i = 0, buildOrder_2 = buildOrder; _i < buildOrder_2.length; _i++) { - var resolved = buildOrder_2[_i]; + for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) { + var resolved = _a[_i]; var resolvedPath = toResolvedConfigFilePath(state, resolved); // Watch this file watchConfigFile(state, resolved, resolvedPath); @@ -97428,6 +98655,7 @@ var ts; }, invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); }, buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); }, + getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); }, }; } function relName(state, path) { @@ -97438,7 +98666,7 @@ var ts; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } - state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args))); + state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); } function reportWatchStatus(state, message) { var args = []; @@ -97446,7 +98674,7 @@ var ts; args[_i - 2] = arguments[_i]; } if (state.hostWithWatch.onWatchStatusChange) { - state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)), state.host.getNewLine(), state.baseCompilerOptions); + state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)), state.host.getNewLine(), state.baseCompilerOptions); } } function reportErrors(_a, errors) { @@ -97464,23 +98692,33 @@ var ts; reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]); } function reportErrorSummary(state, buildOrder) { - if (!state.needsSummary || (!state.watch && !state.host.reportErrorSummary)) + if (!state.needsSummary) return; state.needsSummary = false; + var canReportSummary = state.watch || !!state.host.reportErrorSummary; var diagnostics = state.diagnostics; - // Report errors from the other projects - buildOrder.forEach(function (project) { - var projectPath = toResolvedConfigFilePath(state, project); - if (!state.projectErrorsReported.has(projectPath)) { - reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); - } - }); var totalErrors = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + if (isCircularBuildOrder(buildOrder)) { + reportBuildQueue(state, buildOrder.buildOrder); + reportErrors(state, buildOrder.circularDiagnostics); + if (canReportSummary) + totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics); + } + else { + // Report errors from the other projects + buildOrder.forEach(function (project) { + var projectPath = toResolvedConfigFilePath(state, project); + if (!state.projectErrorsReported.has(projectPath)) { + reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); + } + }); + if (canReportSummary) + diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + } if (state.watch) { reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors); } - else { + else if (state.host.reportErrorSummary) { state.host.reportErrorSummary(totalErrors); } } @@ -97513,13 +98751,16 @@ var ts; case ts.UpToDateStatusType.UpstreamOutOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.UpstreamBlocked: - return reportStatus(state, ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); + return reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built : + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.Unbuildable: return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason); case ts.UpToDateStatusType.TsVersionOutputOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relName(state, configFileName), status.version, ts.version); case ts.UpToDateStatusType.ContainerOnly: // Don't report status on "solution" projects + // falls through case ts.UpToDateStatusType.ComputingUpstream: // Should never leak from getUptoDateStatusWorker break; @@ -97541,7 +98782,6 @@ var ts; (function (ts) { var server; (function (server) { - // tslint:disable variable-name server.ActionSet = "action::set"; server.ActionInvalidate = "action::invalidate"; server.ActionPackageInstalled = "action::packageInstalled"; @@ -98181,6 +99421,8 @@ var ts; this.sendResponse({ kind: server.EventBeginInstallTypes, eventId: requestId, + // qualified explicitly to prevent occasional shadowing + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier typingsInstallerVersion: ts.version, projectName: req.projectName }); @@ -98228,7 +99470,9 @@ var ts; projectName: req.projectName, packagesToInstall: scopedTypings, installSuccess: ok, - typingsInstallerVersion: ts.version // tslint:disable-line no-unnecessary-qualifier (qualified explicitly to prevent occasional shadowing) + // qualified explicitly to prevent occasional shadowing + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier + typingsInstallerVersion: ts.version }; _this.sendResponse(response); } @@ -98545,7 +99789,7 @@ var ts; this.log.writeLine("Exec: " + command); } try { - var stdout = this.nodeExecSync(command, __assign({}, options, { encoding: "utf-8" })); + var stdout = this.nodeExecSync(command, __assign(__assign({}, options), { encoding: "utf-8" })); if (this.log.isEnabled()) { this.log.writeLine(" Succeeded. stdout:" + indent(ts.sys.newLine, stdout)); } From cc8764fd724a71d701ddc3bf48a98588ff388d67 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 17 Sep 2019 17:24:24 -0700 Subject: [PATCH 7/7] Revert "Remove lib change" This reverts commit 2cd6752498d28fb4df3fb62ff84a4c4b443314aa. --- src/harness/fourslash.ts | 2 +- src/lib/es5.d.ts | 6 +- ...uralTagTypesUsingGlobalTagAlias.errors.txt | 52 ++++-- ...ucturalTagTypesUsingGlobalTagAlias.symbols | 20 ++- ...tructuralTagTypesUsingGlobalTagAlias.types | 164 +++++++++--------- 5 files changed, 137 insertions(+), 107 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index c5e22f3dff890..dac5ae4e55190 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -4672,7 +4672,7 @@ namespace FourSlashInterface { typeEntry("ReturnType"), typeEntry("InstanceType"), interfaceEntry("ThisType"), - // typeEntry("Tag"), + typeEntry("Tag"), varEntry("ArrayBuffer"), interfaceEntry("ArrayBufferTypes"), typeEntry("ArrayBufferLike"), diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index cca2a6f676c93..035ba04ffb659 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1481,9 +1481,9 @@ interface ThisType { } /** * Constructs a structural tag over property name(s) `K` */ -// type Tag = tag { -// [_ in K]: void; -// }; +type Tag = tag { + [_ in K]: void; +}; /** * Represents a raw buffer of binary data, which is used to store data for the diff --git a/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.errors.txt b/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.errors.txt index 99dc014a2b45e..4e6029db2b260 100644 --- a/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.errors.txt +++ b/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.errors.txt @@ -1,17 +1,24 @@ -tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(2,17): error TS2304: Cannot find name 'Tag'. -tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(3,17): error TS2304: Cannot find name 'Tag'. -tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(31,32): error TS2304: Cannot find name 'Tag'. -tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(32,30): error TS2304: Cannot find name 'Tag'. +tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(53,29): error TS2345: Argument of type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to parameter of type 'AbsolutePath'. + Type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to type 'Tag<"AbsolutePath">'. +tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(55,39): error TS2345: Argument of type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to parameter of type 'NormalizedAbsolutePath'. + Type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'. +tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(60,31): error TS2345: Argument of type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to parameter of type 'NormalizedPath'. + Type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to type 'Tag<"NormalizedPath">'. +tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(63,39): error TS2345: Argument of type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to parameter of type 'NormalizedAbsolutePath'. + Type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'. +tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(66,31): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath'. + Type '"/a/b/c"' is not assignable to type 'Tag<"NormalizedPath">'. +tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(67,29): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'AbsolutePath'. + Type '"/a/b/c"' is not assignable to type 'Tag<"AbsolutePath">'. +tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(68,41): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath | AbsolutePath'. +tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts(69,39): error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedAbsolutePath'. + Type '"/a/b/c"' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'. -==== tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts (4 errors) ==== +==== tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAlias.ts (8 errors) ==== export type Paired = { x: number & Tag<"x">; - ~~~ -!!! error TS2304: Cannot find name 'Tag'. y: number & Tag<"y">; - ~~~ -!!! error TS2304: Cannot find name 'Tag'. }; @@ -40,11 +47,7 @@ tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAli type NormalizedPath = string & Tag<"NormalizedPath">; - ~~~ -!!! error TS2304: Cannot find name 'Tag'. type AbsolutePath = string & Tag<"AbsolutePath">; - ~~~ -!!! error TS2304: Cannot find name 'Tag'. type NormalizedAbsolutePath = NormalizedPath & AbsolutePath; declare function isNormalizedPath(x: string): x is NormalizedPath; @@ -66,22 +69,45 @@ tests/cases/conformance/types/structuralTags/structuralTagTypesUsingGlobalTagAli else { consumeNormalizedPath(p); consumeAbsolutePath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to parameter of type 'AbsolutePath'. +!!! error TS2345: Type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to type 'Tag<"AbsolutePath">'. consumeNormalizedOrAbsolutePath(p); consumeNormalizedAbsolutePath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to parameter of type 'NormalizedAbsolutePath'. +!!! error TS2345: Type '"/a/b/c" & Tag<"NormalizedPath">' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'. } } else { if (isAbsolutePath(p)) { consumeNormalizedPath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to parameter of type 'NormalizedPath'. +!!! error TS2345: Type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to type 'Tag<"NormalizedPath">'. consumeAbsolutePath(p); consumeNormalizedOrAbsolutePath(p); consumeNormalizedAbsolutePath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to parameter of type 'NormalizedAbsolutePath'. +!!! error TS2345: Type '"/a/b/c" & Tag<"AbsolutePath">' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'. } else { consumeNormalizedPath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath'. +!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'Tag<"NormalizedPath">'. consumeAbsolutePath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'AbsolutePath'. +!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'Tag<"AbsolutePath">'. consumeNormalizedOrAbsolutePath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedPath | AbsolutePath'. consumeNormalizedAbsolutePath(p); // err + ~ +!!! error TS2345: Argument of type '"/a/b/c"' is not assignable to parameter of type 'NormalizedAbsolutePath'. +!!! error TS2345: Type '"/a/b/c"' is not assignable to type 'Tag<"NormalizedPath"> & Tag<"AbsolutePath">'. } } \ No newline at end of file diff --git a/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.symbols b/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.symbols index 3b430533138d4..b8f6e1934238d 100644 --- a/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.symbols +++ b/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.symbols @@ -4,9 +4,11 @@ export type Paired = { x: number & Tag<"x">; >x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) +>Tag : Symbol(Tag, Decl(lib.es5.d.ts, --, --)) y: number & Tag<"y">; >y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) +>Tag : Symbol(Tag, Decl(lib.es5.d.ts, --, --)) }; @@ -70,17 +72,17 @@ if (isPaired(b)) { >b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5)) b.x = a.x; ->b.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 11)) +>b.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) >b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5)) ->x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 11)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) >a.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) >a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5)) >x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) b.y = a.y; ->b.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 16)) +>b.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) >b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5)) ->y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 16)) +>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) >a.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) >a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5)) >y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) @@ -89,25 +91,27 @@ if (isPaired(b)) { >a.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) >a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5)) >x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) ->b.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 11)) +>b.x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) >b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5)) ->x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 11)) +>x : Symbol(x, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 0, 22)) a.y = b.y; >a.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) >a : Symbol(a, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 14, 5)) >y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) ->b.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 16)) +>b.y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) >b : Symbol(b, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 5)) ->y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 15, 16)) +>y : Symbol(y, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 1, 25)) } type NormalizedPath = string & Tag<"NormalizedPath">; >NormalizedPath : Symbol(NormalizedPath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 27, 1)) +>Tag : Symbol(Tag, Decl(lib.es5.d.ts, --, --)) type AbsolutePath = string & Tag<"AbsolutePath">; >AbsolutePath : Symbol(AbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 30, 53)) +>Tag : Symbol(Tag, Decl(lib.es5.d.ts, --, --)) type NormalizedAbsolutePath = NormalizedPath & AbsolutePath; >NormalizedAbsolutePath : Symbol(NormalizedAbsolutePath, Decl(structuralTagTypesUsingGlobalTagAlias.ts, 31, 49)) diff --git a/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.types b/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.types index 5725bc65f7c04..b73dfb6f1f7db 100644 --- a/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.types +++ b/tests/baselines/reference/structuralTagTypesUsingGlobalTagAlias.types @@ -3,10 +3,10 @@ export type Paired = { >Paired : Paired x: number & Tag<"x">; ->x : any +>x : number & Tag<"x"> y: number & Tag<"y">; ->y : any +>y : number & Tag<"y"> }; @@ -57,22 +57,22 @@ if (Math.random() > 0.3) { >0.3 : 0.3 b.x = a.x; ->b.x = a.x : any +>b.x = a.x : number & Tag<"x"> >b.x : number >b : { x: number; y: number; } >x : number ->a.x : any +>a.x : number & Tag<"x"> >a : Paired ->x : any +>x : number & Tag<"x"> b.y = a.y; ->b.y = a.y : any +>b.y = a.y : number & Tag<"y"> >b.y : number >b : { x: number; y: number; } >y : number ->a.y : any +>a.y : number & Tag<"y"> >a : Paired ->y : any +>y : number & Tag<"y"> } if (isPaired(b)) { @@ -81,75 +81,75 @@ if (isPaired(b)) { >b : { x: number; y: number; } b.x = a.x; ->b.x = a.x : any ->b.x : number ->b : { x: number; y: number; } ->x : number ->a.x : any +>b.x = a.x : number & Tag<"x"> +>b.x : number & Tag<"x"> +>b : Paired +>x : number & Tag<"x"> +>a.x : number & Tag<"x"> >a : Paired ->x : any +>x : number & Tag<"x"> b.y = a.y; ->b.y = a.y : any ->b.y : number ->b : { x: number; y: number; } ->y : number ->a.y : any +>b.y = a.y : number & Tag<"y"> +>b.y : number & Tag<"y"> +>b : Paired +>y : number & Tag<"y"> +>a.y : number & Tag<"y"> >a : Paired ->y : any +>y : number & Tag<"y"> a.x = b.x; ->a.x = b.x : number ->a.x : any +>a.x = b.x : number & Tag<"x"> +>a.x : number & Tag<"x"> >a : Paired ->x : any ->b.x : number ->b : { x: number; y: number; } ->x : number +>x : number & Tag<"x"> +>b.x : number & Tag<"x"> +>b : Paired +>x : number & Tag<"x"> a.y = b.y; ->a.y = b.y : number ->a.y : any +>a.y = b.y : number & Tag<"y"> +>a.y : number & Tag<"y"> >a : Paired ->y : any ->b.y : number ->b : { x: number; y: number; } ->y : number +>y : number & Tag<"y"> +>b.y : number & Tag<"y"> +>b : Paired +>y : number & Tag<"y"> } type NormalizedPath = string & Tag<"NormalizedPath">; ->NormalizedPath : any +>NormalizedPath : NormalizedPath type AbsolutePath = string & Tag<"AbsolutePath">; ->AbsolutePath : any +>AbsolutePath : AbsolutePath type NormalizedAbsolutePath = NormalizedPath & AbsolutePath; ->NormalizedAbsolutePath : any +>NormalizedAbsolutePath : NormalizedAbsolutePath declare function isNormalizedPath(x: string): x is NormalizedPath; ->isNormalizedPath : (x: string) => x is any +>isNormalizedPath : (x: string) => x is NormalizedPath >x : string declare function isAbsolutePath(x: string): x is AbsolutePath; ->isAbsolutePath : (x: string) => x is any +>isAbsolutePath : (x: string) => x is AbsolutePath >x : string declare function consumeNormalizedPath(x: NormalizedPath): void; ->consumeNormalizedPath : (x: any) => void ->x : any +>consumeNormalizedPath : (x: NormalizedPath) => void +>x : NormalizedPath declare function consumeAbsolutePath(x: AbsolutePath): void; ->consumeAbsolutePath : (x: any) => void ->x : any +>consumeAbsolutePath : (x: AbsolutePath) => void +>x : AbsolutePath declare function consumeNormalizedOrAbsolutePath(x: NormalizedPath | AbsolutePath): void; ->consumeNormalizedOrAbsolutePath : (x: any) => void ->x : any +>consumeNormalizedOrAbsolutePath : (x: NormalizedPath | AbsolutePath) => void +>x : NormalizedPath | AbsolutePath declare function consumeNormalizedAbsolutePath(x: NormalizedAbsolutePath): void; ->consumeNormalizedAbsolutePath : (x: any) => void ->x : any +>consumeNormalizedAbsolutePath : (x: NormalizedAbsolutePath) => void +>x : NormalizedAbsolutePath const p = "/a/b/c"; >p : "/a/b/c" @@ -157,102 +157,102 @@ const p = "/a/b/c"; if (isNormalizedPath(p)) { >isNormalizedPath(p) : boolean ->isNormalizedPath : (x: string) => x is any +>isNormalizedPath : (x: string) => x is NormalizedPath >p : "/a/b/c" if (isAbsolutePath(p)) { >isAbsolutePath(p) : boolean ->isAbsolutePath : (x: string) => x is any ->p : "/a/b/c" +>isAbsolutePath : (x: string) => x is AbsolutePath +>p : "/a/b/c" & Tag<"NormalizedPath"> consumeNormalizedPath(p); >consumeNormalizedPath(p) : void ->consumeNormalizedPath : (x: any) => void ->p : "/a/b/c" +>consumeNormalizedPath : (x: NormalizedPath) => void +>p : "/a/b/c" & (Tag<"NormalizedPath"> & Tag<"AbsolutePath">) consumeAbsolutePath(p); >consumeAbsolutePath(p) : void ->consumeAbsolutePath : (x: any) => void ->p : "/a/b/c" +>consumeAbsolutePath : (x: AbsolutePath) => void +>p : "/a/b/c" & (Tag<"NormalizedPath"> & Tag<"AbsolutePath">) consumeNormalizedOrAbsolutePath(p); >consumeNormalizedOrAbsolutePath(p) : void ->consumeNormalizedOrAbsolutePath : (x: any) => void ->p : "/a/b/c" +>consumeNormalizedOrAbsolutePath : (x: NormalizedPath | AbsolutePath) => void +>p : "/a/b/c" & (Tag<"NormalizedPath"> & Tag<"AbsolutePath">) consumeNormalizedAbsolutePath(p); >consumeNormalizedAbsolutePath(p) : void ->consumeNormalizedAbsolutePath : (x: any) => void ->p : "/a/b/c" +>consumeNormalizedAbsolutePath : (x: NormalizedAbsolutePath) => void +>p : "/a/b/c" & (Tag<"NormalizedPath"> & Tag<"AbsolutePath">) } else { consumeNormalizedPath(p); >consumeNormalizedPath(p) : void ->consumeNormalizedPath : (x: any) => void ->p : never +>consumeNormalizedPath : (x: NormalizedPath) => void +>p : "/a/b/c" & Tag<"NormalizedPath"> consumeAbsolutePath(p); // err >consumeAbsolutePath(p) : void ->consumeAbsolutePath : (x: any) => void ->p : never +>consumeAbsolutePath : (x: AbsolutePath) => void +>p : "/a/b/c" & Tag<"NormalizedPath"> consumeNormalizedOrAbsolutePath(p); >consumeNormalizedOrAbsolutePath(p) : void ->consumeNormalizedOrAbsolutePath : (x: any) => void ->p : never +>consumeNormalizedOrAbsolutePath : (x: NormalizedPath | AbsolutePath) => void +>p : "/a/b/c" & Tag<"NormalizedPath"> consumeNormalizedAbsolutePath(p); // err >consumeNormalizedAbsolutePath(p) : void ->consumeNormalizedAbsolutePath : (x: any) => void ->p : never +>consumeNormalizedAbsolutePath : (x: NormalizedAbsolutePath) => void +>p : "/a/b/c" & Tag<"NormalizedPath"> } } else { if (isAbsolutePath(p)) { >isAbsolutePath(p) : boolean ->isAbsolutePath : (x: string) => x is any ->p : never +>isAbsolutePath : (x: string) => x is AbsolutePath +>p : "/a/b/c" consumeNormalizedPath(p); // err >consumeNormalizedPath(p) : void ->consumeNormalizedPath : (x: any) => void ->p : never +>consumeNormalizedPath : (x: NormalizedPath) => void +>p : "/a/b/c" & Tag<"AbsolutePath"> consumeAbsolutePath(p); >consumeAbsolutePath(p) : void ->consumeAbsolutePath : (x: any) => void ->p : never +>consumeAbsolutePath : (x: AbsolutePath) => void +>p : "/a/b/c" & Tag<"AbsolutePath"> consumeNormalizedOrAbsolutePath(p); >consumeNormalizedOrAbsolutePath(p) : void ->consumeNormalizedOrAbsolutePath : (x: any) => void ->p : never +>consumeNormalizedOrAbsolutePath : (x: NormalizedPath | AbsolutePath) => void +>p : "/a/b/c" & Tag<"AbsolutePath"> consumeNormalizedAbsolutePath(p); // err >consumeNormalizedAbsolutePath(p) : void ->consumeNormalizedAbsolutePath : (x: any) => void ->p : never +>consumeNormalizedAbsolutePath : (x: NormalizedAbsolutePath) => void +>p : "/a/b/c" & Tag<"AbsolutePath"> } else { consumeNormalizedPath(p); // err >consumeNormalizedPath(p) : void ->consumeNormalizedPath : (x: any) => void ->p : never +>consumeNormalizedPath : (x: NormalizedPath) => void +>p : "/a/b/c" consumeAbsolutePath(p); // err >consumeAbsolutePath(p) : void ->consumeAbsolutePath : (x: any) => void ->p : never +>consumeAbsolutePath : (x: AbsolutePath) => void +>p : "/a/b/c" consumeNormalizedOrAbsolutePath(p); // err >consumeNormalizedOrAbsolutePath(p) : void ->consumeNormalizedOrAbsolutePath : (x: any) => void ->p : never +>consumeNormalizedOrAbsolutePath : (x: NormalizedPath | AbsolutePath) => void +>p : "/a/b/c" consumeNormalizedAbsolutePath(p); // err >consumeNormalizedAbsolutePath(p) : void ->consumeNormalizedAbsolutePath : (x: any) => void ->p : never +>consumeNormalizedAbsolutePath : (x: NormalizedAbsolutePath) => void +>p : "/a/b/c" } }